qml format changes and format
This commit is contained in:
+12
-12
@@ -25,7 +25,7 @@ MyStackViewPage {
|
|||||||
Layout.preferredWidth: 250
|
Layout.preferredWidth: 250
|
||||||
Layout.maximumWidth: 250
|
Layout.maximumWidth: 250
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
spacing: 18
|
spacing: 10
|
||||||
MyPushButton {
|
MyPushButton {
|
||||||
id: steamVRButton
|
id: steamVRButton
|
||||||
activationSoundEnabled: false
|
activationSoundEnabled: false
|
||||||
@@ -92,6 +92,17 @@ MyStackViewPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MyPushButton {
|
||||||
|
id: videoButton
|
||||||
|
activationSoundEnabled: false
|
||||||
|
text: "Video"
|
||||||
|
Layout.fillWidth: true
|
||||||
|
onClicked: {
|
||||||
|
MyResources.playFocusChangedSound()
|
||||||
|
mainView.push(videoPage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MyPushButton {
|
MyPushButton {
|
||||||
id: reviveButton
|
id: reviveButton
|
||||||
activationSoundEnabled: false
|
activationSoundEnabled: false
|
||||||
@@ -137,17 +148,6 @@ MyStackViewPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MyPushButton {
|
|
||||||
id: videoButton
|
|
||||||
activationSoundEnabled: false
|
|
||||||
text: "Video"
|
|
||||||
Layout.fillWidth: true
|
|
||||||
onClicked: {
|
|
||||||
MyResources.playFocusChangedSound()
|
|
||||||
mainView.push(videoPage)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ Rectangle {
|
|||||||
stackView: mainView
|
stackView: mainView
|
||||||
visible:false
|
visible:false
|
||||||
}
|
}
|
||||||
|
|
||||||
property DesktopOverlayPage desktopOverlayPage: DesktopOverlayPage {
|
property DesktopOverlayPage desktopOverlayPage: DesktopOverlayPage {
|
||||||
stackView: mainView
|
stackView: mainView
|
||||||
visible: false
|
visible: false
|
||||||
|
|||||||
@@ -6,10 +6,7 @@
|
|||||||
|
|
||||||
namespace advsettings
|
namespace advsettings
|
||||||
{
|
{
|
||||||
void VideoTabController::initStage1()
|
void VideoTabController::initStage1() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoTabController::initStage2( OverlayController* var_parent,
|
void VideoTabController::initStage2( OverlayController* var_parent,
|
||||||
QQuickWindow* var_widget )
|
QQuickWindow* var_widget )
|
||||||
@@ -21,15 +18,17 @@ namespace advsettings
|
|||||||
+ ".dimnotification";
|
+ ".dimnotification";
|
||||||
|
|
||||||
vr::VROverlayError overlayError = vr::VROverlay()->CreateOverlay(
|
vr::VROverlayError overlayError = vr::VROverlay()->CreateOverlay(
|
||||||
notifKey.c_str(), notifKey.c_str(), &m_brightnessNotificationOverlayHandle);
|
notifKey.c_str(),
|
||||||
|
notifKey.c_str(),
|
||||||
|
&m_brightnessNotificationOverlayHandle );
|
||||||
if ( overlayError == vr::VROverlayError_None )
|
if ( overlayError == vr::VROverlayError_None )
|
||||||
{
|
{
|
||||||
const auto notifIconPath
|
const auto notifIconPath = paths::binaryDirectoryFindFile(
|
||||||
= paths::binaryDirectoryFindFile(video_keys::k_brightnessOverlayFilename);
|
video_keys::k_brightnessOverlayFilename );
|
||||||
if ( notifIconPath.has_value() )
|
if ( notifIconPath.has_value() )
|
||||||
{
|
{
|
||||||
vr::VROverlay()->SetOverlayFromFile(m_brightnessNotificationOverlayHandle,
|
vr::VROverlay()->SetOverlayFromFile(
|
||||||
notifIconPath->c_str());
|
m_brightnessNotificationOverlayHandle, notifIconPath->c_str() );
|
||||||
vr::VROverlay()->SetOverlayWidthInMeters(
|
vr::VROverlay()->SetOverlayWidthInMeters(
|
||||||
m_brightnessNotificationOverlayHandle, k_overlayWidth );
|
m_brightnessNotificationOverlayHandle, k_overlayWidth );
|
||||||
vr::HmdMatrix34_t notificationTransform
|
vr::HmdMatrix34_t notificationTransform
|
||||||
@@ -57,35 +56,32 @@ namespace advsettings
|
|||||||
reloadVideoConfig();
|
reloadVideoConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoTabController::eventLoopTick()
|
void VideoTabController::eventLoopTick() {}
|
||||||
|
|
||||||
|
void VideoTabController::reloadVideoConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void VideoTabController::reloadVideoConfig() {
|
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( getSettingsName() );
|
settings->beginGroup( getSettingsName() );
|
||||||
setBrightnessEnabled(settings->value("brightnessEnabled", false).toBool(), true);
|
setBrightnessEnabled(
|
||||||
|
settings->value( "brightnessEnabled", false ).toBool(), true );
|
||||||
m_opacityValue = settings->value( "opacityValue", 0.0f ).toFloat();
|
m_opacityValue = settings->value( "opacityValue", 0.0f ).toFloat();
|
||||||
m_brightnessValue = settings->value( "brightnessValue", 1.0f ).toFloat();
|
m_brightnessValue = settings->value( "brightnessValue", 1.0f ).toFloat();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
setOpacityValue();
|
setOpacityValue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoTabController::saveVideoConfig()
|
||||||
|
{
|
||||||
void VideoTabController::saveVideoConfig() {
|
|
||||||
auto settings = OverlayController::appSettings();
|
auto settings = OverlayController::appSettings();
|
||||||
settings->beginGroup( getSettingsName() );
|
settings->beginGroup( getSettingsName() );
|
||||||
settings->setValue( "brightnessEnabled", brightnessEnabled() );
|
settings->setValue( "brightnessEnabled", brightnessEnabled() );
|
||||||
settings->setValue( "opacityValue", opacityValue() );
|
settings->setValue( "opacityValue", opacityValue() );
|
||||||
settings->setValue( "brightnessValue", brightnessValue() );
|
settings->setValue( "brightnessValue", brightnessValue() );
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float VideoTabController::opacityValue() const {
|
float VideoTabController::opacityValue() const
|
||||||
|
{
|
||||||
return m_opacityValue;
|
return m_opacityValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,20 +95,21 @@ namespace advsettings
|
|||||||
return m_brightnessEnabled;
|
return m_brightnessEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VideoTabController::setBrightnessEnabled( bool value, bool notify )
|
void VideoTabController::setBrightnessEnabled( bool value, bool notify )
|
||||||
{
|
{
|
||||||
if ( value != m_brightnessEnabled )
|
if ( value != m_brightnessEnabled )
|
||||||
{
|
{
|
||||||
m_brightnessEnabled = value;
|
m_brightnessEnabled = value;
|
||||||
if (value) {
|
if ( value )
|
||||||
|
{
|
||||||
if ( getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid )
|
if ( getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid )
|
||||||
{
|
{
|
||||||
vr::VROverlay()->ShowOverlay( getBrightnessOverlayHandle() );
|
vr::VROverlay()->ShowOverlay( getBrightnessOverlayHandle() );
|
||||||
LOG( INFO ) << "Brightness Overlay toggled on";
|
LOG( INFO ) << "Brightness Overlay toggled on";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
if ( getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid )
|
if ( getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid )
|
||||||
{
|
{
|
||||||
vr::VROverlay()->HideOverlay( getBrightnessOverlayHandle() );
|
vr::VROverlay()->HideOverlay( getBrightnessOverlayHandle() );
|
||||||
@@ -129,17 +126,21 @@ namespace advsettings
|
|||||||
|
|
||||||
void VideoTabController::setBrightnessValue( float percvalue, bool notify )
|
void VideoTabController::setBrightnessValue( float percvalue, bool notify )
|
||||||
{
|
{
|
||||||
|
// This takes the Perceived value, and converts it to allow more accurate
|
||||||
//This takes the Perceived value, and converts it to allow more accurate linear positioning. (human perception logarithmic)
|
// linear positioning. (human perception logarithmic)
|
||||||
float realvalue = static_cast<float>(std::pow(static_cast<double>(1.0f - percvalue), 1/3.));
|
float realvalue = static_cast<float>(
|
||||||
|
std::pow( static_cast<double>( 1.0f - percvalue ), 1 / 3. ) );
|
||||||
|
|
||||||
if ( realvalue != m_opacityValue )
|
if ( realvalue != m_opacityValue )
|
||||||
{
|
{
|
||||||
m_brightnessValue = percvalue;
|
m_brightnessValue = percvalue;
|
||||||
if (realvalue <= 1.0f && realvalue >= 0.0f) {
|
if ( realvalue <= 1.0f && realvalue >= 0.0f )
|
||||||
|
{
|
||||||
m_opacityValue = realvalue;
|
m_opacityValue = realvalue;
|
||||||
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(m_brightnessNotificationOverlayHandle, realvalue);
|
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(
|
||||||
if (overlayError != vr::VROverlayError_None) {
|
m_brightnessNotificationOverlayHandle, realvalue );
|
||||||
|
if ( overlayError != vr::VROverlayError_None )
|
||||||
|
{
|
||||||
LOG( ERROR ) << "Could not set alpha: "
|
LOG( ERROR ) << "Could not set alpha: "
|
||||||
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||||
overlayError );
|
overlayError );
|
||||||
@@ -147,12 +148,12 @@ namespace advsettings
|
|||||||
// only saves if opacity Value is valid. [1-0]
|
// only saves if opacity Value is valid. [1-0]
|
||||||
saveVideoConfig();
|
saveVideoConfig();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
LOG( WARNING ) << "alpha value is invalid setting to 1.0";
|
LOG( WARNING ) << "alpha value is invalid setting to 1.0";
|
||||||
m_opacityValue = 0.0f;
|
m_opacityValue = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( notify )
|
if ( notify )
|
||||||
{
|
{
|
||||||
emit brightnessValueChanged( percvalue );
|
emit brightnessValueChanged( percvalue );
|
||||||
@@ -160,13 +161,16 @@ namespace advsettings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoTabController::setOpacityValue() {
|
void VideoTabController::setOpacityValue()
|
||||||
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(m_brightnessNotificationOverlayHandle, m_opacityValue);
|
{
|
||||||
if (overlayError != vr::VROverlayError_None) {
|
vr::VROverlayError overlayError = vr::VROverlay()->SetOverlayAlpha(
|
||||||
|
m_brightnessNotificationOverlayHandle, m_opacityValue );
|
||||||
|
if ( overlayError != vr::VROverlayError_None )
|
||||||
|
{
|
||||||
LOG( ERROR ) << "Could not set alpha: "
|
LOG( ERROR ) << "Could not set alpha: "
|
||||||
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
<< vr::VROverlay()->GetOverlayErrorNameFromEnum(
|
||||||
overlayError );
|
overlayError );
|
||||||
}
|
}
|
||||||
emit brightnessValueChanged( m_brightnessValue );
|
emit brightnessValueChanged( m_brightnessValue );
|
||||||
}
|
}
|
||||||
}
|
} // namespace advsettings
|
||||||
@@ -1,21 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <openvr.h>
|
#include <openvr.h>
|
||||||
|
|
||||||
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
|
|
||||||
namespace video_keys {
|
namespace video_keys
|
||||||
|
{
|
||||||
constexpr auto k_brightnessOverlayFilename = "/res/img/video/dimmer.png";
|
constexpr auto k_brightnessOverlayFilename = "/res/img/video/dimmer.png";
|
||||||
|
|
||||||
} // namespace video_keys
|
} // namespace video_keys
|
||||||
|
|
||||||
namespace advsettings {
|
namespace advsettings
|
||||||
|
{
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OverlayController;
|
class OverlayController;
|
||||||
|
|
||||||
@@ -28,7 +27,6 @@ namespace advsettings {
|
|||||||
setBrightnessValue NOTIFY brightnessValueChanged )
|
setBrightnessValue NOTIFY brightnessValueChanged )
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// how far away the overlay is, any OVERLAY closer will not be dimmed.
|
// how far away the overlay is, any OVERLAY closer will not be dimmed.
|
||||||
const float k_hmdDistance = -0.15f;
|
const float k_hmdDistance = -0.15f;
|
||||||
// how wide overlay is, Increase this value if edges of view are not dimmed.
|
// how wide overlay is, Increase this value if edges of view are not dimmed.
|
||||||
@@ -42,13 +40,12 @@ namespace advsettings {
|
|||||||
float m_brightnessValue = 1.0f;
|
float m_brightnessValue = 1.0f;
|
||||||
bool m_brightnessEnabled = false;
|
bool m_brightnessEnabled = false;
|
||||||
|
|
||||||
|
|
||||||
void reloadVideoConfig();
|
void reloadVideoConfig();
|
||||||
void saveVideoConfig();
|
void saveVideoConfig();
|
||||||
void setOpacityValue();
|
void setOpacityValue();
|
||||||
|
|
||||||
|
QString getSettingsName()
|
||||||
QString getSettingsName(){
|
{
|
||||||
return "videoSettings";
|
return "videoSettings";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +54,7 @@ namespace advsettings {
|
|||||||
return m_brightnessNotificationOverlayHandle;
|
return m_brightnessNotificationOverlayHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
float opacityValue() const;
|
float opacityValue() const;
|
||||||
// inverse of brightnessValue
|
// inverse of brightnessValue
|
||||||
float brightnessValue() const;
|
float brightnessValue() const;
|
||||||
@@ -70,12 +64,10 @@ namespace advsettings {
|
|||||||
void initStage2( OverlayController* var_parent, QQuickWindow* var_widget );
|
void initStage2( OverlayController* var_parent, QQuickWindow* var_widget );
|
||||||
void eventLoopTick();
|
void eventLoopTick();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setBrightnessEnabled( bool value, bool notify = true );
|
void setBrightnessEnabled( bool value, bool notify = true );
|
||||||
void setBrightnessValue( float percvalue, bool notify = true );
|
void setBrightnessValue( float percvalue, bool notify = true );
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void brightnessEnabledChanged( bool value );
|
void brightnessEnabledChanged( bool value );
|
||||||
void brightnessValueChanged( float value );
|
void brightnessValueChanged( float value );
|
||||||
|
|||||||
Reference in New Issue
Block a user