qml format changes and format

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