From a94c37b858dcd5736e24ad79eaee44e8dd8fab27 Mon Sep 17 00:00:00 2001 From: Vasily Date: Sat, 26 Jan 2019 18:32:29 +0100 Subject: [PATCH 1/3] Move UtilitiesPage and media_keys into separate folder The QML at the moment is a giant mess. Moving pages into individual folders and properly abstracting the sub components of the pages will allow for much easier development and better error messages. Additionally it will prevent polluting the global namespace. Really, all the reasons for avoiding globally available values and using abstractions in regular programming also come into play here. --- advancedSettings.pro | 4 ++-- src/res/qml/RootPage.qml | 1 + src/res/qml/mainwidget.qml | 2 +- src/res/qml/{ => utilities_page}/UtilitiesPage.qml | 1 + src/res/qml/{ => utilities_page}/media_keys/MediaButton.qml | 2 +- .../{ => utilities_page}/media_keys/MediaControllerKeys.qml | 2 +- .../media_keys/outline_play_pause_white_24dp.svg | 0 .../media_keys/outline_skip_next_white_24dp.svg | 0 .../media_keys/outline_skip_previous_white_24dp.svg | 0 .../media_keys/outline_stop_white_24dp.svg | 0 10 files changed, 7 insertions(+), 5 deletions(-) rename src/res/qml/{ => utilities_page}/UtilitiesPage.qml (99%) rename src/res/qml/{ => utilities_page}/media_keys/MediaButton.qml (98%) rename src/res/qml/{ => utilities_page}/media_keys/MediaControllerKeys.qml (99%) rename src/res/qml/{ => utilities_page}/media_keys/outline_play_pause_white_24dp.svg (100%) rename src/res/qml/{ => utilities_page}/media_keys/outline_skip_next_white_24dp.svg (100%) rename src/res/qml/{ => utilities_page}/media_keys/outline_skip_previous_white_24dp.svg (100%) rename src/res/qml/{ => utilities_page}/media_keys/outline_stop_white_24dp.svg (100%) diff --git a/advancedSettings.pro b/advancedSettings.pro index 4c17b2a..84d1f91 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -158,6 +158,6 @@ DISTFILES += \ src/res/qml/SettingsPage.qml \ src/res/qml/StatisticsPage.qml \ src/res/qml/SteamVRPage.qml \ - src/res/qml/UtilitiesPage.qml \ - src/res/qml/media_keys/* \ + src/res/qml/utilities_page/* \ + src/res/qml/utilities_page/media_keys/* \ src/res/qml/LineSeparator.qml diff --git a/src/res/qml/RootPage.qml b/src/res/qml/RootPage.qml index 1580e3f..04162b4 100644 --- a/src/res/qml/RootPage.qml +++ b/src/res/qml/RootPage.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import matzman666.advsettings 1.0 import "." // QTBUG-34418, singletons require explicit import to load qmldir file +import "utilities_page" MyStackViewPage { id: rootPage diff --git a/src/res/qml/mainwidget.qml b/src/res/qml/mainwidget.qml index 01fd8f0..e5f8f54 100644 --- a/src/res/qml/mainwidget.qml +++ b/src/res/qml/mainwidget.qml @@ -1,7 +1,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 - +import "utilities_page" Rectangle { id: root diff --git a/src/res/qml/UtilitiesPage.qml b/src/res/qml/utilities_page/UtilitiesPage.qml similarity index 99% rename from src/res/qml/UtilitiesPage.qml rename to src/res/qml/utilities_page/UtilitiesPage.qml index 7a10d02..609a839 100644 --- a/src/res/qml/UtilitiesPage.qml +++ b/src/res/qml/utilities_page/UtilitiesPage.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import matzman666.advsettings 1.0 import "media_keys" +import ".." MyStackViewPage { headerText: "Utilities" diff --git a/src/res/qml/media_keys/MediaButton.qml b/src/res/qml/utilities_page/media_keys/MediaButton.qml similarity index 98% rename from src/res/qml/media_keys/MediaButton.qml rename to src/res/qml/utilities_page/media_keys/MediaButton.qml index f9cb7c0..6536290 100644 --- a/src/res/qml/media_keys/MediaButton.qml +++ b/src/res/qml/utilities_page/media_keys/MediaButton.qml @@ -3,7 +3,7 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import matzman666.advsettings 1.0 // Necessary for the project specific Components. -import ".." +import "../.." MyPushButton2 { // Public properties diff --git a/src/res/qml/media_keys/MediaControllerKeys.qml b/src/res/qml/utilities_page/media_keys/MediaControllerKeys.qml similarity index 99% rename from src/res/qml/media_keys/MediaControllerKeys.qml rename to src/res/qml/utilities_page/media_keys/MediaControllerKeys.qml index d81da5f..0e0f094 100644 --- a/src/res/qml/media_keys/MediaControllerKeys.qml +++ b/src/res/qml/utilities_page/media_keys/MediaControllerKeys.qml @@ -3,7 +3,7 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import matzman666.advsettings 1.0 // Necessary for the project specific Components. -import ".." +import "../.." GroupBox { id: mediaKeysGroupBox diff --git a/src/res/qml/media_keys/outline_play_pause_white_24dp.svg b/src/res/qml/utilities_page/media_keys/outline_play_pause_white_24dp.svg similarity index 100% rename from src/res/qml/media_keys/outline_play_pause_white_24dp.svg rename to src/res/qml/utilities_page/media_keys/outline_play_pause_white_24dp.svg diff --git a/src/res/qml/media_keys/outline_skip_next_white_24dp.svg b/src/res/qml/utilities_page/media_keys/outline_skip_next_white_24dp.svg similarity index 100% rename from src/res/qml/media_keys/outline_skip_next_white_24dp.svg rename to src/res/qml/utilities_page/media_keys/outline_skip_next_white_24dp.svg diff --git a/src/res/qml/media_keys/outline_skip_previous_white_24dp.svg b/src/res/qml/utilities_page/media_keys/outline_skip_previous_white_24dp.svg similarity index 100% rename from src/res/qml/media_keys/outline_skip_previous_white_24dp.svg rename to src/res/qml/utilities_page/media_keys/outline_skip_previous_white_24dp.svg diff --git a/src/res/qml/media_keys/outline_stop_white_24dp.svg b/src/res/qml/utilities_page/media_keys/outline_stop_white_24dp.svg similarity index 100% rename from src/res/qml/media_keys/outline_stop_white_24dp.svg rename to src/res/qml/utilities_page/media_keys/outline_stop_white_24dp.svg From 629c4e2edba7b040754fe3114b863d4ab9bc3bb7 Mon Sep 17 00:00:00 2001 From: Vasily Date: Sat, 26 Jan 2019 20:29:14 +0100 Subject: [PATCH 2/3] Separate individual components into qml files This removes the massively indented logic in the previous version. Notice that individual components will still be imported with an import "utilities_page". Therefore anything except UtilitiesPage.qml should be in a separate folder. --- advancedSettings.pro | 5 +- src/res/qml/utilities_page/AlarmGroupBox.qml | 183 +++++++++ .../qml/utilities_page/KeyboardGroupBox.qml | 101 +++++ .../utilities_page/SteamDesktopGroupBox.qml | 109 ++++++ src/res/qml/utilities_page/UtilitiesPage.qml | 363 +----------------- 5 files changed, 400 insertions(+), 361 deletions(-) create mode 100644 src/res/qml/utilities_page/AlarmGroupBox.qml create mode 100644 src/res/qml/utilities_page/KeyboardGroupBox.qml create mode 100644 src/res/qml/utilities_page/SteamDesktopGroupBox.qml diff --git a/advancedSettings.pro b/advancedSettings.pro index 84d1f91..5abe543 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -160,4 +160,7 @@ DISTFILES += \ src/res/qml/SteamVRPage.qml \ src/res/qml/utilities_page/* \ src/res/qml/utilities_page/media_keys/* \ - src/res/qml/LineSeparator.qml + src/res/qml/LineSeparator.qml \ + src/res/qml/utilities_page/KeyboardGroupBox.qml \ + src/res/qml/utilities_page/AlarmGroupBox.qml \ + src/res/qml/utilities_page/SteamDesktopGroupBox.qml diff --git a/src/res/qml/utilities_page/AlarmGroupBox.qml b/src/res/qml/utilities_page/AlarmGroupBox.qml new file mode 100644 index 0000000..64ecab2 --- /dev/null +++ b/src/res/qml/utilities_page/AlarmGroupBox.qml @@ -0,0 +1,183 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import matzman666.advsettings 1.0 +import "media_keys" +import ".." + +GroupBox { + id: alarmGroupBox + Layout.fillWidth: true + + label: MyText { + leftPadding: 10 + text: "Alarm Clock" + bottomPadding: -10 + } + background: Rectangle { + color: "transparent" + border.color: "#ffffff" + radius: 8 + } + ColumnLayout { + anchors.fill: parent + + Rectangle { + color: "#ffffff" + height: 1 + Layout.fillWidth: true + Layout.bottomMargin: 5 + } + + RowLayout { + MyToggleButton { + id: alarmClockToggle + text: "" + onCheckedChanged: { + UtilitiesTabController.setAlarmEnabled(checked, false) + } + } + + Item { + Layout.fillWidth: true + } + + MyTextField { + id: alarmClockHourText + text: "00" + keyBoardUID: 602 + Layout.preferredWidth: 50 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseInt(input) + if (!isNaN(val)) { + if (val < 0) { + val = 0 + } else if (val > 23) { + val = 23 + } + UtilitiesTabController.setAlarmTimeHour(val, false) + } + parent.parent.parent.setAlarmHourText(UtilitiesTabController.alarmTimeHour) + } + } + + MyText { + text: ":" + } + + MyTextField { + id: alarmClockMinuteText + text: "00" + keyBoardUID: 603 + Layout.preferredWidth: 50 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseInt(input) + if (!isNaN(val)) { + if (val < 0) { + val = 0 + } else if (val > 59) { + val = 59 + } + UtilitiesTabController.setAlarmTimeMinute(val, false) + } + parent.parent.parent.setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute) + } + } + + Item { + Layout.fillWidth: true + } + + MyPushButton2 { + Layout.preferredWidth: 200 + text: "Current Time" + onClicked: { + UtilitiesTabController.setAlarmTimeToCurrentTime() + } + } + + MyPushButton2 { + Layout.leftMargin: 50 + Layout.preferredWidth: 120 + text: "+1 Hour" + onClicked: { + UtilitiesTabController.modAlarmTimeHour(1) + } + } + + MyPushButton2 { + Layout.preferredWidth: 120 + text: "-1 Hour" + onClicked: { + UtilitiesTabController.modAlarmTimeHour(-1) + } + } + + MyPushButton2 { + text: "+5 Min" + Layout.leftMargin: 50 + Layout.preferredWidth: 120 + onClicked: { + UtilitiesTabController.modAlarmTimeMinute(5) + } + } + + MyPushButton2 { + Layout.preferredWidth: 120 + text: "-5 Min" + onClicked: { + UtilitiesTabController.modAlarmTimeMinute(-5) + } + } + } + + RowLayout { + MyToggleButton { + id: alarmDontAnnoyToggle + text: "Don't Annoy me" + onCheckedChanged: { + UtilitiesTabController.setAlarmIsModal(!checked, false) + } + } + } + } + + Component.onCompleted: { + alarmClockToggle.checked = UtilitiesTabController.alarmEnabled + alarmDontAnnoyToggle.checked = !UtilitiesTabController.alarmIsModal + setAlarmHourText(UtilitiesTabController.alarmTimeHour) + setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute) + alarmGroupBox.visible = !OverlayController.desktopMode + } + Connections { + target: UtilitiesTabController + onAlarmEnabledChanged: { + alarmClockToggle.checked = UtilitiesTabController.alarmEnabled + } + onAlarmIsModalChanged: { + alarmDontAnnoyToggle.checked = !UtilitiesTabController.alarmIsModal + } + onAlarmTimeHourChanged: { + setAlarmHourText(UtilitiesTabController.alarmTimeHour) + } + onAlarmTimeMinuteChanged: { + setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute) + } + } + function setAlarmHourText(value) { + if (value < 9) { + alarmClockHourText.text = "0" + value + } else { + alarmClockHourText.text = value + } + } + function setAlarmMinuteText(value) { + if (value < 9) { + alarmClockMinuteText.text = "0" + value + } else { + alarmClockMinuteText.text = value + } + } +} diff --git a/src/res/qml/utilities_page/KeyboardGroupBox.qml b/src/res/qml/utilities_page/KeyboardGroupBox.qml new file mode 100644 index 0000000..f664c4b --- /dev/null +++ b/src/res/qml/utilities_page/KeyboardGroupBox.qml @@ -0,0 +1,101 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import matzman666.advsettings 1.0 +import "media_keys" +import ".." + +GroupBox { + id: keyboardGroupBox + Layout.fillWidth: true + + label: MyText { + leftPadding: 10 + text: "Keyboard Utilities" + bottomPadding: -10 + } + background: Rectangle { + color: "transparent" + border.color: "#ffffff" + radius: 8 + } + ColumnLayout { + anchors.fill: parent + + Rectangle { + color: "#ffffff" + height: 1 + Layout.fillWidth: true + Layout.bottomMargin: 5 + } + + + MyText { + text: "Send to active application: " + } + + RowLayout { + spacing: 18 + Layout.fillWidth: true + + MyPushButton { + text: "Keyboard Input" + Layout.fillWidth: true + onClicked: { + OverlayController.showKeyboard("", 601) + } + Connections { + target: OverlayController + onKeyBoardInputSignal: { + if (userValue == 601) { + UtilitiesTabController.sendKeyboardInput(input) + } + } + } + } + + MyPushButton { + text: "Enter" + Layout.fillWidth: true + onClicked: { + UtilitiesTabController.sendKeyboardEnter() + } + } + + MyPushButton { + text: "Alt-Tab" + Layout.fillWidth: true + onClicked: { + UtilitiesTabController.sendKeyboardAltTab() + } + } + + MyPushButton { + text: "Backspace" + Layout.fillWidth: true + onClicked: { + UtilitiesTabController.sendKeyboardBackspace(1) + } + } + + MyPushButton { + text: "10x Backspace" + Layout.fillWidth: true + onClicked: { + UtilitiesTabController.sendKeyboardBackspace(10) + } + } + + MyPushButton { + text: "Alt-Enter" + Layout.fillWidth: true + onClicked: { + UtilitiesTabController.sendKeyboardAltEnter() + } + } + } + } + Component.onCompleted: { + keyboardGroupBox.visible = !OverlayController.desktopMode + } +} diff --git a/src/res/qml/utilities_page/SteamDesktopGroupBox.qml b/src/res/qml/utilities_page/SteamDesktopGroupBox.qml new file mode 100644 index 0000000..7d08bc3 --- /dev/null +++ b/src/res/qml/utilities_page/SteamDesktopGroupBox.qml @@ -0,0 +1,109 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import matzman666.advsettings 1.0 +import "media_keys" +import ".." + +GroupBox { + id: steamDesktopGroupBox + Layout.fillWidth: true + + label: MyText { + leftPadding: 10 + text: "Steam Desktop Overlay Width" + bottomPadding: -10 + } + background: Rectangle { + color: "transparent" + border.color: "#ffffff" + radius: 8 + } + ColumnLayout { + anchors.fill: parent + + Rectangle { + color: "#ffffff" + height: 1 + Layout.fillWidth: true + Layout.bottomMargin: 5 + } + + ColumnLayout { + RowLayout { + MyPushButton2 { + id: steamDesktopWidthMinusButton + Layout.preferredWidth: 40 + text: "-" + onClicked: { + steamDesktopWidthSlider.value -= 1.0 + } + } + + MySlider { + id: steamDesktopWidthSlider + from: 0.1 + to: 32.0 + stepSize: 0.1 + value: 1.0 + Layout.fillWidth: true + onPositionChanged: { + var val = this.from + ( this.position * (this.to - this.from)) + steamDesktopWidthText.text = val.toFixed(1) + } + onValueChanged: { + UtilitiesTabController.setSteamDesktopOverlayWidth(value, false) + steamDesktopWidthText.text = value.toFixed(1) + } + } + + MyPushButton2 { + id: steamDesktopWidthPlusButton + Layout.preferredWidth: 40 + text: "+" + onClicked: { + steamDesktopWidthSlider.value += 1.0 + } + } + + MyTextField { + id: steamDesktopWidthText + text: "0.0" + keyBoardUID: 611 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 0.1) { + val = 0.1 + } + steamDesktopWidthSlider.value = val + UtilitiesTabController.setSteamDesktopOverlayWidth(val, false) + } + text = UtilitiesTabController.steamDesktopOverlayWidth.toFixed(1) + } + } + } + } + } + Component.onCompleted: { + steamDesktopGroupBox.visible = UtilitiesTabController.steamDesktopOverlayAvailable + if (steamDesktopGroupBox.visible) { + steamDesktopWidthSlider.value = UtilitiesTabController.steamDesktopOverlayWidth + } + } + Connections { + target: UtilitiesTabController + onSteamDesktopOverlayAvailableChanged: { + steamDesktopGroupBox.visible = UtilitiesTabController.steamDesktopOverlayAvailable + if (steamDesktopGroupBox.visible) { + steamDesktopWidthSlider.value = UtilitiesTabController.steamDesktopOverlayWidth + } + } + onSteamDesktopOverlayWidthChanged: { + steamDesktopWidthSlider.value = UtilitiesTabController.steamDesktopOverlayWidth + } + } +} diff --git a/src/res/qml/utilities_page/UtilitiesPage.qml b/src/res/qml/utilities_page/UtilitiesPage.qml index 609a839..6a8fcc7 100644 --- a/src/res/qml/utilities_page/UtilitiesPage.qml +++ b/src/res/qml/utilities_page/UtilitiesPage.qml @@ -12,322 +12,16 @@ MyStackViewPage { spacing: 18 - GroupBox { + KeyboardGroupBox { id: keyboardGroupBox - Layout.fillWidth: true - - label: MyText { - leftPadding: 10 - text: "Keyboard Utilities" - bottomPadding: -10 - } - background: Rectangle { - color: "transparent" - border.color: "#ffffff" - radius: 8 - } - ColumnLayout { - anchors.fill: parent - - Rectangle { - color: "#ffffff" - height: 1 - Layout.fillWidth: true - Layout.bottomMargin: 5 - } - - - MyText { - text: "Send to active application: " - } - - RowLayout { - spacing: 18 - Layout.fillWidth: true - - MyPushButton { - text: "Keyboard Input" - Layout.fillWidth: true - onClicked: { - OverlayController.showKeyboard("", 601) - } - Connections { - target: OverlayController - onKeyBoardInputSignal: { - if (userValue == 601) { - UtilitiesTabController.sendKeyboardInput(input) - } - } - } - } - - MyPushButton { - text: "Enter" - Layout.fillWidth: true - onClicked: { - UtilitiesTabController.sendKeyboardEnter() - } - } - - MyPushButton { - text: "Alt-Tab" - Layout.fillWidth: true - onClicked: { - UtilitiesTabController.sendKeyboardAltTab() - } - } - - MyPushButton { - text: "Backspace" - Layout.fillWidth: true - onClicked: { - UtilitiesTabController.sendKeyboardBackspace(1) - } - } - - MyPushButton { - text: "10x Backspace" - Layout.fillWidth: true - onClicked: { - UtilitiesTabController.sendKeyboardBackspace(10) - } - } - - MyPushButton { - text: "Alt-Enter" - Layout.fillWidth: true - onClicked: { - UtilitiesTabController.sendKeyboardAltEnter() - } - } - } - } } - - GroupBox { + AlarmGroupBox { id: alarmGroupBox - Layout.fillWidth: true - - label: MyText { - leftPadding: 10 - text: "Alarm Clock" - bottomPadding: -10 - } - background: Rectangle { - color: "transparent" - border.color: "#ffffff" - radius: 8 - } - ColumnLayout { - anchors.fill: parent - - Rectangle { - color: "#ffffff" - height: 1 - Layout.fillWidth: true - Layout.bottomMargin: 5 - } - - RowLayout { - MyToggleButton { - id: alarmClockToggle - text: "" - onCheckedChanged: { - UtilitiesTabController.setAlarmEnabled(checked, false) - } - } - - Item { - Layout.fillWidth: true - } - - MyTextField { - id: alarmClockHourText - text: "00" - keyBoardUID: 602 - Layout.preferredWidth: 50 - horizontalAlignment: Text.AlignHCenter - function onInputEvent(input) { - var val = parseInt(input) - if (!isNaN(val)) { - if (val < 0) { - val = 0 - } else if (val > 23) { - val = 23 - } - UtilitiesTabController.setAlarmTimeHour(val, false) - } - setAlarmHourText(UtilitiesTabController.alarmTimeHour) - } - } - - MyText { - text: ":" - } - - MyTextField { - id: alarmClockMinuteText - text: "00" - keyBoardUID: 603 - Layout.preferredWidth: 50 - horizontalAlignment: Text.AlignHCenter - function onInputEvent(input) { - var val = parseInt(input) - if (!isNaN(val)) { - if (val < 0) { - val = 0 - } else if (val > 59) { - val = 59 - } - UtilitiesTabController.setAlarmTimeMinute(val, false) - } - setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute) - } - } - - Item { - Layout.fillWidth: true - } - - MyPushButton2 { - Layout.preferredWidth: 200 - text: "Current Time" - onClicked: { - UtilitiesTabController.setAlarmTimeToCurrentTime() - } - } - - MyPushButton2 { - Layout.leftMargin: 50 - Layout.preferredWidth: 120 - text: "+1 Hour" - onClicked: { - UtilitiesTabController.modAlarmTimeHour(1) - } - } - - MyPushButton2 { - Layout.preferredWidth: 120 - text: "-1 Hour" - onClicked: { - UtilitiesTabController.modAlarmTimeHour(-1) - } - } - - MyPushButton2 { - text: "+5 Min" - Layout.leftMargin: 50 - Layout.preferredWidth: 120 - onClicked: { - UtilitiesTabController.modAlarmTimeMinute(5) - } - } - - MyPushButton2 { - Layout.preferredWidth: 120 - text: "-5 Min" - onClicked: { - UtilitiesTabController.modAlarmTimeMinute(-5) - } - } - } - - RowLayout { - MyToggleButton { - id: alarmDontAnnoyToggle - text: "Don't Annoy me" - onCheckedChanged: { - UtilitiesTabController.setAlarmIsModal(!checked, false) - } - } - } - } } - GroupBox { + SteamDesktopGroupBox { id: steamDesktopGroupBox - Layout.fillWidth: true - - label: MyText { - leftPadding: 10 - text: "Steam Desktop Overlay Width" - bottomPadding: -10 - } - background: Rectangle { - color: "transparent" - border.color: "#ffffff" - radius: 8 - } - ColumnLayout { - anchors.fill: parent - - Rectangle { - color: "#ffffff" - height: 1 - Layout.fillWidth: true - Layout.bottomMargin: 5 - } - - ColumnLayout { - RowLayout { - MyPushButton2 { - id: steamDesktopWidthMinusButton - Layout.preferredWidth: 40 - text: "-" - onClicked: { - steamDesktopWidthSlider.value -= 1.0 - } - } - - MySlider { - id: steamDesktopWidthSlider - from: 0.1 - to: 32.0 - stepSize: 0.1 - value: 1.0 - Layout.fillWidth: true - onPositionChanged: { - var val = this.from + ( this.position * (this.to - this.from)) - steamDesktopWidthText.text = val.toFixed(1) - } - onValueChanged: { - UtilitiesTabController.setSteamDesktopOverlayWidth(value, false) - steamDesktopWidthText.text = value.toFixed(1) - } - } - - MyPushButton2 { - id: steamDesktopWidthPlusButton - Layout.preferredWidth: 40 - text: "+" - onClicked: { - steamDesktopWidthSlider.value += 1.0 - } - } - - MyTextField { - id: steamDesktopWidthText - text: "0.0" - keyBoardUID: 611 - Layout.preferredWidth: 100 - Layout.leftMargin: 10 - horizontalAlignment: Text.AlignHCenter - function onInputEvent(input) { - var val = parseFloat(input) - if (!isNaN(val)) { - if (val < 0.1) { - val = 0.1 - } - steamDesktopWidthSlider.value = val - UtilitiesTabController.setSteamDesktopOverlayWidth(val, false) - } - text = UtilitiesTabController.steamDesktopOverlayWidth.toFixed(1) - } - } - } - } - } } MediaControllerKeys { @@ -338,56 +32,5 @@ MyStackViewPage { Layout.fillHeight: true } - Component.onCompleted: { - alarmClockToggle.checked = UtilitiesTabController.alarmEnabled - alarmDontAnnoyToggle.checked = !UtilitiesTabController.alarmIsModal - setAlarmHourText(UtilitiesTabController.alarmTimeHour) - setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute) - alarmGroupBox.visible = !OverlayController.desktopMode - keyboardGroupBox.visible = !OverlayController.desktopMode - steamDesktopGroupBox.visible = UtilitiesTabController.steamDesktopOverlayAvailable - if (steamDesktopGroupBox.visible) { - steamDesktopWidthSlider.value = UtilitiesTabController.steamDesktopOverlayWidth - } - } - - Connections { - target: UtilitiesTabController - onAlarmEnabledChanged: { - alarmClockToggle.checked = UtilitiesTabController.alarmEnabled - } - onAlarmIsModalChanged: { - alarmDontAnnoyToggle.checked = !UtilitiesTabController.alarmIsModal - } - onAlarmTimeHourChanged: { - setAlarmHourText(UtilitiesTabController.alarmTimeHour) - } - onAlarmTimeMinuteChanged: { - setAlarmMinuteText(UtilitiesTabController.alarmTimeMinute) - } - onSteamDesktopOverlayAvailableChanged: { - steamDesktopGroupBox.visible = UtilitiesTabController.steamDesktopOverlayAvailable - if (steamDesktopGroupBox.visible) { - steamDesktopWidthSlider.value = UtilitiesTabController.steamDesktopOverlayWidth - } - } - onSteamDesktopOverlayWidthChanged: { - steamDesktopWidthSlider.value = UtilitiesTabController.steamDesktopOverlayWidth - } - } - } - function setAlarmHourText(value) { - if (value < 9) { - alarmClockHourText.text = "0" + value - } else { - alarmClockHourText.text = value - } - } - function setAlarmMinuteText(value) { - if (value < 9) { - alarmClockMinuteText.text = "0" + value - } else { - alarmClockMinuteText.text = value - } } } From 70e7556de846b899ad68abfe61b6e119c856e5de Mon Sep 17 00:00:00 2001 From: Vasily Date: Sat, 26 Jan 2019 22:30:38 +0100 Subject: [PATCH 3/3] Move components into their own directories This prevents the import "utilities_page" from also importing the subcomponents. They should not be in the global namespace. --- advancedSettings.pro | 6 +++--- src/res/qml/utilities_page/UtilitiesPage.qml | 4 +++- .../qml/utilities_page/{ => alarm_clock}/AlarmGroupBox.qml | 3 +-- .../{ => desktop_size}/SteamDesktopGroupBox.qml | 3 +-- .../{ => keyboard_utils}/KeyboardGroupBox.qml | 3 +-- 5 files changed, 9 insertions(+), 10 deletions(-) rename src/res/qml/utilities_page/{ => alarm_clock}/AlarmGroupBox.qml (99%) rename src/res/qml/utilities_page/{ => desktop_size}/SteamDesktopGroupBox.qml (99%) rename src/res/qml/utilities_page/{ => keyboard_utils}/KeyboardGroupBox.qml (98%) diff --git a/advancedSettings.pro b/advancedSettings.pro index 5abe543..a9485ea 100644 --- a/advancedSettings.pro +++ b/advancedSettings.pro @@ -161,6 +161,6 @@ DISTFILES += \ src/res/qml/utilities_page/* \ src/res/qml/utilities_page/media_keys/* \ src/res/qml/LineSeparator.qml \ - src/res/qml/utilities_page/KeyboardGroupBox.qml \ - src/res/qml/utilities_page/AlarmGroupBox.qml \ - src/res/qml/utilities_page/SteamDesktopGroupBox.qml + src/res/qml/utilities_page/keyboard_utils/* \ + src/res/qml/utilities_page/desktop_size/* \ + src/res/qml/utilities_page/alarm_clock/* diff --git a/src/res/qml/utilities_page/UtilitiesPage.qml b/src/res/qml/utilities_page/UtilitiesPage.qml index 6a8fcc7..146d60d 100644 --- a/src/res/qml/utilities_page/UtilitiesPage.qml +++ b/src/res/qml/utilities_page/UtilitiesPage.qml @@ -3,6 +3,9 @@ import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import matzman666.advsettings 1.0 import "media_keys" +import "alarm_clock" +import "desktop_size" +import "keyboard_utils" import ".." MyStackViewPage { @@ -11,7 +14,6 @@ MyStackViewPage { content: ColumnLayout { spacing: 18 - KeyboardGroupBox { id: keyboardGroupBox } diff --git a/src/res/qml/utilities_page/AlarmGroupBox.qml b/src/res/qml/utilities_page/alarm_clock/AlarmGroupBox.qml similarity index 99% rename from src/res/qml/utilities_page/AlarmGroupBox.qml rename to src/res/qml/utilities_page/alarm_clock/AlarmGroupBox.qml index 64ecab2..445c25f 100644 --- a/src/res/qml/utilities_page/AlarmGroupBox.qml +++ b/src/res/qml/utilities_page/alarm_clock/AlarmGroupBox.qml @@ -2,8 +2,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import matzman666.advsettings 1.0 -import "media_keys" -import ".." +import "../.." GroupBox { id: alarmGroupBox diff --git a/src/res/qml/utilities_page/SteamDesktopGroupBox.qml b/src/res/qml/utilities_page/desktop_size/SteamDesktopGroupBox.qml similarity index 99% rename from src/res/qml/utilities_page/SteamDesktopGroupBox.qml rename to src/res/qml/utilities_page/desktop_size/SteamDesktopGroupBox.qml index 7d08bc3..b43a0c2 100644 --- a/src/res/qml/utilities_page/SteamDesktopGroupBox.qml +++ b/src/res/qml/utilities_page/desktop_size/SteamDesktopGroupBox.qml @@ -2,8 +2,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import matzman666.advsettings 1.0 -import "media_keys" -import ".." +import "../.." GroupBox { id: steamDesktopGroupBox diff --git a/src/res/qml/utilities_page/KeyboardGroupBox.qml b/src/res/qml/utilities_page/keyboard_utils/KeyboardGroupBox.qml similarity index 98% rename from src/res/qml/utilities_page/KeyboardGroupBox.qml rename to src/res/qml/utilities_page/keyboard_utils/KeyboardGroupBox.qml index f664c4b..9100064 100644 --- a/src/res/qml/utilities_page/KeyboardGroupBox.qml +++ b/src/res/qml/utilities_page/keyboard_utils/KeyboardGroupBox.qml @@ -2,8 +2,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 import matzman666.advsettings 1.0 -import "media_keys" -import ".." +import "../.." GroupBox { id: keyboardGroupBox