From f94a55ee4e5dc9f036f05c7f9465b018b8276993 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 11 Jan 2017 12:21:53 +0100 Subject: [PATCH] QmlDesigner: Some changes to DesignerActionManager * Adding ToolBarAction as a new type for pure toolbar action * Adjusting handling of separators * Do not show an empty menu. This allows grouping just for the toolbar. Change-Id: I0ff59473ea5d3a798ec963ac0984f20e7e857c56 Reviewed-by: Tim Jenssen --- .../componentcore/actioninterface.h | 1 + .../componentcore/designeractionmanager.cpp | 19 +++++++++---------- .../componentcore/modelnodecontextmenu.cpp | 13 +++++++------ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/plugins/qmldesigner/components/componentcore/actioninterface.h b/src/plugins/qmldesigner/components/componentcore/actioninterface.h index 668438218ac..b52e516954e 100644 --- a/src/plugins/qmldesigner/components/componentcore/actioninterface.h +++ b/src/plugins/qmldesigner/components/componentcore/actioninterface.h @@ -40,6 +40,7 @@ public: enum Type { ContextMenu, ContextMenuAction, + ToolBarAction, Action }; diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index cd0e18578b2..1332e3b0546 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -24,6 +24,7 @@ ****************************************************************************/ #include "designeractionmanager.h" + #include "modelnodecontextmenu_helper.h" #include #include @@ -80,24 +81,16 @@ DesignerActionToolBar *DesignerActionManager::createToolBar(QWidget *parent) con }); bool addSeparator = false; - bool lastWasSeparator = false; for (auto *action : actions) { - if (action->type() == ActionInterface::Action - && action->action() - && !action->action()->icon().isNull()) { + if ((action->type() == ActionInterface::Action || action->type() == ActionInterface::ToolBarAction) + && action->action()) { toolBar->registerAction(action); addSeparator = true; - lastWasSeparator = false; } else if (addSeparator && action->action()->isSeparator()) { toolBar->registerAction(action); - lastWasSeparator = true; } } - - if (addSeparator && !lastWasSeparator) { - toolBar->addSeparator(); - } } return toolBar; @@ -541,6 +534,8 @@ void DesignerActionManager::createDefaultDesignerActions() &resetSize, &selectionNotEmptyAndHasWidthOrHeightProperty)); + addDesignerAction(new SeperatorDesignerAction(editCategory, 170)); + addDesignerAction(new VisiblityModelNodeAction( visiblityCommandId, visibilityDisplayName, @@ -578,6 +573,8 @@ void DesignerActionManager::createDefaultDesignerActions() &anchorsReset, &singleSelectionItemIsAnchored)); + addDesignerAction(new SeperatorDesignerAction(anchorsCategory, 170)); + addDesignerAction(new ActionGroup( positionCategoryDisplayName, positionCategory, @@ -685,6 +682,8 @@ void DesignerActionManager::createDefaultDesignerActions() &layoutGridLayout, &selectionCanBeLayoutedAndQtQuickLayoutPossible)); + addDesignerAction(new SeperatorDesignerAction(layoutCategory, 50)); + addDesignerAction(new FillWidthModelNodeAction( layoutFillWidthCommandId, layoutFillWidthDisplayName, diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp index 4139dd677fe..b449cec9a12 100644 --- a/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp +++ b/src/plugins/qmldesigner/components/componentcore/modelnodecontextmenu.cpp @@ -69,14 +69,15 @@ void populateMenu(QSet &actionInterfaces, }); foreach (ActionInterface* actionInterface, matchingFactoriesList) { - if (actionInterface->type() == ActionInterface::ContextMenu) { - actionInterface->currentContextChanged(selectionContext); - QMenu *newMenu = actionInterface->action()->menu(); - menu->addMenu(newMenu); + if (actionInterface->type() == ActionInterface::ContextMenu) { + actionInterface->currentContextChanged(selectionContext); + QMenu *newMenu = actionInterface->action()->menu(); + if (newMenu && !newMenu->title().isEmpty()) + menu->addMenu(newMenu); - //recurse + //recurse - populateMenu(actionInterfaces, actionInterface->menuId(), newMenu, selectionContext); + populateMenu(actionInterfaces, actionInterface->menuId(), newMenu, selectionContext); } else if (actionInterface->type() == ActionInterface::ContextMenuAction || actionInterface->type() == ActionInterface::Action) { QAction* action = actionInterface->action();