forked from qt-creator/qt-creator
QmlDesigner: Fix material manager
Task-number: QDS-1332 Change-Id: I70828c3ce584ab72115f92dda4a27341e00085e2 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
3094d5b3ae
commit
88bbd748dd
@@ -55,8 +55,6 @@ Rectangle {
|
||||
border.color: StudioTheme.Values.themeControlOutline
|
||||
border.width: StudioTheme.Values.border
|
||||
|
||||
property int numVisibleItems: myRepeater.count
|
||||
|
||||
Layout.preferredWidth: StudioTheme.Values.height * 10
|
||||
Layout.preferredHeight: myColumn.height
|
||||
|
||||
@@ -158,6 +156,13 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: dummyItem
|
||||
visible: myRepeater.count === 0
|
||||
width: StudioTheme.Values.height
|
||||
height: StudioTheme.Values.height
|
||||
}
|
||||
|
||||
Row {
|
||||
id: row
|
||||
spacing: -StudioTheme.Values.border
|
||||
@@ -175,7 +180,7 @@ Rectangle {
|
||||
StudioControls.AbstractButton {
|
||||
buttonIcon: "+"
|
||||
iconFont: StudioTheme.Constants.font
|
||||
enabled: !myRepeater.dirty
|
||||
enabled: !myRepeater.dirty && !(editableListView.backendValue.isInModel && !editableListView.backendValue.isIdList)
|
||||
onClicked: {
|
||||
var idx = myRepeater.localModel.push("") - 1
|
||||
myRepeater.model = myRepeater.localModel // trigger on change handler
|
||||
@@ -187,7 +192,7 @@ Rectangle {
|
||||
StudioControls.AbstractButton {
|
||||
buttonIcon: "-"
|
||||
iconFont: StudioTheme.Constants.font
|
||||
enabled: myRepeater.model.length
|
||||
enabled: myRepeater.model.length && !(editableListView.backendValue.isInModel && !editableListView.backendValue.isIdList)
|
||||
onClicked: {
|
||||
var lastItem = myColumn.currentIndex === myRepeater.localModel.length - 1
|
||||
if (myColumn.currentItem.initialModelData === "") {
|
||||
|
@@ -375,7 +375,9 @@ QStringList PropertyEditorValue::getExpressionAsList() const
|
||||
|
||||
bool PropertyEditorValue::idListAdd(const QString &value)
|
||||
{
|
||||
QTC_ASSERT(isIdList(), return false);
|
||||
const QmlDesigner::QmlObjectNode objectNode(modelNode());
|
||||
if (!isIdList() && (objectNode.isValid() && objectNode.hasProperty(name())))
|
||||
return false;
|
||||
|
||||
static const QRegExp rx("^[a-z_]\\w*|^[A-Z]\\w*\\.{1}([a-z_]\\w*\\.?)+");
|
||||
if (!rx.exactMatch(value))
|
||||
@@ -393,7 +395,6 @@ bool PropertyEditorValue::idListRemove(int idx)
|
||||
QTC_ASSERT(isIdList(), return false);
|
||||
|
||||
auto stringList = generateStringList(expression());
|
||||
|
||||
if (idx < 0 || idx >= stringList.size())
|
||||
return false;
|
||||
|
||||
@@ -438,6 +439,8 @@ QString PropertyEditorValue::generateString(const QStringList &stringList) const
|
||||
{
|
||||
if (stringList.size() > 1)
|
||||
return "[" + stringList.join(",") + "]";
|
||||
else if (stringList.isEmpty())
|
||||
return QString();
|
||||
else
|
||||
return stringList.first();
|
||||
}
|
||||
|
@@ -83,6 +83,7 @@ class PropertyEditorValue : public QObject
|
||||
Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged FINAL)
|
||||
Q_PROPERTY(bool isTranslated READ isTranslated NOTIFY expressionChanged FINAL)
|
||||
|
||||
Q_PROPERTY(bool isIdList READ isIdList NOTIFY expressionChanged FINAL)
|
||||
Q_PROPERTY(QStringList expressionAsList READ getExpressionAsList NOTIFY expressionChanged FINAL)
|
||||
|
||||
Q_PROPERTY(QString name READ nameAsQString FINAL)
|
||||
|
@@ -280,8 +280,10 @@ void PropertyEditorView::changeExpression(const QString &propertyName)
|
||||
}
|
||||
}
|
||||
|
||||
if (value->expression().isEmpty())
|
||||
if (value->expression().isEmpty()) {
|
||||
value->resetValue();
|
||||
return;
|
||||
}
|
||||
|
||||
if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name))
|
||||
qmlObjectNode.setBindingProperty(name, value->expression());
|
||||
|
Reference in New Issue
Block a user