diff --git a/src/openvr/overlay_utils.cpp b/src/openvr/overlay_utils.cpp index d70ec0d..c2dc164 100644 --- a/src/openvr/overlay_utils.cpp +++ b/src/openvr/overlay_utils.cpp @@ -1,4 +1,5 @@ #include "overlay_utils.h" +#include "../overlaycontroller.h" namespace overlay { @@ -54,7 +55,10 @@ void setDesktopOverlayWidth( double width ) void setSettingsToValue( const std::string setting, const double value ) { - QSettings settings; + QSettings settings( QSettings::Format::IniFormat, + QSettings::Scope::UserScope, + application_strings::applicationOrganizationName, + application_strings::applicationName ); settings.beginGroup( strings::settingsGroupName ); settings.setValue( setting.c_str(), value ); settings.endGroup(); @@ -62,7 +66,12 @@ void setSettingsToValue( const std::string setting, const double value ) overlay::DesktopOverlay::DesktopOverlay() { - QSettings settings; + QSettings settings( QSettings::Format::IniFormat, + QSettings::Scope::UserScope, + application_strings::applicationOrganizationName, + application_strings::applicationName ); + + LOG( INFO ) << settings.fileName(); settings.beginGroup( strings::settingsGroupName ); m_width = settings.value( strings::widthSettingsName, defaultOverlayWidth ) .toDouble(); diff --git a/src/res/qml/common/FullWidthSliderBox.qml b/src/res/qml/common/FullWidthSliderBox.qml new file mode 100644 index 0000000..5a231ec --- /dev/null +++ b/src/res/qml/common/FullWidthSliderBox.qml @@ -0,0 +1,95 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 +import ovras.advsettings 1.0 + +GroupBox { + // Public properties + // Overload + property alias headerMessage: headerText.text + property alias sliderText: steamDesktopForwardText.text + property alias sliderValue: steamDesktopForwardSlider.value + property alias lowerLimit: steamDesktopForwardSlider.from + property alias upperLimit: steamDesktopForwardSlider.to + + + function onValueChanged(value) { + + } + + function onComponentComplete() { + + } + + + // Private properties + id: sliderBox + Layout.fillWidth: true + label: MyText { + id: headerText + leftPadding: 10 + text: "MISSING HEADER TEXT" + bottomPadding: -10 + } + background: Rectangle { + color: "transparent" + border.color: "#ffffff" + radius: 8 + } + + property real sliderStepSize: 0.10 + readonly property real rightLeftLimit: 4.0 + + ColumnLayout { + anchors.fill: parent + + LineSeparator { + } + + ColumnLayout { + RowLayout { + MyPushButton2 { + Layout.preferredWidth: 40 + text: "-" + onClicked: { + steamDesktopForwardSlider.value -= sliderStepSize + } + } + + MySlider { + id: steamDesktopForwardSlider + from: -rightLeftLimit + to: rightLeftLimit + stepSize: sliderStepSize + Layout.fillWidth: true + onValueChanged: { + sliderBox.onValueChanged(this.value) + } + } + + MyPushButton2 { + Layout.preferredWidth: 40 + text: "+" + onClicked: { + steamDesktopForwardSlider.value += sliderStepSize + } + } + + MyTextField { + id: steamDesktopForwardText + text: "0.0" + keyBoardUID: 611 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + onAcceptableInputChanged: { + steamDesktopForwardSlider.value = this.value + } + } + } + } + } + Component.onCompleted: { + sliderBox.onComponentComplete() + } +} diff --git a/src/res/qml/desktop_overlay_page/desktop_size/SteamDesktopGroupBox.qml b/src/res/qml/desktop_overlay_page/desktop_size/SteamDesktopGroupBox.qml index f5321ed..a9b7b95 100644 --- a/src/res/qml/desktop_overlay_page/desktop_size/SteamDesktopGroupBox.qml +++ b/src/res/qml/desktop_overlay_page/desktop_size/SteamDesktopGroupBox.qml @@ -4,84 +4,19 @@ import QtQuick.Layouts 1.3 import ovras.advsettings 1.0 import "../../common" -GroupBox { - Layout.fillWidth: true +FullWidthSliderBox { + headerMessage: "Overlay Width" - label: MyText { - leftPadding: 10 - text: "Steam Desktop Overlay Width" - bottomPadding: -10 + lowerLimit: 0.0 + upperLimit: 32.0 + sliderStepSize: 0.5 + + function onValueChanged(value) { + DesktopOverlay.width = value + sliderText = value.toFixed(2) } - background: Rectangle { - color: "transparent" - border.color: "#ffffff" - radius: 8 - } - - property real sliderStepSize: 1.0 - property real sliderStartingValue: 1.0 - - ColumnLayout { - anchors.fill: parent - - LineSeparator { - } - - ColumnLayout { - RowLayout { - MyPushButton2 { - Layout.preferredWidth: 40 - text: "-" - onClicked: { - steamDesktopWidthSlider.value -= sliderStepSize - } - } - - MySlider { - id: steamDesktopWidthSlider - from: 0.1 - to: 32.0 - stepSize: 0.1 - value: sliderStartingValue - Layout.fillWidth: true - onPositionChanged: { - // - } - onValueChanged: { - DesktopOverlay.width = this.value - steamDesktopWidthText.text = this.value.toFixed(2) - } - } - - MyPushButton2 { - Layout.preferredWidth: 40 - text: "+" - onClicked: { - steamDesktopWidthSlider.value += sliderStepSize - } - } - - 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 - } - } - } - } - } - } - Component.onCompleted: { - steamDesktopWidthSlider.value = DesktopOverlay.width + function onComponentComplete() { + sliderValue = DesktopOverlay.width } } + diff --git a/src/res/qml/desktop_overlay_page/translation_back_forwards/SteamDesktopTranslationBackForwards.qml b/src/res/qml/desktop_overlay_page/translation_back_forwards/SteamDesktopTranslationBackForwards.qml index c3f7ddd..be88c06 100644 --- a/src/res/qml/desktop_overlay_page/translation_back_forwards/SteamDesktopTranslationBackForwards.qml +++ b/src/res/qml/desktop_overlay_page/translation_back_forwards/SteamDesktopTranslationBackForwards.qml @@ -4,74 +4,18 @@ import QtQuick.Layouts 1.3 import ovras.advsettings 1.0 import "../../common" -GroupBox { - Layout.fillWidth: true +FullWidthSliderBox { + headerMessage: "Forwards/Backwards Translation" - label: MyText { - leftPadding: 10 - text: "Backwards/Forwards Translation" - bottomPadding: -10 + lowerLimit: -4.0 + upperLimit: 4.0 + sliderStepSize: 0.10 + + function onValueChanged(value) { + DesktopOverlay.forwardsMovement = value + sliderText = value.toFixed(2) } - background: Rectangle { - color: "transparent" - border.color: "#ffffff" - radius: 8 - } - property real sliderStepSize: 0.10 - property real rightLeftLimit: 4.0 - - ColumnLayout { - anchors.fill: parent - - LineSeparator { - } - - ColumnLayout { - RowLayout { - MyPushButton2 { - Layout.preferredWidth: 40 - text: "-" - onClicked: { - steamDesktopForwardSlider.value -= sliderStepSize - } - } - - MySlider { - id: steamDesktopForwardSlider - from: -rightLeftLimit - to: rightLeftLimit - stepSize: sliderStepSize - value: 0.0 - Layout.fillWidth: true - onValueChanged: { - DesktopOverlay.forwardsMovement = this.value - steamDesktopForwardText.text = this.value.toFixed(2) - } - } - - MyPushButton2 { - Layout.preferredWidth: 40 - text: "+" - onClicked: { - steamDesktopForwardSlider.value += sliderStepSize - } - } - - MyTextField { - id: steamDesktopForwardText - text: "0.0" - keyBoardUID: 611 - Layout.preferredWidth: 100 - Layout.leftMargin: 10 - horizontalAlignment: Text.AlignHCenter - onAcceptableInputChanged: { - steamDesktopForwardSlider.value = this.value - } - } - } - } - } - Component.onCompleted: { - steamDesktopForwardSlider.value = DesktopOverlay.forwardsMovement + function onComponentComplete() { + sliderValue = DesktopOverlay.forwardsMovement } } diff --git a/src/res/qml/desktop_overlay_page/translation_left_right/SteamDesktopTranslationLeftRight.qml b/src/res/qml/desktop_overlay_page/translation_left_right/SteamDesktopTranslationLeftRight.qml index 8d4d865..8938bdd 100644 --- a/src/res/qml/desktop_overlay_page/translation_left_right/SteamDesktopTranslationLeftRight.qml +++ b/src/res/qml/desktop_overlay_page/translation_left_right/SteamDesktopTranslationLeftRight.qml @@ -4,74 +4,18 @@ import QtQuick.Layouts 1.3 import ovras.advsettings 1.0 import "../../common" -GroupBox { - Layout.fillWidth: true +FullWidthSliderBox { + headerMessage: "Left/Right Translation" - label: MyText { - leftPadding: 10 - text: "Left/Right Translation" - bottomPadding: -10 + lowerLimit: -4.0 + upperLimit: 4.0 + sliderStepSize: 0.10 + + function onValueChanged(value) { + DesktopOverlay.rightMovement = value + sliderText = value.toFixed(2) } - background: Rectangle { - color: "transparent" - border.color: "#ffffff" - radius: 8 - } - property real sliderStepSize: 0.10 - property real rightLeftLimit: 4.0 - - ColumnLayout { - anchors.fill: parent - - LineSeparator { - } - - ColumnLayout { - RowLayout { - MyPushButton2 { - Layout.preferredWidth: 40 - text: "-" - onClicked: { - steamDesktopRightSlider.value -= sliderStepSize - } - } - - MySlider { - id: steamDesktopRightSlider - from: -rightLeftLimit - to: rightLeftLimit - stepSize: sliderStepSize - value: 0.0 - Layout.fillWidth: true - onValueChanged: { - DesktopOverlay.rightMovement = this.value - steamDesktopRightText.text = this.value.toFixed(2) - } - } - - MyPushButton2 { - Layout.preferredWidth: 40 - text: "+" - onClicked: { - steamDesktopRightSlider.value += sliderStepSize - } - } - - MyTextField { - id: steamDesktopRightText - text: "0.0" - keyBoardUID: 611 - Layout.preferredWidth: 100 - Layout.leftMargin: 10 - horizontalAlignment: Text.AlignHCenter - onAcceptableInputChanged: { - steamDesktopRightSlider.value = this.value - } - } - } - } - } - Component.onCompleted: { - steamDesktopRightSlider.value = DesktopOverlay.rightMovement + function onComponentComplete() { + sliderValue = DesktopOverlay.rightMovement } } diff --git a/src/res/qml/desktop_overlay_page/translation_up_down/SteamDesktopTranslationUpDown.qml b/src/res/qml/desktop_overlay_page/translation_up_down/SteamDesktopTranslationUpDown.qml index 7b56435..f2d9997 100644 --- a/src/res/qml/desktop_overlay_page/translation_up_down/SteamDesktopTranslationUpDown.qml +++ b/src/res/qml/desktop_overlay_page/translation_up_down/SteamDesktopTranslationUpDown.qml @@ -4,74 +4,18 @@ import QtQuick.Layouts 1.3 import ovras.advsettings 1.0 import "../../common" -GroupBox { - Layout.fillWidth: true +FullWidthSliderBox { + headerMessage: "Up/Down Translation" - label: MyText { - leftPadding: 10 - text: "Up/Down Translation" - bottomPadding: -10 + lowerLimit: -4.0 + upperLimit: 4.0 + sliderStepSize: 0.10 + + function onValueChanged(value) { + DesktopOverlay.height = value + sliderText = value.toFixed(2) } - background: Rectangle { - color: "transparent" - border.color: "#ffffff" - radius: 8 - } - property real sliderStepSize: 0.10 - property real rightLeftLimit: 4.0 - - ColumnLayout { - anchors.fill: parent - - LineSeparator { - } - - ColumnLayout { - RowLayout { - MyPushButton2 { - Layout.preferredWidth: 40 - text: "-" - onClicked: { - steamDesktopUpSlider.value -= sliderStepSize - } - } - - MySlider { - id: steamDesktopUpSlider - from: -rightLeftLimit - to: rightLeftLimit - stepSize: sliderStepSize - value: 0.0 - Layout.fillWidth: true - onValueChanged: { - DesktopOverlay.height = this.value - steamDesktopUpText.text = this.value.toFixed(2) - } - } - - MyPushButton2 { - Layout.preferredWidth: 40 - text: "+" - onClicked: { - steamDesktopUpSlider.value += sliderStepSize - } - } - - MyTextField { - id: steamDesktopUpText - text: "0.0" - keyBoardUID: 611 - Layout.preferredWidth: 100 - Layout.leftMargin: 10 - horizontalAlignment: Text.AlignHCenter - onAcceptableInputChanged: { - steamDesktopUpSlider.value = this.value - } - } - } - } - } - Component.onCompleted: { - steamDesktopUpSlider.value = DesktopOverlay.height + function onComponentComplete() { + sliderValue = DesktopOverlay.height } }