diff --git a/dashboard/CMakeLists.txt b/dashboard/CMakeLists.txt index fdd1b0bf..5bd3e8c9 100644 --- a/dashboard/CMakeLists.txt +++ b/dashboard/CMakeLists.txt @@ -27,11 +27,16 @@ target_sources(wivrn-dashboard PRIVATE ${DBUS_INTERFACE_SRC}) set_source_files_properties(../images/wivrn.svg PROPERTIES QT_RESOURCE_ALIAS qml/wivrn.svg) +set_source_files_properties(qml/DashboardSettings.qml PROPERTIES + QT_QML_SINGLETON_TYPE TRUE +) + qt_add_qml_module(wivrn-dashboard URI io.github.wivrn.wivrn QML_FILES qml/Main.qml qml/ApkInstallPage.qml + qml/DashboardSettings.qml qml/SettingsPage.qml qml/HeadsetsPage.qml qml/HeadsetStatsPage.qml @@ -50,7 +55,6 @@ qt_add_qml_module(wivrn-dashboard qml/Github.svg ) - configure_file(gui_config.h.in gui_config.h) configure_file(io.github.wivrn.wivrn.desktop.in io.github.wivrn.wivrn.desktop) diff --git a/dashboard/qml/DashboardSettings.qml b/dashboard/qml/DashboardSettings.qml new file mode 100644 index 00000000..b681e497 --- /dev/null +++ b/dashboard/qml/DashboardSettings.qml @@ -0,0 +1,13 @@ +pragma Singleton + +import QtCore + +Settings { + property bool first_run: true + property bool show_system_checks: true + property string last_run_version: "" + + property bool adb_custom: false + property string adb_location: "" +} + diff --git a/dashboard/qml/Main.qml b/dashboard/qml/Main.qml index e810fb3d..a1f49d8c 100644 --- a/dashboard/qml/Main.qml +++ b/dashboard/qml/Main.qml @@ -42,15 +42,6 @@ Kirigami.ApplicationWindow { onClosing: Qt.quit() - Core.Settings { - id: settings - property alias first_run: root.first_run - property alias last_run_version: root.last_run_version - property bool show_system_checks: true - } - property bool first_run: true - property string last_run_version - width: 900 height: 800 @@ -76,10 +67,10 @@ Kirigami.ApplicationWindow { if (value == WivrnServer.FailedToStart) message_failed_to_start.visible = true; - if (root.first_run && started) { + if (DashboardSettings.first_run && started) { console.log("First run"); root.pageStack.push(Qt.createComponent("WizardPage.qml").createObject()); - root.first_run = false; + DashboardSettings.first_run = false; } } @@ -109,8 +100,8 @@ Kirigami.ApplicationWindow { if (WivrnServer.serverStatus == WivrnServer.Stopped) WivrnServer.start_server(); - if (root.last_run_version != ApkInstaller.currentVersion) { - root.last_run_version = ApkInstaller.currentVersion; + if (DashboardSettings.last_run_version != ApkInstaller.currentVersion) { + DashboardSettings.last_run_version = ApkInstaller.currentVersion; } } @@ -130,7 +121,7 @@ Kirigami.ApplicationWindow { text: i18n("Avahi daemon is not installed") type: Kirigami.MessageType.Warning showCloseButton: true - visible: settings.show_system_checks && !Avahi.installed + visible: DashboardSettings.show_system_checks && !Avahi.installed } Kirigami.InlineMessage { @@ -138,7 +129,7 @@ Kirigami.ApplicationWindow { text: i18n("Avahi daemon is not started") type: Kirigami.MessageType.Warning showCloseButton: true - visible: settings.show_system_checks && Avahi.installed && !Avahi.running + visible: DashboardSettings.show_system_checks && Avahi.installed && !Avahi.running actions: [ Kirigami.Action { visible: Avahi.canStart @@ -154,7 +145,7 @@ Kirigami.ApplicationWindow { // type: Kirigami.MessageType.Warning type: Kirigami.MessageType.Information showCloseButton: true - visible: settings.show_system_checks && !WivrnServer.capSysNice + visible: DashboardSettings.show_system_checks && !WivrnServer.capSysNice actions: [ Kirigami.Action { text: i18n("Fix it") @@ -168,7 +159,7 @@ Kirigami.ApplicationWindow { text: i18n("Firewall may not allow port 9757") type: Kirigami.MessageType.Warning showCloseButton: true - visible: settings.show_system_checks && Firewall.needSetup + visible: DashboardSettings.show_system_checks && Firewall.needSetup actions: [ Kirigami.Action { text: i18n("Fix it") diff --git a/dashboard/qml/SettingsPage.qml b/dashboard/qml/SettingsPage.qml index c3ad4bb3..944b6843 100644 --- a/dashboard/qml/SettingsPage.qml +++ b/dashboard/qml/SettingsPage.qml @@ -19,14 +19,6 @@ Kirigami.ScrollablePage { id: config } - Core.Settings { - property alias adb_custom: settings.adb_custom - property alias adb_location: settings.adb_location - property alias show_system_checks: show_system_checks.checked - } - property bool adb_custom - property string adb_location - ColumnLayout { id: column anchors.fill: parent @@ -272,7 +264,7 @@ Kirigami.ScrollablePage { enabled: adb_custom.checked Controls.TextField { id: adb_location - placeholderText: settings.adb_location + placeholderText: DashboardSettings.adb_location Layout.fillWidth: true } Controls.Button { @@ -383,9 +375,11 @@ Kirigami.ScrollablePage { } else { config.openvr = openvr.value } - settings.adb_custom = adb_custom.checked; - settings.adb_location = adb_location.text; - Adb.setPath(adb_custom.checked ? adb_location.text : "adb"); + DashboardSettings.adb_custom = adb_custom.checked; + DashboardSettings.adb_location = adb_location.text; + Adb.setPath(DashboardSettings.adb_custom.checked ? adb_location.text : "adb"); + + DashboardSettings.show_system_checks = show_system_checks.checked; config.debugGui = debug_gui.checked; config.steamVrLh = steamvr_lh.checked; @@ -403,8 +397,10 @@ Kirigami.ScrollablePage { openvr_combobox.load() - adb_custom.checked = settings.adb_custom; - adb_location.text = settings.adb_location; + adb_custom.checked = DashboardSettings.adb_custom; + adb_location.text = DashboardSettings.adb_location; + + show_system_checks.checked = DashboardSettings.show_system_checks; } Shortcut {