mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 05:37:17 +02:00
allow passing properties to preferences; left align 'User real-world height' & right-align 'reset sensors' (Mukul's request)
This commit is contained in:
parent
56cd4e57a6
commit
2c07aa787f
4 changed files with 45 additions and 8 deletions
|
@ -26,11 +26,9 @@ Preference {
|
||||||
preference.save();
|
preference.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Row {
|
||||||
id: control
|
id: control
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
}
|
}
|
||||||
height: Math.max(spinnerLabel.height, spinner.controlHeight)
|
height: Math.max(spinnerLabel.height, spinner.controlHeight)
|
||||||
|
@ -40,15 +38,14 @@ Preference {
|
||||||
text: root.label + ":"
|
text: root.label + ":"
|
||||||
colorScheme: hifi.colorSchemes.dark
|
colorScheme: hifi.colorSchemes.dark
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
|
||||||
right: spinner.left
|
|
||||||
rightMargin: hifi.dimensions.labelPadding
|
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
horizontalAlignment: Text.AlignRight
|
horizontalAlignment: Text.AlignRight
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spacing: hifi.dimensions.labelPadding
|
||||||
|
|
||||||
SpinBox {
|
SpinBox {
|
||||||
id: spinner
|
id: spinner
|
||||||
decimals: preference.decimals
|
decimals: preference.decimals
|
||||||
|
@ -56,7 +53,6 @@ Preference {
|
||||||
maximumValue: preference.max
|
maximumValue: preference.max
|
||||||
width: 100
|
width: 100
|
||||||
anchors {
|
anchors {
|
||||||
right: parent.right
|
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
colorScheme: hifi.colorSchemes.dark
|
colorScheme: hifi.colorSchemes.dark
|
||||||
|
|
|
@ -163,6 +163,28 @@ Preference {
|
||||||
|
|
||||||
if (builder) {
|
if (builder) {
|
||||||
preferences.push(builder.createObject(contentContainer, { preference: preference, isFirstCheckBox: (checkBoxCount === 1) , z: zpos}));
|
preferences.push(builder.createObject(contentContainer, { preference: preference, isFirstCheckBox: (checkBoxCount === 1) , z: zpos}));
|
||||||
|
|
||||||
|
var preferenceObject = preferences[preferences.length - 1];
|
||||||
|
var props = preference.properties;
|
||||||
|
|
||||||
|
for(var prop in props) {
|
||||||
|
var value = props[prop];
|
||||||
|
if(value.indexOf('.') !== -1) {
|
||||||
|
var splittedValues = value.split('.');
|
||||||
|
if(splittedValues[0] === 'parent') {
|
||||||
|
value = preferenceObject.parent[splittedValues[1]];
|
||||||
|
}
|
||||||
|
} else if(value === 'undefined') {
|
||||||
|
value = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(prop.indexOf('.') !== -1) {
|
||||||
|
var splittedProps = prop.split('.');
|
||||||
|
preferenceObject[splittedProps[0]][splittedProps[1]] = value;
|
||||||
|
} else {
|
||||||
|
preferenceObject[prop] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,13 +298,21 @@ void setupPreferences() {
|
||||||
preference->setMax(2.2f);
|
preference->setMax(2.2f);
|
||||||
preference->setDecimals(3);
|
preference->setDecimals(3);
|
||||||
preference->setStep(0.001f);
|
preference->setStep(0.001f);
|
||||||
|
|
||||||
|
QVariantMap properties;
|
||||||
|
properties["anchors.right"] = "undefined";
|
||||||
|
preference->setProperties(properties);
|
||||||
|
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto preference = new ButtonPreference(MOVEMENT, "RESET SENSORS", [] {
|
auto preference = new ButtonPreference(MOVEMENT, "RESET SENSORS", [] {
|
||||||
qApp->resetSensors();
|
qApp->resetSensors();
|
||||||
});
|
});
|
||||||
|
QVariantMap properties;
|
||||||
|
properties["width"] = "180";
|
||||||
|
properties["anchors.left"] = "undefined";
|
||||||
|
preference->setProperties(properties);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QVariantMap>
|
||||||
|
|
||||||
#include "DependencyManager.h"
|
#include "DependencyManager.h"
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ class Preference : public QObject {
|
||||||
Q_PROPERTY(QString name READ getName CONSTANT)
|
Q_PROPERTY(QString name READ getName CONSTANT)
|
||||||
Q_PROPERTY(Type type READ getType CONSTANT)
|
Q_PROPERTY(Type type READ getType CONSTANT)
|
||||||
Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged)
|
Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged)
|
||||||
|
Q_PROPERTY(QVariantMap properties READ getProperties);
|
||||||
Q_ENUMS(Type)
|
Q_ENUMS(Type)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -81,6 +83,14 @@ public:
|
||||||
|
|
||||||
void setEnabler(BoolPreference* enabler, bool inverse = false);
|
void setEnabler(BoolPreference* enabler, bool inverse = false);
|
||||||
|
|
||||||
|
const QVariantMap& getProperties() {
|
||||||
|
return _properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setProperties(const QVariantMap& properties) {
|
||||||
|
_properties = properties;
|
||||||
|
}
|
||||||
|
|
||||||
virtual Type getType() { return Invalid; };
|
virtual Type getType() { return Invalid; };
|
||||||
|
|
||||||
Q_INVOKABLE virtual void load() {};
|
Q_INVOKABLE virtual void load() {};
|
||||||
|
@ -100,6 +110,7 @@ protected:
|
||||||
const QString _name;
|
const QString _name;
|
||||||
bool _enabled { true };
|
bool _enabled { true };
|
||||||
bool _enablerInverted { false };
|
bool _enablerInverted { false };
|
||||||
|
QVariantMap _properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ButtonPreference : public Preference {
|
class ButtonPreference : public Preference {
|
||||||
|
|
Loading…
Reference in a new issue