1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 02:32:29 +01:00

Update ScreenPlay App type to be a QML_SINGLETON

This should in theory fix QtCreator autocompletion,
but https://bugreports.qt.io/browse/QTCREATORBUG-30197
must be fixed first
This commit is contained in:
Elias Steurer 2024-01-12 16:10:34 +01:00
parent ca30748c69
commit 59a6523f28
72 changed files with 543 additions and 496 deletions

View File

@ -11,6 +11,7 @@ include(GenerateCMakeVariableHeader)
set(SOURCES
# cmake-format: sort
src/applicationengine.cpp
src/app.cpp
src/create.cpp
src/createimportvideo.cpp
@ -31,6 +32,7 @@ set(HEADER
# cmake-format: sort
inc/public/ScreenPlay/app.h
inc/public/ScreenPlay/applicationengine.h
inc/public/ScreenPlay/create.h
inc/public/ScreenPlay/createimportstates.h
inc/public/ScreenPlay/createimportvideo.h
@ -96,6 +98,7 @@ set(QML
qml/Settings/SettingsPage.qml
qml/Settings/SettingsView.qml
qml/TrayIcon.qml
qml/Base.qml
qml/Workshop/WorkshopView.qml)
set(TS_FILES
@ -351,6 +354,9 @@ if(WIN32
file(MAKE_DIRECTORY ${FONTS_OUT_DIR})
copy_recursive(${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts ${FONTS_OUT_DIR} "*.ttf")
copy_recursive(${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts ${FONTS_OUT_DIR} "*.otf")
set(RESOURCES_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/assets")
file(MAKE_DIRECTORY ${RESOURCES_DIR})
endif()
if(WIN32)
@ -412,14 +418,14 @@ if(APPLE)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffmpeg
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffmpeg"
"${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/")
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffprobe
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffprobe"
"${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/")
# fonts
include(CopyRecursive)
@ -428,12 +434,13 @@ if(APPLE)
copy_recursive(${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts ${FONTS_OUT_DIR} "*.ttf")
copy_recursive(${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts ${FONTS_OUT_DIR} "*.otf")
# .qm translations
set(QM_OUT_DIR "${RESOURCES_DIR}/translations")
file(MAKE_DIRECTORY ${QM_OUT_DIR})
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${QM_OUT_DIR})
endif()
# .qm translations
set(QM_OUT_DIR "${RESOURCES_DIR}/translations")
file(MAKE_DIRECTORY ${QM_OUT_DIR})
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${QM_OUT_DIR})
# Must be called here, because we need to change the OUTPUT_LOCATION for macos
qt_add_lrelease(${PROJECT_NAME} TS_FILES ${TS_FILES})

View File

@ -1,21 +1,7 @@
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
#pragma once
#include <QDir>
#include <QElapsedTimer>
#include <QGuiApplication>
#include <QIcon>
#include <QObject>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickWindow>
#include <QStringList>
#include <QUrl>
#include <QtGlobal>
#include <QtQml>
#include <QtSvg>
#include <QString>
#include "ScreenPlay/create.h"
#include "ScreenPlay/globalvariables.h"
@ -27,6 +13,7 @@
#include "ScreenPlay/settings.h"
#include "ScreenPlay/wizards.h"
#include "ScreenPlayUtil/util.h"
#include <QQmlEngine>
#include <memory>
@ -38,25 +25,26 @@ namespace ScreenPlay {
class App : public QObject {
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(QQmlApplicationEngine* mainWindowEngine READ mainWindowEngine WRITE setMainWindowEngine NOTIFY mainWindowEngineChanged)
Q_PROPERTY(GlobalVariables* globalVariables READ globalVariables WRITE setGlobalVariables NOTIFY globalVariablesChanged)
Q_PROPERTY(ScreenPlayManager* screenPlayManager READ screenPlayManager WRITE setScreenPlayManager NOTIFY screenPlayManagerChanged)
Q_PROPERTY(Create* create READ create WRITE setCreate NOTIFY createChanged)
Q_PROPERTY(Wizards* wizards READ wizards WRITE setWizards NOTIFY wizardsChanged)
Q_PROPERTY(Util* util READ util WRITE setUtil NOTIFY utilChanged)
Q_PROPERTY(Settings* settings READ settings WRITE setSettings NOTIFY settingsChanged)
Q_PROPERTY(InstalledListModel* installedListModel READ installedListModel WRITE setInstalledListModel NOTIFY installedListModelChanged)
Q_PROPERTY(InstalledListFilter* installedListFilter READ installedListFilter WRITE setInstalledListFilter NOTIFY installedListFilterChanged)
Q_PROPERTY(MonitorListModel* monitorListModel READ monitorListModel WRITE setMonitorListModel NOTIFY monitorListModelChanged)
Q_PROPERTY(ProfileListModel* profileListModel READ profileListModel WRITE setProfileListModel NOTIFY profileListModelChanged)
Q_PROPERTY(GlobalVariables* globalVariables READ globalVariables WRITE setGlobalVariables NOTIFY globalVariablesChanged FINAL)
Q_PROPERTY(ScreenPlayManager* screenPlayManager READ screenPlayManager WRITE setScreenPlayManager NOTIFY screenPlayManagerChanged FINAL)
Q_PROPERTY(Create* create READ create WRITE setCreate NOTIFY createChanged FINAL)
Q_PROPERTY(Wizards* wizards READ wizards WRITE setWizards NOTIFY wizardsChanged FINAL)
Q_PROPERTY(Util* util READ util WRITE setUtil NOTIFY utilChanged FINAL)
Q_PROPERTY(Settings* settings READ settings WRITE setSettings NOTIFY settingsChanged FINAL)
Q_PROPERTY(InstalledListModel* installedListModel READ installedListModel WRITE setInstalledListModel NOTIFY installedListModelChanged FINAL)
Q_PROPERTY(InstalledListFilter* installedListFilter READ installedListFilter WRITE setInstalledListFilter NOTIFY installedListFilterChanged FINAL)
Q_PROPERTY(MonitorListModel* monitorListModel READ monitorListModel WRITE setMonitorListModel NOTIFY monitorListModelChanged FINAL)
Q_PROPERTY(ProfileListModel* profileListModel READ profileListModel WRITE setProfileListModel NOTIFY profileListModelChanged FINAL)
public:
explicit App();
void init();
bool m_isAnotherScreenPlayInstanceRunning { false };
// QML callable functions
Q_INVOKABLE void init();
Q_INVOKABLE QString version() const;
Q_INVOKABLE void showDockIcon(const bool show);
Q_INVOKABLE void exit();
GlobalVariables* globalVariables() const { return m_globalVariables.get(); }
ScreenPlayManager* screenPlayManager() const { return m_screenPlayManager.get(); }
@ -67,9 +55,11 @@ public:
MonitorListModel* monitorListModel() const { return m_monitorListModel.get(); }
ProfileListModel* profileListModel() const { return m_profileListModel.get(); }
InstalledListFilter* installedListFilter() const { return m_installedListFilter.get(); }
QQmlApplicationEngine* mainWindowEngine() const { return m_mainWindowEngine.get(); }
Wizards* wizards() const { return m_wizards.get(); }
QQmlEngine* engine() const;
void setEngine(QQmlEngine* engine);
signals:
void globalVariablesChanged(ScreenPlay::GlobalVariables* globalVariables);
void screenPlayManagerChanged(ScreenPlay::ScreenPlayManager* screenPlayManager);
@ -80,15 +70,11 @@ signals:
void monitorListModelChanged(ScreenPlay::MonitorListModel* monitorListModel);
void profileListModelChanged(ScreenPlay::ProfileListModel* profileListModel);
void installedListFilterChanged(ScreenPlay::InstalledListFilter* installedListFilter);
void mainWindowEngineChanged(QQmlApplicationEngine* mainWindowEngine);
void wizardsChanged(ScreenPlay::Wizards* wizards);
void requestExit();
void requestRetranslation();
public slots:
QString version() const;
void showDockIcon(const bool show);
void exit();
QPointF cursorPos() { return QCursor::pos(); }
void setGlobalVariables(GlobalVariables* globalVariables);
void setScreenPlayManager(ScreenPlayManager* screenPlayManager);
void setCreate(Create* create);
@ -98,20 +84,16 @@ public slots:
void setMonitorListModel(MonitorListModel* monitorListModel);
void setProfileListModel(ProfileListModel* profileListModel);
void setInstalledListFilter(InstalledListFilter* installedListFilter);
void setMainWindowEngine(QQmlApplicationEngine* mainWindowEngine);
void setWizards(Wizards* wizards);
private:
QNetworkAccessManager m_networkAccessManager;
std::unique_ptr<QQmlApplicationEngine> m_mainWindowEngine;
QQmlEngine* m_engine = nullptr;
std::unique_ptr<Create> m_create;
std::unique_ptr<Wizards> m_wizards;
std::unique_ptr<ScreenPlayManager> m_screenPlayManager;
std::unique_ptr<Util> m_util;
std::shared_ptr<GlobalVariables> m_globalVariables;
std::shared_ptr<Settings> m_settings;
std::shared_ptr<InstalledListModel> m_installedListModel;
std::shared_ptr<MonitorListModel> m_monitorListModel;

View File

@ -0,0 +1,18 @@
#pragma once
#include <QByteArray>
#include <QGuiApplication>
#include <QLocalSocket>
#include <QObject>
#include <QQmlApplicationEngine>
namespace ScreenPlay {
class ApplicationEngine : public QQmlApplicationEngine {
Q_OBJECT
public:
explicit ApplicationEngine(QObject* parent = nullptr);
bool isAnotherScreenPlayInstanceRunning();
void init();
};
}

View File

@ -17,8 +17,9 @@ class GlobalVariables : public QObject {
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
Q_PROPERTY(QVersionNumber version READ version CONSTANT)
Q_PROPERTY(Version version READ version WRITE setVersion NOTIFY versionChanged FINAL)
Q_PROPERTY(QUrl localStoragePath READ localStoragePath WRITE setLocalStoragePath NOTIFY localStoragePathChanged FINAL)
Q_PROPERTY(QUrl localSettingsPath READ localSettingsPath WRITE setLocalSettingsPath NOTIFY localSettingsPathChanged FINAL)
Q_PROPERTY(QUrl wallpaperExecutablePath READ wallpaperExecutablePath WRITE setWallpaperExecutablePath NOTIFY wallpaperExecutablePathChanged FINAL)
@ -29,43 +30,24 @@ class GlobalVariables : public QObject {
public:
explicit GlobalVariables(QObject* parent = nullptr);
/*!
\property GlobalVariables::m_version
\brief Returns the current app version. Not yet used.
*/
QVersionNumber version() const { return m_version; }
/*!
\property GlobalVariables::localStoragePath
\brief Returns the localStoragePath.
*/
enum class Version {
OpenSource,
OpenSourceSteam,
OpenSourcePlus,
OpenSourcePlusSteam
};
Q_ENUM(Version)
Version version() const { return m_version; }
QUrl localStoragePath() const { return m_localStoragePath; }
/*!
\property GlobalVariables::localSettingsPath
\brief Returns the localSettingsPath.
*/
QUrl localSettingsPath() const { return m_localSettingsPath; }
/*!
\property GlobalVariables::wallpaperExecutablePath
\brief Returns the wallpaperExecutablePath. This only differes in development builds.
*/
QUrl wallpaperExecutablePath() const { return m_wallpaperExecutablePath; }
/*!
\property GlobalVariables::widgetExecutablePath
\brief Returns the widgetExecutablePath. This only differes in development builds.
*/
QUrl widgetExecutablePath() const { return m_widgetExecutablePath; }
/*!
\property GlobalVariables::m_version
\brief Returns the current app version. Not yet used.
*/
QUrl godotWallpaperExecutablePath() const { return m_godotWallpaperExecutablePath; }
/*!
\property GlobalVariables::m_version
\brief Returns the current app version. Not yet used.
*/
QUrl godotEditorExecutablePath() const { return m_godotEditorExecutablePath; }
signals:
void versionChanged(Version version);
void localStoragePathChanged(QUrl localStoragePath);
void localSettingsPathChanged(QUrl localSettingsPath);
void wallpaperExecutablePathChanged(QUrl wallpaperExecutablePath);
@ -74,6 +56,7 @@ signals:
void godotEditorExecutablePathChanged(QUrl godotEditorExecutablePath);
public slots:
void setVersion(Version version);
void setLocalStoragePath(QUrl localStoragePath);
void setLocalSettingsPath(QUrl localSettingsPath);
void setWallpaperExecutablePath(QUrl wallpaperExecutablePath);
@ -93,8 +76,8 @@ private:
QUrl m_localSettingsPath;
QUrl m_wallpaperExecutablePath;
QUrl m_widgetExecutablePath;
QVersionNumber m_version { 1, 0, 0 };
QUrl m_godotWallpaperExecutablePath;
QUrl m_godotEditorExecutablePath;
Version m_version = Version::OpenSource;
};
}

View File

@ -39,7 +39,6 @@ public:
int activeWallpaperCounter() const { return m_activeWallpaperCounter; }
int activeWidgetsCounter() const { return m_activeWidgetsCounter; }
bool isAnotherScreenPlayInstanceRunning() { return m_isAnotherScreenPlayInstanceRunning; }
signals:
void activeWallpaperCounterChanged(int activeWallpaperCounter);
@ -77,8 +76,8 @@ public slots:
const QJsonObject& properties,
const bool saveToProfilesConfigFile);
bool removeAllWallpapers();
bool removeAllWidgets();
bool removeAllWallpapers(bool saveToProfile = false);
bool removeAllWidgets(bool saveToProfile = false);
bool removeWallpaperAt(const int index);
bool requestProjectSettingsAtMonitorIndex(const int index);
@ -159,7 +158,6 @@ private:
int m_activeWallpaperCounter { 0 };
int m_activeWidgetsCounter { 0 };
bool m_isAnotherScreenPlayInstanceRunning = false;
QTimer m_saveLimiter;
const quint16 m_webSocketPort = 16395;

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
#include "ScreenPlay/CMakeVariables.h"
#include "ScreenPlay/app.h"
#include "ScreenPlay/applicationengine.h"
#include "ScreenPlayUtil/logginghandler.h"
#include "qcorotask.h"
#include "qml/qcoroqml.h"
@ -18,6 +18,7 @@
Q_IMPORT_QML_PLUGIN(ScreenPlayWorkshopPlugin)
#endif
#include <QQmlEngineExtensionPlugin>
Q_IMPORT_QML_PLUGIN(ScreenPlayAppPlugin)
Q_IMPORT_QML_PLUGIN(ScreenPlayUtilPlugin)
Q_IMPORT_QML_PLUGIN(PlausiblePlugin)
@ -30,14 +31,14 @@ int main(int argc, char* argv[])
#endif
QGuiApplication qtGuiApp(argc, argv);
ScreenPlay::App app;
ScreenPlay::ApplicationEngine appEngine;
if (app.m_isAnotherScreenPlayInstanceRunning) {
if (appEngine.isAnotherScreenPlayInstanceRunning()) {
return 0;
}
auto logging = std::make_unique<const ScreenPlayUtil::LoggingHandler>("ScreenPlay");
app.init();
appEngine.init();
const int status = qtGuiApp.exec();
#if defined(Q_OS_WIN)
sentry_shutdown();

View File

@ -1,57 +1,16 @@
import QtCore as QCore
import QtQml
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
import Qt5Compat.GraphicalEffects
import Plausible 1.0
import "qml/Monitors" as Monitors
import "qml/Installed" as Installed
import "qml/Navigation" as Navigation
import "qml/Community" as Community
import "qml"
import ScreenPlayApp 1.0
import QtCore as QCore
ApplicationWindow {
id: root
function setTheme(theme) {
switch (theme) {
case Settings.Theme.System:
root.Material.theme = Material.System;
break;
case Settings.Theme.Dark:
root.Material.theme = Material.Dark;
break;
case Settings.Theme.Light:
root.Material.theme = Material.Light;
break;
}
}
function switchPage(name) {
if (nav.currentNavigationName === name) {
if (name === "Installed")
App.installedListModel.reset();
}
if (name === "Installed") {
stackView.replace("qrc:/qml/ScreenPlayApp/qml/Installed/InstalledView.qml", {
"sidebar": sidebar
});
return;
}
stackView.replace("qrc:/qml/ScreenPlayApp/qml/" + name + "/" + name + "View.qml", {
"modalSource": content
});
nav.setNavigation(name);
sidebar.state = "inactive";
}
color: Material.theme === Material.Dark ? Qt.darker(Material.background) : Material.background
color: Material.theme === Material.Dark ? Qt.darker(
Material.background) : Material.background
// Set visible if the -silent parameter was not set (see app.cpp end of constructor).
visible: false
width: 1400
@ -59,6 +18,71 @@ ApplicationWindow {
title: "ScreenPlay - v" + App.version()
minimumHeight: 450
minimumWidth: 1050
Component.onCompleted: {
// App is now a qml singleton to fix QtC autocompletion.
// This also now means we have to make sure to init it here
// and do _not_ access any other properties before we called init.
App.init()
setTheme(App.settings.theme)
if (!App.settings.silentStart) {
App.showDockIcon(true)
root.show()
}
baseLoader.setSource("qrc:/qml/ScreenPlayApp/qml/Base.qml")
}
Connections {
target: App
function onRequestExit(){
Qt.exit(0)
}
}
function setTheme(theme) {
switch (theme) {
case Settings.Theme.System:
root.Material.theme = Material.System
break
case Settings.Theme.Dark:
root.Material.theme = Material.Dark
break
case Settings.Theme.Light:
root.Material.theme = Material.Light
break
}
}
// Partial workaround for
// https://bugreports.qt.io/browse/QTBUG-86047
Material.accent: Material.color(Material.Orange)
onVisibilityChanged: {
if (root.visibility !== 2)
return
}
QCore.Settings {
id: settings
}
onClosing: close => {
close.accepted = false
if (App.screenPlayManager.activeWallpaperCounter === 0
&& App.screenPlayManager.activeWidgetsCounter === 0) {
App.exit()
}
const alwaysMinimize = settings.value("alwaysMinimize", null)
if (alwaysMinimize === null) {
console.error(
"Unable to retreive alwaysMinimize setting")
}
if (alwaysMinimize === "true") {
root.hide()
App.showDockIcon(false)
return
}
exitDialog.open()
}
Plausible {
id: plausible
@ -68,204 +92,9 @@ ApplicationWindow {
enabled: false
}
// Partial workaround for
// https://bugreports.qt.io/browse/QTBUG-86047
Material.accent: Material.color(Material.Orange)
onVisibilityChanged: {
if (root.visibility !== 2)
return;
}
onClosing: close => {
close.accepted = false;
if (App.screenPlayManager.activeWallpaperCounter === 0 && App.screenPlayManager.activeWidgetsCounter === 0) {
App.exit();
}
const alwaysMinimize = settings.value("alwaysMinimize", null);
if (alwaysMinimize === null) {
console.error("Unable to retreive alwaysMinimize setting");
}
if (alwaysMinimize === "true") {
root.hide();
App.showDockIcon(false);
return;
}
exitDialog.open();
}
QCore.Settings {
id: settings
}
Navigation.ExitPopup {
id: exitDialog
applicationWindow: root
modalSource: content
}
Component.onCompleted: {
setTheme(App.settings.theme);
stackView.push("qrc:/qml/ScreenPlayApp/qml/Installed/InstalledView.qml", {
"sidebar": sidebar
});
if (!App.settings.silentStart) {
App.showDockIcon(true);
root.show();
}
App.installedListModel.reset();
}
Item {
id: noneContentItems
Util.SteamNotAvailable {
id: dialogSteam
modalSource: content
}
Util.MonitorConfiguration {
modalSource: content
}
Util.CriticalError {
window: root
modalSource: content
}
Monitors.MonitorsView {
id: monitors
modalSource: content
}
TrayIcon {
window: root
}
}
Connections {
function onThemeChanged(theme) {
setTheme(theme);
}
target: App.settings
}
Connections {
function onRequestNavigation(nav) {
switchPage(nav);
}
target: App.util
}
Connections {
function onRequestRaise() {
App.showDockIcon(true);
root.show();
}
function onActiveWidgetsCounterChanged() {
plausible.pageView("widget/count/" + App.screenPlayManager.activeWidgetsCounter);
}
function onActiveWallpaperCounterChanged() {
plausible.pageView("wallpaper/count/" + App.screenPlayManager.activeWallpaperCounter);
}
target: App.screenPlayManager
}
Item {
id: content
Loader {
id: baseLoader
asynchronous: true
anchors.fill: parent
StackView {
id: stackView
objectName: "stackView"
property int duration: 300
anchors {
top: nav.bottom
right: parent.right
bottom: parent.bottom
left: parent.left
}
replaceEnter: Transition {
OpacityAnimator {
from: 0
to: 1
duration: stackView.duration
easing.type: Easing.InOutQuart
}
ScaleAnimator {
from: 0.8
to: 1
duration: stackView.duration
easing.type: Easing.InOutQuart
}
}
replaceExit: Transition {
OpacityAnimator {
from: 1
to: 0
duration: stackView.duration
easing.type: Easing.InOutQuart
}
ScaleAnimator {
from: 1
to: 0.8
duration: stackView.duration
easing.type: Easing.InOutQuart
}
}
}
Connections {
function onSetSidebarActive(active) {
if (active)
sidebar.state = "active";
else
sidebar.state = "inactive";
}
function onSetNavigationItem(pos) {
if (pos === 0)
nav.onPageChanged("Create");
else
nav.onPageChanged("Workshop");
}
target: stackView.currentItem
ignoreUnknownSignals: true
}
Installed.Sidebar {
id: sidebar
objectName: "installedSidebar"
navHeight: nav.height
anchors {
top: parent.top
right: parent.right
bottom: parent.bottom
}
}
Navigation.Navigation {
id: nav
modalSource: content
anchors {
top: parent.top
right: parent.right
left: parent.left
}
onChangePage: function (name) {
monitors.close();
switchPage(name);
}
}
}
}

202
ScreenPlay/qml/Base.qml Normal file
View File

@ -0,0 +1,202 @@
import QtQuick
import QtQuick.Controls
import ScreenPlayUtil as Util
import ScreenPlayApp 1.0
import "Monitors" as Monitors
import "Installed" as Installed
import "Navigation" as Navigation
import "Community" as Community
Item {
id: content
anchors.fill: parent
Component.onCompleted: {
stackView.push(
"qrc:/qml/ScreenPlayApp/qml/Installed/InstalledView.qml", {
"sidebar": sidebar
})
startTimer.start()
}
Timer {
id: startTimer
interval: 10
onTriggered: App.installedListModel.reset()
}
function switchPage(name) {
if (nav.currentNavigationName === name) {
if (name === "Installed")
App.installedListModel.reset();
}
if (name === "Installed") {
stackView.replace("qrc:/qml/ScreenPlayApp/qml/Installed/InstalledView.qml", {
"sidebar": sidebar
});
return;
}
stackView.replace("qrc:/qml/ScreenPlayApp/qml/" + name + "/" + name + "View.qml", {
"modalSource": content
});
nav.setNavigation(name);
sidebar.state = "inactive";
}
Navigation.ExitPopup {
id: exitDialog
applicationWindow: root
modalSource: content
}
Item {
id: noneContentItems
Util.SteamNotAvailable {
id: dialogSteam
modalSource: content
}
Util.MonitorConfiguration {
modalSource: content
}
Util.CriticalError {
window: root
modalSource: content
}
Monitors.MonitorsView {
id: monitors
modalSource: content
}
TrayIcon {
window: root
}
}
Connections {
function onThemeChanged(theme) {
setTheme(theme);
}
target: App.settings
}
Connections {
function onRequestNavigation(nav) {
switchPage(nav);
}
target: App.util
}
Connections {
function onRequestRaise() {
App.showDockIcon(true);
root.show();
}
function onActiveWidgetsCounterChanged() {
plausible.pageView("widget/count/" + App.screenPlayManager.activeWidgetsCounter);
}
function onActiveWallpaperCounterChanged() {
plausible.pageView("wallpaper/count/" + App.screenPlayManager.activeWallpaperCounter);
}
target: App.screenPlayManager
}
StackView {
id: stackView
objectName: "stackView"
property int duration: 300
anchors {
top: nav.bottom
right: parent.right
bottom: parent.bottom
left: parent.left
}
replaceEnter: Transition {
OpacityAnimator {
from: 0
to: 1
duration: stackView.duration
easing.type: Easing.InOutQuart
}
ScaleAnimator {
from: 0.8
to: 1
duration: stackView.duration
easing.type: Easing.InOutQuart
}
}
replaceExit: Transition {
OpacityAnimator {
from: 1
to: 0
duration: stackView.duration
easing.type: Easing.InOutQuart
}
ScaleAnimator {
from: 1
to: 0.8
duration: stackView.duration
easing.type: Easing.InOutQuart
}
}
}
Connections {
function onSetSidebarActive(active) {
if (active)
sidebar.state = "active";
else
sidebar.state = "inactive";
}
function onSetNavigationItem(pos) {
if (pos === 0)
nav.onPageChanged("Create");
else
nav.onPageChanged("Workshop");
}
target: stackView.currentItem
ignoreUnknownSignals: true
}
Installed.Sidebar {
id: sidebar
objectName: "installedSidebar"
navHeight: nav.height
anchors {
top: parent.top
right: parent.right
bottom: parent.bottom
}
}
Navigation.Navigation {
id: nav
modalSource: content
anchors {
top: parent.top
right: parent.right
left: parent.left
}
onChangePage: function (name) {
monitors.close();
switchPage(name);
}
}
}

View File

@ -2,7 +2,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
TabButton {
id: control

View File

@ -4,7 +4,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
Item {
id: root

View File

@ -5,7 +5,7 @@ import Qt5Compat.GraphicalEffects
import QtQuick.Layouts
import QtQml.XmlListModel
import ScreenPlayApp
import ScreenPlay
Item {
id: root

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material.impl
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
Rectangle {

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material.impl
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
Item {

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material.impl
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
Item {

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material.impl
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
Item {

View File

@ -4,7 +4,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
Item {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls.Material
import QtQuick.Controls
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
WizardPage {

View File

@ -4,7 +4,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
WizardPage {

View File

@ -4,7 +4,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
WizardPage {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls.Material
import QtQuick.Controls
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
WizardPage {

View File

@ -4,7 +4,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
Item {
id: root

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import QtQuick.Layouts
import QtQuick.Dialogs
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
import "../../"

View File

@ -4,7 +4,7 @@ import QtQuick.Controls.Material
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import ScreenPlayApp
import ScreenPlay
Item {
id: wrapperError

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import QtQuick.Layouts
import QtQuick.Dialogs
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
Item {

View File

@ -4,7 +4,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
Item {

View File

@ -4,7 +4,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
WizardPage {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls.Material
import QtQuick.Controls
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
WizardPage {

View File

@ -4,7 +4,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
WizardPage {

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import QtQuick.Layouts
import QtQuick.Window
import ScreenPlayApp
import ScreenPlay
FocusScope {
id: root

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material.impl
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
Item {

View File

@ -7,7 +7,7 @@ import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material.impl
import QtCore as QCore
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
Item {

View File

@ -2,7 +2,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
Item {

View File

@ -3,7 +3,7 @@ import Qt5Compat.GraphicalEffects
import QtQuick.Controls
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
Item {

View File

@ -6,7 +6,7 @@ import QtQuick.Dialogs
import QtQuick.Controls.Material
import QtQuick.Controls.Material.impl
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
import "../Monitors"

View File

@ -4,7 +4,7 @@ import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
ColumnLayout {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
Rectangle {
id: root

View File

@ -2,7 +2,7 @@ import QtQuick
import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
Item {

View File

@ -5,7 +5,7 @@ import QtQuick.Layouts
import QtQuick.Dialogs
import Qt5Compat.GraphicalEffects
import ScreenPlayApp
import ScreenPlay
Item {
id: root

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import QtQuick.Layouts
import QtQuick.Controls.Material.impl
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
Util.Popup {
@ -142,7 +142,7 @@ Util.Popup {
font.family: App.settings.font
enabled: App.screenPlayManager.activeWallpaperCounter > 0
onClicked: {
if (!App.screenPlayManager.removeAllWallpapers())
if (!App.screenPlayManager.removeAllWallpapers(true))
print("Unable to close all wallpaper!");
root.close();
}

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Controls.Material.impl
import ScreenPlayApp
import ScreenPlay
Rectangle {
id: root

View File

@ -6,7 +6,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
import Qt5Compat.GraphicalEffects

View File

@ -6,7 +6,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material.impl
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
Rectangle {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
Item {
id: settingsBool

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
Item {
id: settingsButton

View File

@ -1,7 +1,7 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import ScreenPlay
import ScreenPlayApp
Control {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
Item {
id: root

View File

@ -2,7 +2,7 @@ import QtQuick
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import ScreenPlayApp
import ScreenPlay
Item {
id: settingsHeader

View File

@ -6,7 +6,6 @@ import QtQuick.Controls.Material
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil
Item {
@ -200,7 +199,8 @@ Item {
}
}
onActivated: {
App.settings.setLanguage(settingsLanguage.comboBox.currentValue);
let language = settingsLanguage.comboBox.currentValue
App.settings.setLanguage(language);
App.settings.retranslateUI();
}
}

View File

@ -2,7 +2,7 @@ import QtQuick
import QtQuick.Window
import Qt.labs.platform
import ScreenPlayApp
import ScreenPlay
SystemTrayIcon {
id: root

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Layouts
import ScreenPlay
import ScreenPlayWorkshop
Item {

View File

@ -1,18 +1,24 @@
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
#include "ScreenPlay/app.h"
#include <QDir>
#include <QElapsedTimer>
#include <QGuiApplication>
#include <QIcon>
#include <QObject>
#include <QProcessEnvironment>
#include <QQuickStyle>
#include <QStringList>
#include <QUrl>
#include <QVersionNumber>
#include <QtGlobal>
#include <QtSvg>
#if defined(Q_OS_MACOS)
#include "ScreenPlayUtil/macutils.h"
#endif
#include "ScreenPlay/CMakeVariables.h"
#include "ScreenPlayUtil/steamenumsgenerated.h"
#include "app.h"
#include <QGuiApplication>
#include <QProcessEnvironment>
#include <QQuickStyle>
#include <QVersionNumber>
namespace ScreenPlay {
/*!
@ -32,25 +38,6 @@ namespace ScreenPlay {
\brief The App class contains all members for ScreenPlay.
*/
/*!
\brief Constructor creates and holds all classes used by ScreenPlay via unique_ptr or
shared_ptr.
*/
App::App()
: QObject(nullptr)
{
QGuiApplication::setWindowIcon(QIcon(":/qml/ScreenPlayApp/assets/icons/app.ico"));
QGuiApplication::setOrganizationName("ScreenPlay");
QGuiApplication::setOrganizationDomain("screen-play.app");
QGuiApplication::setApplicationName("ScreenPlay");
QGuiApplication::setApplicationVersion(QString(SCREENPLAY_VERSION));
QGuiApplication::setQuitOnLastWindowClosed(false);
// ScreenPlayManager first to check if another ScreenPlay Instace is running
m_screenPlayManager = std::make_unique<ScreenPlayManager>();
m_isAnotherScreenPlayInstanceRunning = m_screenPlayManager->isAnotherScreenPlayInstanceRunning();
}
/*!
\brief Used for initialization after the constructor. The sole purpose is to check if
another ScreenPlay instance is running and then quit early. This is also because we cannot
@ -77,6 +64,7 @@ void App::init()
using std::make_shared, std::make_unique;
m_screenPlayManager = make_unique<ScreenPlayManager>();
m_globalVariables = make_shared<GlobalVariables>();
m_monitorListModel = make_shared<MonitorListModel>();
m_util = make_unique<Util>();
@ -84,7 +72,6 @@ void App::init()
m_settings = make_shared<Settings>(m_globalVariables);
m_installedListModel = make_shared<InstalledListModel>(m_globalVariables, m_settings);
m_installedListFilter = make_shared<InstalledListFilter>(m_installedListModel);
m_mainWindowEngine = make_unique<QQmlApplicationEngine>();
// Only create anonymousTelemetry if user did not disallow!
if (m_settings->anonymousTelemetry()) {
@ -114,7 +101,7 @@ void App::init()
// When the installed storage path changed
QObject::connect(m_settings.get(), &Settings::resetInstalledListmodel, m_installedListModel.get(), &InstalledListModel::reset);
QObject::connect(m_settings.get(), &Settings::requestRetranslation, m_mainWindowEngine.get(), &QQmlEngine::retranslate);
QObject::connect(m_settings.get(), &Settings::requestRetranslation, this, &App::requestRetranslation);
m_settings->setupLanguage();
QObject::connect(m_globalVariables.get(), &GlobalVariables::localStoragePathChanged, this, [this](QUrl localStoragePath) {
@ -122,9 +109,6 @@ void App::init()
m_settings->setqSetting("ScreenPlayContentPath", localStoragePath.toString());
});
// Init after we have the paths from settings
m_installedListModel->init();
auto* guiAppInst = dynamic_cast<QGuiApplication*>(QGuiApplication::instance());
// Set visible if the -silent parameter was not set
@ -133,16 +117,15 @@ void App::init()
settings()->setSilentStart(true);
}
qmlRegisterSingletonInstance("ScreenPlay", 1, 0, "App", this);
m_mainWindowEngine->addImportPath(guiAppInst->applicationDirPath() + "/qml");
guiAppInst->addLibraryPath(guiAppInst->applicationDirPath() + "/qml");
QQuickStyle::setStyle("Material");
m_mainWindowEngine->load(QUrl(QStringLiteral("qrc:/qml/ScreenPlayApp/main.qml")));
// Must be called last to display a error message on startup by the qml engine
m_screenPlayManager->init(m_globalVariables, m_monitorListModel, m_settings);
QObject::connect(m_monitorListModel.get(), &MonitorListModel::monitorConfigurationChanged, m_screenPlayManager.get(), &ScreenPlayManager::removeAllWallpapers);
QObject::connect(
m_monitorListModel.get(),
&MonitorListModel::monitorConfigurationChanged,
m_screenPlayManager.get(), [this]() {
m_screenPlayManager->removeAllWallpapers(true);
});
}
QString App::version() const
@ -156,18 +139,13 @@ QString App::version() const
*/
void App::exit()
{
m_screenPlayManager->removeAllWallpapers();
m_screenPlayManager->removeAllWidgets();
m_screenPlayManager->removeAllWallpapers(false);
m_screenPlayManager->removeAllWidgets(false);
// Must be called inside a separate event loop otherwise we
// would kill the qml engine while it is calling this function.
// A single shot timer is a handy woraround for this.
QTimer::singleShot(0, this, [this]() {
auto* appInst = QGuiApplication::instance();
// We must ensure that we kill the qml engine first
// before we destory the rest of the app
m_mainWindowEngine->clearSingletons();
m_mainWindowEngine.reset();
appInst->quit();
emit requestExit();
});
}
@ -303,20 +281,6 @@ void App::setInstalledListFilter(InstalledListFilter* installedListFilter)
m_installedListFilter.reset(installedListFilter);
emit installedListFilterChanged(m_installedListFilter.get());
}
/*!
\property App::mainWindowEngine
\brief .
.
*/
void App::setMainWindowEngine(QQmlApplicationEngine* mainWindowEngine)
{
if (m_mainWindowEngine.get() == mainWindowEngine)
return;
m_mainWindowEngine.reset(mainWindowEngine);
emit mainWindowEngineChanged(m_mainWindowEngine.get());
}
/*!
\property App::wizards
\brief .
@ -331,6 +295,24 @@ void App::setWizards(Wizards* wizards)
m_wizards.reset(wizards);
emit wizardsChanged(m_wizards.get());
}
QQmlEngine* App::engine() const
{
return m_engine;
}
void App::setEngine(QQmlEngine* engine)
{
m_engine = engine;
if (!m_engine) {
qFatal("QQmlEngine not set");
}
QObject::connect(
m_settings.get(),
&Settings::requestRetranslation,
m_engine,
&QQmlEngine::retranslate);
}
}
#include "moc_app.cpp"

View File

@ -0,0 +1,59 @@
#include "ScreenPlay/applicationengine.h"
#include "ScreenPlay/CMakeVariables.h"
#include "ScreenPlay/app.h"
#include "ScreenPlay/applicationengine.h"
#include <QIcon>
#include <QQuickStyle>
namespace ScreenPlay {
ApplicationEngine::ApplicationEngine(QObject* parent)
: QQmlApplicationEngine { parent }
{
QGuiApplication::setWindowIcon(QIcon(":/qml/ScreenPlayApp/assets/icons/app.ico"));
QGuiApplication::setOrganizationName("ScreenPlay");
QGuiApplication::setOrganizationDomain("screen-play.app");
QGuiApplication::setApplicationName("ScreenPlay");
QGuiApplication::setApplicationVersion(QString(SCREENPLAY_VERSION));
QGuiApplication::setQuitOnLastWindowClosed(false);
}
/*!
\brief Checks if another ScreenPlay instance is running by trying to connect to a pipe
with the name ScreenPlay.
If successful we send a raise command and quit via m_isAnotherScreenPlayInstanceRunning = true.
*/
bool ScreenPlay::ApplicationEngine::isAnotherScreenPlayInstanceRunning()
{
QLocalSocket socket;
socket.connectToServer("ScreenPlay", QIODeviceBase::ExistingOnly);
// If we cannot connect to a running ScreenPlay
// pipe we are alone
if (!socket.isOpen()) {
socket.close();
return false;
}
qInfo("Another ScreenPlay app is already running!");
QByteArray msg = "command=requestRaise";
socket.write(msg);
socket.waitForBytesWritten(500);
socket.close();
return true;
}
void ApplicationEngine::init()
{
auto* guiAppInst = dynamic_cast<QGuiApplication*>(QGuiApplication::instance());
addImportPath(guiAppInst->applicationDirPath() + "/qml");
guiAppInst->addLibraryPath(guiAppInst->applicationDirPath() + "/qml");
QQuickStyle::setStyle("Material");
load(QUrl(QStringLiteral("qrc:/qml/ScreenPlayApp/main.qml")));
App* singleton = singletonInstance<App*>("ScreenPlayApp", "App");
singleton->setEngine(this);
}
}

View File

@ -13,7 +13,7 @@ namespace ScreenPlay {
/*!
\brief Constructs the global variabls.
*/
ScreenPlay::GlobalVariables::GlobalVariables(QObject* parent)
GlobalVariables::GlobalVariables(QObject* parent)
: QObject(parent)
{
setLocalSettingsPath(QUrl { QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) });
@ -71,6 +71,13 @@ void GlobalVariables::setGodotEditorExecutablePath(QUrl godotEditorExecutablePat
emit godotEditorExecutablePathChanged(m_godotEditorExecutablePath);
}
void GlobalVariables::setVersion(Version version)
{
if (m_version == version)
return;
m_version = version;
emit versionChanged(m_version);
}
}
#include "moc_globalvariables.cpp"

View File

@ -23,12 +23,6 @@ ScreenPlayManager::ScreenPlayManager(
QObject* parent)
: QObject { parent }
{
if (checkIsAnotherScreenPlayInstanceRunning()) {
m_isAnotherScreenPlayInstanceRunning = true;
return;
}
m_server = std::make_unique<QLocalServer>();
QObject::connect(m_server.get(), &QLocalServer::newConnection, this, &ScreenPlayManager::newConnection);
@ -47,29 +41,6 @@ ScreenPlayManager::ScreenPlayManager(
});
}
/*!
\brief Checks if another ScreenPlay instance is running by trying to connect to a pipe
with the name ScreenPlay.
If successful we send a raise command and quit via m_isAnotherScreenPlayInstanceRunning = true.
*/
bool ScreenPlayManager::checkIsAnotherScreenPlayInstanceRunning()
{
QLocalSocket socket;
socket.connectToServer("ScreenPlay");
if (!socket.isOpen()) {
socket.close();
return false;
}
qInfo("Another ScreenPlay app is already running!");
QByteArray msg = "command=requestRaise";
socket.write(msg);
socket.waitForBytesWritten(500);
socket.close();
return true;
}
/*!
\brief Inits this class instead of init in the constructor. This is because we need to check
first if another ScreenPlay instance is running. If it is not the case we call this function.
@ -227,11 +198,11 @@ bool ScreenPlayManager::createWidget(
/*!
\brief Removes all wallpaper entries in the profiles.json.
*/
bool ScreenPlayManager::removeAllWallpapers()
bool ScreenPlayManager::removeAllWallpapers(bool saveToProfile)
{
if (m_screenPlayWallpapers.empty()) {
qWarning() << "Trying to remove all Wallpapers while m_screenPlayWallpapers is not empty. Count: " << m_screenPlayWallpapers.size();
qWarning() << "Trying to remove all Wallpapers while m_screenPlayWallpapers is not empty.";
return false;
}
@ -247,7 +218,8 @@ bool ScreenPlayManager::removeAllWallpapers()
}
}
emit requestSaveProfiles();
if (saveToProfile)
emit requestSaveProfiles();
return true;
}
@ -255,10 +227,10 @@ bool ScreenPlayManager::removeAllWallpapers()
/*!
\brief Removes all widgets and resets the activeWidgetCounter to 0.
*/
bool ScreenPlayManager::removeAllWidgets()
bool ScreenPlayManager::removeAllWidgets(bool saveToProfile)
{
if (m_screenPlayWidgets.empty()) {
qWarning() << "Trying to remove all Widgets while m_screenPlayWidgets is empty. Count: " << m_screenPlayWidgets.size();
qWarning() << "Trying to remove all Widgets while m_screenPlayWidgets is empty.";
return false;
}
@ -274,7 +246,8 @@ bool ScreenPlayManager::removeAllWidgets()
}
}
emit requestSaveProfiles();
if (saveToProfile)
emit requestSaveProfiles();
return true;
}
@ -557,9 +530,9 @@ bool ScreenPlayManager::loadProfiles()
}
std::optional<QVersionNumber> version = util.getVersionNumberFromString(configObj->value("version").toString());
if (version && *version != m_globalVariables->version()) {
qWarning() << "Version missmatch fileVersion: " << version->toString() << "m_version: " << m_globalVariables->version().toString();
QVersionNumber requiredVersion { 1, 0, 0 };
if (version && *version != requiredVersion) {
qWarning() << "Version missmatch fileVersion: " << version->toString() << "m_version: " << requiredVersion.toString();
return false;
}

View File

@ -302,7 +302,7 @@ bool Settings::retranslateUI()
QString langCode = fixLanguageCode(QVariant::fromValue(language()).toString());
QFile tsFile;
const QString qmPath = QGuiApplication::applicationDirPath() + "/translations/ScreenPlay_" + langCode + ".qm";
const QString qmPath = QGuiApplication::applicationDirPath() + "/assets/translations/ScreenPlay_" + langCode + ".qm";
if (tsFile.exists(qmPath)) {
if (!m_translator.load(qmPath)) {
qWarning() << "Unable to load translation file: " << qmPath;

View File

@ -10,14 +10,18 @@
#include <QDebug>
#include <QDir>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickItem>
#include <QQuickWindow>
#include <QtTest>
#include <QQmlEngineExtensionPlugin>
Q_IMPORT_QML_PLUGIN(ScreenPlayAppPlugin)
Q_IMPORT_QML_PLUGIN(ScreenPlayUtilPlugin)
#ifdef SCREENPLAY_STEAM
Q_IMPORT_QML_PLUGIN(ScreenPlayWorkshopPlugin)
#endif
class ScreenPlayTest : public QObject {
Q_OBJECT
@ -26,7 +30,7 @@ private slots:
{
app.init();
m_window = qobject_cast<QQmlApplicationEngine*>(app.mainWindowEngine()->rootObjects().first());
// m_window = qobject_cast<QQmlApplicationEngine*>(app.mainWindowEngine()->rootObjects().first());
m_window->addImportPath(QGuiApplication::instance()->applicationDirPath() + "/qml");
QVERIFY(m_window);

View File

@ -5,7 +5,7 @@ import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material.impl
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
Dialog {
id: root

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import QtQuick.Window
import Qt5Compat.GraphicalEffects
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
Util.Dialog {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
import ScreenPlayUtil as Util
Util.Dialog {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Dialogs
import ScreenPlayApp
import ScreenPlay
/*!
\qmltype Image Selector

View File

@ -1,7 +1,7 @@
import QtQuick
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
Item {
id: root

View File

@ -1,7 +1,7 @@
import QtQuick
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
Text {
text: qsTr("Headline Section")

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Dialogs
import ScreenPlayApp
import ScreenPlay
/*!
\qmltype Image Selector

View File

@ -3,7 +3,7 @@ import QtQuick.Controls.Material 2.0 as QQCM
import QtQuick.Layouts
import QtQuick.Controls as QQC
import ScreenPlayApp
import ScreenPlay
Item {
id: root

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
ColumnLayout {
id: root

View File

@ -2,7 +2,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
Item {
id: tag

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import Qt5Compat.GraphicalEffects
import QtQuick.Controls.Material
import ScreenPlayApp
import ScreenPlay
Item {
id: root

View File

@ -4,7 +4,7 @@ import QtQuick.Controls.Material
import QtQuick.Controls
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
ColumnLayout {
id: root

View File

@ -254,7 +254,9 @@ void LoggingHandler::writeToConsole(QtMsgType type, const QMessageLogContext& co
fmt::styled(now.toStdString(), fmt::emphasis::bold),
fmt::styled(typeIndicator.toStdString(), fg(color)),
message.toStdString(),
context.file,
// Using context.file (char*) directly results
// in a runtime crash in release
QString::fromUtf8(context.file).toStdString(),
line);
}
}

View File

@ -4,7 +4,7 @@ import QtQuick.Controls.Material
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import ScreenPlayApp
import ScreenPlay
Item {
id: root

View File

@ -5,7 +5,7 @@ import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import ScreenPlayWorkshop
import ScreenPlayUtil
import ScreenPlay
import ScreenPlayApp
Popup {

View File

@ -3,7 +3,7 @@ import QtQuick.Controls
import QtQuick.Controls.Material
import Qt5Compat.GraphicalEffects
import QtQuick.Layouts
import ScreenPlay
Item {
id: root