forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -19,6 +19,7 @@ Item {
|
||||
materialsView.closeContextMenu()
|
||||
texturesView.closeContextMenu()
|
||||
environmentsView.closeContextMenu()
|
||||
HelperWidgets.Controller.closeContextMenu()
|
||||
}
|
||||
|
||||
// Called from C++
|
||||
|
@@ -27,6 +27,7 @@ Item {
|
||||
{
|
||||
ctxMenu.close()
|
||||
ctxMenuTextures.close()
|
||||
HelperWidgets.Controller.closeContextMenu()
|
||||
}
|
||||
|
||||
// Called from C++ to refresh a preview material after it changes
|
||||
|
@@ -18,10 +18,11 @@ PropertyEditorPane {
|
||||
topSection.refreshPreview()
|
||||
}
|
||||
|
||||
// Called also from C++ to close context menu on focus out
|
||||
// Called from C++ to close context menu on focus out
|
||||
function closeContextMenu()
|
||||
{
|
||||
topSection.closeContextMenu()
|
||||
Controller.closeContextMenu()
|
||||
}
|
||||
|
||||
// Called from C++ to initialize preview menu checkmarks
|
||||
|
@@ -11,4 +11,5 @@ QtObject {
|
||||
|
||||
signal collapseAll(string category)
|
||||
signal expandAll(string category)
|
||||
signal closeContextMenu()
|
||||
}
|
||||
|
@@ -18,6 +18,12 @@ Rectangle {
|
||||
|
||||
default property alias content: mainColumn.children
|
||||
|
||||
// Called from C++ to close context menu on focus out
|
||||
function closeContextMenu()
|
||||
{
|
||||
Controller.closeContextMenu()
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: forceActiveFocus()
|
||||
|
@@ -67,6 +67,9 @@ Item {
|
||||
section.expand()
|
||||
}
|
||||
}
|
||||
function onCloseContextMenu() {
|
||||
contextMenu.close()
|
||||
}
|
||||
}
|
||||
|
||||
signal drop(var drag)
|
||||
|
@@ -16,10 +16,10 @@ PropertyEditorPane {
|
||||
topSection.refreshPreview()
|
||||
}
|
||||
|
||||
// Called also from C++ to close context menu on focus out
|
||||
// Called from C++ to close context menu on focus out
|
||||
function closeContextMenu()
|
||||
{
|
||||
// Nothing
|
||||
Controller.closeContextMenu()
|
||||
}
|
||||
|
||||
TextureEditorTopSection {
|
||||
|
@@ -380,7 +380,7 @@ PropertyEditorContextObject* PropertyEditorQmlBackend::contextObject() {
|
||||
return m_contextObject.data();
|
||||
}
|
||||
|
||||
QWidget *PropertyEditorQmlBackend::widget() {
|
||||
QQuickWidget *PropertyEditorQmlBackend::widget() {
|
||||
return m_view;
|
||||
}
|
||||
|
||||
|
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
QQmlContext *context();
|
||||
PropertyEditorContextObject* contextObject();
|
||||
QWidget *widget();
|
||||
QQuickWidget *widget();
|
||||
void setSource(const QUrl& url);
|
||||
Internal::QmlAnchorBindingProxy &backendAnchorBinding();
|
||||
DesignerPropertyMap &backendValuesPropertyMap();
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user