Convert DesktopOverlay to new settings API
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
#include "overlay_utils.h"
|
#include "overlay_utils.h"
|
||||||
#include "../overlaycontroller.h"
|
#include "../overlaycontroller.h"
|
||||||
|
#include "../settings/settings.h"
|
||||||
|
|
||||||
namespace overlay
|
namespace overlay
|
||||||
{
|
{
|
||||||
|
namespace strings
|
||||||
|
{
|
||||||
|
constexpr auto overlaykey = "valve.steam.desktop";
|
||||||
|
} // namespace strings
|
||||||
|
|
||||||
vr::VROverlayHandle_t getOverlayHandle()
|
vr::VROverlayHandle_t getOverlayHandle()
|
||||||
{
|
{
|
||||||
vr::VROverlayHandle_t pOverlayHandle;
|
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()
|
void DesktopOverlay::update()
|
||||||
{
|
{
|
||||||
setDesktopOverlayWidth( m_width );
|
setDesktopOverlayWidth(
|
||||||
|
settings::getSetting( settings::DoubleSetting::UTILITY_desktopWidth ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DesktopOverlay::isAvailable() const
|
bool DesktopOverlay::isAvailable() const
|
||||||
@@ -74,13 +57,14 @@ void overlay::DesktopOverlay::setWidth( double width )
|
|||||||
width = 0.01;
|
width = 0.01;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSettingsToValue( strings::widthSettingsName, width );
|
settings::setSetting( settings::DoubleSetting::UTILITY_desktopWidth,
|
||||||
m_width = width;
|
width );
|
||||||
}
|
}
|
||||||
|
|
||||||
double DesktopOverlay::getCurrentWidth() const noexcept
|
double DesktopOverlay::getCurrentWidth() const noexcept
|
||||||
{
|
{
|
||||||
return m_width;
|
return settings::getSetting(
|
||||||
|
settings::DoubleSetting::UTILITY_desktopWidth );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace overlay
|
} // namespace overlay
|
||||||
|
|||||||
@@ -11,32 +11,18 @@ void transformMat();
|
|||||||
|
|
||||||
namespace overlay
|
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
|
class DesktopOverlay : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Q_PROPERTY( double width READ getCurrentWidth WRITE setWidth )
|
Q_PROPERTY( double width READ getCurrentWidth WRITE setWidth )
|
||||||
|
|
||||||
DesktopOverlay();
|
|
||||||
|
|
||||||
Q_INVOKABLE void update();
|
Q_INVOKABLE void update();
|
||||||
|
|
||||||
bool isAvailable() const;
|
bool isAvailable() const;
|
||||||
|
|
||||||
void setWidth( double width );
|
void setWidth( double width );
|
||||||
double getCurrentWidth() const noexcept;
|
double getCurrentWidth() const noexcept;
|
||||||
|
|
||||||
private:
|
|
||||||
double m_width = defaultOverlayWidth;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace overlay
|
} // namespace overlay
|
||||||
|
|||||||
Reference in New Issue
Block a user