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

Remove explicit workshop loading

This does not really make sense because it (und)loaded the
plugin twice and cause crashes on macos. The new version
now lets the QML engine handle the lifetime.
This commit is contained in:
Elias Steurer 2021-05-23 17:23:59 +02:00
parent b0eac04ff9
commit 8c344b7c3d
16 changed files with 136 additions and 220 deletions

View File

@ -13,8 +13,8 @@ check:
script:
- cd Tools
- pip install cmakelang
- python format-cmake.py
- python format-cpp.py
- python format_cmake.py
- python format_cpp.py
build:windows_debug:
stage: build

View File

@ -138,5 +138,6 @@
<file>assets/icons/icon_sort-up-solid.svg</file>
<file>assets/icons/icon_sort-down-solid.svg</file>
<file>assets/icons/brand_reddit.svg</file>
<file>assets/icons/steam_default_avatar.png</file>
</qresource>
</RCC>

View File

@ -58,7 +58,7 @@ App::App()
QGuiApplication::setOrganizationName("ScreenPlay");
QGuiApplication::setOrganizationDomain("https://screen-play.app");
QGuiApplication::setApplicationName("ScreenPlay");
QGuiApplication::setApplicationVersion("0.13.2");
QGuiApplication::setApplicationVersion("0.13.3");
QGuiApplication::setQuitOnLastWindowClosed(false);
QFontDatabase::addApplicationFont(":/assets/fonts/LibreBaskerville-Italic.ttf");
@ -216,49 +216,4 @@ void App::exit()
QApplication::instance()->quit();
}
/*!
\brief Loads the Steam plugin when needed. This enables to start ScreenPlay
via OS autostart without waiting for Steam first.
*/
bool App::loadSteamPlugin()
{
#ifdef Q_OS_MACOS
#ifdef QT_NO_DEBUG
const QString fileSuffix = ".dylib";
#else
const QString fileSuffix = "d.dylib";
#endif
#endif
#ifdef Q_OS_WIN
#ifdef QT_NO_DEBUG
const QString fileSuffix = ".dll";
#else
const QString fileSuffix = "d.dll";
#endif
#endif
#ifdef Q_OS_LINUX
const QString fileSuffix = ".so";
#endif
m_workshopPlugin.setFileName(QApplication::applicationDirPath() + "/ScreenPlayWorkshop" + fileSuffix);
if (!m_workshopPlugin.load()) {
qWarning() << "Steam plugin not provided!" << QApplication::applicationDirPath() + "/ScreenPlayWorkshop" + fileSuffix;
qWarning() << m_workshopPlugin.fileName() << " - With error: " << m_workshopPlugin.errorString();
return false;
}
const ScreenPlayWorkshopPlugin* workshopPlugin = reinterpret_cast<ScreenPlayWorkshopPlugin*>(m_workshopPlugin.instance());
Q_UNUSED(workshopPlugin)
settings()->setSteamVersion(true);
return true;
}
bool App::unloadSteamPlugin()
{
return m_workshopPlugin.unload();
}
}

View File

@ -36,6 +36,7 @@
#include <QDir>
#include <QElapsedTimer>
#include <QGuiApplication>
#include <QIcon>
#include <QObject>
#include <QQmlApplicationEngine>
@ -119,8 +120,6 @@ signals:
public slots:
QString version() const;
void exit();
bool loadSteamPlugin();
bool unloadSteamPlugin();
void setGlobalVariables(GlobalVariables* globalVariables)
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -32,27 +32,12 @@ ApplicationWindow {
}
function switchPage(name) {
const unloadSteamPlugin = nav.currentNavigationName === "Workshop";
if (nav.currentNavigationName === name) {
if (name === "Installed")
ScreenPlay.installedListModel.reset();
return ;
}
if (name === "Workshop") {
if (!ScreenPlay.settings.steamVersion) {
const steamAvialable = ScreenPlay.loadSteamPlugin();
if (!steamAvialable) {
dialogSteam.open();
switchPage("Installed");
return ;
}
}
}
stackView.replace("qrc:/qml/" + name + "/" + name + ".qml");
if (unloadSteamPlugin)
ScreenPlay.unloadSteamPlugin();
sidebar.state = "inactive";
}

View File

