forked from qt-creator/qt-creator
QmlDesigner: Cleanup alignment button related code
Change-Id: Ib6b20c5a3d0e92040bbb268be7a1a4df43e22f0f Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
0a8545c068
commit
0db724eb25
@@ -34,9 +34,9 @@ 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
|
||||
property color __currentColor: root.blueHighlight ? StudioTheme.Values.themeIconColorInteraction
|
||||
: StudioTheme.Values.themeIconColor
|
||||
|
||||
onValueChanged: {
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,9 +34,9 @@ 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
|
||||
property color __currentColor: root.blueHighlight ? StudioTheme.Values.themeIconColorInteraction
|
||||
: StudioTheme.Values.themeIconColor
|
||||
|
||||
onValueChanged: {
|
||||
@@ -44,43 +44,43 @@ Row {
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,46 +34,42 @@ StudioControls.Button {
|
||||
property variant backendValue
|
||||
property bool isHighlighted: false
|
||||
|
||||
iconColor: isHighlighted ? StudioTheme.Values.themeIconColorInteraction
|
||||
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
|
||||
if (button.backendValue !== null && innerObject.isInModel)
|
||||
button.isHighlighted = true
|
||||
else
|
||||
button.isHighlighted = false
|
||||
} else {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user