forked from qt-creator/qt-creator
QmlDesigner: Remove usage of gradientLine in ColorEditor
Using the model instead. We still have to get rid of gradientLine.currentColor. Change-Id: I9c7a9e6852e70525a6abddfbd874b6a7cc4d7691 Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
@@ -103,19 +103,20 @@ SecondColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onColorChanged: {
|
onColorChanged: {
|
||||||
if (!cePopup.gradientLine.isInValidState)
|
if (!cePopup.isInValidState)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (colorEditor.supportGradient && cePopup.gradientLine.hasGradient) {
|
if (colorEditor.supportGradient && cePopup.gradientModel.hasGradient) {
|
||||||
var hexColor = convertColorToString(colorEditor.color)
|
var hexColor = convertColorToString(colorEditor.color)
|
||||||
hexTextField.text = hexColor
|
hexTextField.text = hexColor
|
||||||
cePopup.popupHexTextField.text = hexColor
|
cePopup.popupHexTextField.text = hexColor
|
||||||
cePopup.gradientLine.currentColor = colorEditor.color
|
cePopup.gradientLine.currentColor = colorEditor.color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delay setting the color to keep ui responsive
|
||||||
if (cePopup.isNotInGradientMode())
|
if (cePopup.isNotInGradientMode())
|
||||||
colorEditorTimer.restart(
|
colorEditorTimer.restart(
|
||||||
) // Delay setting the color to keep ui responsive
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer {
|
Spacer {
|
||||||
|
@@ -40,6 +40,10 @@ T.Popup {
|
|||||||
property alias gradientPropertyName: cePopup.gradientLine.gradientPropertyName
|
property alias gradientPropertyName: cePopup.gradientLine.gradientPropertyName
|
||||||
property alias gradientOrientation: gradientOrientation
|
property alias gradientOrientation: gradientOrientation
|
||||||
|
|
||||||
|
property alias gradientModel: gradientModel
|
||||||
|
|
||||||
|
property bool isInValidState: false
|
||||||
|
|
||||||
function isNotInGradientMode() {
|
function isNotInGradientMode() {
|
||||||
return ceMode.currentValue === "Solid"
|
return ceMode.currentValue === "Solid"
|
||||||
}
|
}
|
||||||
@@ -60,29 +64,29 @@ T.Popup {
|
|||||||
// Build the color editor combobox model
|
// Build the color editor combobox model
|
||||||
ceMode.items.clear()
|
ceMode.items.clear()
|
||||||
ceMode.items.append({
|
ceMode.items.append({
|
||||||
value: "Solid",
|
value: "Solid",
|
||||||
text: qsTr("Solid"),
|
text: qsTr("Solid"),
|
||||||
enabled: true
|
enabled: true
|
||||||
})
|
})
|
||||||
ceMode.items.append({
|
ceMode.items.append({
|
||||||
value: "LinearGradient",
|
value: "LinearGradient",
|
||||||
text: qsTr("Linear"),
|
text: qsTr("Linear"),
|
||||||
enabled: colorEditor.supportGradient
|
enabled: colorEditor.supportGradient
|
||||||
})
|
})
|
||||||
ceMode.items.append({
|
ceMode.items.append({
|
||||||
value: "RadialGradient",
|
value: "RadialGradient",
|
||||||
text: qsTr("Radial"),
|
text: qsTr("Radial"),
|
||||||
enabled: colorEditor.supportGradient && colorEditor.shapeGradients
|
enabled: colorEditor.supportGradient && colorEditor.shapeGradients
|
||||||
})
|
})
|
||||||
ceMode.items.append({
|
ceMode.items.append({
|
||||||
value: "ConicalGradient",
|
value: "ConicalGradient",
|
||||||
text: qsTr("Conical"),
|
text: qsTr("Conical"),
|
||||||
enabled: colorEditor.supportGradient && colorEditor.shapeGradients
|
enabled: colorEditor.supportGradient && colorEditor.shapeGradients
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function determineActiveColorMode() {
|
function determineActiveColorMode() {
|
||||||
if (colorEditor.supportGradient && gradientLine.hasGradient) {
|
if (colorEditor.supportGradient && gradientModel.hasGradient) {
|
||||||
if (colorEditor.shapeGradients) {
|
if (colorEditor.shapeGradients) {
|
||||||
switch (gradientModel.gradientTypeName) {
|
switch (gradientModel.gradientTypeName) {
|
||||||
case "LinearGradient":
|
case "LinearGradient":
|
||||||
@@ -110,7 +114,7 @@ T.Popup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateThumbnail() {
|
function updateThumbnail() {
|
||||||
if (!cePopup.gradientLine.hasGradient)
|
if (!gradientModel.hasGradient)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (!colorEditor.shapeGradients) {
|
if (!colorEditor.shapeGradients) {
|
||||||
@@ -288,7 +292,7 @@ T.Popup {
|
|||||||
else
|
else
|
||||||
gradientModel.gradientTypeName = "Gradient"
|
gradientModel.gradientTypeName = "Gradient"
|
||||||
|
|
||||||
if (gradientLine.hasGradient)
|
if (gradientModel.hasGradient)
|
||||||
gradientLine.updateGradient()
|
gradientLine.updateGradient()
|
||||||
else {
|
else {
|
||||||
gradientLine.deleteGradient()
|
gradientLine.deleteGradient()
|
||||||
@@ -310,7 +314,7 @@ T.Popup {
|
|||||||
colorEditor.resetShapeColor()
|
colorEditor.resetShapeColor()
|
||||||
gradientModel.gradientTypeName = "ConicalGradient"
|
gradientModel.gradientTypeName = "ConicalGradient"
|
||||||
|
|
||||||
if (gradientLine.hasGradient)
|
if (gradientModel.hasGradient)
|
||||||
gradientLine.updateGradient()
|
gradientLine.updateGradient()
|
||||||
else {
|
else {
|
||||||
gradientLine.deleteGradient()
|
gradientLine.deleteGradient()
|
||||||
@@ -358,7 +362,7 @@ T.Popup {
|
|||||||
visible: false
|
visible: false
|
||||||
|
|
||||||
function applyPreset() {
|
function applyPreset() {
|
||||||
if (!gradientLine.hasGradient) {
|
if (!gradientModel.hasGradient) {
|
||||||
if (colorEditor.shapeGradients)
|
if (colorEditor.shapeGradients)
|
||||||
gradientModel.gradientTypeName = "LinearGradient"
|
gradientModel.gradientTypeName = "LinearGradient"
|
||||||
else
|
else
|
||||||
@@ -420,14 +424,14 @@ T.Popup {
|
|||||||
|
|
||||||
GradientLine {
|
GradientLine {
|
||||||
id: gradientLine
|
id: gradientLine
|
||||||
property bool isInValidState: false
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
visible: !cePopup.isNotInGradientMode()
|
visible: !cePopup.isNotInGradientMode()
|
||||||
|
|
||||||
model: gradientModel
|
model: gradientModel
|
||||||
|
|
||||||
onCurrentColorChanged: {
|
onCurrentColorChanged: {
|
||||||
if (colorEditor.supportGradient && gradientLine.hasGradient) {
|
if (colorEditor.supportGradient && gradientModel.hasGradient) {
|
||||||
colorEditor.color = gradientLine.currentColor
|
colorEditor.color = gradientLine.currentColor
|
||||||
colorPicker.color = colorEditor.color
|
colorPicker.color = colorEditor.color
|
||||||
}
|
}
|
||||||
@@ -441,7 +445,7 @@ T.Popup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSelectedNodeChanged: {
|
onSelectedNodeChanged: {
|
||||||
if (colorEditor.supportGradient && gradientLine.hasGradient)
|
if (colorEditor.supportGradient && gradientModel.hasGradient)
|
||||||
colorEditor.originalColor = gradientLine.currentColor
|
colorEditor.originalColor = gradientLine.currentColor
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +455,7 @@ T.Popup {
|
|||||||
target: modelNodeBackend
|
target: modelNodeBackend
|
||||||
function onSelectionToBeChanged() {
|
function onSelectionToBeChanged() {
|
||||||
colorEditorTimer.stop()
|
colorEditorTimer.stop()
|
||||||
gradientLine.isInValidState = false
|
cePopup.isInValidState = false
|
||||||
|
|
||||||
var hexOriginalColor = convertColorToString(colorEditor.originalColor)
|
var hexOriginalColor = convertColorToString(colorEditor.originalColor)
|
||||||
var hexColor = convertColorToString(colorEditor.color)
|
var hexColor = convertColorToString(colorEditor.color)
|
||||||
@@ -469,14 +473,14 @@ T.Popup {
|
|||||||
Connections {
|
Connections {
|
||||||
target: modelNodeBackend
|
target: modelNodeBackend
|
||||||
function onSelectionChanged() {
|
function onSelectionChanged() {
|
||||||
if (colorEditor.supportGradient && gradientLine.hasGradient) {
|
if (colorEditor.supportGradient && gradientModel.hasGradient) {
|
||||||
colorEditor.color = gradientLine.currentColor
|
colorEditor.color = gradientLine.currentColor
|
||||||
gradientLine.currentColor = colorEditor.color
|
gradientLine.currentColor = colorEditor.color
|
||||||
hexTextField.text = colorEditor.color
|
hexTextField.text = colorEditor.color
|
||||||
popupHexTextField.text = colorEditor.color
|
popupHexTextField.text = colorEditor.color
|
||||||
}
|
}
|
||||||
|
|
||||||
gradientLine.isInValidState = true
|
cePopup.isInValidState = true
|
||||||
colorEditor.originalColor = colorEditor.color
|
colorEditor.originalColor = colorEditor.color
|
||||||
colorPalette.selectedColor = colorEditor.color
|
colorPalette.selectedColor = colorEditor.color
|
||||||
colorPicker.color = colorEditor.color
|
colorPicker.color = colorEditor.color
|
||||||
@@ -1149,8 +1153,10 @@ T.Popup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} //content
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: StudioTheme.Values.themeControlBackground
|
color: StudioTheme.Values.themeControlBackground
|
||||||
|
Reference in New Issue
Block a user