From 92f1c5910410987f675296012106951064aade69 Mon Sep 17 00:00:00 2001 From: Vasily Date: Sun, 1 Dec 2019 00:18:29 +0100 Subject: [PATCH] Convert DesktopOverlay to new settings API --- src/openvr/overlay_utils.cpp | 40 +++++++++++------------------------- src/openvr/overlay_utils.h | 14 ------------- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/openvr/overlay_utils.cpp b/src/openvr/overlay_utils.cpp index 7551062..54c58c1 100644 --- a/src/openvr/overlay_utils.cpp +++ b/src/openvr/overlay_utils.cpp @@ -1,8 +1,14 @@ #include "overlay_utils.h" #include "../overlaycontroller.h" +#include "../settings/settings.h" namespace overlay { +namespace strings +{ + constexpr auto overlaykey = "valve.steam.desktop"; +} // namespace strings + vr::VROverlayHandle_t getOverlayHandle() { vr::VROverlayHandle_t pOverlayHandle; @@ -23,33 +29,10 @@ void setDesktopOverlayWidth( double width ) } } -void setSettingsToValue( const std::string setting, const double value ) -{ - 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(); -} - -overlay::DesktopOverlay::DesktopOverlay() -{ - QSettings settings( QSettings::Format::IniFormat, - QSettings::Scope::UserScope, - application_strings::applicationOrganizationName, - application_strings::applicationName ); - - settings.beginGroup( strings::settingsGroupName ); - m_width = settings.value( strings::widthSettingsName, defaultOverlayWidth ) - .toDouble(); - settings.endGroup(); -} - void DesktopOverlay::update() { - setDesktopOverlayWidth( m_width ); + setDesktopOverlayWidth( + settings::getSetting( settings::DoubleSetting::UTILITY_desktopWidth ) ); } bool DesktopOverlay::isAvailable() const @@ -74,13 +57,14 @@ void overlay::DesktopOverlay::setWidth( double width ) width = 0.01; } - setSettingsToValue( strings::widthSettingsName, width ); - m_width = width; + settings::setSetting( settings::DoubleSetting::UTILITY_desktopWidth, + width ); } double DesktopOverlay::getCurrentWidth() const noexcept { - return m_width; + return settings::getSetting( + settings::DoubleSetting::UTILITY_desktopWidth ); } } // namespace overlay diff --git a/src/openvr/overlay_utils.h b/src/openvr/overlay_utils.h index 4c2ee66..59aac33 100644 --- a/src/openvr/overlay_utils.h +++ b/src/openvr/overlay_utils.h @@ -11,32 +11,18 @@ void transformMat(); namespace overlay { -namespace strings -{ - constexpr auto overlaykey = "valve.steam.desktop"; - constexpr auto settingsGroupName = "utilitiesSettings"; - constexpr auto widthSettingsName = "desktopWidth"; -} // namespace strings - -constexpr auto defaultOverlayWidth = 4.0; - class DesktopOverlay : public QObject { Q_OBJECT public: Q_PROPERTY( double width READ getCurrentWidth WRITE setWidth ) - DesktopOverlay(); - Q_INVOKABLE void update(); bool isAvailable() const; void setWidth( double width ); double getCurrentWidth() const noexcept; - -private: - double m_width = defaultOverlayWidth; }; } // namespace overlay