forked from qt-creator/qt-creator
QmlDesigner Binding Editor UX improvement
Binding Editor now shows which property type it expects. Binding Editor now works with alias and unknown types. Change-Id: I23d0bed3db5126de5107cf2f1f6b46485b89e1ea Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -102,9 +102,16 @@ void BindingEditor::setBackendValue(const QVariant &backendValue)
|
|||||||
m_backendValue = backendValue;
|
m_backendValue = backendValue;
|
||||||
const QObject *backendValueObj = backendValue.value<QObject*>();
|
const QObject *backendValueObj = backendValue.value<QObject*>();
|
||||||
const PropertyEditorValue *propertyEditorValue = qobject_cast<const PropertyEditorValue *>(backendValueObj);
|
const PropertyEditorValue *propertyEditorValue = qobject_cast<const PropertyEditorValue *>(backendValueObj);
|
||||||
|
const ModelNode node = propertyEditorValue->modelNode();
|
||||||
|
|
||||||
m_backendValueTypeName = propertyEditorValue->modelNode().metaInfo().propertyTypeName(
|
if (node.isValid())
|
||||||
propertyEditorValue->name());
|
{
|
||||||
|
m_backendValueTypeName = node.metaInfo().propertyTypeName(propertyEditorValue->name());
|
||||||
|
|
||||||
|
if (m_backendValueTypeName == "alias" || m_backendValueTypeName == "unknown")
|
||||||
|
if (QmlObjectNode::isValidQmlObjectNode(node))
|
||||||
|
m_backendValueTypeName = QmlObjectNode(node).instanceType(propertyEditorValue->name());
|
||||||
|
}
|
||||||
|
|
||||||
emit backendValueChanged();
|
emit backendValueChanged();
|
||||||
}
|
}
|
||||||
@@ -154,8 +161,16 @@ void BindingEditor::prepareBindings()
|
|||||||
for (auto objnode : allNodes) {
|
for (auto objnode : allNodes) {
|
||||||
BindingEditorDialog::BindingOption binding;
|
BindingEditorDialog::BindingOption binding;
|
||||||
for (auto propertyName : objnode.metaInfo().propertyNames())
|
for (auto propertyName : objnode.metaInfo().propertyNames())
|
||||||
if (m_backendValueTypeName == objnode.metaInfo().propertyTypeName(propertyName))
|
{
|
||||||
|
TypeName propertyTypeName = objnode.metaInfo().propertyTypeName(propertyName);
|
||||||
|
|
||||||
|
if ((propertyTypeName == "alias" || propertyTypeName == "unknown"))
|
||||||
|
if (QmlObjectNode::isValidQmlObjectNode(objnode))
|
||||||
|
propertyTypeName = QmlObjectNode(objnode).instanceType(propertyName);
|
||||||
|
|
||||||
|
if (m_backendValueTypeName == propertyTypeName)
|
||||||
binding.properties.append(QString::fromUtf8(propertyName));
|
binding.properties.append(QString::fromUtf8(propertyName));
|
||||||
|
}
|
||||||
|
|
||||||
if (!binding.properties.isEmpty() && objnode.hasId()) {
|
if (!binding.properties.isEmpty() && objnode.hasId()) {
|
||||||
binding.item = objnode.displayName();
|
binding.item = objnode.displayName();
|
||||||
@@ -165,6 +180,16 @@ void BindingEditor::prepareBindings()
|
|||||||
|
|
||||||
if (!bindings.isEmpty() && !m_dialog.isNull())
|
if (!bindings.isEmpty() && !m_dialog.isNull())
|
||||||
m_dialog->setAllBindings(bindings);
|
m_dialog->setAllBindings(bindings);
|
||||||
|
|
||||||
|
updateWindowName();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BindingEditor::updateWindowName()
|
||||||
|
{
|
||||||
|
if (!m_dialog.isNull() && !m_backendValueTypeName.isEmpty())
|
||||||
|
{
|
||||||
|
m_dialog->setWindowTitle(m_dialog->defaultTitle() + " [" + m_backendValueTypeName + "]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant BindingEditor::backendValue() const
|
QVariant BindingEditor::backendValue() const
|
||||||
|
@@ -62,6 +62,7 @@ public:
|
|||||||
void setStateModelNode(const QVariant &stateModelNode);
|
void setStateModelNode(const QVariant &stateModelNode);
|
||||||
|
|
||||||
Q_INVOKABLE void prepareBindings();
|
Q_INVOKABLE void prepareBindings();
|
||||||
|
Q_INVOKABLE void updateWindowName();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void accepted();
|
void accepted();
|
||||||
|
@@ -45,7 +45,7 @@ BindingEditorDialog::BindingEditorDialog(QWidget *parent)
|
|||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
setWindowTitle(tr("Binding Editor"));
|
setWindowTitle(defaultTitle());
|
||||||
setModal(false);
|
setModal(false);
|
||||||
|
|
||||||
setupJSEditor();
|
setupJSEditor();
|
||||||
@@ -153,6 +153,11 @@ void BindingEditorDialog::unregisterAutoCompletion()
|
|||||||
m_editorWidget->unregisterAutoCompletion();
|
m_editorWidget->unregisterAutoCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString BindingEditorDialog::defaultTitle() const
|
||||||
|
{
|
||||||
|
return titleString;
|
||||||
|
}
|
||||||
|
|
||||||
void BindingEditorDialog::setupJSEditor()
|
void BindingEditorDialog::setupJSEditor()
|
||||||
{
|
{
|
||||||
static BindingEditorFactory f;
|
static BindingEditorFactory f;
|
||||||
|
@@ -71,6 +71,8 @@ public:
|
|||||||
|
|
||||||
void unregisterAutoCompletion();
|
void unregisterAutoCompletion();
|
||||||
|
|
||||||
|
QString defaultTitle() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupJSEditor();
|
void setupJSEditor();
|
||||||
void setupUIComponents();
|
void setupUIComponents();
|
||||||
@@ -92,6 +94,7 @@ private:
|
|||||||
QList<BindingEditorDialog::BindingOption> m_bindings;
|
QList<BindingEditorDialog::BindingOption> m_bindings;
|
||||||
bool m_lock = false;
|
bool m_lock = false;
|
||||||
const QString undefinedString = {"[Undefined]"};
|
const QString undefinedString = {"[Undefined]"};
|
||||||
|
const QString titleString = {tr("Binding Editor")};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user