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 <thomas.hartmann@qt.io>
This commit is contained in:
Thomas Hartmann
2020-02-24 16:27:45 +01:00
parent ea7457410b
commit 620e17cf7b
10 changed files with 78 additions and 9 deletions

View File

@@ -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 {
}

View File

@@ -31,6 +31,7 @@ Section {
anchors.left: parent.left
anchors.right: parent.right
caption: qsTr("Layer")
visible: backendValues.layer_effect.isAvailable
SectionLayout {
columns: 2

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -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) {

View File

@@ -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"

View File

@@ -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);

View File

@@ -97,6 +97,8 @@ public:
void changeToDocumentModel();
bool isQtForMCUsProject() const;
signals:
void displayNameChanged(const QString &newFileName);
void dirtyStateChanged(bool newState);

View File

@@ -25,16 +25,18 @@
#include "propertyeditorvalue.h"
#include <abstractview.h>
#include <bindingproperty.h>
#include <designdocument.h>
#include <nodeproperty.h>
#include <nodemetainfo.h>
#include <qmldesignerplugin.h>
#include <qmlobjectnode.h>
#include <utils/qtcassert.h>
#include <QRegExp>
#include <QUrl>
#include <abstractview.h>
#include <nodeproperty.h>
#include <nodemetainfo.h>
#include <qmlobjectnode.h>
#include <bindingproperty.h>
#include <utils/qtcassert.h>
//using namespace QmlDesigner;
@@ -261,6 +263,22 @@ bool PropertyEditorValue::isTranslated() const
return false;
}
bool PropertyEditorValue::isAvailable() const
{
const QList<QByteArray> mcuProperties = {"layer", "opacity", "rotation", "scale", "transformOrigin", "smooth", "antialiasing", "border"};
const QList<QByteArray> 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;

View File

@@ -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);