1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-06 19:12:30 +01:00

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.
This commit is contained in:
Elias Steurer 2021-12-27 11:57:39 +01:00
parent c2459bf4de
commit be370a0ad4
8 changed files with 44 additions and 175 deletions

View File

@ -176,8 +176,6 @@ find_package(
WebSockets WebSockets
Svg Svg
LinguistTools LinguistTools
WebEngineQuick
WebEngineCore
Test) Test)
qt_add_resources(RESOURCES Resources.qrc) qt_add_resources(RESOURCES Resources.qrc)
@ -202,8 +200,6 @@ target_link_libraries(
Qt6::Core Qt6::Core
Qt6::WebSockets Qt6::WebSockets
Qt6::Svg Qt6::Svg
Qt6::WebEngineQuick
Qt6::WebEngineCore
SteamSDKQtEnums) SteamSDKQtEnums)
if(${TESTS_ENABLED}) if(${TESTS_ENABLED})

View File

@ -48,7 +48,6 @@
#include <QtGlobal> #include <QtGlobal>
#include <QtQml> #include <QtQml>
#include <QtSvg> #include <QtSvg>
#include <QtWebEngineCore>
#include "src/create.h" #include "src/create.h"
#include "src/globalvariables.h" #include "src/globalvariables.h"

View File

@ -36,7 +36,6 @@
#include <QApplication> #include <QApplication>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QDebug> #include <QDebug>
#include <QtWebEngineQuick>
#include <sentry.h> #include <sentry.h>
#define DOCTEST_CONFIG_IMPLEMENT #define DOCTEST_CONFIG_IMPLEMENT
@ -47,9 +46,6 @@ int main(int argc, char* argv[])
{ {
Q_INIT_RESOURCE(Resources); Q_INIT_RESOURCE(Resources);
QtWebEngineQuick::initialize();
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
QApplication qtGuiApp(argc, argv); QApplication qtGuiApp(argc, argv);
// Unit tests // Unit tests

View File

@ -4,16 +4,24 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import QtQuick.Layouts import QtQuick.Layouts
import ScreenPlay 1.0 import ScreenPlay 1.0
import QtWebEngine
Item { Item {
id: root id: root
XMLNewsfeed {
anchors {
top: navWrapper.bottom
right: parent.right
bottom: parent.bottom
left: parent.left
}
}
Rectangle { Rectangle {
id: navWrapper id: navWrapper
color: Material.theme === Material.Light ? "white" : Material.background color: Material.theme === Material.Light ? "white" : Material.background
height: 50 height: 60
anchors { anchors {
top: parent.top top: parent.top
@ -21,60 +29,72 @@ Item {
left: parent.left left: parent.left
} }
TabBar { RowLayout {
id: nav id: nav
height: parent.height height: parent.height
currentIndex: 0
anchors { anchors {
top: parent.top top: parent.top
left: parent.left left: parent.left
leftMargin: 20
bottom: parent.bottom bottom: parent.bottom
right: parent.right
} }
CommunityNavItem { Button {
text: qsTr("News") 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.source: "qrc:/assets/icons/icon_document.svg"
icon.width: 14
icon.height: 14
Layout.alignment: Qt.AlignVCenter
} }
CommunityNavItem { Button {
text: qsTr("Wiki") 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.source: "qrc:/assets/icons/icon_help_center.svg"
icon.width: 14
icon.height: 14
Layout.alignment: Qt.AlignVCenter
} }
CommunityNavItem { Button {
text: qsTr("Forum") 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.source: "qrc:/assets/icons/icon_forum.svg"
icon.width: 14
icon.height: 14
Layout.alignment: Qt.AlignVCenter
} }
CommunityNavItem { Button {
text: qsTr("Issue List") text: qsTr("Issue Tracker")
openLink: "https://gitlab.com/kelteseth/ScreenPlay/-/issues" onClicked: Qt.openUrlExternally("https://gitlab.com/kelteseth/ScreenPlay/-/issues")
icon.source: "qrc:/assets/icons/icon_report_problem.svg" icon.source: "qrc:/assets/icons/icon_report_problem.svg"
icon.width: 14
icon.height: 14
Layout.alignment: Qt.AlignVCenter
} }
CommunityNavItem { Button {
text: qsTr("Contribute") 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.source: "qrc:/assets/icons/icon_supervisor_account.svg"
icon.width: 14
icon.height: 14
Layout.alignment: Qt.AlignVCenter
} }
CommunityNavItem { Button {
text: qsTr("Steam Workshop") 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.source: "qrc:/assets/icons/icon_steam.svg"
icon.width: 14
icon.height: 14
Layout.alignment: Qt.AlignVCenter
} }
background: Item {
}
} }
} }
LinearGradient { LinearGradient {
@ -99,90 +119,8 @@ Item {
position: 1 position: 1
color: "transparent" 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
}
} }

View File

@ -9,6 +9,7 @@ TabButton {
property url openLink property url openLink
height: parent.height height: parent.height
onClicked: Qt.openUrlExternally(control.openLink)
contentItem: Item { contentItem: Item {
anchors.fill: parent anchors.fill: parent

View File

@ -17,7 +17,6 @@ Item {
flickDeceleration: 5000 flickDeceleration: 5000
cellHeight: 250 cellHeight: 250
cellWidth: 450 cellWidth: 450
clip: true
model: feedModel model: feedModel
anchors { anchors {

View File

@ -3,7 +3,6 @@ import QtQuick.Controls
import QtQuick.Controls.Material import QtQuick.Controls.Material
import QtQuick.Layouts import QtQuick.Layouts
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import QtWebEngine
import ScreenPlay 1.0 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"
}
} }

View File

@ -2,7 +2,6 @@ import QtQuick
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import QtWebEngine
import QtQuick.Controls.Material import QtQuick.Controls.Material
import Workshop 1.0 import Workshop 1.0
import ScreenPlay 1.0 import ScreenPlay 1.0
@ -29,7 +28,6 @@ Drawer {
root.close() root.close()
return return
} }
webView.opacity = 0
root.publishedFileID = publishedFileID root.publishedFileID = publishedFileID
root.imgUrl = imgUrl root.imgUrl = imgUrl
root.subscriptionCount = subscriptionCount root.subscriptionCount = subscriptionCount
@ -41,7 +39,6 @@ Drawer {
root.open() root.open()
steamWorkshop.requestWorkshopItemDetails(publishedFileID) steamWorkshop.requestWorkshopItemDetails(publishedFileID)
webView.setVideo()
} }
edge: Qt.RightEdge edge: Qt.RightEdge
@ -50,16 +47,6 @@ Drawer {
modal: false modal: false
width: 400 width: 400
interactive: false 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 { Connections {
function onRequestItemDetailReturned(title, tags, steamIDOwner, description, votesUp, votesDown, url, fileSize, publishedFileId) { function onRequestItemDetailReturned(title, tags, steamIDOwner, description, votesUp, votesDown, url, fileSize, publishedFileId) {
@ -106,42 +93,7 @@ Drawer {
anchors.fill: parent 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 { LinearGradient {
height: 50 height: 50