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
|
||||
|
||||
QtObject {
|
||||
id: innerObject
|
||||
id: root
|
||||
|
||||
property variant backendValue
|
||||
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 isInModel: {
|
||||
if (backendValue !== undefined && backendValue.isInModel !== undefined)
|
||||
return backendValue.isInModel
|
||||
if (root.backendValue !== undefined && root.backendValue.isInModel !== undefined)
|
||||
return root.backendValue.isInModel
|
||||
|
||||
return false
|
||||
}
|
||||
property bool isInSubState: {
|
||||
if (backendValue !== undefined && backendValue.isInSubState !== undefined)
|
||||
return backendValue.isInSubState
|
||||
if (root.backendValue !== undefined && root.backendValue.isInSubState !== undefined)
|
||||
return root.backendValue.isInSubState
|
||||
|
||||
return false
|
||||
}
|
||||
property bool highlight: textColor === __changedTextColor
|
||||
property bool highlight: root.textColor === root.__changedTextColor
|
||||
property bool errorState: false
|
||||
|
||||
readonly property color __defaultTextColor: StudioTheme.Values.themeTextColor
|
||||
readonly property color __changedTextColor: StudioTheme.Values.themeInteraction
|
||||
readonly property color __errorTextColor: StudioTheme.Values.themeError
|
||||
|
||||
onBackendValueChanged: evaluate()
|
||||
onValueFromBackendChanged: evaluate()
|
||||
onBaseStateFlagChanged: evaluate()
|
||||
onIsInModelChanged: evaluate()
|
||||
onIsInSubStateChanged: evaluate()
|
||||
onErrorStateChanged: evaluate()
|
||||
onBackendValueChanged: root.evaluate()
|
||||
onValueFromBackendChanged: root.evaluate()
|
||||
onBaseStateFlagChanged: root.evaluate()
|
||||
onIsInModelChanged: root.evaluate()
|
||||
onIsInSubStateChanged: root.evaluate()
|
||||
onErrorStateChanged: root.evaluate()
|
||||
|
||||
function evaluate() {
|
||||
if (innerObject.backendValue === undefined)
|
||||
if (root.backendValue === undefined)
|
||||
return
|
||||
|
||||
if (innerObject.errorState) {
|
||||
innerObject.textColor = __errorTextColor
|
||||
if (root.errorState) {
|
||||
root.textColor = root.__errorTextColor
|
||||
return
|
||||
}
|
||||
|
||||
if (innerObject.baseStateFlag) {
|
||||
if (innerObject.backendValue.isInModel)
|
||||
innerObject.textColor = __changedTextColor
|
||||
if (root.baseStateFlag) {
|
||||
if (root.backendValue.isInModel)
|
||||
root.textColor = root.__changedTextColor
|
||||
else
|
||||
innerObject.textColor = __defaultTextColor
|
||||
root.textColor = root.__defaultTextColor
|
||||
} else {
|
||||
if (innerObject.backendValue.isInSubState)
|
||||
innerObject.textColor = StudioTheme.Values.themeChangedStateText
|
||||
if (root.backendValue.isInSubState)
|
||||
root.textColor = StudioTheme.Values.themeChangedStateText
|
||||
else
|
||||
innerObject.textColor = __defaultTextColor
|
||||
root.textColor = root.__defaultTextColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user