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
+6 -6
View File
@@ -258,11 +258,11 @@ OverlayController::OverlayController( bool desktopMode,
1, 1,
0, 0,
"VideoTabController", "VideoTabController",
[](QQmlEngine*, QJSEngine*) { []( QQmlEngine*, QJSEngine* ) {
QObject* obj = &(objectAddress->m_videoTabController); QObject* obj = &( objectAddress->m_videoTabController );
QQmlEngine::setObjectOwnership(obj, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership( obj, QQmlEngine::CppOwnership );
return obj; return obj;
}); } );
qmlRegisterSingletonType<overlay::DesktopOverlay>( qmlRegisterSingletonType<overlay::DesktopOverlay>(
qmlSingletonImportName, qmlSingletonImportName,
1, 1,
@@ -427,7 +427,7 @@ void OverlayController::SetWidget( QQuickItem* quickItem,
m_settingsTabController.initStage2( this, m_pWindow.get() ); m_settingsTabController.initStage2( this, m_pWindow.get() );
m_reviveTabController.initStage2( this, m_pWindow.get() ); m_reviveTabController.initStage2( this, m_pWindow.get() );
m_utilitiesTabController.initStage2( this, m_pWindow.get() ); m_utilitiesTabController.initStage2( this, m_pWindow.get() );
m_videoTabController.initStage2(this, m_pWindow.get()); m_videoTabController.initStage2( this, m_pWindow.get() );
} }
void OverlayController::OnRenderRequest() void OverlayController::OnRenderRequest()
@@ -846,7 +846,7 @@ void OverlayController::mainEventLoop()
m_settingsTabController.eventLoopTick(); m_settingsTabController.eventLoopTick();
m_reviveTabController.eventLoopTick(); m_reviveTabController.eventLoopTick();
m_audioTabController.eventLoopTick(); m_audioTabController.eventLoopTick();
//TODO do I need loop for vide? // TODO do I need loop for vide?
if ( m_ulOverlayThumbnailHandle != vr::k_ulOverlayHandleInvalid ) if ( m_ulOverlayThumbnailHandle != vr::k_ulOverlayHandleInvalid )
{ {
+12 -12
View File
@@ -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
+1
View File
@@ -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
+96 -92
View File
@@ -6,32 +6,31 @@
namespace advsettings namespace advsettings
{ {
void VideoTabController::initStage1() void VideoTabController::initStage1() {}
{
} void VideoTabController::initStage2( OverlayController* var_parent,
QQuickWindow* var_widget )
void VideoTabController::initStage2(OverlayController* var_parent, {
QQuickWindow* var_widget)
{
this->parent = var_parent; this->parent = var_parent;
this->widget = var_widget; this->widget = var_widget;
std::string notifKey = std::string(application_strings::applicationKey) std::string notifKey = std::string( application_strings::applicationKey )
+ ".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(),
if (overlayError == vr::VROverlayError_None) notifKey.c_str(),
&m_brightnessNotificationOverlayHandle );
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
= { { { 1.0f, 0.0f, 0.0f, 0.00f }, = { { { 1.0f, 0.0f, 0.0f, 0.00f },
{ 0.0f, 1.0f, 0.0f, 0.00f }, { 0.0f, 1.0f, 0.0f, 0.00f },
@@ -39,134 +38,139 @@ namespace advsettings
vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative( vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative(
m_brightnessNotificationOverlayHandle, m_brightnessNotificationOverlayHandle,
vr::k_unTrackedDeviceIndex_Hmd, vr::k_unTrackedDeviceIndex_Hmd,
&notificationTransform); &notificationTransform );
} }
else else
{ {
LOG(ERROR) << "Could not find notification icon \"" LOG( ERROR ) << "Could not find notification icon \""
<< video_keys::k_brightnessOverlayFilename << "\""; << video_keys::k_brightnessOverlayFilename << "\"";
} }
} }
else else
{ {
LOG(ERROR) << "Could not create dimmer notification overlay: " LOG( ERROR ) << "Could not create dimmer notification overlay: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum( << vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError); overlayError );
} }
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(
m_opacityValue = settings->value("opacityValue", 0.0f).toFloat(); settings->value( "brightnessEnabled", false ).toBool(), true );
m_brightnessValue=settings->value("brightnessValue", 1.0f).toFloat(); m_opacityValue = settings->value( "opacityValue", 0.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;
} }
float VideoTabController::brightnessValue() const float VideoTabController::brightnessValue() const
{ {
return m_brightnessValue; return m_brightnessValue;
} }
bool VideoTabController::brightnessEnabled() const bool VideoTabController::brightnessEnabled() const
{ {
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)
{ {
vr::VROverlay()->ShowOverlay(getBrightnessOverlayHandle()); if ( getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid )
LOG(INFO) << "Brightness Overlay toggled on"; {
vr::VROverlay()->ShowOverlay( getBrightnessOverlayHandle() );
LOG( INFO ) << "Brightness Overlay toggled on";
} }
} }
else { else
if (getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid)
{ {
vr::VROverlay()->HideOverlay(getBrightnessOverlayHandle()); if ( getBrightnessOverlayHandle() != vr::k_ulOverlayHandleInvalid )
LOG(INFO) << "Brightness Overlay toggled off"; {
vr::VROverlay()->HideOverlay( getBrightnessOverlayHandle() );
LOG( INFO ) << "Brightness Overlay toggled off";
} }
} }
saveVideoConfig(); saveVideoConfig();
if (notify) if ( notify )
{ {
emit brightnessEnabledChanged(value); emit brightnessEnabledChanged( value );
}
} }
} }
}
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
// 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) if ( realvalue != m_opacityValue )
float realvalue = static_cast<float>(std::pow(static_cast<double>(1.0f - percvalue), 1/3.));
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 );
LOG(ERROR) << "Could not set alpha: " if ( overlayError != vr::VROverlayError_None )
{
LOG( ERROR ) << "Could not set alpha: "
<< vr::VROverlay()->GetOverlayErrorNameFromEnum( << vr::VROverlay()->GetOverlayErrorNameFromEnum(
overlayError); overlayError );
} }
//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 );
} }
} }
}
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);
}
} }
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
+29 -37
View File
@@ -1,39 +1,37 @@
#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
{
// forward declaration
class OverlayController;
namespace advsettings { class VideoTabController : public QObject
// forward declaration {
class OverlayController;
class VideoTabController : public QObject
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool brightnessEnabled READ brightnessEnabled WRITE Q_PROPERTY( bool brightnessEnabled READ brightnessEnabled WRITE
setBrightnessEnabled NOTIFY brightnessEnabledChanged) setBrightnessEnabled NOTIFY brightnessEnabledChanged )
Q_PROPERTY(float brightnessValue READ brightnessValue WRITE Q_PROPERTY( float brightnessValue READ brightnessValue WRITE
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.
const float k_overlayWidth = 1.0f; const float k_overlayWidth = 1.0f;
OverlayController * parent; OverlayController* parent;
QQuickWindow* widget; QQuickWindow* widget;
vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle vr::VROverlayHandle_t m_brightnessNotificationOverlayHandle
@@ -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,28 +54,23 @@ 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;
bool brightnessEnabled() const; bool brightnessEnabled() const;
void initStage1(); void initStage1();
void initStage2(OverlayController* var_parent, QQuickWindow* var_widget); void initStage2( OverlayController* var_parent, QQuickWindow* var_widget );
void eventLoopTick(); void eventLoopTick();
public slots:
void setBrightnessEnabled( bool value, bool notify = true );
void setBrightnessValue( float percvalue, bool notify = true );
public slots: signals:
void setBrightnessEnabled(bool value, bool notify = true); void brightnessEnabledChanged( bool value );
void setBrightnessValue(float percvalue, bool notify = true); void brightnessValueChanged( float value );
};
} // namespace advsettings
signals:
void brightnessEnabledChanged(bool value);
void brightnessValueChanged(float value);
};
}// namespace advsettings