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-03-31 18:43:12 +02:00
|
|
|
import Bauhaus 1.0
|
|
|
|
|
|
|
|
|
|
QWidget { //This is a special doubleSpinBox that does color coding for states
|
|
|
|
|
|
|
|
|
|
id: doubleSpinBox;
|
|
|
|
|
|
2010-04-13 11:20:39 +02:00
|
|
|
property variant backendValue;
|
|
|
|
|
property variant baseStateFlag;
|
2010-03-31 18:43:12 +02:00
|
|
|
property alias singleStep: box.singleStep
|
|
|
|
|
property alias minimum: box.minimum
|
|
|
|
|
property alias maximum: box.maximum
|
|
|
|
|
property alias spacing: layoutH.spacing
|
|
|
|
|
property alias text: label.text
|
|
|
|
|
property bool alignRight: true
|
|
|
|
|
property bool enabled: true
|
|
|
|
|
|
|
|
|
|
minimumHeight: 22;
|
|
|
|
|
|
|
|
|
|
onBaseStateFlagChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onBackendValueChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onEnabledChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function evaluate() {
|
|
|
|
|
if (backendValue === undefined)
|
|
|
|
|
return;
|
|
|
|
|
if (!enabled) {
|
|
|
|
|
box.setStyleSheet("color: "+scheme.disabledColor);
|
|
|
|
|
} else {
|
|
|
|
|
if (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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ColorScheme { id:scheme; }
|
|
|
|
|
|
|
|
|
|
property bool isInModel: backendValue.isInModel;
|
|
|
|
|
|
|
|
|
|
onIsInModelChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property bool isInSubState: backendValue.isInSubState;
|
|
|
|
|
|
|
|
|
|
onIsInSubStateChanged: {
|
|
|
|
|
evaluate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layout: HorizontalLayout {
|
|
|
|
|
id: layoutH;
|
|
|
|
|
|
|
|
|
|
QLabel {
|
|
|
|
|
id: label;
|
|
|
|
|
font.bold: true;
|
|
|
|
|
alignment: doubleSpinBox.alignRight ? "Qt::AlignRight | Qt::AlignVCenter" : "Qt::AlignLeft | Qt::AlignVCenter";
|
2010-05-21 11:19:45 +02:00
|
|
|
fixedWidth: frame.labelWidth
|
2010-03-31 18:43:12 +02:00
|
|
|
visible: doubleSpinBox.text != "";
|
2010-04-01 15:54:48 +02:00
|
|
|
toolTip: text
|
2010-03-31 18:43:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDoubleSpinBox {
|
|
|
|
|
id: box;
|
|
|
|
|
decimals: 1;
|
|
|
|
|
keyboardTracking: false;
|
|
|
|
|
enabled: !backendValue.isBound && doubleSpinBox.enabled;
|
2010-10-01 13:17:59 +02:00
|
|
|
minimum: -1000
|
|
|
|
|
maximum: 1000
|
2010-03-31 18:43:12 +02:00
|
|
|
|
|
|
|
|
property bool readingFromBackend: false;
|
|
|
|
|
property real valueFromBackend: doubleSpinBox.backendValue.value;
|
|
|
|
|
|
|
|
|
|
onValueFromBackendChanged: {
|
|
|
|
|
readingFromBackend = true;
|
|
|
|
|
value = valueFromBackend
|
|
|
|
|
readingFromBackend = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onValueChanged: {
|
|
|
|
|
doubleSpinBox.backendValue.value = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMouseOverChanged: {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onFocusChanged: {
|
|
|
|
|
if (focus)
|
|
|
|
|
transaction.start();
|
|
|
|
|
else
|
|
|
|
|
transaction.end();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExtendedFunctionButton {
|
|
|
|
|
backendValue: doubleSpinBox.backendValue;
|
|
|
|
|
y: box.y + 4
|
|
|
|
|
x: box.x + 2
|
|
|
|
|
visible: doubleSpinBox.enabled
|
|
|
|
|
}
|
|
|
|
|
}
|