Add snap turn angle settings ui
This commit is contained in:
@@ -7,6 +7,7 @@ import "space_drag"
|
|||||||
import "space_turn"
|
import "space_turn"
|
||||||
import "height_toggle"
|
import "height_toggle"
|
||||||
import "gravity"
|
import "gravity"
|
||||||
|
import "snap_turn"
|
||||||
|
|
||||||
MyStackViewPage {
|
MyStackViewPage {
|
||||||
headerText: "Motion Settings"
|
headerText: "Motion Settings"
|
||||||
@@ -22,6 +23,8 @@ MyStackViewPage {
|
|||||||
|
|
||||||
GravityGroupBox { id: gravityGroupBox }
|
GravityGroupBox { id: gravityGroupBox }
|
||||||
|
|
||||||
|
SnapTurnGroupBox { id: snapTurnGroupBox }
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
import QtQuick 2.7
|
||||||
|
import QtQuick.Controls 2.0
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import ovras.advsettings 1.0
|
||||||
|
import "../../common"
|
||||||
|
|
||||||
|
GroupBox {
|
||||||
|
id: snapTurnGroupBox
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
label: MyText {
|
||||||
|
leftPadding: 10
|
||||||
|
text: "Snap Turn Angle"
|
||||||
|
bottomPadding: -10
|
||||||
|
}
|
||||||
|
background: Rectangle {
|
||||||
|
color: "transparent"
|
||||||
|
border.color: "#ffffff"
|
||||||
|
radius: 8
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: "#ffffff"
|
||||||
|
height: 1
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.bottomMargin: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
MyTextField {
|
||||||
|
id: snapTurnAngleText
|
||||||
|
text: "45°"
|
||||||
|
keyBoardUID: 154
|
||||||
|
Layout.preferredWidth: 150
|
||||||
|
Layout.leftMargin: 10
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
function onInputEvent(input) {
|
||||||
|
var val = parseFloat(input)
|
||||||
|
if (!isNaN(val)) {
|
||||||
|
val = val % 180
|
||||||
|
MoveCenterTabController.snapTurnAngle = val.toFixed(2) * 100
|
||||||
|
text = ( Math.round( MoveCenterTabController.snapTurnAngle / 100 ) ) + "°"
|
||||||
|
} else {
|
||||||
|
text = ( Math.round( MoveCenterTabController.snapTurnAngle / 100 ) ) + "°"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
MyPushButton {
|
||||||
|
id: snapTurnButton15
|
||||||
|
Layout.preferredWidth: 90
|
||||||
|
text:"15°"
|
||||||
|
onClicked: {
|
||||||
|
MoveCenterTabController.snapTurnAngle = 1500
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MyPushButton {
|
||||||
|
id: snapTurnButton30
|
||||||
|
Layout.preferredWidth: 90
|
||||||
|
text:"30°"
|
||||||
|
onClicked: {
|
||||||
|
MoveCenterTabController.snapTurnAngle = 3000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MyPushButton {
|
||||||
|
id: snapTurnButton45
|
||||||
|
Layout.preferredWidth: 90
|
||||||
|
text:"45°"
|
||||||
|
onClicked: {
|
||||||
|
MoveCenterTabController.snapTurnAngle = 4500
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MyPushButton {
|
||||||
|
id: snapTurnButton90
|
||||||
|
Layout.preferredWidth: 90
|
||||||
|
text:"90°"
|
||||||
|
onClicked: {
|
||||||
|
MoveCenterTabController.snapTurnAngle = 9000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MyPushButton {
|
||||||
|
id: snapTurnButton180
|
||||||
|
Layout.preferredWidth: 90
|
||||||
|
text:"180°"
|
||||||
|
onClicked: {
|
||||||
|
MoveCenterTabController.snapTurnAngle = 18000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
snapTurnAngleText.text = ( Math.round( MoveCenterTabController.snapTurnAngle / 100 ) ) + "°"
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: MoveCenterTabController
|
||||||
|
|
||||||
|
onSnapTurnAngleChanged: {
|
||||||
|
snapTurnAngleText.text = ( Math.round( MoveCenterTabController.snapTurnAngle / 100 ) ) + "°"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -78,6 +78,11 @@ void MoveCenterTabController::initStage1()
|
|||||||
{
|
{
|
||||||
m_turnComfortFactor = value.toUInt();
|
m_turnComfortFactor = value.toUInt();
|
||||||
}
|
}
|
||||||
|
value = settings->value( "snapTurnAngle", m_snapTurnAngle );
|
||||||
|
if ( value.isValid() && !value.isNull() )
|
||||||
|
{
|
||||||
|
m_snapTurnAngle = value.toInt();
|
||||||
|
}
|
||||||
value = settings->value( "heightToggleOffset", m_heightToggleOffset );
|
value = settings->value( "heightToggleOffset", m_heightToggleOffset );
|
||||||
if ( value.isValid() && !value.isNull() )
|
if ( value.isValid() && !value.isNull() )
|
||||||
{
|
{
|
||||||
@@ -256,6 +261,28 @@ void MoveCenterTabController::setTempRotation( int value, bool notify )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MoveCenterTabController::snapTurnAngle() const
|
||||||
|
{
|
||||||
|
return m_snapTurnAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoveCenterTabController::setSnapTurnAngle( int value, bool notify )
|
||||||
|
{
|
||||||
|
if ( m_snapTurnAngle != value )
|
||||||
|
{
|
||||||
|
m_snapTurnAngle = value;
|
||||||
|
auto settings = OverlayController::appSettings();
|
||||||
|
settings->beginGroup( "playspaceSettings" );
|
||||||
|
settings->setValue( "snapTurnAngle", m_snapTurnAngle );
|
||||||
|
settings->endGroup();
|
||||||
|
settings->sync();
|
||||||
|
if ( notify )
|
||||||
|
{
|
||||||
|
emit snapTurnAngleChanged( m_snapTurnAngle );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool MoveCenterTabController::adjustChaperone() const
|
bool MoveCenterTabController::adjustChaperone() const
|
||||||
{
|
{
|
||||||
return m_adjustChaperone;
|
return m_adjustChaperone;
|
||||||
@@ -1363,7 +1390,7 @@ void MoveCenterTabController::snapTurnLeft( bool snapTurnLeftJustPressed )
|
|||||||
|
|
||||||
// TODO add interface to configure snap angle.
|
// TODO add interface to configure snap angle.
|
||||||
// temporarily hard coded to 45 degrees
|
// temporarily hard coded to 45 degrees
|
||||||
int newRotationAngleDeg = m_rotation - 4500;
|
int newRotationAngleDeg = m_rotation - m_snapTurnAngle;
|
||||||
// Keep angle within -18000 ~ 18000 centidegrees
|
// Keep angle within -18000 ~ 18000 centidegrees
|
||||||
if ( newRotationAngleDeg > 18000 )
|
if ( newRotationAngleDeg > 18000 )
|
||||||
{
|
{
|
||||||
@@ -1386,7 +1413,7 @@ void MoveCenterTabController::snapTurnRight( bool snapTurnRightJustPressed )
|
|||||||
|
|
||||||
// TODO add interface to configure snap angle.
|
// TODO add interface to configure snap angle.
|
||||||
// temporarily hard coded to 45 degrees
|
// temporarily hard coded to 45 degrees
|
||||||
int newRotationAngleDeg = m_rotation + 4500;
|
int newRotationAngleDeg = m_rotation + m_snapTurnAngle;
|
||||||
// Keep angle within -18000 ~ 18000 centidegrees
|
// Keep angle within -18000 ~ 18000 centidegrees
|
||||||
if ( newRotationAngleDeg > 18000 )
|
if ( newRotationAngleDeg > 18000 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ class MoveCenterTabController : public QObject
|
|||||||
int rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
|
int rotation READ rotation WRITE setRotation NOTIFY rotationChanged )
|
||||||
Q_PROPERTY( int tempRotation READ tempRotation WRITE setTempRotation NOTIFY
|
Q_PROPERTY( int tempRotation READ tempRotation WRITE setTempRotation NOTIFY
|
||||||
tempRotationChanged )
|
tempRotationChanged )
|
||||||
|
Q_PROPERTY( int snapTurnAngle READ snapTurnAngle WRITE setSnapTurnAngle
|
||||||
|
NOTIFY snapTurnAngleChanged )
|
||||||
Q_PROPERTY( bool adjustChaperone READ adjustChaperone WRITE
|
Q_PROPERTY( bool adjustChaperone READ adjustChaperone WRITE
|
||||||
setAdjustChaperone NOTIFY adjustChaperoneChanged )
|
setAdjustChaperone NOTIFY adjustChaperoneChanged )
|
||||||
Q_PROPERTY( bool moveShortcutRight READ moveShortcutRight WRITE
|
Q_PROPERTY( bool moveShortcutRight READ moveShortcutRight WRITE
|
||||||
@@ -81,6 +83,7 @@ private:
|
|||||||
int m_rotation = 0;
|
int m_rotation = 0;
|
||||||
int m_oldRotation = 0;
|
int m_oldRotation = 0;
|
||||||
int m_tempRotation = 0;
|
int m_tempRotation = 0;
|
||||||
|
int m_snapTurnAngle = 4500;
|
||||||
bool m_adjustChaperone = true;
|
bool m_adjustChaperone = true;
|
||||||
bool m_moveShortcutRightPressed = false;
|
bool m_moveShortcutRightPressed = false;
|
||||||
bool m_moveShortcutLeftPressed = false;
|
bool m_moveShortcutLeftPressed = false;
|
||||||
@@ -170,6 +173,7 @@ public:
|
|||||||
float offsetZ() const;
|
float offsetZ() const;
|
||||||
int rotation() const;
|
int rotation() const;
|
||||||
int tempRotation() const;
|
int tempRotation() const;
|
||||||
|
int snapTurnAngle() const;
|
||||||
bool adjustChaperone() const;
|
bool adjustChaperone() const;
|
||||||
bool moveShortcutRight() const;
|
bool moveShortcutRight() const;
|
||||||
bool moveShortcutLeft() const;
|
bool moveShortcutLeft() const;
|
||||||
@@ -219,11 +223,10 @@ public slots:
|
|||||||
void setOffsetZ( float value, bool notify = true );
|
void setOffsetZ( float value, bool notify = true );
|
||||||
|
|
||||||
void setRotation( int value, bool notify = true );
|
void setRotation( int value, bool notify = true );
|
||||||
|
|
||||||
void setTempRotation( int value, bool notify = true );
|
void setTempRotation( int value, bool notify = true );
|
||||||
|
void setSnapTurnAngle( int value, bool notify = true );
|
||||||
|
|
||||||
void setAdjustChaperone( bool value, bool notify = true );
|
void setAdjustChaperone( bool value, bool notify = true );
|
||||||
|
|
||||||
void setMoveShortcutRight( bool value, bool notify = true );
|
void setMoveShortcutRight( bool value, bool notify = true );
|
||||||
void setMoveShortcutLeft( bool value, bool notify = true );
|
void setMoveShortcutLeft( bool value, bool notify = true );
|
||||||
void setTurnBindRight( bool value, bool notify = true );
|
void setTurnBindRight( bool value, bool notify = true );
|
||||||
@@ -255,6 +258,7 @@ signals:
|
|||||||
void offsetZChanged( float value );
|
void offsetZChanged( float value );
|
||||||
void rotationChanged( int value );
|
void rotationChanged( int value );
|
||||||
void tempRotationChanged( int value );
|
void tempRotationChanged( int value );
|
||||||
|
void snapTurnAngleChanged( int value );
|
||||||
void adjustChaperoneChanged( bool value );
|
void adjustChaperoneChanged( bool value );
|
||||||
void moveShortcutRightChanged( bool value );
|
void moveShortcutRightChanged( bool value );
|
||||||
void moveShortcutLeftChanged( bool value );
|
void moveShortcutLeftChanged( bool value );
|
||||||
|
|||||||
Reference in New Issue
Block a user