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 <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2017-01-11 12:21:53 +01:00
parent dcf19a10c6
commit f94a55ee4e
3 changed files with 17 additions and 16 deletions

View File

@@ -40,6 +40,7 @@ public:
enum Type {
ContextMenu,
ContextMenuAction,
ToolBarAction,
Action
};

View File

@@ -24,6 +24,7 @@
****************************************************************************/
#include "designeractionmanager.h"
#include "modelnodecontextmenu_helper.h"
#include <nodeproperty.h>
#include <nodemetainfo.h>
@@ -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,

View File

@@ -72,6 +72,7 @@ void populateMenu(QSet<ActionInterface* > &actionInterfaces,
if (actionInterface->type() == ActionInterface::ContextMenu) {
actionInterface->currentContextChanged(selectionContext);
QMenu *newMenu = actionInterface->action()->menu();
if (newMenu && !newMenu->title().isEmpty())
menu->addMenu(newMenu);
//recurse