From d866725724eb15f63e1bad9248bcbca1e5cbf9c9 Mon Sep 17 00:00:00 2001 From: ykeara Date: Wed, 10 Apr 2019 20:09:39 -0500 Subject: [PATCH] get/set implemented --- .../brightness/BrightnessGroupBox.qml | 63 +++++++++------ src/tabcontrollers/VideoTabController.cpp | 38 +++++++++ src/tabcontrollers/VideoTabController.h | 81 +++++++++++-------- 3 files changed, 123 insertions(+), 59 deletions(-) diff --git a/src/res/qml/video_page/brightness/BrightnessGroupBox.qml b/src/res/qml/video_page/brightness/BrightnessGroupBox.qml index ea93a11..5b0e21c 100644 --- a/src/res/qml/video_page/brightness/BrightnessGroupBox.qml +++ b/src/res/qml/video_page/brightness/BrightnessGroupBox.qml @@ -33,51 +33,62 @@ GroupBox { Layout.fillWidth: true MyToggleButton { - id: turnBindLeft - text: "Enable Left Hand" + id: brightnessToggle + text: "Toggle Brightness Adjustment" onCheckedChanged: { MoveCenterTabController.turnBindLeft = this.checked } } - MyToggleButton { - id: turnBindRight - text: "Enable Right Hand" - onCheckedChanged: { - MoveCenterTabController.turnBindRight = this.checked - } - } - Item { Layout.fillWidth: true } MyText { - text: "Turn Comfort Mode:" + text: "Brightness:" horizontalAlignment: Text.AlignRight Layout.rightMargin: 10 } MySlider { - id: turnComfortSlider - from: 0 - to: 10 - stepSize: 1 - value: 0 - Layout.preferredWidth: 200 - Layout.alignment: Qt.AlignVCenter | Qt.AlignRight + id: brightnessSlider + from: 0.00 + to: 1.0 + stepSize: 0.01 + value: 1.0. + var val = (this.position * 100)/2 + 50 + chaperoneVisibilityText.text = Math.round(val) + "%" + } onValueChanged: { - turnComfortText.text = turnComfortSlider.value - MoveCenterTabController.turnComfortFactor = turnComfortSlider.value + //TODO change value + ChaperoneTabController.setBoundsVisibility(value.toFixed(2), false) } } - MyText { - id: turnComfortText - text: "0" - horizontalAlignment: Text.AlignRight - Layout.preferredWidth: 30 - Layout.rightMargin: 10 + MyTextField { + id: chaperoneVisibilityText + text: "100.00" + keyBoardUID: 301 + Layout.preferredWidth: 100 + Layout.leftMargin: 10 + horizontalAlignment: Text.AlignHCenter + function onInputEvent(input) { + var val = parseFloat(input) + if (!isNaN(val)) { + if (val < 50.0) { + val = 50.0 + } else if (val > 100.0) { + val = 100.0 + } + var v = (val/100).toFixed(2) + if (v <= chaperoneVisibilitySlider.to) { + chaperoneVisibilitySlider.value = v + } else { + ChaperoneTabController.setBoundsVisibility(v, false) + } + } + text = Math.round(ChaperoneTabController.boundsVisibility * 100) + "%" + } } } } diff --git a/src/tabcontrollers/VideoTabController.cpp b/src/tabcontrollers/VideoTabController.cpp index 55d4d77..9bde64a 100644 --- a/src/tabcontrollers/VideoTabController.cpp +++ b/src/tabcontrollers/VideoTabController.cpp @@ -85,4 +85,42 @@ namespace advsettings void VideoTabController::saveVideoConfig() { } + + float VideoTabController::brightnessValue() const + { + return m_brightnessValue; + } + + bool VideoTabController::brightnessEnabled() const + { + return m_brightnessEnabled; + } + + void VideoTabController::setBrightnessEnabled(bool value, bool notify) + { + //TODO mutex? + //std::lock_guard lock(eventLoopMutex); + if (value != m_brightnessEnabled) + { + m_brightnessEnabled = value; + if (notify) + { + emit brightnessEnabledChanged(value); + } + } + } + + void VideoTabController::setBrightnessvalue(float value, bool notify) + { + //TODO mutex? + //std::lock_guard lock(eventLoopMutex); + if (value != m_brightnessValue) + { + m_brightnessValue = value; + if (notify) + { + emit brightnessValueChanged(value); + } + } + } } \ No newline at end of file diff --git a/src/tabcontrollers/VideoTabController.h b/src/tabcontrollers/VideoTabController.h index 46cc99e..983a041 100644 --- a/src/tabcontrollers/VideoTabController.h +++ b/src/tabcontrollers/VideoTabController.h @@ -2,40 +2,55 @@ namespace advsettings { - Q_OBJECT - Q_PROPERTY(int playbackDeviceIndex READ playbackDeviceIndex WRITE - setPlaybackDeviceIndex NOTIFY playbackDeviceIndexChanged) - Q_PROPERTY(int mirrorDeviceIndex READ mirrorDeviceIndex WRITE - setMirrorDeviceIndex NOTIFY mirrorDeviceIndexChanged) - -private: - //TODO - constexpr auto notificationBrightnessFilename - = "todo"; - vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle - = vr::k_ulOverlayHandleInvalid; - float m_brightnessValue = 1.0; - bool m_brightnessEnabled = false; - - void reloadVideoConfig(); - void saveVideoConfig(); - - - QString getSettingsName() override + class ChaperoneTabController : public QObject { - return "videoSettings"; + Q_OBJECT + Q_PROPERTY(bool brightnessEnabled READ brightnessEnabled WRITE + setBrightnessEnabled NOTIFY brightnessEnabledChanged) + Q_PROPERTY(float brightnessValue READ brightnessValue WRITE + setBrightnessValue NOTIFY brightnessValueChanged) + + private: + //TODO + constexpr auto notificationBrightnessFilename + = "todo"; + vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle + = vr::k_ulOverlayHandleInvalid; + float m_brightnessValue = 1.0; + bool m_brightnessEnabled = false; + + void reloadVideoConfig(); + void saveVideoConfig(); + + + QString getSettingsName() override + { + return "videoSettings"; + } + + vr::VROverlayHandle_t getBrightnessOverlayHandle() + { + return m_brightnessNotificationOverlayHandle; + } + + + public: + float brightnessValue() const; + bool brightnessEnabled() const; + + void initStage1(); + //TODO ?? on args + void initStage2(OverlayController* var_parent, QQuickWindow* var_widget); + + + public slots: + void setBrightnessEnabled(bool value, bool notify = true); + void setBrightnessValue(float value, bool notify = true); + + + signals: + void brightnessEnabledChanged(bool value); + void brightnessValueChanged(float value); } - vr::VROverlayHandle_t getBrightnessOverlayHandle() - { - return m_brightnessNotificationOverlayHandle; - } - - -public: - - void initStage1(); - //TODO ?? on args - void initStage2(OverlayController* var_parent, QQuickWindow* var_widget); - } \ No newline at end of file