2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-07-06 15:48:52 +00:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-07-06 15:48:52 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-07-06 15:48:52 +00:00
|
|
|
|
2012-09-27 10:50:54 +02:00
|
|
|
import QtQuick 1.0
|
2010-01-07 12:14:35 +01:00
|
|
|
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
|
|
|
|
2010-04-13 11:20:39 +02:00
|
|
|
property variant backendValue;
|
|
|
|
|
property variant baseStateFlag;
|
2010-01-07 12:14:35 +01:00
|
|
|
property alias singleStep: box.singleStep;
|
|
|
|
|
property alias minimum: box.minimum
|
|
|
|
|
property alias maximum: box.maximum
|
2010-03-24 17:09:17 +01:00
|
|
|
property bool enabled: true
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
minimumHeight: 22;
|
|
|
|
|
|
|
|
|
|
onBaseStateFlagChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBackendValueChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-13 11:20:39 +02:00
|
|
|
property variant isEnabled: spinBox.enabled
|
2010-02-25 16:48:20 +01:00
|
|
|
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 {
|
2011-05-26 11:35:54 +02:00
|
|
|
spacing: 4
|
2010-01-07 12:14:35 +01:00
|
|
|
QSpinBox {
|
2010-02-05 15:42:31 +10:00
|
|
|
property alias backendValue: spinBox.backendValue
|
2010-04-29 09:51:24 +02:00
|
|
|
toolTip: backendValue.isBound ? backendValue.expression : ""
|
2011-05-26 11:35:54 +02:00
|
|
|
|
|
|
|
|
enabled: !backendValue.isBound && spinBox.enabled;
|
2010-01-07 12:14:35 +01:00
|
|
|
|
|
|
|
|
keyboardTracking: false;
|
|
|
|
|
id: box;
|
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: {
|
2011-04-12 16:05:41 +02:00
|
|
|
readingFromBackend = true;
|
|
|
|
|
if (maximum < valueFromBackend)
|
|
|
|
|
maximum = valueFromBackend;
|
|
|
|
|
if (minimum > valueFromBackend)
|
|
|
|
|
minimum = valueFromBackend;
|
2011-05-26 11:35:54 +02:00
|
|
|
if (valueFromBackend !== value)
|
|
|
|
|
value = valueFromBackend;
|
2010-01-27 11:48:46 +01:00
|
|
|
readingFromBackend = false;
|
2011-05-26 11:35:54 +02:00
|
|
|
|
|
|
|
|
if (!focus)
|
|
|
|
|
evaluate();
|
2010-01-13 14:49:28 +01:00
|
|
|
}
|
2010-01-13 13:54:02 +01:00
|
|
|
|
2011-05-26 11:35:54 +02:00
|
|
|
onValueChanged: {
|
|
|
|
|
if (backendValue.value !== value)
|
|
|
|
|
backendValue.value = value;
|
2010-02-25 16:48:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onFocusChanged: {
|
2011-05-26 11:35:54 +02:00
|
|
|
if (focus) {
|
|
|
|
|
transaction.start();
|
|
|
|
|
} else {
|
|
|
|
|
transaction.end();
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
2010-02-25 16:48:20 +01:00
|
|
|
}
|
|
|
|
|
onEditingFinished: {
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|