1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-14 22:42:34 +02: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
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})

View File

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

View File

@ -36,7 +36,6 @@
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include <QtWebEngineQuick>
#include <sentry.h>
#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

View File

@ -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
}
}

View File

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

View File

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

View File

@ -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"
}
}

View File

@ -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