From 6e1a26c55e9194f5f762d38e9387247afb482cfd Mon Sep 17 00:00:00 2001 From: kelteseth Date: Fri, 23 Feb 2018 12:34:10 +0100 Subject: [PATCH] Add basic and not working check if user is ingame --- ScreenPlay/qml/Settings/Settings.qml | 60 +++++++++++++++++----------- ScreenPlay/src/settings.cpp | 19 +++++++++ ScreenPlay/src/settings.h | 22 +++++++++- 3 files changed, 76 insertions(+), 25 deletions(-) diff --git a/ScreenPlay/qml/Settings/Settings.qml b/ScreenPlay/qml/Settings/Settings.qml index 7a9cab6b..cd312010 100644 --- a/ScreenPlay/qml/Settings/Settings.qml +++ b/ScreenPlay/qml/Settings/Settings.qml @@ -38,7 +38,7 @@ Item { anchors { top: parent.top topMargin: 20 - bottom:parent.bottom + bottom: parent.bottom bottomMargin: 20 horizontalCenter: parent.horizontalCenter } @@ -124,6 +124,19 @@ Item { } SettingsHorizontalSeperator { } + SettingBool { + headline: qsTr("Send anonymous crash reports and statistics") + description: qsTr("Help us make ScreenPlay faster and more stable. All collected data is purely anonymous and only used for development purposes!") + isChecked: screenPlaySettings.sendStatistics + onCheckboxChanged: { + screenPlaySettings.setSendStatistics(checked) + screenPlaySettings.writeSingleSettingConfig( + "sendStatistics", checked) + } + } + SettingsHorizontalSeperator { + } + SettingsButton { headline: qsTr("Set save location") description: screenPlaySettings.localStoragePath //qsTr("Choose where to find you content. The default save location is you steam installation") @@ -139,24 +152,13 @@ Item { } } } - SettingsHorizontalSeperator { - } - SettingBool { - headline: qsTr("Send anonymous crash reports and statistics") - description: qsTr("Help us make ScreenPlay faster and more stable. All collected data is purely anonymous and only used for development purposes!") - isChecked: screenPlaySettings.sendStatistics - onCheckboxChanged: { - screenPlaySettings.setSendStatistics(checked) - screenPlaySettings.writeSingleSettingConfig("sendStatistics",checked) - } - } } } } Item { id: settingsPerformanceWrapper - height: 220 + height: 300 width: parent.width RectangularGlow { @@ -201,6 +203,18 @@ Item { } spacing: 10 + + SettingBool { + headline: qsTr("Pause wallpaper when ingame") + description: qsTr("To maximise your framerates ingame, you can enable this setting to pause all active wallpapers!") + isChecked: screenPlaySettings.pauseWallpaperWhenIngame + onCheckboxChanged: { + screenPlaySettings.setPauseWallpaperWhenIngame(checked) + screenPlaySettings.writeSingleSettingConfig("setPauseWallpaperWhenIngame",checked) + } + } + SettingsHorizontalSeperator { + } SettingsComboBox { id: settingsComboBox headline: qsTr("Default decoder") @@ -330,13 +344,13 @@ Item { horizontalAlignment: Text.AlignLeft font.pixelSize: 14 font.family: "Roboto" - width: parent.width *.6 - anchors{ - top:txtHeadline.bottom + width: parent.width * .6 + anchors { + top: txtHeadline.bottom topMargin: 6 - left:parent.left + left: parent.left leftMargin: 20 - right:imgLogoHead.left + right: imgLogoHead.left rightMargin: 20 bottom: parent.bottom } @@ -346,13 +360,12 @@ Item { source: "qrc:/assets/icons/icon_logo_head.svg" width: 150 height: 150 - sourceSize: Qt.size(150,150) - anchors{ - top:txtHeadline.bottom + sourceSize: Qt.size(150, 150) + anchors { + top: txtHeadline.bottom topMargin: -10 - right:parent.right + right: parent.right rightMargin: 20 - } } } @@ -366,7 +379,6 @@ Item { } } - } } } diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index 090a7756..dedac3b2 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -79,6 +79,11 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo m_highPriorityStart = configObj.value("highPriorityStart").toBool(); m_sendStatistics = configObj.value("sendStatistics").toBool(); int renderer = static_cast(configObj.value("renderer-value").toInt()); + + m_checkForOtherFullscreenApplicationTimer = new QTimer(this); + QObject::connect(&m_checkForOtherFullscreenApplicationTimer, &QTimer::timeout, this, &Settings::checkForOtherFullscreenApplication); + timer.start(1500); + } Settings::~Settings() @@ -323,6 +328,20 @@ void Settings::setScreenPlayWindowPath(const QUrl& screenPlayWindowPath) m_screenPlayWindowPath = screenPlayWindowPath; } +void Settings::checkForOtherFullscreenApplication() +{ + Wnd = GetForegroundWindow(); + RECT appBounds; + RECT rc; + GetWindowRect(GetDesktopWindow(), &rc); + if(hWnd =! GetDesktopWindow() && hWnd != GetShellWindow()) + { + GetWindowRect(hWnd, &appBounds); + } else { + + } +} + ActiveProfiles::ActiveProfiles() { } diff --git a/ScreenPlay/src/settings.h b/ScreenPlay/src/settings.h index 8c3caa62..a4a8db31 100644 --- a/ScreenPlay/src/settings.h +++ b/ScreenPlay/src/settings.h @@ -44,6 +44,7 @@ public: Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged) Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged) + Q_PROPERTY(bool pauseWallpaperWhenIngame READ pauseWallpaperWhenIngame WRITE setPauseWallpaperWhenIngame NOTIFY pauseWallpaperWhenIngameChanged) Q_PROPERTY(QUrl localStoragePath READ localStoragePath WRITE setLocalStoragePath NOTIFY localStoragePathChanged) Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged) Q_PROPERTY(int activeWallpaperCounter READ activeWallpaperCounter WRITE setActiveWallpaperCounter NOTIFY activeWallpaperCounterChanged) @@ -113,6 +114,11 @@ public: QUrl getScreenPlayWindowPath() const; void setScreenPlayWindowPath(const QUrl &screenPlayWindowPath); + bool pauseWallpaperWhenIngame() const + { + return m_pauseWallpaperWhenIngame; + } + signals: void autostartChanged(bool autostart); void highPriorityStartChanged(bool highPriorityStart); @@ -123,8 +129,12 @@ signals: void setMainWindowVisible(bool visible); void activeWallpaperCounterChanged(int activeWallpaperCounter); + void pauseWallpaperWhenIngameChanged(bool pauseWallpaperWhenIngame); + public slots: + void checkForOtherFullscreenApplication(); + void destroyWallpaper(QObject *ref); //Global settings @@ -256,6 +266,15 @@ public slots: emit activeWallpaperCounterChanged(m_activeWallpaperCounter); } + void setPauseWallpaperWhenIngame(bool pauseWallpaperWhenIngame) + { + if (m_pauseWallpaperWhenIngame == pauseWallpaperWhenIngame) + return; + + m_pauseWallpaperWhenIngame = pauseWallpaperWhenIngame; + emit pauseWallpaperWhenIngameChanged(m_pauseWallpaperWhenIngame); + } + private: void createDefaultConfig(); void createProfileConfig(); @@ -272,7 +291,7 @@ private: MonitorListModel* m_mlm; SDKConnector* m_sdkc; - QThread m_thread; + QTimer* m_checkForOtherFullscreenApplicationTimer; QVector> m_wallpapers; QVector m_widgets; @@ -285,6 +304,7 @@ private: bool m_hasWorkshopBannerSeen = false; QString m_decoder; int m_activeWallpaperCounter = 0; + bool m_pauseWallpaperWhenIngame = true; }; class ActiveProfiles {