summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenning Gruendl <henning.gruendl@qt.io>2021-09-24 17:23:28 +0200
committerHenning Gründl <henning.gruendl@qt.io>2021-09-24 15:32:32 +0000
commit0db724eb2549874fc6d44382a49c10a8ca532c3b (patch)
tree2010fdf90b4652f8eb2e34176a6a764bc673c923
parent0a8545c068b99609127eda34484ccc8614d90af4 (diff)
downloadqt-creator-0db724eb2549874fc6d44382a49c10a8ca532c3b.tar.gz
QmlDesigner: Cleanup alignment button related code
Change-Id: Ib6b20c5a3d0e92040bbb268be7a1a4df43e22f0f Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentHorizontalButtons.qml68
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentVerticalButtons.qml60
-rw-r--r--share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/BoolButtonRowButton.qml34
3 files changed, 79 insertions, 83 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentHorizontalButtons.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentHorizontalButtons.qml
index 2172430561..ab83bea7d1 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentHorizontalButtons.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentHorizontalButtons.qml
@@ -34,10 +34,10 @@ Row {
property string scope: "Text"
property bool blueHighlight: false
property variant backendValue: backendValues.horizontalAlignment
- property variant value: backendValue.enumeration
+ property variant value: root.backendValue.enumeration
property bool baseStateFlag: isBaseState
- property color __currentColor: blueHighlight ? StudioTheme.Values.themeIconColorInteraction
- : StudioTheme.Values.themeIconColor
+ property color __currentColor: root.blueHighlight ? StudioTheme.Values.themeIconColorInteraction
+ : StudioTheme.Values.themeIconColor
onValueChanged: {
buttonAlignLeft.checked = true
@@ -45,45 +45,45 @@ Row {
buttonAlignRight.checked = false
buttonAlignJustify.checked = false
- if (value !== undefined) {
- if (value === "AlignLeft")
+ if (root.value !== undefined) {
+ if (root.value === "AlignLeft")
buttonAlignLeft.checked = true
- else if (value === "AlignHCenter")
+ else if (root.value === "AlignHCenter")
buttonAlignHCenter.checked = true
- else if (value === "AlignRight")
+ else if (root.value === "AlignRight")
buttonAlignRight.checked = true
- else if (value === "AlignJustify")
+ else if (root.value === "AlignJustify")
buttonAlignJustify.checked = true
}
- evaluate()
+ root.evaluate()
}
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
}
- onIsInModelChanged: evaluate()
+ onIsInModelChanged: root.evaluate()
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
}
- onIsInSubStateChanged: evaluate()
+ onIsInSubStateChanged: root.evaluate()
function evaluate() {
- if (baseStateFlag) {
- if (backendValue !== null && backendValue.isInModel)
- blueHighlight = true
+ if (root.baseStateFlag) {
+ if (root.backendValue !== null && root.backendValue.isInModel)
+ root.blueHighlight = true
else
- blueHighlight = false
+ root.blueHighlight = false
} else {
- if (backendValue !== null && backendValue.isInSubState)
- blueHighlight = true
+ if (root.backendValue !== null && root.backendValue.isInSubState)
+ root.blueHighlight = true
else
- blueHighlight = false
+ root.blueHighlight = false
}
}
@@ -109,10 +109,10 @@ Row {
checkable: true
autoExclusive: true
StudioControls.ButtonGroup.group: group
- iconColor: __currentColor
+ iconColor: root.__currentColor
onClicked: {
- if (checked)
- backendValue.setEnumeration(root.scope, "AlignLeft")
+ if (buttonAlignLeft.checked)
+ root.backendValue.setEnumeration(root.scope, "AlignLeft")
}
}
@@ -122,10 +122,10 @@ Row {
checkable: true
autoExclusive: true
StudioControls.ButtonGroup.group: group
- iconColor: __currentColor
+ iconColor: root.__currentColor
onClicked: {
- if (checked)
- backendValue.setEnumeration(root.scope, "AlignHCenter")
+ if (buttonAlignHCenter.checked)
+ root.backendValue.setEnumeration(root.scope, "AlignHCenter")
}
}
@@ -135,10 +135,10 @@ Row {
checkable: true
autoExclusive: true
StudioControls.ButtonGroup.group: group
- iconColor: __currentColor
+ iconColor: root.__currentColor
onClicked: {
- if (checked)
- backendValue.setEnumeration(root.scope, "AlignRight")
+ if (buttonAlignRight.checked)
+ root.backendValue.setEnumeration(root.scope, "AlignRight")
}
}
@@ -148,10 +148,10 @@ Row {
checkable: true
autoExclusive: true
StudioControls.ButtonGroup.group: group
- iconColor: __currentColor
+ iconColor: root.__currentColor
onClicked: {
- if (checked)
- backendValue.setEnumeration(root.scope, "AlignJustify")
+ if (buttonAlignRight.checked)
+ root.backendValue.setEnumeration(root.scope, "AlignJustify")
}
}
}
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentVerticalButtons.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentVerticalButtons.qml
index ea69901ae7..488ba804be 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentVerticalButtons.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AlignmentVerticalButtons.qml
@@ -34,53 +34,53 @@ Row {
property string scope: "Text"
property bool blueHighlight: false
property variant backendValue: backendValues.verticalAlignment
- property variant value: backendValue.enumeration
+ property variant value: root.backendValue.enumeration
property bool baseStateFlag: isBaseState
- property color __currentColor: blueHighlight ? StudioTheme.Values.themeIconColorInteraction
- : StudioTheme.Values.themeIconColor
+ property color __currentColor: root.blueHighlight ? StudioTheme.Values.themeIconColorInteraction
+ : StudioTheme.Values.themeIconColor
onValueChanged: {
buttonAlignTop.checked = true
buttonAlignVCenter.checked = false
buttonAlignBottom.checked = false
- if (value !== undefined) {
- if (value === "AlignTop")
+ if (root.value !== undefined) {
+ if (root.value === "AlignTop")
buttonAlignTop.checked = true
- else if (value === "AlignVCenter")
+ else if (root.value === "AlignVCenter")
buttonAlignVCenter.checked = true
- else if (value === "AlignBottom")
+ else if (root.value === "AlignBottom")
buttonAlignBottom.checked = true
}
- evaluate()
+ root.evaluate()
}
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
}
- onIsInModelChanged: evaluate()
+ onIsInModelChanged: root.evaluate()
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
}
- onIsInSubStateChanged: evaluate()
+ onIsInSubStateChanged: root.evaluate()
function evaluate() {
- if (baseStateFlag) {
- if (backendValue !== null && backendValue.isInModel)
- blueHighlight = true
+ if (root.baseStateFlag) {
+ if (root.backendValue !== null && root.backendValue.isInModel)
+ root.blueHighlight = true
else
- blueHighlight = false
+ root.blueHighlight = false
} else {
- if (backendValue !== null && backendValue.isInSubState)
- blueHighlight = true
+ if (root.backendValue !== null && root.backendValue.isInSubState)
+ root.blueHighlight = true
else
- blueHighlight = false
+ root.blueHighlight = false
}
}
@@ -108,10 +108,10 @@ Row {
checkable: true
autoExclusive: true
StudioControls.ButtonGroup.group: group
- iconColor: __currentColor
+ iconColor: root.__currentColor
onClicked: {
- if (checked)
- backendValue.setEnumeration(root.scope, "AlignTop")
+ if (buttonAlignTop.checked)
+ root.backendValue.setEnumeration(root.scope, "AlignTop")
}
}
StudioControls.AbstractButton {
@@ -120,10 +120,10 @@ Row {
checkable: true
autoExclusive: true
StudioControls.ButtonGroup.group: group
- iconColor: __currentColor
+ iconColor: root.__currentColor
onClicked: {
- if (checked)
- backendValue.setEnumeration(root.scope, "AlignVCenter")
+ if (buttonAlignVCenter.checked)
+ root.backendValue.setEnumeration(root.scope, "AlignVCenter")
}
}
StudioControls.AbstractButton {
@@ -132,10 +132,10 @@ Row {
checkable: true
autoExclusive: true
StudioControls.ButtonGroup.group: group
- iconColor: __currentColor
+ iconColor: root.__currentColor
onClicked: {
- if (checked)
- backendValue.setEnumeration(root.scope, "AlignBottom")
+ if (buttonAlignBottom.checked)
+ root.backendValue.setEnumeration(root.scope, "AlignBottom")
}
}
}
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/BoolButtonRowButton.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/BoolButtonRowButton.qml
index 7477d0baf5..b633167681 100644
--- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/BoolButtonRowButton.qml
+++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/BoolButtonRowButton.qml
@@ -34,46 +34,42 @@ StudioControls.Button {
property variant backendValue
property bool isHighlighted: false
- iconColor: isHighlighted ? StudioTheme.Values.themeIconColorInteraction
- : StudioTheme.Values.themeIconColor
+ iconColor: button.isHighlighted ? StudioTheme.Values.themeIconColorInteraction
+ : StudioTheme.Values.themeIconColor
actionIndicatorVisible: true
checkable: true
QtObject {
id: innerObject
+
function evaluate() {
if (innerObject.baseStateFlag) {
- if (button.backendValue !== null
- && innerObject.isInModel) {
- isHighlighted = true
- } else {
- isHighlighted = false
- }
+ if (button.backendValue !== null && innerObject.isInModel)
+ button.isHighlighted = true
+ else
+ button.isHighlighted = false
} else {
- if (button.backendValue !== null
- && innerObject.isInSubState) {
- isHighlighted = true
- } else {
- isHighlighted = false
- }
+ if (button.backendValue !== null && innerObject.isInSubState)
+ button.isHighlighted = true
+ else
+ button.isHighlighted = false
}
}
property bool baseStateFlag: isBaseState
- onBaseStateFlagChanged: evaluate()
+ onBaseStateFlagChanged: innerObject.evaluate()
property bool isInModel: button.backendValue === undefined ? false
: button.backendValue.isInModel
- onIsInModelChanged: evaluate()
-
+ onIsInModelChanged: innerObject.evaluate()
property bool isInSubState: button.backendValue === undefined ? false
: button.backendValue.isInSubState
- onIsInSubStateChanged: evaluate()
+ onIsInSubStateChanged: innerObject.evaluate()
property variant theValue: button.backendValue === undefined ? 0 : button.backendValue.value
onTheValueChanged: {
- evaluate()
+ innerObject.evaluate()
button.checked = innerObject.theValue
}
}