2010-01-07 12:14:35 +01:00
|
|
|
import Qt 4.6
|
|
|
|
|
import Bauhaus 1.0
|
|
|
|
|
|
|
|
|
|
QWidget { //This is a special SpinBox that does color coding for states
|
|
|
|
|
id: SpinBox;
|
|
|
|
|
|
|
|
|
|
property var backendValue;
|
|
|
|
|
property var baseStateFlag;
|
|
|
|
|
property alias singleStep: box.singleStep;
|
|
|
|
|
property alias minimum: box.minimum
|
|
|
|
|
property alias maximum: box.maximum
|
|
|
|
|
|
|
|
|
|
minimumHeight: 22;
|
|
|
|
|
|
|
|
|
|
onBaseStateFlagChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBackendValueChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Script {
|
|
|
|
|
function evaluate() {
|
|
|
|
|
if (baseStateFlag) {
|
|
|
|
|
if (backendValue != null && backendValue.isInModel)
|
|
|
|
|
SpinBox.setStyleSheet("color: white;");
|
|
|
|
|
else
|
|
|
|
|
SpinBox.setStyleSheet("color: gray;");
|
|
|
|
|
} else {
|
2010-01-13 13:54:02 +01:00
|
|
|
if (backendValue != null && backendValue.isInSubState)
|
|
|
|
|
SpinBox.setStyleSheet("color: #7799FF;");
|
|
|
|
|
else
|
|
|
|
|
SpinBox.setStyleSheet("color: gray;");
|
2010-01-07 12:14:35 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layout: QHBoxLayout {
|
|
|
|
|
topMargin: 0;
|
|
|
|
|
bottomMargin: 0;
|
|
|
|
|
leftMargin: 0;
|
|
|
|
|
rightMargin: 10;
|
|
|
|
|
spacing: 0;
|
|
|
|
|
|
|
|
|
|
QSpinBox {
|
|
|
|
|
property alias backendValue: SpinBox.backendValue
|
|
|
|
|
|
|
|
|
|
keyboardTracking: false;
|
|
|
|
|
id: box;
|
|
|
|
|
enabled: backendValue === undefined || backendValue.isBound === undefined || backendValue.isBound === null ? false : !backendValue.isBound
|
2010-01-13 13:54:02 +01:00
|
|
|
property bool readingFromBackend: false;
|
|
|
|
|
property int valueFromBackend: SpinBox.backendValue == null ? .0 : SpinBox.backendValue.value;
|
|
|
|
|
|
|
|
|
|
onValueFromBackendChanged: {
|
|
|
|
|
readingFromBackend = true;
|
|
|
|
|
value = valueFromBackend
|
|
|
|
|
readingFromBackend = false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-07 12:14:35 +01:00
|
|
|
onValueChanged: {
|
2010-01-13 13:54:02 +01:00
|
|
|
if (SpinBox.backendValue != null && readingFromBackend == false)
|
2010-01-07 12:14:35 +01:00
|
|
|
backendValue.value = value;
|
|
|
|
|
}
|
|
|
|
|
onFocusChanged: {
|
|
|
|
|
//extendedSwitches.active = focus;
|
|
|
|
|
//extendedSwitches.backendValue = backendValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-13 13:54:02 +01:00
|
|
|
QToolButton {
|
2010-01-07 12:14:35 +01:00
|
|
|
visible: false;
|
|
|
|
|
width: 10;
|
|
|
|
|
height: 10;
|
|
|
|
|
y: box.y + box.height - 11;
|
|
|
|
|
x: box.width - 1;
|
|
|
|
|
focusPolicy: "Qt::NoFocus";
|
|
|
|
|
}
|
|
|
|
|
}
|