forked from qt-creator/qt-creator
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:
@@ -40,6 +40,7 @@ public:
|
|||||||
enum Type {
|
enum Type {
|
||||||
ContextMenu,
|
ContextMenu,
|
||||||
ContextMenuAction,
|
ContextMenuAction,
|
||||||
|
ToolBarAction,
|
||||||
Action
|
Action
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "designeractionmanager.h"
|
#include "designeractionmanager.h"
|
||||||
|
|
||||||
#include "modelnodecontextmenu_helper.h"
|
#include "modelnodecontextmenu_helper.h"
|
||||||
#include <nodeproperty.h>
|
#include <nodeproperty.h>
|
||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
@@ -80,24 +81,16 @@ DesignerActionToolBar *DesignerActionManager::createToolBar(QWidget *parent) con
|
|||||||
});
|
});
|
||||||
|
|
||||||
bool addSeparator = false;
|
bool addSeparator = false;
|
||||||
bool lastWasSeparator = false;
|
|
||||||
|
|
||||||
for (auto *action : actions) {
|
for (auto *action : actions) {
|
||||||
if (action->type() == ActionInterface::Action
|
if ((action->type() == ActionInterface::Action || action->type() == ActionInterface::ToolBarAction)
|
||||||
&& action->action()
|
&& action->action()) {
|
||||||
&& !action->action()->icon().isNull()) {
|
|
||||||
toolBar->registerAction(action);
|
toolBar->registerAction(action);
|
||||||
addSeparator = true;
|
addSeparator = true;
|
||||||
lastWasSeparator = false;
|
|
||||||
} else if (addSeparator && action->action()->isSeparator()) {
|
} else if (addSeparator && action->action()->isSeparator()) {
|
||||||
toolBar->registerAction(action);
|
toolBar->registerAction(action);
|
||||||
lastWasSeparator = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addSeparator && !lastWasSeparator) {
|
|
||||||
toolBar->addSeparator();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return toolBar;
|
return toolBar;
|
||||||
@@ -541,6 +534,8 @@ void DesignerActionManager::createDefaultDesignerActions()
|
|||||||
&resetSize,
|
&resetSize,
|
||||||
&selectionNotEmptyAndHasWidthOrHeightProperty));
|
&selectionNotEmptyAndHasWidthOrHeightProperty));
|
||||||
|
|
||||||
|
addDesignerAction(new SeperatorDesignerAction(editCategory, 170));
|
||||||
|
|
||||||
addDesignerAction(new VisiblityModelNodeAction(
|
addDesignerAction(new VisiblityModelNodeAction(
|
||||||
visiblityCommandId,
|
visiblityCommandId,
|
||||||
visibilityDisplayName,
|
visibilityDisplayName,
|
||||||
@@ -578,6 +573,8 @@ void DesignerActionManager::createDefaultDesignerActions()
|
|||||||
&anchorsReset,
|
&anchorsReset,
|
||||||
&singleSelectionItemIsAnchored));
|
&singleSelectionItemIsAnchored));
|
||||||
|
|
||||||
|
addDesignerAction(new SeperatorDesignerAction(anchorsCategory, 170));
|
||||||
|
|
||||||
addDesignerAction(new ActionGroup(
|
addDesignerAction(new ActionGroup(
|
||||||
positionCategoryDisplayName,
|
positionCategoryDisplayName,
|
||||||
positionCategory,
|
positionCategory,
|
||||||
@@ -685,6 +682,8 @@ void DesignerActionManager::createDefaultDesignerActions()
|
|||||||
&layoutGridLayout,
|
&layoutGridLayout,
|
||||||
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
||||||
|
|
||||||
|
addDesignerAction(new SeperatorDesignerAction(layoutCategory, 50));
|
||||||
|
|
||||||
addDesignerAction(new FillWidthModelNodeAction(
|
addDesignerAction(new FillWidthModelNodeAction(
|
||||||
layoutFillWidthCommandId,
|
layoutFillWidthCommandId,
|
||||||
layoutFillWidthDisplayName,
|
layoutFillWidthDisplayName,
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ void populateMenu(QSet<ActionInterface* > &actionInterfaces,
|
|||||||
if (actionInterface->type() == ActionInterface::ContextMenu) {
|
if (actionInterface->type() == ActionInterface::ContextMenu) {
|
||||||
actionInterface->currentContextChanged(selectionContext);
|
actionInterface->currentContextChanged(selectionContext);
|
||||||
QMenu *newMenu = actionInterface->action()->menu();
|
QMenu *newMenu = actionInterface->action()->menu();
|
||||||
|
if (newMenu && !newMenu->title().isEmpty())
|
||||||
menu->addMenu(newMenu);
|
menu->addMenu(newMenu);
|
||||||
|
|
||||||
//recurse
|
//recurse
|
||||||
|
|||||||
Reference in New Issue
Block a user