diff --git a/interface/resources/qml/dialogs/preferences/SpinBoxPreference.qml b/interface/resources/qml/dialogs/preferences/SpinBoxPreference.qml index 89e1096a04..b2c334b674 100644 --- a/interface/resources/qml/dialogs/preferences/SpinBoxPreference.qml +++ b/interface/resources/qml/dialogs/preferences/SpinBoxPreference.qml @@ -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 diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/preferences/Section.qml b/interface/resources/qml/hifi/tablet/tabletWindows/preferences/Section.qml index 15db58decc..cf32b21c67 100644 --- a/interface/resources/qml/hifi/tablet/tabletWindows/preferences/Section.qml +++ b/interface/resources/qml/hifi/tablet/tabletWindows/preferences/Section.qml @@ -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; + } + } } } } diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 600c7043d3..4943a4be65 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -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); } diff --git a/libraries/shared/src/Preferences.h b/libraries/shared/src/Preferences.h index 931508e825..5352d0e726 100644 --- a/libraries/shared/src/Preferences.h +++ b/libraries/shared/src/Preferences.h @@ -15,6 +15,7 @@ #include #include #include +#include #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 {