@ -1,6 +1,6 @@
import QtQuick 2.13
import QtGraphicalEffects 1.0
import ScreenPlay.Workshop 1.0
import Workshop 1.0
Rectangle {
id: root

View File

@ -3,16 +3,15 @@ import QtQuick.Controls 2.13
import QtQuick.Controls.Material 2.13
import QtGraphicalEffects 1.0
import QtQuick.Controls.Material.impl 2.12
import ScreenPlay.Workshop 1.0
import SteamQMLImageProvider 1.0
import Workshop 1.0
import ScreenPlay 1.0
Rectangle {
id: root
property SteamWorkshop steamWorkshop
property SteamWorkshop steam
signal uploadPressed()
signal uploadPressed
implicitWidth: 800
height: 50
@ -39,7 +38,8 @@ Rectangle {
verticalAlignment: Qt.AlignVCenter
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
text: {
return steamWorkshop.steamAccount.username + qsTr(" Subscribed items: ") + steamWorkshop.steamAccount.amountSubscribedItems;
return steam.steamAccount.username + qsTr(
" Subscribed items: ") + steam.steamAccount.amountSubscribedItems
}
anchors {
@ -50,7 +50,6 @@ Rectangle {
right: btnUplaod.left
rightMargin: 10
}
}
SteamImage {
@ -59,7 +58,7 @@ Rectangle {
width: 30
height: 30
Component.onCompleted: {
steamWorkshop.steamAccount.loadAvatar();
steam.steamAccount.loadAvatar()
}
anchors {
@ -70,12 +69,18 @@ Rectangle {
Connections {
function onAvatarChanged(_avatar) {
avatar.setImage(_avatar);
avatar.setImage(_avatar)
avatarPlaceholder.opacity = 0
}
target: steamWorkshop.steamAccount
target: steam.steamAccount
}
}
Image {
id: avatarPlaceholder
anchors.fill: avatar
source: "qrc:/assets/icons/steam_default_avatar.png"
}
Button {
@ -93,9 +98,7 @@ Rectangle {
right: parent.right
rightMargin: 10
}
}
}
states: [
@ -106,7 +109,6 @@ Rectangle {
target: bg
radius: 3
}
},
State {
name: "scrolling"
@ -115,7 +117,6 @@ Rectangle {
target: bg
radius: 0
}
}
]
}

View File

@ -2,7 +2,7 @@ import QtQuick 2.0
import QtQuick.Controls 2.13
import QtQuick.Controls.Material 2.13
import QtGraphicalEffects 1.0
import ScreenPlay.Workshop 1.0
import Workshop 1.0
import ScreenPlay 1.0
Popup {

View File

@ -4,7 +4,7 @@ import QtQuick.Controls 2.3
import QtQuick.Layouts 1.11
import QtWebEngine 1.8
import QtQuick.Controls.Material 2.2
import ScreenPlay.Workshop 1.0
import Workshop 1.0
import ScreenPlay 1.0
Drawer {

View File

@ -3,8 +3,7 @@ import QtQuick.Controls 2.13
import QtQuick.Controls.Material 2.13
import QtGraphicalEffects 1.0
import QtQuick.Layouts 1.12
import ScreenPlay.Workshop 1.0
import ScreenPlay.Workshop.SteamEnums 1.0
import Workshop 1.0
import ScreenPlay 1.0
import "upload/"
import "../Common" as Common
@ -12,19 +11,21 @@ import "../Common" as Common
Item {
id: root
property alias steamWorkshop: screenPlayWorkshop.steamWorkshop
ScreenPlayWorkshop {
id: workshop
property alias steam: workshop.steamWorkshop
}
state: "base"
onVisibleChanged: {
if (!visible)
sidebar.close();
sidebar.close()
}
Component.onCompleted: {
if (steamWorkshop.online)
steamWorkshop.searchWorkshop(SteamEnums.K_EUGCQuery_RankedByTrend);
if (workshop.steam.online)
workshop.steam.searchWorkshop(
SteamEnums.K_EUGCQuery_RankedByTrend)
else
popupOffline.open();
popupOffline.open()
}
MouseArea {
@ -37,19 +38,16 @@ Item {
preventStealing: true
}
ScreenPlayWorkshop {
id: screenPlayWorkshop
}
Connections {
function onWorkshopSearched() {
bannerTxt.text = steamWorkshop.workshopListModel.getBannerText();
background.backgroundImage = steamWorkshop.workshopListModel.getBannerUrl();
banner.bannerPublishedFileID = steamWorkshop.workshopListModel.getBannerID();
bannerTxtUnderline.numberSubscriber = steamWorkshop.workshopListModel.getBannerAmountSubscriber();
bannerTxt.text = workshop.steam.workshopListModel.getBannerText()
background.backgroundImage = workshop.steam.workshopListModel.getBannerUrl()
banner.bannerPublishedFileID = workshop.steam.workshopListModel.getBannerID()
bannerTxtUnderline.numberSubscriber
= workshop.steam.workshopListModel.getBannerAmountSubscriber()
}
target: steamWorkshop
target: workshop.steam
}
Background {
@ -65,8 +63,7 @@ Item {
UploadProject {
id: popupUploadProject
steamWorkshop: steamWorkshop
workshop: screenPlayWorkshop
screenPlayWorkshop: workshop
}
PopupSteamWorkshopAgreement {
@ -75,16 +72,16 @@ Item {
Connections {
function onUserNeedsToAcceptWorkshopLegalAgreement() {
popupSteamWorkshopAgreement.open();
popupSteamWorkshopAgreement.open()
}
target: steamWorkshop.uploadListModel
target: workshop.steam.uploadListModel
}
Navigation {
id: nav
steamWorkshop: steamWorkshop
steam: workshop.steam
z: 3
onUploadPressed: popupUploadProject.open()
@ -93,7 +90,6 @@ Item {
right: parent.right
left: parent.left
}
}
Flickable {
@ -105,13 +101,9 @@ Item {
onContentYChanged: {
// Calculate parallax scrolling
if (contentY >= 0)
background.imageOffsetTop = (contentY * -0.4);
background.imageOffsetTop = (contentY * -0.4)
else
background.imageOffsetTop = 0;
if (contentY >= (header.height))
root.state = "scrolling";
else
root.state = "base";
background.imageOffsetTop = 0
}
Item {
@ -150,7 +142,6 @@ Item {
left: parent.left
bottom: parent.bottom
}
}
ColumnLayout {
@ -194,8 +185,10 @@ Item {
Material.foreground: "white"
icon.source: "qrc:/assets/icons/icon_download.svg"
onClicked: {
text = qsTr("Downloading...");
steamWorkshop.subscribeItem(steamWorkshop.workshopListModel.getBannerID());
text = qsTr("Downloading...")
workshop.steam.subscribeItem(
workshop.steam.workshopListModel.getBannerID(
))
}
}
@ -206,14 +199,18 @@ Item {
icon.source: "qrc:/assets/icons/icon_info.svg"
visible: false
onClicked: {
sidebar.setWorkshopItem(publishedFileID, imgUrl, additionalPreviewUrl, subscriptionCount);
sidebar.setWorkshopItem(publishedFileID,
imgUrl,
additionalPreviewUrl,
subscriptionCount)
}
}
}
MouseArea {
onClicked: Qt.openUrlExternally("steam://url/CommunityFilePage/" + banner.bannerPublishedFileID)
onClicked: Qt.openUrlExternally(
"steam://url/CommunityFilePage/"
+ banner.bannerPublishedFileID)
height: 30
width: bannerTxtOpenInSteam.paintedWidth
cursorShape: Qt.PointingHandCursor
@ -229,13 +226,9 @@ Item {
font.family: ScreenPlay.settings.font
font.weight: Font.Thin
}
}
}
}
}
GridView {
@ -247,7 +240,7 @@ Item {
cellHeight: 190
height: contentHeight
interactive: false
model: steamWorkshop.workshopListModel
model: workshop.steam.workshopListModel
boundsBehavior: Flickable.StopAtBounds
anchors {
@ -285,9 +278,6 @@ Item {
TextField {
id: tiSearch
leftPadding: 25
selectByMouse: true
placeholderText: qsTr("Search for Wallpaper and Widgets...")
onTextChanged: timerSearch.restart()
@ -303,9 +293,9 @@ Item {
id: timerSearch
interval: 500
onTriggered: steamWorkshop.searchWorkshopByText(tiSearch.text)
onTriggered: workshop.steam.searchWorkshopByText(
tiSearch.text)
}
}
Image {
@ -320,7 +310,6 @@ Item {
bottom: parent.bottom
bottomMargin: 22
}
}
ToolButton {
@ -335,9 +324,7 @@ Item {
bottom: parent.bottom
bottomMargin: 10
}
}
}
RowLayout {
@ -360,7 +347,8 @@ Item {
text: qsTr("Open Workshop in Steam")
font.capitalization: Font.Capitalize
font.family: ScreenPlay.settings.font
onClicked: Qt.openUrlExternally("steam://url/SteamWorkshopPage/672870")
onClicked: Qt.openUrlExternally(
"steam://url/SteamWorkshopPage/672870")
icon.source: "qrc:/assets/icons/icon_steam.svg"
icon.width: 18
icon.height: 18
@ -371,13 +359,13 @@ Item {
text: qsTr("Open GameHub in Steam")
font.capitalization: Font.Capitalize
font.family: ScreenPlay.settings.font
onClicked: Qt.openUrlExternally("steam://url/GameHub/672870")
onClicked: Qt.openUrlExternally(
"steam://url/GameHub/672870")
icon.source: "qrc:/assets/icons/icon_steam.svg"
icon.width: 18
icon.height: 18
height: cbQuerySort.height
}
}
ComboBox {
@ -422,7 +410,8 @@ Item {
"text": qsTr("Total Unique Subscriptions")
}]
onActivated: {
steamWorkshop.searchWorkshop(cbQuerySort.currentValue);
workshop.steam.searchWorkshop(
cbQuerySort.currentValue)
}
anchors {
@ -430,11 +419,8 @@ Item {
right: parent.right
rightMargin: 10
}
}
}
}
delegate: WorkshopItem {
@ -444,9 +430,11 @@ Item {
additionalPreviewUrl: m_additionalPreviewUrl
subscriptionCount: m_subscriptionCount
itemIndex: index
steamWorkshop: root.steamWorkshop
steamWorkshop: workshop.steamWorkshop
onClicked: {
sidebar.setWorkshopItem(publishedFileID, imgUrl, additionalPreviewUrl, subscriptionCount);
sidebar.setWorkshopItem(publishedFileID, imgUrl,
additionalPreviewUrl,
subscriptionCount)
}
}
@ -470,10 +458,12 @@ Item {
Layout.alignment: Qt.AlignVCenter
text: qsTr("Back")
enabled: steamWorkshop.workshopListModel.currentPage > 1
enabled: workshop.steam.workshopListModel.currentPage > 1
onClicked: {
steamWorkshop.workshopListModel.setCurrentPage(steamWorkshop.workshopListModel.currentPage - 1);
steamWorkshop.searchWorkshop(SteamEnums.K_EUGCQuery_RankedByTrend);
workshop.steam.workshopListModel.setCurrentPage(
workshop.steam.workshopListModel.currentPage - 1)
workshop.steam.searchWorkshop(
SteamEnums.K_EUGCQuery_RankedByTrend)
}
}
@ -481,7 +471,8 @@ Item {
id: txtPage
Layout.alignment: Qt.AlignVCenter
text: steamWorkshop.workshopListModel.currentPage + "/" + steamWorkshop.workshopListModel.pages
text: workshop.steam.workshopListModel.currentPage
+ "/" + workshop.steam.workshopListModel.pages
font.family: ScreenPlay.settings.font
color: Material.primaryTextColor
}
@ -491,19 +482,20 @@ Item {
Layout.alignment: Qt.AlignVCenter
text: qsTr("Forward")
enabled: steamWorkshop.workshopListModel.currentPage <= steamWorkshop.workshopListModel.pages - 1
enabled: workshop.steam.workshopListModel.currentPage
<= workshop.steam.workshopListModel.pages - 1
onClicked: {
steamWorkshop.workshopListModel.setCurrentPage(steamWorkshop.workshopListModel.currentPage + 1);
steamWorkshop.searchWorkshop(SteamEnums.K_EUGCQuery_RankedByTrend);
workshop.steam.workshopListModel.setCurrentPage(
workshop.steam.workshopListModel.currentPage + 1)
workshop.steam.searchWorkshop(
SteamEnums.K_EUGCQuery_RankedByTrend)
}
}
Item {
Layout.fillWidth: true
}
}
}
Behavior on contentHeight {
@ -512,24 +504,21 @@ Item {
property: "contentHeight"
easing.type: Easing.InOutQuart
}
}
ScrollBar.vertical: ScrollBar {
snapMode: ScrollBar.SnapOnRelease
}
}
Sidebar {
id: sidebar
topMargin: 60
steamWorkshop: root.steamWorkshop
steamWorkshop: workshop.steamWorkshop
onTagClicked: {
gridView.headerItem.searchField.text = tag;
sidebar.close();
gridView.headerItem.searchField.text = tag
sidebar.close()
}
}
}

View File

@ -2,7 +2,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.3
import QtQuick.Controls.Styles 1.4
import QtGraphicalEffects 1.0
import ScreenPlay.Workshop 1.0 as SP
import Workshop 1.0 as SP
Item {
id: pageInstalled

View File

@ -2,7 +2,7 @@ import QtQuick 2.12
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.2
import ScreenPlay.Workshop 1.0
import Workshop 1.0
import ScreenPlay 1.0
Item {

View File

@ -2,7 +2,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
import QtQuick.Layouts 1.12
import ScreenPlay.Workshop 1.0 as SP
import Workshop 1.0 as SP
import ScreenPlay 1.0
import "../../Common"

View File

@ -2,14 +2,14 @@ import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
import QtQuick.Layouts 1.12
import ScreenPlay.Workshop 1.0
import Workshop 1.0
import ScreenPlay 1.0
Popup {
id: root
property SteamWorkshop steamWorkshop
property ScreenPlayWorkshop workshop
property ScreenPlayWorkshop screenPlayWorkshop
property SteamWorkshop steam: screenPlayWorkshop.steamWorkshop
width: 1200
height: 700
@ -28,7 +28,7 @@ Popup {
Connections {
function onRequestClosePopup() {
root.close();
root.close()
}
target: uploadLoader.item
@ -40,7 +40,7 @@ Popup {
Item {
id: wrapper
signal requestClosePopup()
signal requestClosePopup
Item {
id: headerWrapper
@ -67,9 +67,7 @@ Popup {
top: parent.top
horizontalCenter: parent.horizontalCenter
}
}
}
SwipeView {
@ -99,7 +97,7 @@ Popup {
cellWidth: parent.width
cellHeight: 250
clip: true
model: workshop.installedListModel
model: screenPlayWorkshop.installedListModel
anchors {
top: parent.top
@ -124,11 +122,11 @@ Popup {
onItemClicked: {
for (let childItem in gridView.contentItem.children) {
if (gridView.contentItem.children[childItem].isSelected) {
btnUploadProjects.enabled = true;
return ;
btnUploadProjects.enabled = true
return
}
}
btnUploadProjects.enabled = false;
btnUploadProjects.enabled = false
}
}
@ -136,7 +134,6 @@ Popup {
snapMode: ScrollBar.SnapOnRelease
policy: ScrollBar.AlwaysOn
}
}
Button {
@ -144,7 +141,7 @@ Popup {
text: qsTr("Abort")
onClicked: {
wrapper.requestClosePopup();
wrapper.requestClosePopup()
}
anchors {
@ -152,7 +149,6 @@ Popup {
bottom: parent.bottom
margins: 10
}
}
Button {
@ -162,14 +158,14 @@ Popup {
highlighted: true
enabled: false
onClicked: {
var uploadListArray = [];
var uploadListArray = []
for (let childItem in gridView.contentItem.children) {
if (gridView.contentItem.children[childItem].isSelected)
uploadListArray.push(gridView.contentItem.children[childItem].absoluteStoragePath);
uploadListArray.push(
gridView.contentItem.children[childItem].absoluteStoragePath)
}
view.currentIndex = 1;
steamWorkshop.bulkUploadToWorkshop(uploadListArray);
view.currentIndex = 1
steam.bulkUploadToWorkshop(uploadListArray)
}
anchors {
@ -177,9 +173,7 @@ Popup {
bottom: parent.bottom
margins: 10
}
}
}
Item {
@ -193,7 +187,7 @@ Popup {
flickDeceleration: 5000
cacheBuffer: 1000
clip: true
model: steamWorkshop.uploadListModel
model: steam.uploadListModel
width: parent.width - 50
spacing: 25
@ -214,7 +208,6 @@ Popup {
ScrollBar.vertical: ScrollBar {
snapMode: ScrollBar.SnapOnRelease
}
}
Button {
@ -224,7 +217,7 @@ Popup {
highlighted: true
enabled: false
onClicked: {
root.close();
root.close()
}
anchors {
@ -235,16 +228,13 @@ Popup {
Connections {
function onUploadCompleted() {
btnFinish.enabled = true;
btnFinish.enabled = true
}
target: steamWorkshop.uploadListModel
target: steam.uploadListModel
}
}
}
}
PageIndicator {
@ -255,13 +245,10 @@ Popup {
anchors.bottom: view.bottom
anchors.horizontalCenter: parent.horizontalCenter
}
}
}
background: Rectangle {
color: Material.theme === Material.Light ? "white" : Material.background
}
}

View File

@ -2,7 +2,6 @@ import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.0
import QtQuick.Controls.Material 2.12
import ScreenPlay.Workshop.SteamEnums 1.0
import QtQuick.Layouts 1.12
import QtQuick.Controls.Material.impl 2.12