mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-12 16:56:52 +02:00
Fix SpinBox. attempt 1
This commit is contained in:
parent
6f420ffae2
commit
663af09605
3 changed files with 12 additions and 2 deletions
|
@ -20,6 +20,7 @@ SpinBox {
|
||||||
property int colorScheme: hifi.colorSchemes.light
|
property int colorScheme: hifi.colorSchemes.light
|
||||||
readonly property bool isLightColorScheme: colorScheme === hifi.colorSchemes.light
|
readonly property bool isLightColorScheme: colorScheme === hifi.colorSchemes.light
|
||||||
property string label: ""
|
property string label: ""
|
||||||
|
property string suffix: ""
|
||||||
property string labelInside: ""
|
property string labelInside: ""
|
||||||
property color colorLabelInside: hifi.colors.white
|
property color colorLabelInside: hifi.colors.white
|
||||||
property real controlHeight: height + (spinBoxLabel.visible ? spinBoxLabel.height + spinBoxLabel.anchors.bottomMargin : 0)
|
property real controlHeight: height + (spinBoxLabel.visible ? spinBoxLabel.height + spinBoxLabel.anchors.bottomMargin : 0)
|
||||||
|
@ -34,6 +35,8 @@ SpinBox {
|
||||||
property real realTo: 100.0
|
property real realTo: 100.0
|
||||||
property real realStepSize: 1.0
|
property real realStepSize: 1.0
|
||||||
|
|
||||||
|
signal editingFinished()
|
||||||
|
|
||||||
implicitHeight: height
|
implicitHeight: height
|
||||||
implicitWidth: width
|
implicitWidth: width
|
||||||
|
|
||||||
|
@ -88,12 +91,14 @@ SpinBox {
|
||||||
: (spinBox.activeFocus ? hifi.colors.white : hifi.colors.lightGrayText)
|
: (spinBox.activeFocus ? hifi.colors.white : hifi.colors.lightGrayText)
|
||||||
selectedTextColor: hifi.colors.black
|
selectedTextColor: hifi.colors.black
|
||||||
selectionColor: hifi.colors.primaryHighlight
|
selectionColor: hifi.colors.primaryHighlight
|
||||||
text: spinBox.textFromValue(spinBox.value, spinBox.locale)
|
text: spinBox.textFromValue(spinBox.value, spinBox.locale) + suffix
|
||||||
verticalAlignment: Qt.AlignVCenter
|
verticalAlignment: Qt.AlignVCenter
|
||||||
leftPadding: spinBoxLabelInside.visible ? 30 : hifi.dimensions.textPadding
|
leftPadding: spinBoxLabelInside.visible ? 30 : hifi.dimensions.textPadding
|
||||||
//rightPadding: hifi.dimensions.spinnerSize
|
//rightPadding: hifi.dimensions.spinnerSize
|
||||||
width: spinBox.width - hifi.dimensions.spinnerSize
|
width: spinBox.width - hifi.dimensions.spinnerSize
|
||||||
|
onEditingFinished: spinBox.editingFinished()
|
||||||
}
|
}
|
||||||
|
|
||||||
up.indicator: Item {
|
up.indicator: Item {
|
||||||
x: spinBox.width - implicitWidth - 5
|
x: spinBox.width - implicitWidth - 5
|
||||||
y: 1
|
y: 1
|
||||||
|
|
|
@ -298,7 +298,7 @@ void setupPreferences() {
|
||||||
{
|
{
|
||||||
static const int MIN_PORT_NUMBER { 0 };
|
static const int MIN_PORT_NUMBER { 0 };
|
||||||
static const int MAX_PORT_NUMBER { 65535 };
|
static const int MAX_PORT_NUMBER { 65535 };
|
||||||
auto getter = [nodelist] { return static_cast<int>(nodelist->getSocketLocalPort()); };
|
auto getter = [nodelist] { qWarning() << "vladest: port" << static_cast<int>(nodelist->getSocketLocalPort()); return static_cast<int>(nodelist->getSocketLocalPort()); };
|
||||||
auto setter = [nodelist](int preset) { nodelist->setSocketLocalPort(static_cast<quint16>(preset)); };
|
auto setter = [nodelist](int preset) { nodelist->setSocketLocalPort(static_cast<quint16>(preset)); };
|
||||||
auto preference = new IntSpinnerPreference(NETWORKING, "Listening Port", getter, setter);
|
auto preference = new IntSpinnerPreference(NETWORKING, "Listening Port", getter, setter);
|
||||||
preference->setMin(MIN_PORT_NUMBER);
|
preference->setMin(MIN_PORT_NUMBER);
|
||||||
|
|
|
@ -198,6 +198,7 @@ class IntPreference : public TypedPreference<int> {
|
||||||
Q_PROPERTY(float min READ getMin CONSTANT)
|
Q_PROPERTY(float min READ getMin CONSTANT)
|
||||||
Q_PROPERTY(float max READ getMax CONSTANT)
|
Q_PROPERTY(float max READ getMax CONSTANT)
|
||||||
Q_PROPERTY(float step READ getStep CONSTANT)
|
Q_PROPERTY(float step READ getStep CONSTANT)
|
||||||
|
Q_PROPERTY(int decimals READ getDecimals CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IntPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
IntPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
||||||
|
@ -212,6 +213,9 @@ public:
|
||||||
float getStep() const { return _step; }
|
float getStep() const { return _step; }
|
||||||
void setStep(float step) { _step = step; };
|
void setStep(float step) { _step = step; };
|
||||||
|
|
||||||
|
int getDecimals() const { return _decimals; }
|
||||||
|
void setDecimals(int decimals) { _decimals = decimals; };
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void valueChanged();
|
void valueChanged();
|
||||||
|
|
||||||
|
@ -221,6 +225,7 @@ protected:
|
||||||
int _min { std::numeric_limits<int>::min() };
|
int _min { std::numeric_limits<int>::min() };
|
||||||
int _max { std::numeric_limits<int>::max() };
|
int _max { std::numeric_limits<int>::max() };
|
||||||
int _step { 1 };
|
int _step { 1 };
|
||||||
|
int _decimals { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
class StringPreference : public TypedPreference<QString> {
|
class StringPreference : public TypedPreference<QString> {
|
||||||
|
|
Loading…
Reference in a new issue