diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ExtendedFunctionLogic.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ExtendedFunctionLogic.qml index 4dc3bb1a672..e8d50b64ea6 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ExtendedFunctionLogic.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ExtendedFunctionLogic.qml @@ -154,9 +154,7 @@ Item { id: bindingEditorParent Component.onCompleted: { - var x = extendedFunctionButton.mapToGlobal(0,0).x - 200 - var y = extendedFunctionButton.mapToGlobal(0,0).y - 40 - bindingEditor.showWidget(x, y) + bindingEditor.showWidget() bindingEditor.text = backendValue.expression bindingEditor.prepareBindings() } diff --git a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml b/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml index 0e94897d5a6..e6e5be75239 100644 --- a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml +++ b/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml @@ -117,9 +117,7 @@ Rectangle { visible: !isBaseState text: qsTr("Set when Condition") onTriggered: { - var x = whenButton.mapToGlobal(0,0).x + 4 - var y = root.mapToGlobal(0,0).y - 32 - bindingEditor.showWidget(x, y) + bindingEditor.showWidget() bindingEditor.text = delegateWhenConditionString bindingEditor.prepareBindings() } diff --git a/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.cpp b/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.cpp index 82947e8c981..c1c1419d2db 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.cpp +++ b/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.cpp @@ -56,7 +56,7 @@ void BindingEditor::registerDeclarativeType() qmlRegisterType("HelperWidgets", 2, 0, "BindingEditor"); } -void BindingEditor::showWidget(int x, int y) +void BindingEditor::prepareDialog() { if (s_lastBindingEditor) s_lastBindingEditor->hideWidget(); @@ -71,6 +71,17 @@ void BindingEditor::showWidget(int x, int y) this, &BindingEditor::rejected); m_dialog->setAttribute(Qt::WA_DeleteOnClose); +} + +void BindingEditor::showWidget() +{ + prepareDialog(); + m_dialog->showWidget(); +} + +void BindingEditor::showWidget(int x, int y) +{ + prepareDialog(); m_dialog->showWidget(x, y); } diff --git a/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.h b/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.h index 8f9a77baec1..790f6995c12 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.h +++ b/src/plugins/qmldesigner/components/bindingeditor/bindingeditor.h @@ -51,6 +51,7 @@ public: static void registerDeclarativeType(); + Q_INVOKABLE void showWidget(); Q_INVOKABLE void showWidget(int x, int y); Q_INVOKABLE void hideWidget(); @@ -75,6 +76,7 @@ private: QVariant backendValue() const; QVariant modelNodeBackend() const; QVariant stateModelNode() const; + void prepareDialog(); private: QPointer m_dialog; diff --git a/src/plugins/qmldesigner/components/bindingeditor/bindingeditordialog.cpp b/src/plugins/qmldesigner/components/bindingeditor/bindingeditordialog.cpp index 3e6d8389903..1967ded0ca3 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/bindingeditordialog.cpp +++ b/src/plugins/qmldesigner/components/bindingeditor/bindingeditordialog.cpp @@ -79,14 +79,19 @@ BindingEditorDialog::~BindingEditorDialog() delete m_verticalLayout; } -void BindingEditorDialog::showWidget(int x, int y) +void BindingEditorDialog::showWidget() { this->show(); this->raise(); - move(QPoint(x, y)); m_editorWidget->setFocus(); } +void BindingEditorDialog::showWidget(int x, int y) +{ + showWidget(); + move(QPoint(x, y)); +} + QString BindingEditorDialog::editorValue() const { if (!m_editorWidget) diff --git a/src/plugins/qmldesigner/components/bindingeditor/bindingeditordialog.h b/src/plugins/qmldesigner/components/bindingeditor/bindingeditordialog.h index 7255d528e69..fdcdca07624 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/bindingeditordialog.h +++ b/src/plugins/qmldesigner/components/bindingeditor/bindingeditordialog.h @@ -67,6 +67,7 @@ public: BindingEditorDialog(QWidget *parent = nullptr, DialogType type = DialogType::BindingDialog); ~BindingEditorDialog() override; + void showWidget(); void showWidget(int x, int y); QString editorValue() const;