From 6b8964071a64dab93881eba07c8505dd8c2a5cfd Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Wed, 2 Apr 2025 17:50:03 +0200 Subject: [PATCH] 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 --- .../QtQuick/AdvancedSection.qml | 30 +++++++++---------- .../QtQuick/EffectsSection.qml | 2 +- .../QtQuick/GeometrySection.qml | 16 +++++----- .../QtQuick/ItemPane.qml | 2 +- .../QtQuick/LayerSection.qml | 10 +++---- .../imports/HelperWidgets/ComboBox.qml | 8 +++-- .../HelperWidgets/ComponentSection.qml | 2 +- .../imports/HelperWidgets/OriginControl.qml | 3 ++ 8 files changed, 39 insertions(+), 34 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml index 1b626623ead..eeb906d9edb 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml @@ -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 {} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/EffectsSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/EffectsSection.qml index 7119bfd84e2..c566e2fd971 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/EffectsSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/EffectsSection.qml @@ -40,7 +40,7 @@ Section { anchors.left: parent.left anchors.right: parent.right caption: qsTr('Effects [beta]').arg(StudioTheme.Values.themeInteraction) - visible: backendValues.layer_effect.isAvailable + visible: backendValues.layer_effect?.isAvailable ?? false property Connections connection: Connections { target: modelNodeBackend diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GeometrySection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GeometrySection.qml index 917b56e474e..02f3b086a70 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GeometrySection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/GeometrySection.qml @@ -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 {} diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml index 2fda6717290..5d73ea78dab 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/ItemPane.qml @@ -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(); diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml index bfb2f51a3bd..860e996d6fc 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml @@ -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 } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml index 4db5a98c225..bf04b904771 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComboBox.qml @@ -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 === "") diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComponentSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComponentSection.qml index d41b225af75..a09199ee7a6 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComponentSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ComponentSection.qml @@ -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 { diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml index e07b371cbde..d2c66c3289d 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml @@ -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