diff --git a/bin/win64/res/qml/RootPage.qml b/bin/win64/res/qml/RootPage.qml index 5746443..2e33634 100644 --- a/bin/win64/res/qml/RootPage.qml +++ b/bin/win64/res/qml/RootPage.qml @@ -5,12 +5,13 @@ import matzman666.advsettings 1.0 import "." // QTBUG-34418, singletons require explicit import to load qmldir file MyStackViewPage { + id: rootPage width: 1200 height: 800 headerText: "OpenVR Advanced Settings" - headerShowBackButton: false - stackView: mainView - content: Item { + headerShowBackButton: false + stackView: mainView + content: Item { ColumnLayout { anchors.fill: parent RowLayout { @@ -81,7 +82,7 @@ MyStackViewPage { activationSoundEnabled: false text: "Revive" Layout.fillWidth: true - visible: ReviveTabController.isOverlayInstalled + visible: SettingsTabController.forceRevivePage ? true : ReviveTabController.isOverlayInstalled onClicked: { MyResources.playFocusChangedSound() mainView.push(revivePage) @@ -394,6 +395,13 @@ MyStackViewPage { } } + Connections { + target: SettingsTabController + onForceRevivePageChanged: { + reviveButton.enabled = SettingsTabController.forceRevivePage + } + } + function updateStatistics() { var rotations = StatisticsTabController.hmdRotations if (rotations > 0) { diff --git a/bin/win64/res/qml/SettingsPage.qml b/bin/win64/res/qml/SettingsPage.qml index 884e198..9f067e2 100644 --- a/bin/win64/res/qml/SettingsPage.qml +++ b/bin/win64/res/qml/SettingsPage.qml @@ -18,12 +18,21 @@ MyStackViewPage { } } + MyToggleButton { + id: forceReviveToggle + text: "Force Revive Page" + onCheckedChanged: { + SettingsTabController.setForceRevivePage(checked, true) + } + } + Item { Layout.fillHeight: true } Component.onCompleted: { settingsAutoStartToggle.checked = SettingsTabController.autoStartEnabled + forceReviveToggle.checked = SettingsTabController.forceRevivePage } Connections { @@ -31,6 +40,9 @@ MyStackViewPage { onAutoStartEnabledChanged: { settingsAutoStartToggle.checked = SettingsTabController.autoStartEnabled } + onForceRevivePageChanged: { + forceReviveToggle.checked = SettingsTabController.forceRevivePage + } } } } diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index 3fcc629..a30da8d 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -67,6 +67,7 @@ private: QUrl m_runtimePathUrl; +public: // I know it's an ugly hack to make them public to enable external access, but I am too lazy to implement getters. SteamVRTabController steamVRTabController; ChaperoneTabController chaperoneTabController; MoveCenterTabController moveCenterTabController; diff --git a/src/tabcontrollers/ReviveTabController.cpp b/src/tabcontrollers/ReviveTabController.cpp index d4c0794..56a3ee6 100644 --- a/src/tabcontrollers/ReviveTabController.cpp +++ b/src/tabcontrollers/ReviveTabController.cpp @@ -26,7 +26,7 @@ namespace advsettings { void ReviveTabController::initStage1() { m_isOverlayInstalled = vr::VRApplications()->IsApplicationInstalled(appkey_overlay); - if (m_isOverlayInstalled) { + if (m_isOverlayInstalled || parent->settingsTabController.forceRevivePage()) { vr::EVRSettingsError vrSettingsError; float valuef = vr::VRSettings()->GetFloat(section_revive, key_pixelsPerDisplayPixel, &vrSettingsError); @@ -157,7 +157,7 @@ namespace advsettings { } void ReviveTabController::eventLoopTick() { - if (m_isOverlayInstalled) { + if (m_isOverlayInstalled || parent->settingsTabController.forceRevivePage()) { if (settingsUpdateCounter >= 50) { settingsUpdateCounter = 0; vr::EVRSettingsError vrSettingsError; @@ -718,7 +718,6 @@ namespace advsettings { } void ReviveTabController::addControllerProfile(QString name) { - vr::EVRSettingsError vrSettingsError; ReviveControllerProfile* profile = nullptr; for (auto& p : controllerProfiles) { if (p.profileName.compare(name.toStdString()) == 0) { diff --git a/src/tabcontrollers/SettingsTabController.cpp b/src/tabcontrollers/SettingsTabController.cpp index 3f6e59c..82bde48 100644 --- a/src/tabcontrollers/SettingsTabController.cpp +++ b/src/tabcontrollers/SettingsTabController.cpp @@ -8,6 +8,13 @@ namespace advsettings { void SettingsTabController::initStage1() { m_autoStartEnabled = vr::VRApplications()->GetApplicationAutoLaunch(OverlayController::applicationKey); + auto settings = OverlayController::appSettings(); + settings->beginGroup("applicationSettings"); + auto value = settings->value("forceRevivePage", m_forceRevivePage); + settings->endGroup(); + if (value.isValid() && !value.isNull()) { + m_forceRevivePage = value.toBool(); + } } void SettingsTabController::initStage2(OverlayController * parent, QQuickWindow * widget) { @@ -41,4 +48,24 @@ void SettingsTabController::setAutoStartEnabled(bool value, bool notify) { } } + +bool SettingsTabController::forceRevivePage() const { + return m_forceRevivePage; +} + + +void SettingsTabController::setForceRevivePage(bool value, bool notify) { + if (m_forceRevivePage != value) { + m_forceRevivePage = value; + auto settings = OverlayController::appSettings(); + settings->beginGroup("applicationSettings"); + settings->setValue("forceRevivePage", m_forceRevivePage); + settings->endGroup(); + settings->sync(); + if (notify) { + emit forceRevivePageChanged(m_forceRevivePage); + } + } +} + } // namespace advconfig diff --git a/src/tabcontrollers/SettingsTabController.h b/src/tabcontrollers/SettingsTabController.h index 3763e5c..c3f91d3 100644 --- a/src/tabcontrollers/SettingsTabController.h +++ b/src/tabcontrollers/SettingsTabController.h @@ -14,6 +14,7 @@ class OverlayController; class SettingsTabController : public QObject { Q_OBJECT Q_PROPERTY(bool autoStartEnabled READ autoStartEnabled WRITE setAutoStartEnabled NOTIFY autoStartEnabledChanged) + Q_PROPERTY(bool forceRevivePage READ forceRevivePage WRITE setForceRevivePage NOTIFY forceRevivePageChanged) private: OverlayController* parent; @@ -22,6 +23,7 @@ private: unsigned settingsUpdateCounter = 0; bool m_autoStartEnabled = false; + bool m_forceRevivePage = false; public: void initStage1(); @@ -30,12 +32,15 @@ public: void eventLoopTick(); bool autoStartEnabled() const; + bool forceRevivePage() const; public slots: void setAutoStartEnabled(bool value, bool notify = true); + void setForceRevivePage(bool value, bool notify = true); signals: void autoStartEnabledChanged(bool value); + void forceRevivePageChanged(bool value); }; } // namespace advsettings