diff options
author | Thomas Hartmann <Thomas.Hartmann@digia.com> | 2013-10-23 14:37:43 +0200 |
---|---|---|
committer | Thomas Hartmann <Thomas.Hartmann@digia.com> | 2013-10-23 14:38:29 +0200 |
commit | 60710f6c05117340b95c7e7c5a12f78491893af3 (patch) | |
tree | 9e40e0ab927b05b0949755c177ba2d235a8003e4 /share | |
parent | 8b2682b2570c3b15889c26522c9081949cd4f24c (diff) | |
download | qt-creator-60710f6c05117340b95c7e7c5a12f78491893af3.tar.gz |
QmlDesigner.PropertyEditor: moving the color logic into component
Change-Id: I3d90618f5826cf77cc9813fd3b31fbfdbd5b50e7
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Diffstat (limited to 'share')
5 files changed, 105 insertions, 102 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CheckBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CheckBox.qml index 3462599b43..a1fa1fd3fa 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CheckBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/CheckBox.qml @@ -37,7 +37,7 @@ Controls.CheckBox { property color borderColor: "#222" property color highlightColor: "orange" - property color textColor: "#eee" + property color textColor: colorLogic.textColor onTextChanged: { if (text.charAt(0) !== " ") @@ -46,16 +46,22 @@ Controls.CheckBox { property variant backendValue + onBackendValueChanged: { + innerObject.evaluate(); + } + ExtendedFunctionButton { x: 22 backendValue: checkBox.backendValue visible: checkBox.enabled } - QtObject { - property int valueFromBackend: checkBox.backendValue.value; + ColorLogic { + id: colorLogic + backendValue: checkBox.backendValue onValueFromBackendChanged: { - checkBox.checked = valueFromBackend; + if (checkBox.checked !== valueFromBackend) + checkBox.checked = valueFromBackend; } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ColorLogic.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ColorLogic.qml new file mode 100644 index 0000000000..b4817ecef4 --- /dev/null +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ColorLogic.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Controls 1.1 as Controls +import QtQuick.Controls.Styles 1.0 +import "Constants.js" as Constants + +QtObject { + id: innerObject + + property variant backendValue + property color textColor: Constants.colorsDefaultText + property variant valueFromBackend: backendValue.value; + property bool baseStateFlag: isBaseState; + property bool isInModel: backendValue.isInModel; + property bool isInSubState: backendValue.isInSubState; + + onBackendValueChanged: { + evaluate(); + } + + onValueFromBackendChanged: { + evaluate(); + } + + onBaseStateFlagChanged: { + evaluate(); + } + + onIsInModelChanged: { + evaluate(); + } + + onIsInSubStateChanged: { + evaluate(); + } + + function evaluate() { + if (innerObject.backendValue === undefined) + return; + + if (baseStateFlag) { + if (innerObject.backendValue.isInModel) + innerObject.textColor = Constants.colorsChangedBaseText + else + innerObject.textColor = Constants.colorsDefaultText + } else { + if (innerObject.backendValue.isInSubState) + innerObject.textColor = Constants.colorsChangedStateText + else + innerObject.textColor = Constants.colorsDefaultText + } + + } +} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ComboBox.qml index a2d8f56a17..0fabf6ac02 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/ComboBox.qml @@ -30,49 +30,23 @@ import QtQuick 2.1 import QtQuick.Controls 1.1 as Controls import QtQuick.Controls.Styles 1.1 -import "Constants.js" as Constants Controls.ComboBox { id: comboBox property variant backendValue - property color textColor: Constants.colorsDefaultText + property color textColor: colorLogic.textColor onBackendValueChanged: { innerObject.evaluate(); } - QtObject { - id: innerObject - - property bool baseStateFlag: isBaseState; - property string valueFromBackend: comboBox.backendValue.value; + ColorLogic { + id: colorLogic + backendValue: comboBox.backendValue onValueFromBackendChanged: { comboBox.currentIndex = comboBox.find( comboBox.backendValue.valueToString); - evaluate(); - } - - onBaseStateFlagChanged: { - evaluate(); - } - - function evaluate() { - if (backendValue === undefined) - return; - - if (baseStateFlag) { - if (backendValue.isInModel) - comboBox.textColor = Constants.colorsChangedBaseText - else - comboBox.textColor = Constants.colorsDefaultText - } else { - if (backendValue.isInSubState) - comboBox.textColor = Constants.colorsChangedStateText - else - comboBox.textColor = Constants.colorsDefaultText - } - } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml index 5777afaede..1a0816b1ee 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/LineEdit.qml @@ -31,7 +31,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.1 as Controls import QtQuick.Controls.Styles 1.0 -import "Constants.js" as Constants Controls.TextField { @@ -39,7 +38,7 @@ Controls.TextField { property variant backendValue property color borderColor: "#222" property color highlightColor: "orange" - property color textColor: "#eee" + property color textColor: colorLogic.textColor ExtendedFunctionButton { x: 2 @@ -48,42 +47,11 @@ Controls.TextField { visible: lineEdit.enabled } - onBackendValueChanged: { - innerObject.evaluate(); - } - - QtObject { - id: innerObject - - property string valueFromBackend: lineEdit.backendValue.value; - property bool baseStateFlag: isBaseState; - + ColorLogic { + id: colorLogic + backendValue: lineEdit.backendValue onValueFromBackendChanged: { lineEdit.text = valueFromBackend; - evaluate(); - } - - onBaseStateFlagChanged: { - evaluate(); - } - - function evaluate() { - print("evaluate") - if (lineEdit.backendValue === undefined) - return; - - if (baseStateFlag) { - if (lineEdit.backendValue.isInModel) - lineEdit.textColor = Constants.colorsChangedBaseText - else - lineEdit.textColor = Constants.colorsDefaultText - } else { - if (lineEdit.backendValue.isInSubState) - lineEdit.textColor = Constants.colorsChangedStateText - else - lineEdit.textColor = Constants.colorsDefaultText - } - } } @@ -108,6 +76,7 @@ Controls.TextField { padding.top: 3 padding.bottom: 1 padding.left: 16 + placeholderTextColor: "gray" background: Rectangle { implicitWidth: 100 implicitHeight: 23 diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/SpinBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/SpinBox.qml index 75eea4c42f..13deba9b11 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/SpinBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/HelperWidgets/SpinBox.qml @@ -30,14 +30,12 @@ import QtQuick 2.1 import QtQuick.Controls 1.1 as Controls import QtQuick.Controls.Styles 1.1 -import "Constants.js" as Constants Controls.SpinBox { id: spinBox property color borderColor: "#222" property color highlightColor: "orange" - property color textColor: Constants.colorsDefaultText - + property color textColor: colorLogic.textColor property variant backendValue; prefix: " " @@ -52,37 +50,11 @@ Controls.SpinBox { innerObject.evaluate(); } - QtObject { - id: innerObject - - property int valueFromBackend: spinBox.backendValue.value; - property bool baseStateFlag: isBaseState; - + ColorLogic { + id: colorLogic + backendValue: spinBox.backendValue onValueFromBackendChanged: { spinBox.value = valueFromBackend; - evaluate(); - } - - onBaseStateFlagChanged: { - evaluate(); - } - - function evaluate() { - if (backendValue === undefined) - return; - - if (baseStateFlag) { - if (backendValue.isInModel) - textColor = Constants.colorsChangedBaseText - else - textColor = Constants.colorsDefaultText - } else { - if (backendValue.isInSubState) - textColor = Constants.colorsChangedStateText - else - textColor = Constants.colorsDefaultText - } - } } |