forked from qt-creator/qt-creator
QmlDesigner: Expose dynamic texture and vector properties in components
Provide editor templates for Texture, TextureInput, and vectorXd type dynamic properties exposed by components. Change-Id: Ie7ae62aeffc5e151a1300b3aefdfc68584ccda6a Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
PropertyLabel {
|
||||||
|
text: "%1"
|
||||||
|
tooltip: "%1"
|
||||||
|
}
|
||||||
|
|
||||||
|
SecondColumnLayout {
|
||||||
|
ItemFilterComboBox {
|
||||||
|
typeFilter: "QtQuick3D.%3"
|
||||||
|
validator: RegExpValidator { regExp: /(^$|^[a-z_]\w*)/ }
|
||||||
|
backendValue: backendValues.%2
|
||||||
|
implicitWidth: StudioTheme.Values.singleControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
width: implicitWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpandingSpacer {}
|
||||||
|
}
|
@@ -78,4 +78,25 @@ AutoTypes {
|
|||||||
sourceFile: "ImageEditorTemplate.template"
|
sourceFile: "ImageEditorTemplate.template"
|
||||||
separateSection: true
|
separateSection: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Type {
|
||||||
|
typeNames: ["TextureInput", "Texture"]
|
||||||
|
sourceFile: "3DItemFilterComboBoxEditorTemplate.template"
|
||||||
|
needsTypeArg: true
|
||||||
|
}
|
||||||
|
|
||||||
|
Type {
|
||||||
|
typeNames: ["vector2d"]
|
||||||
|
sourceFile: "Vector2dEditorTemplate.template"
|
||||||
|
}
|
||||||
|
|
||||||
|
Type {
|
||||||
|
typeNames: ["vector3d"]
|
||||||
|
sourceFile: "Vector3dEditorTemplate.template"
|
||||||
|
}
|
||||||
|
|
||||||
|
Type {
|
||||||
|
typeNames: ["vector4d"]
|
||||||
|
sourceFile: "Vector4dEditorTemplate.template"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,42 @@
|
|||||||
|
PropertyLabel {
|
||||||
|
text: "%1"
|
||||||
|
tooltip: "%1"
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
SecondColumnLayout {
|
||||||
|
SpinBox {
|
||||||
|
minimumValue: -9999999
|
||||||
|
maximumValue: 9999999
|
||||||
|
decimals: 2
|
||||||
|
backendValue: backendValues.%2_x
|
||||||
|
implicitWidth: StudioTheme.Values.twoControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
|
||||||
|
|
||||||
|
ControlLabel {
|
||||||
|
text: "X"
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlGap }
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
minimumValue: -9999999
|
||||||
|
maximumValue: 9999999
|
||||||
|
decimals: 2
|
||||||
|
backendValue: backendValues.%2_y
|
||||||
|
implicitWidth: StudioTheme.Values.twoControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
|
||||||
|
|
||||||
|
ControlLabel {
|
||||||
|
text: "Y"
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpandingSpacer {}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,61 @@
|
|||||||
|
PropertyLabel {
|
||||||
|
text: "%1"
|
||||||
|
tooltip: "%1"
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
SecondColumnLayout {
|
||||||
|
SpinBox {
|
||||||
|
minimumValue: -9999999
|
||||||
|
maximumValue: 9999999
|
||||||
|
decimals: 2
|
||||||
|
backendValue: backendValues.%2_x
|
||||||
|
implicitWidth: StudioTheme.Values.twoControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
|
||||||
|
|
||||||
|
ControlLabel {
|
||||||
|
text: "X"
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlGap }
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
minimumValue: -9999999
|
||||||
|
maximumValue: 9999999
|
||||||
|
decimals: 2
|
||||||
|
backendValue: backendValues.%2_y
|
||||||
|
implicitWidth: StudioTheme.Values.twoControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
|
||||||
|
|
||||||
|
ControlLabel {
|
||||||
|
text: "Y"
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpandingSpacer {}
|
||||||
|
}
|
||||||
|
|
||||||
|
SecondColumnLayout {
|
||||||
|
SpinBox {
|
||||||
|
minimumValue: -9999999
|
||||||
|
maximumValue: 9999999
|
||||||
|
decimals: 2
|
||||||
|
backendValue: backendValues.%2_z
|
||||||
|
implicitWidth: StudioTheme.Values.twoControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
|
||||||
|
|
||||||
|
ControlLabel {
|
||||||
|
text: "Z"
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpandingSpacer {}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,78 @@
|
|||||||
|
PropertyLabel {
|
||||||
|
text: "%1"
|
||||||
|
tooltip: "%1"
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
SecondColumnLayout {
|
||||||
|
SpinBox {
|
||||||
|
minimumValue: -9999999
|
||||||
|
maximumValue: 9999999
|
||||||
|
decimals: 2
|
||||||
|
backendValue: backendValues.%2_x
|
||||||
|
implicitWidth: StudioTheme.Values.twoControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
|
||||||
|
|
||||||
|
ControlLabel {
|
||||||
|
text: "X"
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlGap }
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
minimumValue: -9999999
|
||||||
|
maximumValue: 9999999
|
||||||
|
decimals: 2
|
||||||
|
backendValue: backendValues.%2_y
|
||||||
|
implicitWidth: StudioTheme.Values.twoControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
|
||||||
|
|
||||||
|
ControlLabel {
|
||||||
|
text: "Y"
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpandingSpacer {}
|
||||||
|
}
|
||||||
|
|
||||||
|
SecondColumnLayout {
|
||||||
|
SpinBox {
|
||||||
|
minimumValue: -9999999
|
||||||
|
maximumValue: 9999999
|
||||||
|
decimals: 2
|
||||||
|
backendValue: backendValues.%2_z
|
||||||
|
implicitWidth: StudioTheme.Values.twoControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
|
||||||
|
|
||||||
|
ControlLabel {
|
||||||
|
text: "Z"
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlGap }
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
minimumValue: -9999999
|
||||||
|
maximumValue: 9999999
|
||||||
|
decimals: 2
|
||||||
|
backendValue: backendValues.%2_w
|
||||||
|
implicitWidth: StudioTheme.Values.twoControlColumnWidth
|
||||||
|
+ StudioTheme.Values.actionIndicatorWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
|
||||||
|
|
||||||
|
ControlLabel {
|
||||||
|
text: "W"
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpandingSpacer {}
|
||||||
|
}
|
||||||
|
}
|
@@ -586,7 +586,7 @@ inline bool dotPropertyHeuristic(const QmlObjectNode &node, const NodeMetaInfo &
|
|||||||
NodeMetaInfo rectangleInfo = node.view()->model()->metaInfo("QtQuick.Rectangle");
|
NodeMetaInfo rectangleInfo = node.view()->model()->metaInfo("QtQuick.Rectangle");
|
||||||
NodeMetaInfo imageInfo = node.view()->model()->metaInfo("QtQuick.Image");
|
NodeMetaInfo imageInfo = node.view()->model()->metaInfo("QtQuick.Image");
|
||||||
|
|
||||||
if (typeName == "font"
|
if (typeName == "font" || typeName == "Texture" || typeName == "vector4d"
|
||||||
|| itemInfo.hasProperty(itemProperty)
|
|| itemInfo.hasProperty(itemProperty)
|
||||||
|| textInfo.isSubclassOf(typeName)
|
|| textInfo.isSubclassOf(typeName)
|
||||||
|| rectangleInfo.isSubclassOf(typeName)
|
|| rectangleInfo.isSubclassOf(typeName)
|
||||||
@@ -607,10 +607,13 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
|
|||||||
|
|
||||||
QStringList allTypes; // all template types
|
QStringList allTypes; // all template types
|
||||||
QStringList separateSectionTypes; // separate section types only
|
QStringList separateSectionTypes; // separate section types only
|
||||||
|
QStringList needsTypeArgTypes; // types that need type as third parameter
|
||||||
|
|
||||||
for (const QmlJS::SimpleReaderNode::Ptr &node : nodes) {
|
for (const QmlJS::SimpleReaderNode::Ptr &node : nodes) {
|
||||||
if (node->propertyNames().contains("separateSection"))
|
if (node->propertyNames().contains("separateSection"))
|
||||||
separateSectionTypes.append(variantToStringList(node->property("typeNames").value));
|
separateSectionTypes.append(variantToStringList(node->property("typeNames").value));
|
||||||
|
if (node->propertyNames().contains("needsTypeArg"))
|
||||||
|
needsTypeArgTypes.append(variantToStringList(node->property("typeNames").value));
|
||||||
|
|
||||||
allTypes.append(variantToStringList(node->property("typeNames").value));
|
allTypes.append(variantToStringList(node->property("typeNames").value));
|
||||||
}
|
}
|
||||||
@@ -668,8 +671,8 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
|
|||||||
|
|
||||||
Utils::sort(basicProperties);
|
Utils::sort(basicProperties);
|
||||||
|
|
||||||
auto findAndFillTemplate = [&nodes, &node, &type](const PropertyName &label,
|
auto findAndFillTemplate = [&nodes, &node, &type, &needsTypeArgTypes](
|
||||||
const PropertyName &property) {
|
const PropertyName &label, const PropertyName &property) {
|
||||||
PropertyName underscoreProperty = property;
|
PropertyName underscoreProperty = property;
|
||||||
underscoreProperty.replace('.', '_');
|
underscoreProperty.replace('.', '_');
|
||||||
|
|
||||||
@@ -687,7 +690,14 @@ QString PropertyEditorQmlBackend::templateGeneration(const NodeMetaInfo &type,
|
|||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
QString source = QString::fromUtf8(file.readAll());
|
QString source = QString::fromUtf8(file.readAll());
|
||||||
file.close();
|
file.close();
|
||||||
filledTemplate = source.arg(QString::fromUtf8(label)).arg(QString::fromUtf8(underscoreProperty));
|
if (needsTypeArgTypes.contains(QString::fromUtf8(typeName))) {
|
||||||
|
filledTemplate = source.arg(QString::fromUtf8(label),
|
||||||
|
QString::fromUtf8(underscoreProperty),
|
||||||
|
QString::fromUtf8(typeName));
|
||||||
|
} else {
|
||||||
|
filledTemplate = source.arg(QString::fromUtf8(label),
|
||||||
|
QString::fromUtf8(underscoreProperty));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qWarning().nospace() << "template definition source file not found:" << fileName;
|
qWarning().nospace() << "template definition source file not found:" << fileName;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user