QmlDesigner: Fix some warnings on startup

Those warnings are thrown because some backend values aren't initially
available.

Change-Id: I65858c5ed9dc1701446d6a37237d4135d8d6942e
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Henning Gruendl
2025-04-02 17:50:03 +02:00
committed by Henning Gründl
parent 326b7ba079
commit 6b8964071a
8 changed files with 39 additions and 34 deletions

View File

@@ -25,7 +25,7 @@ Section {
implicitWidth: StudioTheme.Values.twoControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
backendValue: backendValues.enabled
text: backendValues.enabled.valueToString
text: backendValues.enabled?.valueToString
}
ExpandingSpacer {}
@@ -34,7 +34,7 @@ Section {
PropertyLabel {
text: qsTr("Smooth")
tooltip: qsTr("Toggles if the smoothing is performed using linear interpolation method. Keeping it unchecked would follow non-smooth method using nearest neighbor. It is mostly applicable on image based items.")
blockedByTemplate: !backendValues.smooth.isAvailable
blockedByTemplate: !backendValues.smooth?.isAvailable
}
SecondColumnLayout {
@@ -42,8 +42,8 @@ Section {
implicitWidth: StudioTheme.Values.twoControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
backendValue: backendValues.smooth
text: backendValues.smooth.valueToString
enabled: backendValues.smooth.isAvailable
text: backendValues.smooth?.valueToString
enabled: backendValues.smooth?.isAvailable ?? false
}
ExpandingSpacer {}
@@ -52,7 +52,7 @@ Section {
PropertyLabel {
text: qsTr("Antialiasing")
tooltip: qsTr("Refines the edges of the image.")
blockedByTemplate: !backendValues.antialiasing.isAvailable
blockedByTemplate: !backendValues.antialiasing?.isAvailable
}
SecondColumnLayout {
@@ -60,8 +60,8 @@ Section {
implicitWidth: StudioTheme.Values.twoControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
backendValue: backendValues.antialiasing
text: backendValues.antialiasing.valueToString
enabled: backendValues.antialiasing.isAvailable
text: backendValues.antialiasing?.valueToString
enabled: backendValues.antialiasing?.isAvailable ?? false
}
ExpandingSpacer {}
@@ -70,7 +70,7 @@ Section {
PropertyLabel {
text: qsTr("Focus")
tooltip: qsTr("Sets focus on the component within the enclosing focus scope.")
blockedByTemplate: !backendValues.focus.isAvailable
blockedByTemplate: !backendValues.focus?.isAvailable
}
SecondColumnLayout {
@@ -78,8 +78,8 @@ Section {
implicitWidth: StudioTheme.Values.twoControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
backendValue: backendValues.focus
text: backendValues.focus.valueToString
enabled: backendValues.focus.isAvailable
text: backendValues.focus?.valueToString
enabled: backendValues.focus?.isAvailable ?? false
}
ExpandingSpacer {}
@@ -88,7 +88,7 @@ Section {
PropertyLabel {
text: qsTr("Focus on tab")
tooltip: qsTr("Adds the component to the tab focus chain.")
blockedByTemplate: !backendValues.activeFocusOnTab.isAvailable
blockedByTemplate: !backendValues.activeFocusOnTab?.isAvailable
}
SecondColumnLayout {
@@ -96,8 +96,8 @@ Section {
implicitWidth: StudioTheme.Values.twoControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
backendValue: backendValues.activeFocusOnTab
text: backendValues.activeFocusOnTab.valueToString
enabled: backendValues.activeFocusOnTab.isAvailable
text: backendValues.activeFocusOnTab?.valueToString
enabled: backendValues.activeFocusOnTab?.isAvailable ?? false
}
ExpandingSpacer {}
@@ -106,7 +106,7 @@ Section {
PropertyLabel {
text: qsTr("Baseline offset")
tooltip: qsTr("Sets the position of the component's baseline in local coordinates.")
blockedByTemplate: !backendValues.baselineOffset.isAvailable
blockedByTemplate: !backendValues.baselineOffset?.isAvailable
}
SecondColumnLayout {
@@ -119,7 +119,7 @@ Section {
decimals: 0
minimumValue: -1000
maximumValue: 1000
enabled: backendValues.baselineOffset.isAvailable
enabled: backendValues.baselineOffset?.isAvailable ?? false
}
ExpandingSpacer {}

View File

@@ -40,7 +40,7 @@ Section {
anchors.left: parent.left
anchors.right: parent.right
caption: qsTr('Effects <a style="color:%1;">[beta]</a>').arg(StudioTheme.Values.themeInteraction)
visible: backendValues.layer_effect.isAvailable
visible: backendValues.layer_effect?.isAvailable ?? false
property Connections connection: Connections {
target: modelNodeBackend

View File

@@ -161,7 +161,7 @@ Section {
PropertyLabel {
text: qsTr("Rotation")
tooltip: qsTr("Rotate the component at an angle.")
blockedByTemplate: !backendValues.rotation.isAvailable
blockedByTemplate: !backendValues.rotation?.isAvailable ?? false
}
SecondColumnLayout {
@@ -173,7 +173,7 @@ Section {
decimals: 2
minimumValue: -360
maximumValue: 360
enabled: backendValues.rotation.isAvailable
enabled: backendValues.rotation?.isAvailable ?? false
}
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
@@ -181,7 +181,7 @@ Section {
ControlLabel {
text: "°"
tooltip: rotationSpinBox.enabled ? qsTr("Angle (in degree)") : root.disabledTooltip
enabled: backendValues.rotation.isAvailable
enabled: backendValues.rotation?.isAvailable ?? false
}
/*
TODO QDS-4835
@@ -217,7 +217,7 @@ Section {
PropertyLabel {
text: qsTr("Scale")
tooltip: qsTr("Sets the scale of the component by percentage.")
blockedByTemplate: !backendValues.scale.isAvailable
blockedByTemplate: !backendValues.scale?.isAvailable ?? false
}
SecondColumnLayout {
@@ -231,7 +231,7 @@ Section {
stepSize: 0.1
minimumValue: -10
maximumValue: 10
enabled: backendValues.scale.isAvailable
enabled: backendValues.scale?.isAvailable ?? false
}
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
@@ -239,7 +239,7 @@ Section {
ControlLabel {
text: "%"
tooltip: scaleSpinBox.enabled ? qsTr("Percentage") : root.disabledTooltip
enabled: backendValues.scale.isAvailable
enabled: backendValues.scale?.isAvailable ?? false
}
ExpandingSpacer {}
@@ -265,13 +265,13 @@ Section {
PropertyLabel {
text: qsTr("Origin")
tooltip: qsTr("Sets the modification point of the component.")
blockedByTemplate: !backendValues.transformOrigin.isAvailable
blockedByTemplate: !backendValues.transformOrigin?.isAvailable
}
SecondColumnLayout {
OriginControl {
backendValue: backendValues.transformOrigin
enabled: backendValues.transformOrigin.isAvailable
enabled: backendValues.transformOrigin?.isAvailable ?? false
}
ExpandingSpacer {}

View File

@@ -89,7 +89,7 @@ PropertyEditorPane {
anchors.right: parent.right
StudioControls.TabButton {
text: backendValues.__classNamePrivateInternal.value
text: backendValues.__classNamePrivateInternal?.value
onClicked: () => {
if (itemPane.searchBar.hasDoneSearch)
itemPane.searchBar.search();

View File

@@ -10,7 +10,7 @@ Section {
anchors.left: parent.left
anchors.right: parent.right
caption: qsTr("Layer")
visible: backendValues.layer_effect.isAvailable
visible: backendValues.layer_effect?.isAvailable ?? false
SectionLayout {
PropertyLabel {
@@ -22,7 +22,7 @@ Section {
CheckBox {
implicitWidth: StudioTheme.Values.twoControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
text: backendValues.layer_enabled.valueToString
text: backendValues.layer_enabled?.valueToString
backendValue: backendValues.layer_enabled
}
@@ -81,7 +81,7 @@ Section {
function syncIndexToBackendValue() {
samplesComboBox.block = true
samplesComboBox.currentIndex = samplesComboBox.model.indexOf(backendValues.layer_samples.value)
samplesComboBox.currentIndex = samplesComboBox.model.indexOf(backendValues.layer_samples?.value)
samplesComboBox.block = false
}
}
@@ -214,7 +214,7 @@ Section {
CheckBox {
implicitWidth: StudioTheme.Values.twoControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
text: backendValues.layer_mipmap.valueToString
text: backendValues.layer_mipmap?.valueToString
backendValue: backendValues.layer_mipmap
}
@@ -230,7 +230,7 @@ Section {
CheckBox {
implicitWidth: StudioTheme.Values.twoControlColumnWidth
+ StudioTheme.Values.actionIndicatorWidth
text: backendValues.layer_smooth.valueToString
text: backendValues.layer_smooth?.valueToString
backendValue: backendValues.layer_smooth
}

View File

@@ -112,6 +112,11 @@ StudioControls.ComboBox {
comboBox.currentIndex = comboBox.indexOfValue(comboBox.backendValue.value)
}
} else {
if (!comboBox.backendValue) {
comboBox.block = false
return
}
switch (comboBox.valueType) {
case ComboBox.ValueType.String:
if (comboBox.currentText !== comboBox.backendValue.value) {
@@ -129,9 +134,6 @@ StudioControls.ComboBox {
break
case ComboBox.ValueType.Enum:
default:
if (!comboBox.backendValue)
break
var enumString = comboBox.backendValue.enumeration
if (enumString === "")

View File

@@ -36,7 +36,7 @@ Section {
anchors.fill: parent
anchors.leftMargin: StudioTheme.Values.inputHorizontalPadding
anchors.topMargin: StudioTheme.Values.typeLabelVerticalShift
text: backendValues.__classNamePrivateInternal.value
text: backendValues.__classNamePrivateInternal?.value ?? ""
}
ToolTipArea {

View File

@@ -31,6 +31,9 @@ Row {
id: colorLogic
backendValue: root.backendValue
onValueFromBackendChanged: {
if (!root.backendValue)
return
var enumString = root.backendValue.enumeration
if (enumString === "")
enumString = root.backendValue.value