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(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE) 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) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS CoreAddons Syndication Config I18n)
if (ANDROID) if (ANDROID)
@ -26,7 +26,7 @@ if (ANDROID)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Kirigami2)
find_package(OpenSSL REQUIRED) find_package(OpenSSL REQUIRED)
else() else()
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Widgets) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Widgets WebEngine)
endif() endif()
add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_URL_CAST_FROM_STRING) 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) kconfig_add_kcfg_files(alligator_SRCS alligatorsettings.kcfgc GENERATE_MOC)
add_executable(alligator ${alligator_SRCS}) 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) if(ANDROID)
target_link_libraries(alligator PRIVATE target_link_libraries(alligator PRIVATE
@ -35,7 +35,7 @@ if(ANDROID)
globe globe
) )
else() else()
target_link_libraries(alligator PRIVATE Qt5::Widgets) target_link_libraries(alligator PRIVATE Qt5::Widgets Qt5::WebEngine)
endif() endif()
install(TARGETS alligator ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) install(TARGETS alligator ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})

View File

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

View File

@ -21,6 +21,7 @@
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Controls 2.14 as Controls import QtQuick.Controls 2.14 as Controls
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import QtWebView 1.14
import org.kde.kirigami 2.12 as Kirigami import org.kde.kirigami 2.12 as Kirigami
@ -31,17 +32,17 @@ Kirigami.ScrollablePage {
property QtObject entry 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 title: entry.title
ColumnLayout { Flickable {
Controls.Label { WebView {
id: label width: page.width
baseUrl: page.entry.baseUrl height: page.height - 20
text: page.entry.content Component.onCompleted: {
textFormat: Text.RichText loadHtml(page.content, page.entry.baseUrl)
wrapMode: Text.WordWrap }
Layout.fillWidth: true
onLinkActivated: Qt.openUrlExternally(link)
} }
} }
} }