Commit bc9cea81 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner: Fix navigator context menu

Depending on the context and focus we are disabling actions.
But we did not enable actions when setting the focus/context
back to e.g. the navigator. We "simulate" a selection change
to set the proper state of the actions.

Task-number: QTCREATORBUG-19110
Change-Id: Ie4eefb498956de22d33d72bd7189bacd3177912b
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 6c690f68
......@@ -160,6 +160,11 @@ const DesignerActionManager &DesignerActionManagerView::designerActionManager()
return m_designerActionManager;
}
void DesignerActionManagerView::emitSelectionChanged()
{
emit selectionChanged(!selectedModelNodes().isEmpty(), singleSelectedModelNode().isRootNode());
}
/* We should consider compressing this. */
/* One update every 100ms should be enough. */
void DesignerActionManagerView::setupContext()
......
......@@ -68,6 +68,7 @@ public:
void setDesignerActionList(const QList<ActionInterface* > &designerActionList);
DesignerActionManager &designerActionManager();
const DesignerActionManager &designerActionManager() const;
void emitSelectionChanged();
signals:
void selectionChanged(bool itemsSelected, bool rootItemIsSelected);
......
......@@ -248,12 +248,15 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
m_copyAction.setEnabled(itemsSelected);
});
connect(Core::ICore::instance(), &Core::ICore::contextChanged, this, [this](const Core::Context &context){
connect(Core::ICore::instance(), &Core::ICore::contextChanged, this, [&designerActionManager, this](const Core::Context &context){
if (!context.contains(Constants::C_QMLFORMEDITOR) && !context.contains(Constants::C_QMLNAVIGATOR)) {
m_deleteAction.setEnabled(false);
m_cutAction.setEnabled(false);
m_copyAction.setEnabled(false);
m_pasteAction.setEnabled(false);
} else {
designerActionManager.view()->emitSelectionChanged();
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment