Files
qt-creator/share/qtcreator/qmldesigner/propertyeditor/Qt/SpinBox.qml
T

81 lines
2.2 KiB
QML
Raw Normal View History

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 {
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
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: {
if (SpinBox.backendValue != null && readingFromBackend == false)
2010-01-07 12:14:35 +01:00
backendValue.value = value;
}
onFocusChanged: {
//extendedSwitches.active = focus;
//extendedSwitches.backendValue = backendValue;
}
}
}
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";
}
}