diff --git a/src/plugins/qmldesigner/componentsplugin/components.metainfo b/src/plugins/qmldesigner/componentsplugin/components.metainfo index af484dda6b3e73730b9a716b981477a8d642d7bd..cbd5a5835b2580c13881003395d7f050158802e9 100644 --- a/src/plugins/qmldesigner/componentsplugin/components.metainfo +++ b/src/plugins/qmldesigner/componentsplugin/components.metainfo @@ -11,7 +11,7 @@ MetaInfo { version: "1.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "QString"; value: "Button"; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Button\")"; } } } @@ -39,7 +39,7 @@ MetaInfo { version: "1.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "QString"; value: "Check Box"; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Check Box\")"; } } } @@ -54,7 +54,7 @@ MetaInfo { version: "1.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "QString"; value: "Radio Button"; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Radio Button\")"; } } } @@ -108,7 +108,7 @@ MetaInfo { version: "1.0" requiredImport: "QtQuick.Controls" - Property { name: "text"; type: "QString"; value: "Label"; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Label\")"; } } } @@ -123,7 +123,7 @@ MetaInfo { version: "1.0" requiredImport: "QtQuick.Controls" - Property { name: "placeholderText"; type: "QString"; value: "Text Field"; } + Property { name: "placeholderText"; type: "binding"; value: "qsTr(\"Text Field\")"; } } } diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp index 2c883dbcb7a1fc168f9cf94712ff75fb18e14257..32ae0d815945649a62eb297c898d154c1dd5b0fa 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp @@ -32,6 +32,7 @@ #include "qmlchangeset.h" #include "nodelistproperty.h" #include "variantproperty.h" +#include "bindingproperty.h" #include "qmlanchors.h" #include "invalidmodelnodeexception.h" #include "itemlibraryinfo.h" @@ -134,13 +135,20 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary } } + typedef QPair<PropertyName, QString> PropertyBindingEntry; + QList<PropertyBindingEntry> propertyBindingList; if (itemLibraryEntry.qmlSource().isEmpty()) { QList<QPair<PropertyName, QVariant> > propertyPairList; propertyPairList.append(qMakePair(PropertyName("x"), QVariant(qRound(position.x())))); propertyPairList.append(qMakePair(PropertyName("y"), QVariant(qRound(position.y())))); - foreach (const PropertyContainer &property, itemLibraryEntry.properties()) - propertyPairList.append(qMakePair(property.name(), property.value())); + foreach (const PropertyContainer &property, itemLibraryEntry.properties()) { + if (property.type() == QLatin1String("binding")) { + propertyBindingList.append(PropertyBindingEntry(property.name(), property.value().toString())); + } else { + propertyPairList.append(qMakePair(property.name(), property.value())); + } + } newQmlItemNode = QmlItemNode(view->createModelNode(itemLibraryEntry.typeName(), majorVersion, minorVersion, propertyPairList)); } else { @@ -160,6 +168,9 @@ QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibrary newQmlItemNode.setVariantProperty("opacity", 1); } + foreach (const PropertyBindingEntry &propertyBindingEntry, propertyBindingList) + newQmlItemNode.modelNode().bindingProperty(propertyBindingEntry.first).setExpression(propertyBindingEntry.second); + Q_ASSERT(newQmlItemNode.isValid()); } catch (RewritingException &e) { diff --git a/src/plugins/qmldesigner/qtquickplugin/quick.metainfo b/src/plugins/qmldesigner/qtquickplugin/quick.metainfo index 31a1b97a3d3fc7abb62b0c72b5730f056619882d..bd8a6b2dc184cad90d547e6d3fa9f346c74ab981 100644 --- a/src/plugins/qmldesigner/qtquickplugin/quick.metainfo +++ b/src/plugins/qmldesigner/qtquickplugin/quick.metainfo @@ -63,7 +63,8 @@ MetaInfo { libraryIcon: ":/qtquickplugin/images/text-icon.png" version: "1.0" - QmlSource { source: ":/qtquickplugin/source/text.qml" } + Property { name: "font.pixelSize"; type: "int"; value: 12; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text\")"; } } ItemLibraryEntry { @@ -72,7 +73,8 @@ MetaInfo { libraryIcon: ":/qtquickplugin/images/text-icon.png" version: "2.0" - QmlSource { source: ":/qtquickplugin/source/textv2.qml" } + Property { name: "font.pixelSize"; type: "int"; value: 12; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text\")"; } } } @@ -86,7 +88,11 @@ MetaInfo { libraryIcon: ":/qtquickplugin/images/text-edit-icon.png" version: "1.0" - QmlSource { source: ":/qtquickplugin/source/textedit.qml" } + Property { name: "width"; type: "int"; value: 80; } + Property { name: "height"; type: "int"; value: 20; } + Property { name: "font.pixelSize"; type: "int"; value: 12; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text Edit\")"; } + } ItemLibraryEntry { @@ -95,7 +101,10 @@ MetaInfo { libraryIcon: ":/qtquickplugin/images/text-edit-icon.png" version: "2.0" - QmlSource { source: ":/qtquickplugin/source/texteditv2.qml" } + Property { name: "width"; type: "int"; value: 80; } + Property { name: "height"; type: "int"; value: 20; } + Property { name: "font.pixelSize"; type: "int"; value: 12; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text Edit\")"; } } } @@ -109,7 +118,10 @@ MetaInfo { libraryIcon: ":/qtquickplugin/images/text-edit-icon.png" version: "1.0" - QmlSource { source: ":/qtquickplugin/source/textinput.qml" } + Property { name: "width"; type: "int"; value: 80; } + Property { name: "height"; type: "int"; value: 20; } + Property { name: "font.pixelSize"; type: "int"; value: 12; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text Input\")"; } } ItemLibraryEntry { @@ -118,7 +130,10 @@ MetaInfo { libraryIcon: ":/qtquickplugin/images/text-input-icon.png" version: "2.0" - QmlSource { source: ":/qtquickplugin/source/textinput.qml" } + Property { name: "width"; type: "int"; value: 80; } + Property { name: "height"; type: "int"; value: 20; } + Property { name: "font.pixelSize"; type: "int"; value: 12; } + Property { name: "text"; type: "binding"; value: "qsTr(\"Text Input\")"; } } }