mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +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();
|
||||
}
|
||||
|
||||
Item {
|
||||
Row {
|
||||
id: control
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
height: Math.max(spinnerLabel.height, spinner.controlHeight)
|
||||
|
@ -40,15 +38,14 @@ Preference {
|
|||
text: root.label + ":"
|
||||
colorScheme: hifi.colorSchemes.dark
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: spinner.left
|
||||
rightMargin: hifi.dimensions.labelPadding
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
horizontalAlignment: Text.AlignRight
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
spacing: hifi.dimensions.labelPadding
|
||||
|
||||
SpinBox {
|
||||
id: spinner
|
||||
decimals: preference.decimals
|
||||
|
@ -56,7 +53,6 @@ Preference {
|
|||
maximumValue: preference.max
|
||||
width: 100
|
||||
anchors {
|
||||
right: parent.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
colorScheme: hifi.colorSchemes.dark
|
||||
|
|
|
@ -163,6 +163,28 @@ Preference {
|
|||
|
||||
if (builder) {
|
||||
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->setDecimals(3);
|
||||
preference->setStep(0.001f);
|
||||
|
||||
QVariantMap properties;
|
||||
properties["anchors.right"] = "undefined";
|
||||
preference->setProperties(properties);
|
||||
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto preference = new ButtonPreference(MOVEMENT, "RESET SENSORS", [] {
|
||||
qApp->resetSensors();
|
||||
});
|
||||
|
||||
QVariantMap properties;
|
||||
properties["width"] = "180";
|
||||
properties["anchors.left"] = "undefined";
|
||||
preference->setProperties(properties);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVariantMap>
|
||||
|
||||
#include "DependencyManager.h"
|
||||
|
||||
|
@ -43,6 +44,7 @@ class Preference : public QObject {
|
|||
Q_PROPERTY(QString name READ getName CONSTANT)
|
||||
Q_PROPERTY(Type type READ getType CONSTANT)
|
||||
Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged)
|
||||
Q_PROPERTY(QVariantMap properties READ getProperties);
|
||||
Q_ENUMS(Type)
|
||||
|
||||
public:
|
||||
|
@ -81,6 +83,14 @@ public:
|
|||
|
||||
void setEnabler(BoolPreference* enabler, bool inverse = false);
|
||||
|
||||
const QVariantMap& getProperties() {
|
||||
return _properties;
|
||||
}
|
||||
|
||||
void setProperties(const QVariantMap& properties) {
|
||||
_properties = properties;
|
||||
}
|
||||
|
||||
virtual Type getType() { return Invalid; };
|
||||
|
||||
Q_INVOKABLE virtual void load() {};
|
||||
|
@ -100,6 +110,7 @@ protected:
|
|||
const QString _name;
|
||||
bool _enabled { true };
|
||||
bool _enablerInverted { false };
|
||||
QVariantMap _properties;
|
||||
};
|
||||
|
||||
class ButtonPreference : public Preference {
|
||||
|
|
Loading…
Reference in a new issue