forked from qt-creator/qt-creator
QmlDesigner: Cleanup color logic code
Change-Id: I33019c06bc9c1f077ac88367f3b8ea279e2801c5 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
f8f1732a1e
commit
4e1eb3727f
@@ -27,57 +27,57 @@ import QtQuick 2.15
|
|||||||
import StudioTheme 1.0 as StudioTheme
|
import StudioTheme 1.0 as StudioTheme
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: innerObject
|
id: root
|
||||||
|
|
||||||
property variant backendValue
|
property variant backendValue
|
||||||
property color textColor: StudioTheme.Values.themeTextColor
|
property color textColor: StudioTheme.Values.themeTextColor
|
||||||
property variant valueFromBackend: backendValue === undefined ? 0 : backendValue.value
|
property variant valueFromBackend: root.backendValue === undefined ? 0 : root.backendValue.value
|
||||||
property bool baseStateFlag: isBaseState
|
property bool baseStateFlag: isBaseState
|
||||||
property bool isInModel: {
|
property bool isInModel: {
|
||||||
if (backendValue !== undefined && backendValue.isInModel !== undefined)
|
if (root.backendValue !== undefined && root.backendValue.isInModel !== undefined)
|
||||||
return backendValue.isInModel
|
return root.backendValue.isInModel
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
property bool isInSubState: {
|
property bool isInSubState: {
|
||||||
if (backendValue !== undefined && backendValue.isInSubState !== undefined)
|
if (root.backendValue !== undefined && root.backendValue.isInSubState !== undefined)
|
||||||
return backendValue.isInSubState
|
return root.backendValue.isInSubState
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
property bool highlight: textColor === __changedTextColor
|
property bool highlight: root.textColor === root.__changedTextColor
|
||||||
property bool errorState: false
|
property bool errorState: false
|
||||||
|
|
||||||
readonly property color __defaultTextColor: StudioTheme.Values.themeTextColor
|
readonly property color __defaultTextColor: StudioTheme.Values.themeTextColor
|
||||||
readonly property color __changedTextColor: StudioTheme.Values.themeInteraction
|
readonly property color __changedTextColor: StudioTheme.Values.themeInteraction
|
||||||
readonly property color __errorTextColor: StudioTheme.Values.themeError
|
readonly property color __errorTextColor: StudioTheme.Values.themeError
|
||||||
|
|
||||||
onBackendValueChanged: evaluate()
|
onBackendValueChanged: root.evaluate()
|
||||||
onValueFromBackendChanged: evaluate()
|
onValueFromBackendChanged: root.evaluate()
|
||||||
onBaseStateFlagChanged: evaluate()
|
onBaseStateFlagChanged: root.evaluate()
|
||||||
onIsInModelChanged: evaluate()
|
onIsInModelChanged: root.evaluate()
|
||||||
onIsInSubStateChanged: evaluate()
|
onIsInSubStateChanged: root.evaluate()
|
||||||
onErrorStateChanged: evaluate()
|
onErrorStateChanged: root.evaluate()
|
||||||
|
|
||||||
function evaluate() {
|
function evaluate() {
|
||||||
if (innerObject.backendValue === undefined)
|
if (root.backendValue === undefined)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (innerObject.errorState) {
|
if (root.errorState) {
|
||||||
innerObject.textColor = __errorTextColor
|
root.textColor = root.__errorTextColor
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (innerObject.baseStateFlag) {
|
if (root.baseStateFlag) {
|
||||||
if (innerObject.backendValue.isInModel)
|
if (root.backendValue.isInModel)
|
||||||
innerObject.textColor = __changedTextColor
|
root.textColor = root.__changedTextColor
|
||||||
else
|
else
|
||||||
innerObject.textColor = __defaultTextColor
|
root.textColor = root.__defaultTextColor
|
||||||
} else {
|
} else {
|
||||||
if (innerObject.backendValue.isInSubState)
|
if (root.backendValue.isInSubState)
|
||||||
innerObject.textColor = StudioTheme.Values.themeChangedStateText
|
root.textColor = StudioTheme.Values.themeChangedStateText
|
||||||
else
|
else
|
||||||
innerObject.textColor = __defaultTextColor
|
root.textColor = root.__defaultTextColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user