QmlDesigner: Fix view menus intially enabled

- Fix views, workspaces and output menus being enabled in welcome mode
- Use mode instead of context change to enable/disable menus

Change-Id: I68053112d66e100e3bf3b07368310a3c3c50999d
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Henning Gruendl
2023-04-28 13:57:14 +02:00
committed by Henning Gründl
parent 66af0f4dab
commit 4642c5fd7d

View File

@@ -221,13 +221,28 @@ void DesignModeWidget::setup()
mworkspaces->setOnAllDisabledBehavior(Core::ActionContainer::Show); mworkspaces->setOnAllDisabledBehavior(Core::ActionContainer::Show);
// Connect opening of the 'workspaces' menu with creation of the workspaces menu // Connect opening of the 'workspaces' menu with creation of the workspaces menu
connect(mworkspaces->menu(), &QMenu::aboutToShow, this, &DesignModeWidget::aboutToShowWorkspaces); connect(mworkspaces->menu(), &QMenu::aboutToShow, this, &DesignModeWidget::aboutToShowWorkspaces);
// Disable workspace menu when context is different to C_DESIGN_MODE
connect(Core::ICore::instance(), &Core::ICore::contextChanged, Core::ActionContainer *mpanes = Core::ActionManager::actionContainer(Core::Constants::M_VIEW_PANES);
this, [mworkspaces](const Core::Context &context){
if (context.contains(Core::Constants::C_DESIGN_MODE)) // Initially disable menus
mworkspaces->menu()->setEnabled(true); mviews->menu()->setEnabled(false);
else
mworkspaces->menu()->setEnabled(false); mworkspaces->menu()->setEnabled(false);
mpanes->menu()->setEnabled(false);
// Enable/disable menus when mode is different to MODE_DESIGN
connect(Core::ModeManager::instance(),
&Core::ModeManager::currentModeChanged,
this,
[mviews, mworkspaces, mpanes](Utils::Id mode, Utils::Id) {
if (mode == Core::Constants::MODE_DESIGN) {
mviews->menu()->setEnabled(true);
mworkspaces->menu()->setEnabled(true);
mpanes->menu()->setEnabled(true);
} else {
mviews->menu()->setEnabled(false);
mworkspaces->menu()->setEnabled(false);
mpanes->menu()->setEnabled(false);
}
}); });
// Create a DockWidget for each QWidget and add them to the DockManager // Create a DockWidget for each QWidget and add them to the DockManager