From 41178e76d9462445462c1ebc3d17aa2cc89aa210 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Sun, 14 May 2023 22:33:44 +0200 Subject: [PATCH] Feat: dual timers and keyboard control --- android/AndroidManifest.xml | 2 +- headers/scstwappsettings.h | 6 +++-- resources/qml/SettingsDialog/StartPage.qml | 15 +++++++++++ resources/qml/main.qml | 29 +++++++++++++++++++--- shared-libraries | 2 +- 5 files changed, 47 insertions(+), 7 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 0c1bdf9..a718c1c 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/headers/scstwappsettings.h b/headers/scstwappsettings.h index c42fa1d..a2706bf 100644 --- a/headers/scstwappsettings.h +++ b/headers/scstwappsettings.h @@ -16,7 +16,8 @@ public: enum AppInternalSetting { InvalidSetting = -1, AppThemeSetting, - BaseStationIpSetting + BaseStationIpSetting, + KeyboardControlSetting }; Q_ENUM(AppInternalSetting) @@ -39,7 +40,8 @@ public: static QVariant::Type keyToType(int key) { QMap types = { {AppThemeSetting, QVariant::String}, - {BaseStationIpSetting, QVariant::String} + {BaseStationIpSetting, QVariant::String}, + {KeyboardControlSetting, QVariant::Bool} }; if(types.contains(AppInternalSetting(key))) diff --git a/resources/qml/SettingsDialog/StartPage.qml b/resources/qml/SettingsDialog/StartPage.qml index 931cd2f..17e00f8 100644 --- a/resources/qml/SettingsDialog/StartPage.qml +++ b/resources/qml/SettingsDialog/StartPage.qml @@ -74,4 +74,19 @@ Column { appTheme.setting.setValue(checked ? "Dark":"Light") } } + + /*----Style Settings----*/ + SmoothSwitchDelegate { + id: keyboardDel + text: qsTr("keyboard control") + + width: parent.width + height: parentObj.delegateHeight + + checked: scStwAppSettings.readSetting(ScStwAppSettings.KeyboardControlSetting) + + onCheckedChanged: { + scStwAppSettings.writeSetting(ScStwAppSettings.KeyboardControlSetting, checked) + } + } } diff --git a/resources/qml/main.qml b/resources/qml/main.qml index 08b3b72..7f8ea35 100644 --- a/resources/qml/main.qml +++ b/resources/qml/main.qml @@ -47,6 +47,21 @@ ApplicationWindow { state: scStwRemoteRace.state + Keys.onPressed: { + if (!scStwAppSettings.readSetting(ScStwAppSettings.KeyboardControlSetting) || scStwRemoteRace.state !== ScStwRace.RUNNING) { + return + } + + if(event.key === Qt.Key_A) { + defaultTimerA.stop() + } + + if(event.key === Qt.Key_L) { + defaultTimerB.stop() + } + } + + Rectangle { id: backgroundRect anchors.fill: parent @@ -77,7 +92,14 @@ ApplicationWindow { } ScStwTimer { - id: defaultTimer + id: defaultTimerA + letter: "A" + } + + + ScStwTimer { + id: defaultTimerB + letter: "B" } ScStwRemoteRace { @@ -88,7 +110,8 @@ ApplicationWindow { scStwClient: scStwClient Component.onCompleted: { - scStwRemoteRace.addTimer(defaultTimer) + scStwRemoteRace.addTimer(defaultTimerA) + scStwRemoteRace.addTimer(defaultTimerB) } onStateChanged: { @@ -210,7 +233,7 @@ ApplicationWindow { PropertyChanges { target: topToolBar - sizeMode: "medium" + sizeMode: scStwAppSettings.readSetting(ScStwAppSettings.KeyboardControlSetting) ? "large":"medium" } PropertyChanges { diff --git a/shared-libraries b/shared-libraries index 0f269a7..206d55f 160000 --- a/shared-libraries +++ b/shared-libraries @@ -1 +1 @@ -Subproject commit 0f269a76370d84c8d1f43a7298a59b6fac1c6980 +Subproject commit 206d55f301da6fbbb7c8ae3932349cb2bbc57efb