diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2023-03-28 15:49:22 +0300 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2023-03-30 07:31:24 +0000 |
commit | 0b79db5c17a5ea5b5c54973eaf3d3d7433f24235 (patch) | |
tree | a5089dfe8834f656947eec1e9f12e7cf13afb09d /src/plugins/qmldesigner | |
parent | 0d73fae2126567fb39e123ed69190e96ca4f9ff4 (diff) | |
download | qt-creator-0b79db5c17a5ea5b5c54973eaf3d3d7433f24235.tar.gz |
QmlDesigner: Close section's context-menu on view focus out
When clicking outside any view that has sections and a section's
context-menu is visible, it is now closed.
Fixes: QDS-9564
Change-Id: I73cd3a9754c5a18360427525a2a943c2c549e83f
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner')
4 files changed, 23 insertions, 9 deletions
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp index 8a1b8c28d7..909530dbc3 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp @@ -380,7 +380,7 @@ PropertyEditorContextObject* PropertyEditorQmlBackend::contextObject() { return m_contextObject.data(); } -QWidget *PropertyEditorQmlBackend::widget() { +QQuickWidget *PropertyEditorQmlBackend::widget() { return m_view; } diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h index d1fa601878..092d411dfa 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h @@ -39,7 +39,7 @@ public: QQmlContext *context(); PropertyEditorContextObject* contextObject(); - QWidget *widget(); + QQuickWidget *widget(); void setSource(const QUrl& url); Internal::QmlAnchorBindingProxy &backendAnchorBinding(); DesignerPropertyMap &backendValuesPropertyMap(); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp index ff97e22fdb..5dff76453a 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp @@ -6,6 +6,7 @@ #include "propertyeditorqmlbackend.h" #include "propertyeditortransaction.h" #include "propertyeditorvalue.h" +#include "propertyeditorwidget.h" #include <auxiliarydataproperties.h> #include <nodemetainfo.h> @@ -33,6 +34,7 @@ #include <QFileSystemWatcher> #include <QFileInfo> #include <QDebug> +#include <QQuickItem> #include <QTimer> #include <QShortcut> #include <QApplication> @@ -501,6 +503,7 @@ void PropertyEditorView::setupQmlBackend() currentQmlBackend->contextObject()->setSpecificQmlData(specificQmlData); } + currentQmlBackend->widget()->installEventFilter(this); m_stackedWidget->setCurrentWidget(currentQmlBackend->widget()); currentQmlBackend->contextObject()->triggerSelectionChanged(); @@ -898,6 +901,15 @@ void PropertyEditorView::setValue(const QmlObjectNode &qmlObjectNode, m_locked = false; } +bool PropertyEditorView::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::FocusOut) { + if (m_qmlBackEndForCurrentType && m_qmlBackEndForCurrentType->widget() == obj) + QMetaObject::invokeMethod(m_qmlBackEndForCurrentType->widget()->rootObject(), "closeContextMenu"); + } + return AbstractView::eventFilter(obj, event); +} + void PropertyEditorView::reloadQml() { m_qmlBackendHash.clear(); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h index 7964420251..bb2f9dc360 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.h @@ -3,13 +3,15 @@ #pragma once -#include <abstractview.h> +#include "abstractview.h" + #include <QHash> +#include <QObject> #include <QTimer> -#include "propertyeditorwidget.h" QT_BEGIN_NAMESPACE +class QEvent; class QShortcut; class QStackedWidget; class QTimer; @@ -17,14 +19,13 @@ QT_END_NAMESPACE namespace QmlDesigner { -class PropertyEditorTransaction; class CollapseButton; -class PropertyEditorWidget; -class PropertyEditorView; -class PropertyEditorQmlBackend; class ModelNode; +class PropertyEditorQmlBackend; +class PropertyEditorView; +class PropertyEditorWidget; -class PropertyEditorView: public AbstractView +class PropertyEditorView : public AbstractView { Q_OBJECT @@ -84,6 +85,7 @@ protected: void timerEvent(QTimerEvent *event) override; void setupPane(const TypeName &typeName); void setValue(const QmlObjectNode &fxObjectNode, const PropertyName &name, const QVariant &value); + bool eventFilter(QObject *obj, QEvent *event) override; private: //functions void reloadQml(); |