Improve Entry rendering

This commit is contained in:
Tobias Fella 2020-06-01 23:58:58 +02:00
parent 92d3ef4874
commit 8163a4cd6d
4 changed files with 16 additions and 13 deletions

View File

@ -18,7 +18,7 @@ include(KDEClangFormat)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui QuickControls2 Sql)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui QuickControls2 Sql WebView)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS CoreAddons Syndication Config I18n)
if (ANDROID)
@ -26,7 +26,7 @@ if (ANDROID)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2)
find_package(OpenSSL REQUIRED)
else()
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Widgets)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Widgets WebEngine)
endif()
add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_URL_CAST_FROM_STRING)

View File

@ -13,7 +13,7 @@ set(alligator_SRCS
kconfig_add_kcfg_files(alligator_SRCS alligatorsettings.kcfgc GENERATE_MOC)
add_executable(alligator ${alligator_SRCS})
target_link_libraries(alligator PRIVATE Qt5::Core Qt5::Qml Qt5::Quick Qt5::Sql KF5::Syndication KF5::CoreAddons KF5::ConfigGui KF5::I18n)
target_link_libraries(alligator PRIVATE Qt5::Core Qt5::Qml Qt5::Quick Qt5::Sql Qt5::WebView KF5::Syndication KF5::CoreAddons KF5::ConfigGui KF5::I18n)
if(ANDROID)
target_link_libraries(alligator PRIVATE
@ -35,7 +35,7 @@ if(ANDROID)
globe
)
else()
target_link_libraries(alligator PRIVATE Qt5::Widgets)
target_link_libraries(alligator PRIVATE Qt5::Widgets Qt5::WebEngine)
endif()
install(TARGETS alligator ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})

View File

@ -25,6 +25,7 @@
#endif
#include <QCommandLineParser>
#include <QtWebView>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickView>
@ -44,6 +45,7 @@ Q_DECL_EXPORT
#endif
int main(int argc, char *argv[])
{
QtWebView::initialize();
#ifdef Q_OS_ANDROID
QGuiApplication app(argc, argv);
#else

View File

@ -21,6 +21,7 @@
import QtQuick 2.14
import QtQuick.Controls 2.14 as Controls
import QtQuick.Layouts 1.14
import QtWebView 1.14
import org.kde.kirigami 2.12 as Kirigami
@ -31,17 +32,17 @@ Kirigami.ScrollablePage {
property QtObject entry
property var content: "<style> img { max-width: 100%; } body { background: " + Kirigami.Theme.backgroundColor + "; font-family: " + Kirigami.Theme.defaultFont.family + "; }</style><body>" + page.entry.content + "</body>";
title: entry.title
ColumnLayout {
Controls.Label {
id: label
baseUrl: page.entry.baseUrl
text: page.entry.content
textFormat: Text.RichText
wrapMode: Text.WordWrap
Layout.fillWidth: true
onLinkActivated: Qt.openUrlExternally(link)
Flickable {
WebView {
width: page.width
height: page.height - 20
Component.onCompleted: {
loadHtml(page.content, page.entry.baseUrl)
}
}
}
}