From 620e17cf7b5f31f37d81de76f18cb837f4fb9de4 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Mon, 24 Feb 2020 16:27:45 +0100 Subject: [PATCH] QmlDesigner: Implement usage of qtForMCUs property If qtForMCUs is set in the qmlproject file we disable unsupported properties like roation, transformOrigin or layer. Change-Id: I75d9677beca3d4ce71f975b4f0ae75e63967d143 Reviewed-by: Thomas Hartmann --- .../QtQuick/AdvancedSection.qml | 10 +++++++ .../QtQuick/LayerSection.qml | 1 + .../QtQuick/RectangleSpecifics.qml | 2 ++ .../imports/HelperWidgets/Label.qml | 23 ++++++++++++-- .../imports/HelperWidgets/OriginControl.qml | 6 +++- .../imports/StudioTheme/Values.qml | 1 + .../components/integration/designdocument.cpp | 8 +++++ .../components/integration/designdocument.h | 2 ++ .../propertyeditor/propertyeditorvalue.cpp | 30 +++++++++++++++---- .../propertyeditor/propertyeditorvalue.h | 4 +++ 10 files changed, 78 insertions(+), 9 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml index ab6b17dd12b..276284cfc99 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml @@ -37,14 +37,17 @@ Section { Label { text: qsTr("Origin") + disabledState: !backendValues.transformOrigin.isAvailable } OriginControl { backendValue: backendValues.transformOrigin + enabled: backendValues.transformOrigin.isAvailable } Label { text: qsTr("Scale") + disabledState: !backendValues.scale.isAvailable } SecondColumnLayout { @@ -57,12 +60,14 @@ Section { minimumValue: -10 maximumValue: 10 Layout.preferredWidth: 140 + enabled: backendValues.scale.isAvailable } ExpandingSpacer { } } Label { text: qsTr("Rotation") + disabledState: !backendValues.rotation.isAvailable } SecondColumnLayout { SpinBox { @@ -73,6 +78,7 @@ Section { minimumValue: -360 maximumValue: 360 Layout.preferredWidth: 140 + enabled: backendValues.rotation.isAvailable } ExpandingSpacer { } @@ -110,12 +116,14 @@ Section { Label { visible: majorQtQuickVersion > 1 text: qsTr("Smooth") + disabledState: !backendValues.smooth.isAvailable } SecondColumnLayout { visible: majorQtQuickVersion > 1 CheckBox { backendValue: backendValues.smooth text: qsTr("Smooth sampling active") + enabled: backendValues.smooth.isAvailable } ExpandingSpacer { } @@ -124,12 +132,14 @@ Section { Label { visible: majorQtQuickVersion > 1 text: qsTr("Antialiasing") + disabledState: !backendValues.antialiasing.isAvailable } SecondColumnLayout { visible: majorQtQuickVersion > 1 CheckBox { backendValue: backendValues.antialiasing text: qsTr("Anti-aliasing active") + enabled: backendValues.antialiasing.isAvailable } ExpandingSpacer { } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml index 4db19fe275f..b95312f1484 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml @@ -31,6 +31,7 @@ Section { anchors.left: parent.left anchors.right: parent.right caption: qsTr("Layer") + visible: backendValues.layer_effect.isAvailable SectionLayout { columns: 2 diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RectangleSpecifics.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RectangleSpecifics.qml index 65704972975..0fa2b331a8c 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RectangleSpecifics.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RectangleSpecifics.qml @@ -50,6 +50,7 @@ Column { anchors.left: parent.left anchors.right: parent.right caption: qsTr("Border Color") + visible: backendValues.border_color.isAvailable ColorEditor { caption: qsTr("Border Color") @@ -63,6 +64,7 @@ Column { anchors.left: parent.left anchors.right: parent.right caption: "Rectangle" + visible: backendValues.border_color.isAvailable SectionLayout { rows: 2 diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Label.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Label.qml index 127ffa6ac9d..6a14e7f68cc 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Label.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Label.qml @@ -37,7 +37,8 @@ Label { property alias toolTip: toolTipArea.tooltip width: Math.max(Math.min(240, parent.width - 280), 50) - color: StudioTheme.Values.themeTextColor + color: label.disabledState ? StudioTheme.Values.themeDisabledTextColor : StudioTheme.Values.themeTextColor + elide: Text.ElideRight font.pixelSize: StudioTheme.Values.myFontSize @@ -46,9 +47,27 @@ Label { Layout.minimumWidth: width Layout.maximumWidth: width + leftPadding: label.disabledState ? 10 : 0 + rightPadding: label.disabledState ? 10 : 0 + + property bool disabledState: false + + Text { + text: "[" + color: StudioTheme.Values.themeTextColor//StudioTheme.Values.themeDisabledTextColor + visible: label.disabledState + } + + Text { + text: "]" + color: StudioTheme.Values.themeTextColor//StudioTheme.Values.themeDisabledTextColor// + visible: label.disabledState + x: label.contentWidth + 10 + contentWidth + } + ToolTipArea { id: toolTipArea anchors.fill: parent - tooltip: label.text + tooltip: label.disabledState ? qsTr("This property is not available in this configuration.") : label.text } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml index da2f2cac88d..a6db34f4f16 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml @@ -42,6 +42,8 @@ Item { readonly property color selectedColor: Theme.qmlDesignerBackgroundColorDarkAlternate() readonly property color unselectedColor: Theme.qmlDesignerBackgroundColorDarker() + property bool enabled: true + ExtendedFunctionLogic { id: extFuncLogic backendValue: originControl.backendValue @@ -69,6 +71,7 @@ Item { } Grid { + opacity: originControl.enabled ? 1 : 0.5 rows: 3 columns: 3 spacing: 5 @@ -76,7 +79,8 @@ Item { id: grid function setValue(myValue) { - originControl.backendValue.setEnumeration("Item", myValue) + if (originControl.enabled) + originControl.backendValue.setEnumeration("Item", myValue) } function select(myValue) { diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml index ff10e1e79f5..3f432d40808 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml @@ -84,6 +84,7 @@ QtObject { property string themeControlBackground: "#242424" property string themeControlOutline: "#404040" property string themeTextColor: "#ffffff" + property string themeDisabledTextColor: "#909090" property string themePanelBackground: "#2a2a2a" property string themeHoverHighlight: "#313131" diff --git a/src/plugins/qmldesigner/components/integration/designdocument.cpp b/src/plugins/qmldesigner/components/integration/designdocument.cpp index 9d3809727ed..75b45fedb86 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocument.cpp @@ -269,6 +269,14 @@ void DesignDocument::changeToDocumentModel() viewManager().attachViewsExceptRewriterAndComponetView(); } +bool DesignDocument::isQtForMCUsProject() const +{ + if (m_currentTarget) + return m_currentTarget->additionalData("CustomQtForMCUs").toBool(); + + return true; +} + void DesignDocument::changeToInFileComponentModel(ComponentTextModifier *textModifer) { m_inFileComponentTextModifier.reset(textModifer); diff --git a/src/plugins/qmldesigner/components/integration/designdocument.h b/src/plugins/qmldesigner/components/integration/designdocument.h index 7e8509eb4d4..60a0f3f11a1 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.h +++ b/src/plugins/qmldesigner/components/integration/designdocument.h @@ -97,6 +97,8 @@ public: void changeToDocumentModel(); + bool isQtForMCUsProject() const; + signals: void displayNameChanged(const QString &newFileName); void dirtyStateChanged(bool newState); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index b1efd1af0e2..3ec61f9cabb 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -25,16 +25,18 @@ #include "propertyeditorvalue.h" +#include #include +#include +#include +#include +#include +#include + +#include #include #include -#include -#include -#include -#include -#include -#include //using namespace QmlDesigner; @@ -261,6 +263,22 @@ bool PropertyEditorValue::isTranslated() const return false; } +bool PropertyEditorValue::isAvailable() const +{ + const QList mcuProperties = {"layer", "opacity", "rotation", "scale", "transformOrigin", "smooth", "antialiasing", "border"}; + const QList list = name().split('.'); + const QByteArray pureName = list.first(); + + QmlDesigner::DesignDocument *designDocument = + QmlDesigner::QmlDesignerPlugin::instance()->documentManager().currentDesignDocument(); + + + if (designDocument && designDocument->isQtForMCUsProject()) + return !mcuProperties.contains(pureName); + + return true; +} + QmlDesigner::ModelNode PropertyEditorValue::modelNode() const { return m_modelNode; diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h index a69bca8a739..52de9cbb707 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h @@ -89,6 +89,8 @@ class PropertyEditorValue : public QObject Q_PROPERTY(QString name READ nameAsQString FINAL) Q_PROPERTY(PropertyEditorNodeWrapper* complexNode READ complexNode NOTIFY complexNodeChanged FINAL) + Q_PROPERTY(bool isAvailable READ isAvailable NOTIFY isBoundChanged) + public: PropertyEditorValue(QObject *parent=nullptr); @@ -115,6 +117,8 @@ public: bool isTranslated() const; + bool isAvailable() const; + QmlDesigner::PropertyName name() const; QString nameAsQString() const; void setName(const QmlDesigner::PropertyName &name);