From be370a0ad424ab5379c563b0674dbabc16007867 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Mon, 27 Dec 2021 11:57:39 +0100 Subject: [PATCH] Remove QWebEngine from base app when using QWebEngine one is forced to use openGL for the shared context of the main window. This has bad resizing when using custom window decoration that wil be introduced in the next commits. --- ScreenPlay/CMakeLists.txt | 4 - ScreenPlay/app.h | 1 - ScreenPlay/main.cpp | 4 - ScreenPlay/qml/Community/Community.qml | 148 +++++------------- ScreenPlay/qml/Community/CommunityNavItem.qml | 1 + ScreenPlay/qml/Community/XMLNewsfeed.qml | 1 - ScreenPlay/qml/Workshop/Forum.qml | 12 -- ScreenPlay/qml/Workshop/Sidebar.qml | 48 ------ 8 files changed, 44 insertions(+), 175 deletions(-) diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index 75053648..53fda182 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -176,8 +176,6 @@ find_package( WebSockets Svg LinguistTools - WebEngineQuick - WebEngineCore Test) qt_add_resources(RESOURCES Resources.qrc) @@ -202,8 +200,6 @@ target_link_libraries( Qt6::Core Qt6::WebSockets Qt6::Svg - Qt6::WebEngineQuick - Qt6::WebEngineCore SteamSDKQtEnums) if(${TESTS_ENABLED}) diff --git a/ScreenPlay/app.h b/ScreenPlay/app.h index b78f56f0..1fd86d1d 100644 --- a/ScreenPlay/app.h +++ b/ScreenPlay/app.h @@ -48,7 +48,6 @@ #include #include #include -#include #include "src/create.h" #include "src/globalvariables.h" diff --git a/ScreenPlay/main.cpp b/ScreenPlay/main.cpp index 874bc134..b37aa693 100644 --- a/ScreenPlay/main.cpp +++ b/ScreenPlay/main.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #define DOCTEST_CONFIG_IMPLEMENT @@ -47,9 +46,6 @@ int main(int argc, char* argv[]) { Q_INIT_RESOURCE(Resources); - QtWebEngineQuick::initialize(); - QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); - QApplication qtGuiApp(argc, argv); // Unit tests diff --git a/ScreenPlay/qml/Community/Community.qml b/ScreenPlay/qml/Community/Community.qml index 60fae792..5f73f20e 100644 --- a/ScreenPlay/qml/Community/Community.qml +++ b/ScreenPlay/qml/Community/Community.qml @@ -4,16 +4,24 @@ import QtQuick.Controls.Material import Qt5Compat.GraphicalEffects import QtQuick.Layouts import ScreenPlay 1.0 -import QtWebEngine Item { id: root + XMLNewsfeed { + anchors { + top: navWrapper.bottom + right: parent.right + bottom: parent.bottom + left: parent.left + } + } + Rectangle { id: navWrapper color: Material.theme === Material.Light ? "white" : Material.background - height: 50 + height: 60 anchors { top: parent.top @@ -21,60 +29,72 @@ Item { left: parent.left } - TabBar { + RowLayout { id: nav height: parent.height - currentIndex: 0 anchors { top: parent.top left: parent.left + leftMargin: 20 bottom: parent.bottom - right: parent.right } - CommunityNavItem { + Button { text: qsTr("News") - openLink: "https://screen-play.app/blog/" + onClicked: Qt.openUrlExternally("https://screen-play.app/blog/") icon.source: "qrc:/assets/icons/icon_document.svg" + icon.width: 14 + icon.height: 14 + Layout.alignment: Qt.AlignVCenter } - CommunityNavItem { + Button { text: qsTr("Wiki") - openLink: "https://kelteseth.gitlab.io/ScreenPlayDocs/" + onClicked: Qt.openUrlExternally("https://kelteseth.gitlab.io/ScreenPlayDocs/") icon.source: "qrc:/assets/icons/icon_help_center.svg" + icon.width: 14 + icon.height: 14 + Layout.alignment: Qt.AlignVCenter } - CommunityNavItem { + Button { text: qsTr("Forum") - openLink: "https://forum.screen-play.app/" + onClicked: Qt.openUrlExternally("https://forum.screen-play.app/") icon.source: "qrc:/assets/icons/icon_forum.svg" + icon.width: 14 + icon.height: 14 + Layout.alignment: Qt.AlignVCenter } - CommunityNavItem { - text: qsTr("Issue List") - openLink: "https://gitlab.com/kelteseth/ScreenPlay/-/issues" + Button { + text: qsTr("Issue Tracker") + onClicked: Qt.openUrlExternally("https://gitlab.com/kelteseth/ScreenPlay/-/issues") icon.source: "qrc:/assets/icons/icon_report_problem.svg" + icon.width: 14 + icon.height: 14 + Layout.alignment: Qt.AlignVCenter } - CommunityNavItem { + Button { text: qsTr("Contribute") - openLink: "https://gitlab.com/kelteseth/ScreenPlay#general-contributing" + onClicked: Qt.openUrlExternally("https://gitlab.com/kelteseth/ScreenPlay#general-contributing") icon.source: "qrc:/assets/icons/icon_supervisor_account.svg" + icon.width: 14 + icon.height: 14 + Layout.alignment: Qt.AlignVCenter } - CommunityNavItem { + Button { text: qsTr("Steam Workshop") - openLink: "steam://url/GameHub/672870" + onClicked: Qt.openUrlExternally("steam://url/GameHub/672870") icon.source: "qrc:/assets/icons/icon_steam.svg" + icon.width: 14 + icon.height: 14 + Layout.alignment: Qt.AlignVCenter } - - background: Item { - } - } - } LinearGradient { @@ -99,90 +119,8 @@ Item { position: 1 color: "transparent" } - } - } - SwipeView { - id: swipeView - - currentIndex: nav.currentIndex - - anchors { - top: navWrapper.bottom - right: parent.right - bottom: parent.bottom - left: parent.left - } - - XMLNewsfeed { - } - - Repeater { - id: repeater - - Loader { - active: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem - asynchronous: true - - sourceComponent: Item { - Component.onCompleted: timer.start() - - Timer { - id: timer - - interval: 200 - onTriggered: webView.url = webModel.get(index + 1).url - } - - WebEngineView { - id: webView - - anchors.fill: parent - } - - } - - } - - model: ListModel { - id: webModel - - ListElement { - url: "https://screen-play.app/blog/" - } - - ListElement { - url: "https://kelteseth.gitlab.io/ScreenPlayDocs/" - } - - ListElement { - url: "https://forum.screen-play.app/" - } - - ListElement { - url: "https://gitlab.com/kelteseth/ScreenPlay/-/issues" - } - - ListElement { - url: "https://gitlab.com/kelteseth/ScreenPlay#general-contributing" - } - - ListElement { - url: "https://steamcommunity.com/app/672870/workshop/" - } - - } - - } - - } - - Binding { - target: nav - property: "currentIndex" - value: swipeView.currentIndex - } } diff --git a/ScreenPlay/qml/Community/CommunityNavItem.qml b/ScreenPlay/qml/Community/CommunityNavItem.qml index 25f71c62..ad347945 100644 --- a/ScreenPlay/qml/Community/CommunityNavItem.qml +++ b/ScreenPlay/qml/Community/CommunityNavItem.qml @@ -9,6 +9,7 @@ TabButton { property url openLink height: parent.height + onClicked: Qt.openUrlExternally(control.openLink) contentItem: Item { anchors.fill: parent diff --git a/ScreenPlay/qml/Community/XMLNewsfeed.qml b/ScreenPlay/qml/Community/XMLNewsfeed.qml index 28f4e77c..10061b93 100644 --- a/ScreenPlay/qml/Community/XMLNewsfeed.qml +++ b/ScreenPlay/qml/Community/XMLNewsfeed.qml @@ -17,7 +17,6 @@ Item { flickDeceleration: 5000 cellHeight: 250 cellWidth: 450 - clip: true model: feedModel anchors { diff --git a/ScreenPlay/qml/Workshop/Forum.qml b/ScreenPlay/qml/Workshop/Forum.qml index a6a114c8..2b2c5639 100644 --- a/ScreenPlay/qml/Workshop/Forum.qml +++ b/ScreenPlay/qml/Workshop/Forum.qml @@ -3,7 +3,6 @@ import QtQuick.Controls import QtQuick.Controls.Material import QtQuick.Layouts import Qt5Compat.GraphicalEffects -import QtWebEngine import ScreenPlay 1.0 @@ -51,15 +50,4 @@ Item { } } - WebEngineView { - id: webView - anchors { - top: navWrapper.bottom - right: parent.right - bottom: parent.bottom - left: parent.left - } - url:"https://forum.screen-play.app/category/5/wallpaper" - - } } diff --git a/ScreenPlay/qml/Workshop/Sidebar.qml b/ScreenPlay/qml/Workshop/Sidebar.qml index ee22d5e7..ec22b013 100644 --- a/ScreenPlay/qml/Workshop/Sidebar.qml +++ b/ScreenPlay/qml/Workshop/Sidebar.qml @@ -2,7 +2,6 @@ import QtQuick import Qt5Compat.GraphicalEffects import QtQuick.Controls import QtQuick.Layouts -import QtWebEngine import QtQuick.Controls.Material import Workshop 1.0 import ScreenPlay 1.0 @@ -29,7 +28,6 @@ Drawer { root.close() return } - webView.opacity = 0 root.publishedFileID = publishedFileID root.imgUrl = imgUrl root.subscriptionCount = subscriptionCount @@ -41,7 +39,6 @@ Drawer { root.open() steamWorkshop.requestWorkshopItemDetails(publishedFileID) - webView.setVideo() } edge: Qt.RightEdge @@ -50,16 +47,6 @@ Drawer { modal: false width: 400 interactive: false - Component.onCompleted: { - WebEngine.settings.localContentCanAccessFileUrls = true - WebEngine.settings.localContentCanAccessRemoteUrls = true - WebEngine.settings.allowRunningInsecureContent = true - WebEngine.settings.accelerated2dCanvasEnabled = true - WebEngine.settings.javascriptCanOpenWindows = false - WebEngine.settings.showScrollBars = false - WebEngine.settings.playbackRequiresUserGesture = false - WebEngine.settings.focusOnNavigationEnabled = true - } Connections { function onRequestItemDetailReturned(title, tags, steamIDOwner, description, votesUp, votesDown, url, fileSize, publishedFileId) { @@ -106,42 +93,7 @@ Drawer { anchors.fill: parent } - WebEngineView { - id: webView - property bool ready: false - - function getUpdateVideoCommand() { - let src = "" - src += "var video = document.getElementById('video');\n" - src += "video.src = '" + root.videoPreview + "';\n" - // Incase a workshop item has no gif preview - src += "video.poster = '" + root.videoPreview + "';\n" - src += "video.play();\n" - return src - } - - function setVideo() { - if (!root.videoPreview.toString().startsWith("https")) - return - - webView.runJavaScript(getUpdateVideoCommand(), - function (result) { - webView.opacity = 1 - }) - } - - anchors.fill: parent - opacity: 0 - url: "qrc:/assets/WorkshopPreview.html" - onUrlChanged: print(url) - - Behavior on opacity { - NumberAnimation { - duration: 200 - } - } - } LinearGradient { height: 50