2010-01-07 12:14:35 +01:00
|
|
|
import Qt 4.6
|
|
|
|
|
import Bauhaus 1.0
|
|
|
|
|
|
2010-02-05 15:42:31 +10:00
|
|
|
QWidget { //This is a special spinBox that does color coding for states
|
2010-02-04 16:03:45 +01:00
|
|
|
|
2010-02-05 15:42:31 +10:00
|
|
|
id: spinBox;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
property var backendValue;
|
|
|
|
|
property var baseStateFlag;
|
|
|
|
|
property alias singleStep: box.singleStep;
|
|
|
|
|
property alias minimum: box.minimum
|
|
|
|
|
property alias maximum: box.maximum
|
2010-02-26 11:47:03 +01:00
|
|
|
property alias enabled: box.enabled
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
minimumHeight: 22;
|
|
|
|
|
|
|
|
|
|
onBaseStateFlagChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBackendValueChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-25 16:48:20 +01:00
|
|
|
property var isEnabled: spinBox.enabled
|
|
|
|
|
onIsEnabledChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-23 10:02:49 +01:00
|
|
|
function evaluate() {
|
|
|
|
|
if (backendValue === undefined)
|
|
|
|
|
return;
|
|
|
|
|
if (!enabled) {
|
|
|
|
|
box.setStyleSheet("color: "+scheme.disabledColor);
|
|
|
|
|
} else {
|
|
|
|
|
if (!(baseStateFlag === undefined) && baseStateFlag) {
|
|
|
|
|
if (backendValue.isInModel)
|
|
|
|
|
box.setStyleSheet("color: "+scheme.changedBaseColor);
|
|
|
|
|
else
|
|
|
|
|
box.setStyleSheet("color: "+scheme.defaultColor);
|
|
|
|
|
} else {
|
|
|
|
|
if (backendValue.isInSubState)
|
|
|
|
|
box.setStyleSheet("color: "+scheme.changedStateColor);
|
|
|
|
|
else
|
|
|
|
|
box.setStyleSheet("color: "+scheme.defaultColor);
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
2010-02-25 16:48:20 +01:00
|
|
|
}
|
2010-02-26 15:36:27 +01:00
|
|
|
|
2010-03-15 16:24:04 +01:00
|
|
|
property bool isInModel: backendValue.isInModel;
|
2010-02-22 15:48:03 +01:00
|
|
|
|
|
|
|
|
onIsInModelChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-15 16:24:04 +01:00
|
|
|
property bool isInSubState: backendValue.isInSubState;
|
2010-02-22 15:48:03 +01:00
|
|
|
|
|
|
|
|
onIsInSubStateChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
2010-01-07 12:14:35 +01:00
|
|
|
|
2010-02-25 16:48:20 +01:00
|
|
|
ColorScheme { id:scheme; }
|
|
|
|
|
|
2010-01-27 11:48:46 +01:00
|
|
|
layout: HorizontalLayout {
|
2010-01-07 12:14:35 +01:00
|
|
|
QSpinBox {
|
2010-02-05 15:42:31 +10:00
|
|
|
property alias backendValue: spinBox.backendValue
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
keyboardTracking: false;
|
|
|
|
|
id: box;
|
2010-03-15 16:24:04 +01:00
|
|
|
enabled: backendValue.isBound
|
2010-01-13 13:54:02 +01:00
|
|
|
property bool readingFromBackend: false;
|
2010-03-15 16:24:04 +01:00
|
|
|
property int valueFromBackend: spinBox.backendValue.value;
|
2010-01-13 13:54:02 +01:00
|
|
|
|
|
|
|
|
onValueFromBackendChanged: {
|
2010-03-15 16:24:04 +01:00
|
|
|
readingFromBackend = true;
|
2010-02-26 15:36:27 +01:00
|
|
|
value = valueFromBackend;
|
2010-01-27 11:48:46 +01:00
|
|
|
readingFromBackend = false;
|
|
|
|
|
evaluate();
|
2010-01-13 14:49:28 +01:00
|
|
|
}
|
2010-01-13 13:54:02 +01:00
|
|
|
|
2010-03-15 16:24:04 +01:00
|
|
|
onValueChanged: {
|
2010-02-26 15:36:27 +01:00
|
|
|
backendValue.value = value;
|
2010-02-25 16:48:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onFocusChanged: {
|
|
|
|
|
if (focus)
|
2010-03-01 15:59:57 +01:00
|
|
|
transaction.start();
|
2010-02-25 16:48:20 +01:00
|
|
|
else
|
2010-03-01 15:59:57 +01:00
|
|
|
transaction.end();
|
2010-02-25 16:48:20 +01:00
|
|
|
}
|
|
|
|
|
onEditingFinished: {
|
|
|
|
|
focus = false;
|
|
|
|
|
}
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-25 16:48:20 +01:00
|
|
|
ExtendedFunctionButton {
|
2010-03-15 16:24:04 +01:00
|
|
|
backendValue: spinBox.backendValue;
|
2010-01-27 11:48:46 +01:00
|
|
|
y: box.y + 4
|
|
|
|
|
x: box.x + 2
|
2010-02-05 15:42:31 +10:00
|
|
|
visible: spinBox.enabled
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
}
|