QmlDesigner: Adding a toolbar
* Icons are not the final ones. * I fixed a couple of glitches and cleaned up the code. - Action for copy and paste/delete were not properly updated - Delete had no icon - Using std::function for action predicates and operations - The context menu has no icons. This way we avoid having to define 2 icons. Change-Id: Ic23cbc78ba299c19e07e8de775eb813aae55db9b Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
@@ -39,7 +39,7 @@ AbstractActionGroup::AbstractActionGroup(const QString &displayName) :
|
|||||||
|
|
||||||
ActionInterface::Type AbstractActionGroup::type() const
|
ActionInterface::Type AbstractActionGroup::type() const
|
||||||
{
|
{
|
||||||
return ActionInterface::Menu;
|
return ActionInterface::ContextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction *AbstractActionGroup::action() const
|
QAction *AbstractActionGroup::action() const
|
||||||
|
@@ -38,7 +38,8 @@ class QMLDESIGNERCORE_EXPORT ActionInterface
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
Menu,
|
ContextMenu,
|
||||||
|
ContextMenuAction,
|
||||||
Action
|
Action
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -35,3 +35,6 @@ HEADERS += qmldesignericonprovider.h
|
|||||||
FORMS += \
|
FORMS += \
|
||||||
$$PWD/addsignalhandlerdialog.ui
|
$$PWD/addsignalhandlerdialog.ui
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
$$PWD/componentcore.qrc
|
||||||
|
|
||||||
|
@@ -0,0 +1,13 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/qmldesigner/icon/designeractions">
|
||||||
|
<file>images/cancel.png</file>
|
||||||
|
<file>images/column.png</file>
|
||||||
|
<file>images/fill.png</file>
|
||||||
|
<file>images/grid.png</file>
|
||||||
|
<file>images/lower.png</file>
|
||||||
|
<file>images/move.png</file>
|
||||||
|
<file>images/raise.png</file>
|
||||||
|
<file>images/row.png</file>
|
||||||
|
<file>images/size.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
@@ -40,6 +40,32 @@ const char anchorsCategory[] = "Anchors";
|
|||||||
const char positionCategory[] = "Position";
|
const char positionCategory[] = "Position";
|
||||||
const char layoutCategory[] = "Layout";
|
const char layoutCategory[] = "Layout";
|
||||||
|
|
||||||
|
const char toFrontCommandId[] = "ToFront";
|
||||||
|
const char toBackCommandId[] = "ToBack";
|
||||||
|
const char raiseCommandId[] = "Raise";
|
||||||
|
const char lowerCommandId[] = "Lower";
|
||||||
|
const char resetZCommandId[] = "ResetZ";
|
||||||
|
const char resetSizeCommandId[] = "ResetSize";
|
||||||
|
const char resetPositionCommandId[] = "ResetPosition";
|
||||||
|
const char visiblityCommandId[] = "ToggleVisiblity";
|
||||||
|
const char anchorsFillCommandId[] = "AnchorsFill";
|
||||||
|
const char anchorsResetCommandId[] = "AnchorsReset";
|
||||||
|
const char removePositionerCommandId[] = "RemovePositioner";
|
||||||
|
const char layoutRowPositionerCommandId[] = "LayoutRowPositioner";
|
||||||
|
const char layoutColumnPositionerCommandId[] = "LayoutColumnPositioner";
|
||||||
|
const char layoutGridPositionerCommandId[] = "LayoutGridPositioner";
|
||||||
|
const char layoutFlowPositionerCommandId[] = "LayoutFlowPositioner";
|
||||||
|
const char removeLayoutCommandId[] = "RemoveLayout";
|
||||||
|
const char layoutRowLayoutCommandId[] = "LayoutRowLayout";
|
||||||
|
const char layoutColumnLayoutCommandId[] = "LayoutColumnLayout";
|
||||||
|
const char layoutGridLayoutCommandId[] = "LayoutGridLayout";
|
||||||
|
const char layoutFillWidthCommandId[] = "LayoutFillWidth";
|
||||||
|
const char layoutFillHeightCommandId[] = "LayoutFillHeight";
|
||||||
|
const char goIntoComponentCommandId[] = "GoIntoComponent";
|
||||||
|
const char goToImplementationCommandId[] = "GoToImplementation";
|
||||||
|
const char addSignalHandlerCommandId[] = "AddSignalHandler";
|
||||||
|
const char moveToComponentCommandId[] = "MoveToComponent";
|
||||||
|
|
||||||
const char selectionCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Selection");
|
const char selectionCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Selection");
|
||||||
const char stackCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Stack (z)");
|
const char stackCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Stack (z)");
|
||||||
const char editCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit");
|
const char editCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit");
|
||||||
@@ -73,7 +99,7 @@ const char resetPositionDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMen
|
|||||||
const char goIntoComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go into Component");
|
const char goIntoComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go into Component");
|
||||||
const char goToImplementationDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go to Implementation");
|
const char goToImplementationDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Go to Implementation");
|
||||||
const char addSignalHandlerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add New Signal Handler");
|
const char addSignalHandlerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Add New Signal Handler");
|
||||||
const char moveToComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Move to Component");
|
const char moveToComponentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Move to Component into separate file");
|
||||||
|
|
||||||
const char setIdDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Set Id");
|
const char setIdDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Set Id");
|
||||||
|
|
||||||
@@ -96,6 +122,19 @@ const char layoutGridLayoutDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContext
|
|||||||
const char layoutFillWidthDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill Width");
|
const char layoutFillWidthDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill Width");
|
||||||
const char layoutFillHeightDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill Height");
|
const char layoutFillHeightDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill Height");
|
||||||
|
|
||||||
|
const char raiseToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Raise selected item.");
|
||||||
|
const char lowerToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Lower selected item.");
|
||||||
|
|
||||||
|
const char resetSizeToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reset size and use implcit size.");
|
||||||
|
const char resetPositionTooltip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reset position and use implicit position.");
|
||||||
|
|
||||||
|
const char anchorsFillToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill selected item to parent. ");
|
||||||
|
const char anchorsResetToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reset achors for selected item.");
|
||||||
|
|
||||||
|
const char layoutColumnLayoutToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout selected items in ColumnLayout.");
|
||||||
|
const char layoutRowLayoutToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout selected items in RowLayout.");
|
||||||
|
const char layoutGridLayoutToolTip[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout selected items in GridLayout.");
|
||||||
|
|
||||||
|
|
||||||
const int priorityFirst = 220;
|
const int priorityFirst = 220;
|
||||||
const int prioritySelectionCategory = 200;
|
const int prioritySelectionCategory = 200;
|
||||||
|
@@ -28,10 +28,17 @@
|
|||||||
#include <nodeproperty.h>
|
#include <nodeproperty.h>
|
||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
#include "designeractionmanagerview.h"
|
#include "designeractionmanagerview.h"
|
||||||
|
#include "qmldesignerconstants.h"
|
||||||
|
|
||||||
#include <documentmanager.h>
|
#include <documentmanager.h>
|
||||||
#include <qmldesignerplugin.h>
|
#include <qmldesignerplugin.h>
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
static inline QString captionForModelNode(const ModelNode &modelNode)
|
static inline QString captionForModelNode(const ModelNode &modelNode)
|
||||||
@@ -47,20 +54,89 @@ static inline bool contains(const QmlItemNode &node, const QPointF &position)
|
|||||||
return node.isValid() && node.instanceSceneTransform().mapRect(node.instanceBoundingRect()).contains(position);
|
return node.isValid() && node.instanceSceneTransform().mapRect(node.instanceBoundingRect()).contains(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractView *DesignerActionManager::view()
|
DesignerActionManagerView *DesignerActionManager::view()
|
||||||
{
|
{
|
||||||
return m_designerActionManagerView;
|
return m_designerActionManagerView;
|
||||||
}
|
}
|
||||||
|
|
||||||
class VisiblityModelNodeAction : public ModelNodeAction
|
DesignerActionToolBar *DesignerActionManager::createToolBar(QWidget *parent) const
|
||||||
|
{
|
||||||
|
DesignerActionToolBar *toolBar = new DesignerActionToolBar(parent);
|
||||||
|
|
||||||
|
QList<ActionInterface* > categories = Utils::filtered(designerActions(),
|
||||||
|
[](ActionInterface *action) { return action->type() == ActionInterface::ContextMenu; });
|
||||||
|
|
||||||
|
Utils::sort(categories, [](ActionInterface *l, ActionInterface *r) {
|
||||||
|
return l->priority() > r->priority();
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto *categoryAction : categories) {
|
||||||
|
QList<ActionInterface* > actions = Utils::filtered(designerActions(), [categoryAction](ActionInterface *action) {
|
||||||
|
return action->category() == categoryAction->menuId();
|
||||||
|
});
|
||||||
|
|
||||||
|
Utils::sort(actions, [](ActionInterface *l, ActionInterface *r) {
|
||||||
|
return l->priority() > r->priority();
|
||||||
|
});
|
||||||
|
|
||||||
|
bool addSeparator = false;
|
||||||
|
bool lastWasSeparator = false;
|
||||||
|
|
||||||
|
for (auto *action : actions) {
|
||||||
|
if (action->type() == ActionInterface::Action
|
||||||
|
&& action->action()
|
||||||
|
&& !action->action()->icon().isNull()) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignerActionManager::polishActions() const
|
||||||
|
{
|
||||||
|
QList<ActionInterface* > actions = Utils::filtered(designerActions(),
|
||||||
|
[](ActionInterface *action) { return action->type() != ActionInterface::ContextMenu; });
|
||||||
|
|
||||||
|
Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR);
|
||||||
|
|
||||||
|
for (auto *action : actions) {
|
||||||
|
if (!action->menuId().isEmpty()) {
|
||||||
|
const QString id =
|
||||||
|
QString("QmlDesigner.FormEditor.%1.%2").arg(QString::fromLatin1(action->category())).arg(QString::fromLatin1(action->menuId()));
|
||||||
|
|
||||||
|
Core::Command *cmd = Core::ActionManager::registerAction(action->action(), id.toLatin1().constData(), qmlDesignerFormEditorContext);
|
||||||
|
|
||||||
|
cmd->setDefaultKeySequence(action->action()->shortcut());
|
||||||
|
cmd->setDescription(action->action()->toolTip());
|
||||||
|
|
||||||
|
action->action()->setToolTip(cmd->action()->toolTip());
|
||||||
|
action->action()->setShortcut(cmd->action()->shortcut());
|
||||||
|
action->action()->setShortcutContext(Qt::WidgetShortcut); //Hack to avoid conflicting shortcuts. We use the Core::Command for the shortcut.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class VisiblityModelNodeAction : public ModelNodeContextMenuAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VisiblityModelNodeAction(const QString &description, const QByteArray &category, int priority,
|
VisiblityModelNodeAction(const QByteArray &id, const QString &description, const QByteArray &category, const QKeySequence &key, int priority,
|
||||||
ModelNodeOperations::SelectionAction action,
|
SelectionContextOperation action,
|
||||||
SelectionContextFunction enabled = &SelectionContextFunctors::always,
|
SelectionContextPredicate enabled = &SelectionContextFunctors::always,
|
||||||
SelectionContextFunction visibility = &SelectionContextFunctors::always) :
|
SelectionContextPredicate visibility = &SelectionContextFunctors::always) :
|
||||||
ModelNodeAction(description, category, priority, action, enabled, visibility)
|
ModelNodeContextMenuAction(id, description, category, key, priority, action, enabled, visibility)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void updateContext()
|
virtual void updateContext()
|
||||||
{
|
{
|
||||||
defaultAction()->setSelectionContext(selectionContext());
|
defaultAction()->setSelectionContext(selectionContext());
|
||||||
@@ -78,14 +154,14 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class FillLayoutModelNodeAction : public ModelNodeAction
|
class FillLayoutModelNodeAction : public ModelNodeContextMenuAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FillLayoutModelNodeAction(const QString &description, const QByteArray &category, int priority,
|
FillLayoutModelNodeAction(const QByteArray &id, const QString &description, const QByteArray &category, const QKeySequence &key, int priority,
|
||||||
ModelNodeOperations::SelectionAction action,
|
SelectionContextOperation action,
|
||||||
SelectionContextFunction enabled = &SelectionContextFunctors::always,
|
SelectionContextPredicate enabled = &SelectionContextFunctors::always,
|
||||||
SelectionContextFunction visibility = &SelectionContextFunctors::always) :
|
SelectionContextPredicate visibility = &SelectionContextFunctors::always) :
|
||||||
ModelNodeAction(description, category, priority, action, enabled, visibility)
|
ModelNodeContextMenuAction(id, description, category, key, priority, action, enabled, visibility)
|
||||||
{}
|
{}
|
||||||
virtual void updateContext()
|
virtual void updateContext()
|
||||||
{
|
{
|
||||||
@@ -115,11 +191,11 @@ protected:
|
|||||||
class FillWidthModelNodeAction : public FillLayoutModelNodeAction
|
class FillWidthModelNodeAction : public FillLayoutModelNodeAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FillWidthModelNodeAction(const QString &description, const QByteArray &category, int priority,
|
FillWidthModelNodeAction(const QByteArray &id, const QString &description, const QByteArray &category, const QKeySequence &key, int priority,
|
||||||
ModelNodeOperations::SelectionAction action,
|
SelectionContextOperation action,
|
||||||
SelectionContextFunction enabled = &SelectionContextFunctors::always,
|
SelectionContextPredicate enabled = &SelectionContextFunctors::always,
|
||||||
SelectionContextFunction visibility = &SelectionContextFunctors::always) :
|
SelectionContextPredicate visibility = &SelectionContextFunctors::always) :
|
||||||
FillLayoutModelNodeAction(description, category, priority, action, enabled, visibility)
|
FillLayoutModelNodeAction(id, description, category, key, priority, action, enabled, visibility)
|
||||||
{
|
{
|
||||||
m_propertyName = "Layout.fillWidth";
|
m_propertyName = "Layout.fillWidth";
|
||||||
}
|
}
|
||||||
@@ -128,11 +204,11 @@ public:
|
|||||||
class FillHeightModelNodeAction : public FillLayoutModelNodeAction
|
class FillHeightModelNodeAction : public FillLayoutModelNodeAction
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FillHeightModelNodeAction(const QString &description, const QByteArray &category, int priority,
|
FillHeightModelNodeAction(const QByteArray &id, const QString &description, const QByteArray &category, const QKeySequence &key, int priority,
|
||||||
ModelNodeOperations::SelectionAction action,
|
SelectionContextOperation action,
|
||||||
SelectionContextFunction enabled = &SelectionContextFunctors::always,
|
SelectionContextPredicate enabled = &SelectionContextFunctors::always,
|
||||||
SelectionContextFunction visibility = &SelectionContextFunctors::always) :
|
SelectionContextPredicate visibility = &SelectionContextFunctors::always) :
|
||||||
FillLayoutModelNodeAction(description, category, priority, action, enabled, visibility)
|
FillLayoutModelNodeAction(id, description, category, key, priority, action, enabled, visibility)
|
||||||
{
|
{
|
||||||
m_propertyName = "Layout.fillHeight";
|
m_propertyName = "Layout.fillHeight";
|
||||||
}
|
}
|
||||||
@@ -380,140 +456,293 @@ void DesignerActionManager::createDefaultDesignerActions()
|
|||||||
using namespace ComponentCoreConstants;
|
using namespace ComponentCoreConstants;
|
||||||
using namespace ModelNodeOperations;
|
using namespace ModelNodeOperations;
|
||||||
|
|
||||||
addDesignerAction(new SelectionModelNodeAction(selectionCategoryDisplayName, selectionCategory, prioritySelectionCategory));
|
addDesignerAction(new SelectionModelNodeAction(
|
||||||
|
selectionCategoryDisplayName,
|
||||||
|
selectionCategory,
|
||||||
|
prioritySelectionCategory));
|
||||||
|
|
||||||
addDesignerAction(new ActionGroup(stackCategoryDisplayName, stackCategory, priorityStackCategory, &selectionNotEmpty));
|
addDesignerAction(new ActionGroup(
|
||||||
addDesignerAction(new ModelNodeAction
|
stackCategoryDisplayName,
|
||||||
(toFrontDisplayName, stackCategory, 200, &toFront, &singleSelection));
|
stackCategory,
|
||||||
addDesignerAction(new ModelNodeAction
|
priorityStackCategory,
|
||||||
(toBackDisplayName, stackCategory, 180, &toBack, &singleSelection));
|
&selectionNotEmpty));
|
||||||
addDesignerAction(new ModelNodeAction
|
|
||||||
(raiseDisplayName, stackCategory, 160, &raise, &selectionNotEmpty));
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
addDesignerAction(new ModelNodeAction
|
toFrontCommandId,
|
||||||
(lowerDisplayName, stackCategory, 140, &lower, &selectionNotEmpty));
|
toFrontDisplayName,
|
||||||
addDesignerAction(new SeperatorDesignerAction(stackCategory, 120));
|
stackCategory,
|
||||||
addDesignerAction(new ModelNodeAction
|
QKeySequence(),
|
||||||
(resetZDisplayName, stackCategory, 100, &resetZ, &selectionNotEmptyAndHasZProperty));
|
200,
|
||||||
|
&toFront,
|
||||||
|
&singleSelection));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
|
toBackCommandId,
|
||||||
|
toBackDisplayName,
|
||||||
|
stackCategory,
|
||||||
|
QKeySequence(),
|
||||||
|
180,
|
||||||
|
&toBack,
|
||||||
|
&singleSelection));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeAction(
|
||||||
|
raiseCommandId, raiseDisplayName,
|
||||||
|
Utils::Icon(":/qmldesigner/icon/designeractions/images/lower.png").icon(),
|
||||||
|
raiseToolTip,
|
||||||
|
stackCategory,
|
||||||
|
QKeySequence("Ctrl+Up"),
|
||||||
|
160,
|
||||||
|
&raise,
|
||||||
|
&selectionNotEmpty));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeAction(
|
||||||
|
lowerCommandId,
|
||||||
|
lowerDisplayName,
|
||||||
|
Utils::Icon(":/qmldesigner/icon/designeractions/images/raise.png").icon(),
|
||||||
|
lowerToolTip,
|
||||||
|
stackCategory,
|
||||||
|
QKeySequence("Ctrl+Down"),
|
||||||
|
140,
|
||||||
|
&lower,
|
||||||
|
&selectionNotEmpty));
|
||||||
|
|
||||||
|
addDesignerAction(new SeperatorDesignerAction(stackCategory, 120));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
|
resetZCommandId,
|
||||||
|
resetZDisplayName,
|
||||||
|
stackCategory,
|
||||||
|
QKeySequence(),
|
||||||
|
100,
|
||||||
|
&resetZ,
|
||||||
|
&selectionNotEmptyAndHasZProperty));
|
||||||
|
|
||||||
addDesignerAction(new ActionGroup(editCategoryDisplayName, editCategory, priorityEditCategory, &selectionNotEmpty));
|
addDesignerAction(new ActionGroup(editCategoryDisplayName, editCategory, priorityEditCategory, &selectionNotEmpty));
|
||||||
addDesignerAction(new ModelNodeAction
|
|
||||||
(resetPositionDisplayName, editCategory, 200, &resetPosition, &selectionNotEmptyAndHasXorYProperty));
|
|
||||||
addDesignerAction(new ModelNodeAction
|
|
||||||
(resetSizeDisplayName, editCategory, 180, &resetSize, &selectionNotEmptyAndHasWidthOrHeightProperty));
|
|
||||||
addDesignerAction(new VisiblityModelNodeAction
|
|
||||||
(visibilityDisplayName, editCategory, 160, &setVisible, &singleSelectedItem));
|
|
||||||
|
|
||||||
addDesignerAction(new ActionGroup(anchorsCategoryDisplayName, anchorsCategory,
|
addDesignerAction(new SeperatorDesignerAction(editCategory, 220));
|
||||||
priorityAnchorsCategory, &singleSelectionAndInBaseState));
|
|
||||||
addDesignerAction(new ModelNodeAction
|
|
||||||
(anchorsFillDisplayName, anchorsCategory, 200, &anchorsFill, &singleSelectionItemIsNotAnchoredAndSingleSelectionNotRoot));
|
|
||||||
addDesignerAction(new ModelNodeAction
|
|
||||||
(anchorsResetDisplayName, anchorsCategory, 180, &anchorsReset, &singleSelectionItemIsAnchored));
|
|
||||||
|
|
||||||
addDesignerAction(new ActionGroup(positionCategoryDisplayName, positionCategory,
|
addDesignerAction(new ModelNodeAction(
|
||||||
priorityPositionCategory, &positionOptionVisible));
|
resetPositionCommandId,
|
||||||
addDesignerAction(new ActionGroup(layoutCategoryDisplayName, layoutCategory,
|
resetPositionDisplayName,
|
||||||
priorityLayoutCategory, &layoutOptionVisible));
|
Utils::Icon(":/qmldesigner/icon/designeractions/images/move.png").icon(),
|
||||||
|
resetPositionTooltip, editCategory, QKeySequence("Ctrl+d"),
|
||||||
|
200,
|
||||||
|
&resetPosition,
|
||||||
|
&selectionNotEmptyAndHasXorYProperty));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction(
|
||||||
(removePositionerDisplayName,
|
resetSizeCommandId,
|
||||||
positionCategory,
|
resetSizeDisplayName,
|
||||||
210,
|
Utils::Icon(":/qmldesigner/icon/designeractions/images/size.png").icon(),
|
||||||
&removePositioner,
|
resetSizeToolTip,
|
||||||
&isPositioner,
|
editCategory,
|
||||||
&isPositioner));
|
QKeySequence("Ctrl+f"),
|
||||||
|
180,
|
||||||
|
&resetSize,
|
||||||
|
&selectionNotEmptyAndHasWidthOrHeightProperty));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new VisiblityModelNodeAction(
|
||||||
(layoutRowPositionerDisplayName,
|
visiblityCommandId,
|
||||||
positionCategory,
|
visibilityDisplayName,
|
||||||
200,
|
editCategory,
|
||||||
&layoutRowPositioner,
|
QKeySequence("Ctrl+g"),
|
||||||
&selectionCanBeLayouted,
|
160,
|
||||||
&selectionCanBeLayouted));
|
&setVisible,
|
||||||
|
&singleSelectedItem));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ActionGroup(
|
||||||
(layoutColumnPositionerDisplayName,
|
anchorsCategoryDisplayName,
|
||||||
positionCategory,
|
anchorsCategory,
|
||||||
180,
|
priorityAnchorsCategory,
|
||||||
&layoutColumnPositioner,
|
&singleSelectionAndInBaseState));
|
||||||
&selectionCanBeLayouted,
|
|
||||||
&selectionCanBeLayouted));
|
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction(
|
||||||
(layoutGridPositionerDisplayName,
|
anchorsFillCommandId,
|
||||||
positionCategory,
|
anchorsFillDisplayName,
|
||||||
160,
|
Utils::Icon(":/qmldesigner/icon/designeractions/images/fill.png").icon(),
|
||||||
&layoutGridPositioner,
|
anchorsFillToolTip,
|
||||||
&selectionCanBeLayouted,
|
anchorsCategory,
|
||||||
&selectionCanBeLayouted));
|
QKeySequence(QKeySequence("Ctrl+f")),
|
||||||
|
200,
|
||||||
|
&anchorsFill,
|
||||||
|
&singleSelectionItemIsNotAnchoredAndSingleSelectionNotRoot));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction(
|
||||||
(layoutFlowPositionerDisplayName,
|
anchorsResetCommandId,
|
||||||
positionCategory,
|
anchorsResetDisplayName,
|
||||||
140,
|
Utils::Icon(":/qmldesigner/icon/designeractions/images/fill.png").icon(),
|
||||||
&layoutFlowPositioner,
|
anchorsResetToolTip,
|
||||||
&selectionCanBeLayouted,
|
anchorsCategory,
|
||||||
&selectionCanBeLayouted));
|
QKeySequence(QKeySequence("Ctrl+Shift+f")),
|
||||||
|
180,
|
||||||
|
&anchorsReset,
|
||||||
|
&singleSelectionItemIsAnchored));
|
||||||
|
|
||||||
addDesignerAction(new SeperatorDesignerAction(layoutCategory, 120));
|
addDesignerAction(new ActionGroup(
|
||||||
|
positionCategoryDisplayName,
|
||||||
|
positionCategory,
|
||||||
|
priorityPositionCategory,
|
||||||
|
&positionOptionVisible));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ActionGroup(
|
||||||
(removeLayoutDisplayName,
|
layoutCategoryDisplayName,
|
||||||
layoutCategory,
|
layoutCategory,
|
||||||
110,
|
priorityLayoutCategory,
|
||||||
&removeLayout,
|
&layoutOptionVisible));
|
||||||
&isLayout,
|
|
||||||
&isLayout));
|
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
(layoutRowLayoutDisplayName,
|
removePositionerCommandId,
|
||||||
layoutCategory,
|
removePositionerDisplayName,
|
||||||
100,
|
positionCategory,
|
||||||
&layoutRowLayout,
|
QKeySequence("Ctrl+Shift+p"),
|
||||||
&selectionCanBeLayoutedAndQtQuickLayoutPossible,
|
210,
|
||||||
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
&removePositioner,
|
||||||
|
&isPositioner,
|
||||||
|
&isPositioner));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
(layoutColumnLayoutDisplayName,
|
layoutRowPositionerCommandId,
|
||||||
layoutCategory,
|
layoutRowPositionerDisplayName,
|
||||||
80,
|
positionCategory,
|
||||||
&layoutColumnLayout,
|
QKeySequence(),
|
||||||
&selectionCanBeLayoutedAndQtQuickLayoutPossible,
|
200,
|
||||||
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
&layoutRowPositioner,
|
||||||
|
&selectionCanBeLayouted,
|
||||||
|
&selectionCanBeLayouted));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
(layoutGridLayoutDisplayName,
|
layoutColumnPositionerCommandId,
|
||||||
layoutCategory,
|
layoutColumnPositionerDisplayName,
|
||||||
60,
|
positionCategory,
|
||||||
&layoutGridLayout,
|
QKeySequence(),
|
||||||
&selectionCanBeLayoutedAndQtQuickLayoutPossible,
|
180,
|
||||||
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
&layoutColumnPositioner,
|
||||||
|
&selectionCanBeLayouted,
|
||||||
|
&selectionCanBeLayouted));
|
||||||
|
|
||||||
addDesignerAction(new FillWidthModelNodeAction
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
(layoutFillWidthDisplayName,
|
layoutGridPositionerCommandId,
|
||||||
layoutCategory,
|
layoutGridPositionerDisplayName,
|
||||||
40,
|
positionCategory,
|
||||||
&setFillWidth,
|
QKeySequence(),
|
||||||
&singleSelectionAndInQtQuickLayout,
|
160,
|
||||||
&singleSelectionAndInQtQuickLayout));
|
&layoutGridPositioner,
|
||||||
|
&selectionCanBeLayouted,
|
||||||
|
&selectionCanBeLayouted));
|
||||||
|
|
||||||
addDesignerAction(new FillHeightModelNodeAction
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
(layoutFillHeightDisplayName,
|
layoutFlowPositionerCommandId,
|
||||||
layoutCategory,
|
layoutFlowPositionerDisplayName,
|
||||||
20,
|
positionCategory,
|
||||||
&setFillHeight,
|
QKeySequence("Ctrl+m"),
|
||||||
&singleSelectionAndInQtQuickLayout,
|
140,
|
||||||
&singleSelectionAndInQtQuickLayout));
|
&layoutFlowPositioner,
|
||||||
|
&selectionCanBeLayouted,
|
||||||
|
&selectionCanBeLayouted));
|
||||||
|
|
||||||
|
addDesignerAction(new SeperatorDesignerAction(layoutCategory, 120));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
|
removeLayoutCommandId,
|
||||||
|
removeLayoutDisplayName,
|
||||||
|
layoutCategory,
|
||||||
|
QKeySequence("Ctrl+Shift+u"),
|
||||||
|
110,
|
||||||
|
&removeLayout,
|
||||||
|
&isLayout,
|
||||||
|
&isLayout));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeAction(
|
||||||
|
layoutRowLayoutCommandId,
|
||||||
|
layoutRowLayoutDisplayName,
|
||||||
|
Utils::Icon(":/qmldesigner/icon/designeractions/images/row.png").icon(),
|
||||||
|
layoutRowLayoutToolTip,
|
||||||
|
layoutCategory,
|
||||||
|
QKeySequence("Ctrl+u"),
|
||||||
|
100,
|
||||||
|
&layoutRowLayout,
|
||||||
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeAction(
|
||||||
|
layoutColumnLayoutCommandId,
|
||||||
|
layoutColumnLayoutDisplayName,
|
||||||
|
Utils::Icon(":/qmldesigner/icon/designeractions/images/column.png").icon(),
|
||||||
|
layoutColumnLayoutToolTip,
|
||||||
|
layoutCategory,
|
||||||
|
QKeySequence("Ctrl+i"),
|
||||||
|
80,
|
||||||
|
&layoutColumnLayout,
|
||||||
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeAction(
|
||||||
|
layoutGridLayoutCommandId,
|
||||||
|
layoutGridLayoutDisplayName,
|
||||||
|
Utils::Icon(":/qmldesigner/icon/designeractions/images/grid.png").icon(),
|
||||||
|
layoutGridLayoutToolTip,
|
||||||
|
layoutCategory,
|
||||||
|
QKeySequence("Ctrl+h"),
|
||||||
|
60,
|
||||||
|
&layoutGridLayout,
|
||||||
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
||||||
|
|
||||||
|
addDesignerAction(new FillWidthModelNodeAction(
|
||||||
|
layoutFillWidthCommandId,
|
||||||
|
layoutFillWidthDisplayName,
|
||||||
|
layoutCategory,
|
||||||
|
QKeySequence(),
|
||||||
|
40,
|
||||||
|
&setFillWidth,
|
||||||
|
&singleSelectionAndInQtQuickLayout,
|
||||||
|
&singleSelectionAndInQtQuickLayout));
|
||||||
|
|
||||||
|
addDesignerAction(new FillHeightModelNodeAction(
|
||||||
|
layoutFillHeightCommandId,
|
||||||
|
layoutFillHeightDisplayName,
|
||||||
|
layoutCategory,
|
||||||
|
QKeySequence(),
|
||||||
|
20,
|
||||||
|
&setFillHeight,
|
||||||
|
&singleSelectionAndInQtQuickLayout,
|
||||||
|
&singleSelectionAndInQtQuickLayout));
|
||||||
|
|
||||||
addDesignerAction(new SeperatorDesignerAction(rootCategory, priorityTopLevelSeperator));
|
addDesignerAction(new SeperatorDesignerAction(rootCategory, priorityTopLevelSeperator));
|
||||||
addDesignerAction(new ModelNodeAction
|
|
||||||
(goIntoComponentDisplayName, rootCategory, priorityGoIntoComponent, &goIntoComponent, &selectionIsComponent));
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
addDesignerAction(new ModelNodeAction
|
goIntoComponentCommandId,
|
||||||
(goToImplementationDisplayName, rootCategory, 42, &goImplementation, &singleSelectedAndUiFile, &singleSelectedAndUiFile));
|
goIntoComponentDisplayName,
|
||||||
addDesignerAction(new ModelNodeAction
|
rootCategory,
|
||||||
(addSignalHandlerDisplayName, rootCategory, 42, &addNewSignalHandler, &singleSelectedAndUiFile, &singleSelectedAndUiFile));
|
QKeySequence(),
|
||||||
addDesignerAction(new ModelNodeAction
|
priorityGoIntoComponent,
|
||||||
(moveToComponentDisplayName, rootCategory, 44, &moveToComponent, &singleSelection, &singleSelection));
|
&goIntoComponentOperation,
|
||||||
|
&selectionIsComponent));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
|
goToImplementationCommandId,
|
||||||
|
goToImplementationDisplayName,
|
||||||
|
rootCategory,
|
||||||
|
QKeySequence(),
|
||||||
|
42,
|
||||||
|
&goImplementation,
|
||||||
|
&singleSelectedAndUiFile,
|
||||||
|
&singleSelectedAndUiFile));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
|
addSignalHandlerCommandId,
|
||||||
|
addSignalHandlerDisplayName,
|
||||||
|
rootCategory, QKeySequence(),
|
||||||
|
42, &addNewSignalHandler,
|
||||||
|
&singleSelectedAndUiFile,
|
||||||
|
&singleSelectedAndUiFile));
|
||||||
|
|
||||||
|
addDesignerAction(new ModelNodeContextMenuAction(
|
||||||
|
moveToComponentCommandId,
|
||||||
|
moveToComponentDisplayName,
|
||||||
|
rootCategory,
|
||||||
|
QKeySequence(),
|
||||||
|
44,
|
||||||
|
&moveToComponent,
|
||||||
|
&singleSelection,
|
||||||
|
&singleSelection));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignerActionManager::addDesignerAction(ActionInterface *newAction)
|
void DesignerActionManager::addDesignerAction(ActionInterface *newAction)
|
||||||
@@ -522,6 +751,12 @@ void DesignerActionManager::addDesignerAction(ActionInterface *newAction)
|
|||||||
m_designerActionManagerView->setDesignerActionList(designerActions());
|
m_designerActionManagerView->setDesignerActionList(designerActions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DesignerActionManager::addCreatorCommand(Core::Command *command, const QByteArray &category, int priority,
|
||||||
|
const QIcon &overrideIcon)
|
||||||
|
{
|
||||||
|
addDesignerAction(new CommandAction(command, category, priority, overrideIcon));
|
||||||
|
}
|
||||||
|
|
||||||
QList<ActionInterface* > DesignerActionManager::designerActions() const
|
QList<ActionInterface* > DesignerActionManager::designerActions() const
|
||||||
{
|
{
|
||||||
QList<ActionInterface* > list;
|
QList<ActionInterface* > list;
|
||||||
@@ -541,4 +776,35 @@ DesignerActionManager::~DesignerActionManager()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DesignerActionToolBar::DesignerActionToolBar(QWidget *parentWidget) : Utils::StyledBar(parentWidget),
|
||||||
|
m_toolBar(new QToolBar("ActionToolBar", this))
|
||||||
|
{
|
||||||
|
m_toolBar->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_toolBar->setFloatable(true);
|
||||||
|
m_toolBar->setMovable(true);
|
||||||
|
m_toolBar->setOrientation(Qt::Horizontal);
|
||||||
|
|
||||||
|
QHBoxLayout *horizontalLayout = new QHBoxLayout(this);
|
||||||
|
|
||||||
|
horizontalLayout->setMargin(0);
|
||||||
|
horizontalLayout->setSpacing(0);
|
||||||
|
|
||||||
|
horizontalLayout->setMargin(0);
|
||||||
|
horizontalLayout->setSpacing(0);
|
||||||
|
|
||||||
|
horizontalLayout->addWidget(m_toolBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignerActionToolBar::registerAction(ActionInterface *action)
|
||||||
|
{
|
||||||
|
m_toolBar->addAction(action->action());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignerActionToolBar::addSeparator()
|
||||||
|
{
|
||||||
|
QAction *separatorAction = new QAction(m_toolBar);
|
||||||
|
separatorAction->setSeparator(true);
|
||||||
|
m_toolBar->addAction(separatorAction);
|
||||||
|
}
|
||||||
|
|
||||||
} //QmlDesigner
|
} //QmlDesigner
|
||||||
|
@@ -27,22 +27,42 @@
|
|||||||
|
|
||||||
#include <qmldesignercorelib_global.h>
|
#include <qmldesignercorelib_global.h>
|
||||||
#include "actioninterface.h"
|
#include "actioninterface.h"
|
||||||
#include "abstractview.h"
|
|
||||||
|
#include <coreplugin/actionmanager/command.h>
|
||||||
|
#include <utils/styledbar.h>
|
||||||
|
|
||||||
|
#include <QToolBar>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
class DesignerActionManagerView;
|
class DesignerActionManagerView;
|
||||||
|
|
||||||
|
class DesignerActionToolBar : public Utils::StyledBar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DesignerActionToolBar(QWidget *parentWidget);
|
||||||
|
void registerAction(ActionInterface *action);
|
||||||
|
void addSeparator();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QToolBar *m_toolBar;
|
||||||
|
};
|
||||||
|
|
||||||
class QMLDESIGNERCORE_EXPORT DesignerActionManager {
|
class QMLDESIGNERCORE_EXPORT DesignerActionManager {
|
||||||
public:
|
public:
|
||||||
DesignerActionManager(DesignerActionManagerView *designerActionManagerView);
|
DesignerActionManager(DesignerActionManagerView *designerActionManagerView);
|
||||||
~DesignerActionManager();
|
~DesignerActionManager();
|
||||||
|
|
||||||
void addDesignerAction(ActionInterface *newAction);
|
void addDesignerAction(ActionInterface *newAction);
|
||||||
|
void addCreatorCommand(Core::Command *command, const QByteArray &category, int priority,
|
||||||
|
const QIcon &overrideIcon = QIcon());
|
||||||
QList<ActionInterface* > designerActions() const;
|
QList<ActionInterface* > designerActions() const;
|
||||||
|
|
||||||
void createDefaultDesignerActions();
|
void createDefaultDesignerActions();
|
||||||
AbstractView *view();
|
DesignerActionManagerView *view();
|
||||||
|
|
||||||
|
DesignerActionToolBar *createToolBar(QWidget *parent = 0) const;
|
||||||
|
void polishActions() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QSharedPointer<ActionInterface> > m_designerActions;
|
QList<QSharedPointer<ActionInterface> > m_designerActions;
|
||||||
|
@@ -99,9 +99,15 @@ void DesignerActionManagerView::currentStateChanged(const ModelNode &)
|
|||||||
setupContext();
|
setupContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignerActionManagerView::selectedNodesChanged(const QList<ModelNode> &, const QList<ModelNode> &)
|
void DesignerActionManagerView::selectedNodesChanged(const QList<ModelNode> &selectedNodes, const QList<ModelNode> &)
|
||||||
{
|
{
|
||||||
setupContext();
|
setupContext();
|
||||||
|
|
||||||
|
/* This breaks encapsulation, but the selection state is a very minor information.
|
||||||
|
* Without this signal the ShortcutManager would have to be refactored completely.
|
||||||
|
* This signal is only used to update the state of the cut/copy/delete actions.
|
||||||
|
*/
|
||||||
|
emit selectionChanged(!selectedNodes.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesignerActionManagerView::nodeOrderChanged(const NodeListProperty &, const ModelNode &, int)
|
void DesignerActionManagerView::nodeOrderChanged(const NodeListProperty &, const ModelNode &, int)
|
||||||
@@ -124,6 +130,18 @@ void DesignerActionManagerView::signalHandlerPropertiesChanged(const QVector<Sig
|
|||||||
setupContext();
|
setupContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DesignerActionManagerView::variantPropertiesChanged(const QList<VariantProperty> &, AbstractView::PropertyChangeFlags propertyChangeFlag)
|
||||||
|
{
|
||||||
|
if (propertyChangeFlag == AbstractView::PropertiesAdded)
|
||||||
|
setupContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignerActionManagerView::bindingPropertiesChanged(const QList<BindingProperty> &, AbstractView::PropertyChangeFlags propertyChangeFlag)
|
||||||
|
{
|
||||||
|
if (propertyChangeFlag == AbstractView::PropertiesAdded)
|
||||||
|
setupContext();
|
||||||
|
}
|
||||||
|
|
||||||
DesignerActionManager &DesignerActionManagerView::designerActionManager()
|
DesignerActionManager &DesignerActionManagerView::designerActionManager()
|
||||||
{
|
{
|
||||||
return m_designerActionManager;
|
return m_designerActionManager;
|
||||||
|
@@ -60,11 +60,16 @@ public:
|
|||||||
void nodeOrderChanged(const NodeListProperty &, const ModelNode &, int ) override;
|
void nodeOrderChanged(const NodeListProperty &, const ModelNode &, int ) override;
|
||||||
void importsChanged(const QList<Import> &, const QList<Import> &) override;
|
void importsChanged(const QList<Import> &, const QList<Import> &) override;
|
||||||
void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &/*propertyList*/, PropertyChangeFlags /*propertyChange*/) override;
|
void signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &/*propertyList*/, PropertyChangeFlags /*propertyChange*/) override;
|
||||||
|
void variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChangeFlag) override;
|
||||||
|
void bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChangeFlag) override;
|
||||||
|
|
||||||
void setDesignerActionList(const QList<ActionInterface* > &designerActionList);
|
void setDesignerActionList(const QList<ActionInterface* > &designerActionList);
|
||||||
DesignerActionManager &designerActionManager();
|
DesignerActionManager &designerActionManager();
|
||||||
const DesignerActionManager &designerActionManager() const;
|
const DesignerActionManager &designerActionManager() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void selectionChanged(bool itemsSelected);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setupContext();
|
void setupContext();
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 655 B |
After Width: | Height: | Size: 273 B |
BIN
src/plugins/qmldesigner/components/componentcore/images/fill.png
Normal file
After Width: | Height: | Size: 419 B |
BIN
src/plugins/qmldesigner/components/componentcore/images/grid.png
Normal file
After Width: | Height: | Size: 354 B |
After Width: | Height: | Size: 414 B |
BIN
src/plugins/qmldesigner/components/componentcore/images/move.png
Normal file
After Width: | Height: | Size: 309 B |
After Width: | Height: | Size: 345 B |
BIN
src/plugins/qmldesigner/components/componentcore/images/row.png
Normal file
After Width: | Height: | Size: 294 B |
BIN
src/plugins/qmldesigner/components/componentcore/images/size.png
Normal file
After Width: | Height: | Size: 342 B |
@@ -69,7 +69,7 @@ void populateMenu(QSet<ActionInterface* > &actionInterfaces,
|
|||||||
});
|
});
|
||||||
|
|
||||||
foreach (ActionInterface* actionInterface, matchingFactoriesList) {
|
foreach (ActionInterface* actionInterface, matchingFactoriesList) {
|
||||||
if (actionInterface->type() == ActionInterface::Menu) {
|
if (actionInterface->type() == ActionInterface::ContextMenu) {
|
||||||
actionInterface->currentContextChanged(selectionContext);
|
actionInterface->currentContextChanged(selectionContext);
|
||||||
QMenu *newMenu = actionInterface->action()->menu();
|
QMenu *newMenu = actionInterface->action()->menu();
|
||||||
menu->addMenu(newMenu);
|
menu->addMenu(newMenu);
|
||||||
@@ -77,9 +77,11 @@ void populateMenu(QSet<ActionInterface* > &actionInterfaces,
|
|||||||
//recurse
|
//recurse
|
||||||
|
|
||||||
populateMenu(actionInterfaces, actionInterface->menuId(), newMenu, selectionContext);
|
populateMenu(actionInterfaces, actionInterface->menuId(), newMenu, selectionContext);
|
||||||
} else if (actionInterface->type() == ActionInterface::Action) {
|
} else if (actionInterface->type() == ActionInterface::ContextMenuAction
|
||||||
|
|| actionInterface->type() == ActionInterface::Action) {
|
||||||
QAction* action = actionInterface->action();
|
QAction* action = actionInterface->action();
|
||||||
actionInterface->currentContextChanged(selectionContext);
|
actionInterface->currentContextChanged(selectionContext);
|
||||||
|
action->setIconVisibleInMenu(false);
|
||||||
menu->addAction(action);
|
menu->addAction(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,12 +30,19 @@
|
|||||||
#include "abstractactiongroup.h"
|
#include "abstractactiongroup.h"
|
||||||
#include "qmlitemnode.h"
|
#include "qmlitemnode.h"
|
||||||
|
|
||||||
|
#include <coreplugin/actionmanager/command.h>
|
||||||
|
|
||||||
|
#include <utils/proxyaction.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
typedef bool (*SelectionContextFunction)(const SelectionContext &);
|
typedef std::function<bool (const SelectionContext &context)> SelectionContextPredicate;
|
||||||
|
typedef std::function<void (const SelectionContext &context)> SelectionContextOperation;
|
||||||
|
|
||||||
namespace SelectionContextFunctors {
|
namespace SelectionContextFunctors {
|
||||||
|
|
||||||
@@ -96,7 +103,7 @@ class ActionTemplate : public DefaultAction
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActionTemplate(const QString &description, ModelNodeOperations::SelectionAction action)
|
ActionTemplate(const QString &description, SelectionContextOperation action)
|
||||||
: DefaultAction(description), m_action(action)
|
: DefaultAction(description), m_action(action)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -104,17 +111,18 @@ public /*slots*/:
|
|||||||
virtual void actionTriggered(bool b)
|
virtual void actionTriggered(bool b)
|
||||||
{
|
{
|
||||||
m_selectionContext.setToggled(b);
|
m_selectionContext.setToggled(b);
|
||||||
return m_action(m_selectionContext);
|
m_action(m_selectionContext);
|
||||||
}
|
}
|
||||||
ModelNodeOperations::SelectionAction m_action;
|
|
||||||
|
SelectionContextOperation m_action;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ActionGroup : public AbstractActionGroup
|
class ActionGroup : public AbstractActionGroup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ActionGroup(const QString &displayName, const QByteArray &menuId, int priority,
|
ActionGroup(const QString &displayName, const QByteArray &menuId, int priority,
|
||||||
SelectionContextFunction enabled = &SelectionContextFunctors::always,
|
SelectionContextPredicate enabled = &SelectionContextFunctors::always,
|
||||||
SelectionContextFunction visibility = &SelectionContextFunctors::always) :
|
SelectionContextPredicate visibility = &SelectionContextFunctors::always) :
|
||||||
AbstractActionGroup(displayName),
|
AbstractActionGroup(displayName),
|
||||||
m_menuId(menuId),
|
m_menuId(menuId),
|
||||||
m_priority(priority),
|
m_priority(priority),
|
||||||
@@ -128,13 +136,13 @@ public:
|
|||||||
QByteArray category() const { return QByteArray(); }
|
QByteArray category() const { return QByteArray(); }
|
||||||
QByteArray menuId() const { return m_menuId; }
|
QByteArray menuId() const { return m_menuId; }
|
||||||
int priority() const { return m_priority; }
|
int priority() const { return m_priority; }
|
||||||
Type type() const { return Menu; }
|
Type type() const { return ContextMenu; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QByteArray m_menuId;
|
const QByteArray m_menuId;
|
||||||
const int m_priority;
|
const int m_priority;
|
||||||
SelectionContextFunction m_enabled;
|
SelectionContextPredicate m_enabled;
|
||||||
SelectionContextFunction m_visibility;
|
SelectionContextPredicate m_visibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SeperatorDesignerAction : public AbstractAction
|
class SeperatorDesignerAction : public AbstractAction
|
||||||
@@ -151,41 +159,82 @@ public:
|
|||||||
QByteArray category() const { return m_category; }
|
QByteArray category() const { return m_category; }
|
||||||
QByteArray menuId() const { return QByteArray(); }
|
QByteArray menuId() const { return QByteArray(); }
|
||||||
int priority() const { return m_priority; }
|
int priority() const { return m_priority; }
|
||||||
Type type() const { return Action; }
|
Type type() const { return ContextMenuAction; }
|
||||||
void currentContextChanged(const SelectionContext &) {}
|
void currentContextChanged(const SelectionContext &) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QByteArray m_category;
|
const QByteArray m_category;
|
||||||
const int m_priority;
|
const int m_priority;
|
||||||
SelectionContextFunction m_visibility;
|
SelectionContextPredicate m_visibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ModelNodeAction : public AbstractAction
|
class CommandAction : public ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ModelNodeAction(const QString &description, const QByteArray &category, int priority,
|
CommandAction(Core::Command *command, const QByteArray &category, int priority, const QIcon &overrideIcon) :
|
||||||
ModelNodeOperations::SelectionAction selectionAction,
|
m_action(overrideIcon.isNull() ? command->action() : Utils::ProxyAction::proxyActionWithIcon(command->action(), overrideIcon)),
|
||||||
SelectionContextFunction enabled = &SelectionContextFunctors::always,
|
m_category(category),
|
||||||
SelectionContextFunction visibility = &SelectionContextFunctors::always) :
|
m_priority(priority)
|
||||||
|
{}
|
||||||
|
|
||||||
|
QAction *action() const override { return m_action; }
|
||||||
|
QByteArray category() const override { return m_category; }
|
||||||
|
QByteArray menuId() const override { return QByteArray(); }
|
||||||
|
int priority() const override { return m_priority; }
|
||||||
|
Type type() const override { return Action; }
|
||||||
|
void currentContextChanged(const SelectionContext &) override {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QAction *m_action;
|
||||||
|
const QByteArray m_category;
|
||||||
|
const int m_priority;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ModelNodeContextMenuAction : public AbstractAction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ModelNodeContextMenuAction(const QByteArray &id, const QString &description, const QByteArray &category, const QKeySequence &key, int priority,
|
||||||
|
SelectionContextOperation selectionAction,
|
||||||
|
SelectionContextPredicate enabled = &SelectionContextFunctors::always,
|
||||||
|
SelectionContextPredicate visibility = &SelectionContextFunctors::always) :
|
||||||
AbstractAction(new ActionTemplate(description, selectionAction)),
|
AbstractAction(new ActionTemplate(description, selectionAction)),
|
||||||
|
m_id(id),
|
||||||
m_category(category),
|
m_category(category),
|
||||||
m_priority(priority),
|
m_priority(priority),
|
||||||
m_enabled(enabled),
|
m_enabled(enabled),
|
||||||
m_visibility(visibility)
|
m_visibility(visibility)
|
||||||
{}
|
{
|
||||||
|
action()->setShortcut(key);
|
||||||
|
}
|
||||||
|
|
||||||
bool isVisible(const SelectionContext &selectionState) const { return m_visibility(selectionState); }
|
bool isVisible(const SelectionContext &selectionState) const override { return m_visibility(selectionState); }
|
||||||
bool isEnabled(const SelectionContext &selectionState) const { return m_enabled(selectionState); }
|
bool isEnabled(const SelectionContext &selectionState) const override { return m_enabled(selectionState); }
|
||||||
QByteArray category() const { return m_category; }
|
QByteArray category() const override { return m_category; }
|
||||||
QByteArray menuId() const { return QByteArray(); }
|
QByteArray menuId() const override { return m_id; }
|
||||||
int priority() const { return m_priority; }
|
int priority() const override { return m_priority; }
|
||||||
Type type() const { return Action; }
|
Type type() const override { return ContextMenuAction; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const QByteArray m_id;
|
||||||
const QByteArray m_category;
|
const QByteArray m_category;
|
||||||
const int m_priority;
|
const int m_priority;
|
||||||
const SelectionContextFunction m_enabled;
|
const SelectionContextPredicate m_enabled;
|
||||||
const SelectionContextFunction m_visibility;
|
const SelectionContextPredicate m_visibility;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ModelNodeAction : public ModelNodeContextMenuAction
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ModelNodeAction(const QByteArray &id, const QString &description, const QIcon &icon, const QString &tooltip, const QByteArray &category, const QKeySequence &key, int priority,
|
||||||
|
SelectionContextOperation selectionAction,
|
||||||
|
SelectionContextPredicate enabled = &SelectionContextFunctors::always) :
|
||||||
|
ModelNodeContextMenuAction(id, description, category, key, priority, selectionAction, enabled, &SelectionContextFunctors::always)
|
||||||
|
{
|
||||||
|
action()->setIcon(icon);
|
||||||
|
action()->setToolTip(tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
Type type() const override { return Action; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -341,7 +341,7 @@ void resetPosition(const SelectionContext &selectionState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void goIntoComponent(const SelectionContext &selectionState)
|
void goIntoComponentOperation(const SelectionContext &selectionState)
|
||||||
{
|
{
|
||||||
goIntoComponent(selectionState.currentSingleSelectedNode());
|
goIntoComponent(selectionState.currentSingleSelectedNode());
|
||||||
}
|
}
|
||||||
|
@@ -32,8 +32,6 @@ namespace ModelNodeOperations {
|
|||||||
|
|
||||||
void goIntoComponent(const ModelNode &modelNode);
|
void goIntoComponent(const ModelNode &modelNode);
|
||||||
|
|
||||||
typedef void (*SelectionAction)(const SelectionContext &);
|
|
||||||
|
|
||||||
void select(const SelectionContext &selectionState);
|
void select(const SelectionContext &selectionState);
|
||||||
void deSelect(const SelectionContext &selectionState);
|
void deSelect(const SelectionContext &selectionState);
|
||||||
void cut(const SelectionContext &selectionState);
|
void cut(const SelectionContext &selectionState);
|
||||||
@@ -51,7 +49,7 @@ void setFillWidth(const SelectionContext &selectionState);
|
|||||||
void setFillHeight(const SelectionContext &selectionState);
|
void setFillHeight(const SelectionContext &selectionState);
|
||||||
void resetSize(const SelectionContext &selectionState);
|
void resetSize(const SelectionContext &selectionState);
|
||||||
void resetPosition(const SelectionContext &selectionState);
|
void resetPosition(const SelectionContext &selectionState);
|
||||||
void goIntoComponent(const SelectionContext &selectionState);
|
void goIntoComponentOperation(const SelectionContext &selectionState);
|
||||||
void setId(const SelectionContext &selectionState);
|
void setId(const SelectionContext &selectionState);
|
||||||
void resetZ(const SelectionContext &selectionState);
|
void resetZ(const SelectionContext &selectionState);
|
||||||
void anchorsFill(const SelectionContext &selectionState);
|
void anchorsFill(const SelectionContext &selectionState);
|
||||||
|
@@ -51,20 +51,9 @@ namespace QmlDesigner {
|
|||||||
|
|
||||||
FormEditorView::FormEditorView(QObject *parent)
|
FormEditorView::FormEditorView(QObject *parent)
|
||||||
: AbstractView(parent),
|
: AbstractView(parent),
|
||||||
m_formEditorWidget(new FormEditorWidget(this)),
|
|
||||||
m_scene(new FormEditorScene(m_formEditorWidget.data(), this)),
|
|
||||||
m_moveTool(new MoveTool(this)),
|
|
||||||
m_selectionTool(new SelectionTool(this)),
|
|
||||||
m_resizeTool(new ResizeTool(this)),
|
|
||||||
m_dragTool(new DragTool(this)),
|
|
||||||
m_currentTool(m_selectionTool.get()),
|
|
||||||
m_transactionCounter(0)
|
m_transactionCounter(0)
|
||||||
{
|
{
|
||||||
Internal::FormEditorContext *formEditorContext = new Internal::FormEditorContext(m_formEditorWidget.data());
|
|
||||||
Core::ICore::addContextObject(formEditorContext);
|
|
||||||
|
|
||||||
connect(formEditorWidget()->zoomAction(), SIGNAL(zoomLevelChanged(double)), SLOT(updateGraphicsIndicators()));
|
|
||||||
connect(formEditorWidget()->showBoundingRectAction(), SIGNAL(toggled(bool)), scene(), SLOT(setShowBoundingRects(bool)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FormEditorScene* FormEditorView::scene() const
|
FormEditorScene* FormEditorView::scene() const
|
||||||
@@ -148,6 +137,25 @@ void FormEditorView::hideNodeFromScene(const QmlItemNode &qmlItemNode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormEditorView::createFormEditorWidget()
|
||||||
|
{
|
||||||
|
m_formEditorWidget = QPointer<FormEditorWidget>(new FormEditorWidget(this));
|
||||||
|
m_scene = QPointer<FormEditorScene>(new FormEditorScene(m_formEditorWidget.data(), this));
|
||||||
|
|
||||||
|
m_moveTool.reset(new MoveTool(this));
|
||||||
|
m_selectionTool.reset(new SelectionTool(this));
|
||||||
|
m_resizeTool.reset(new ResizeTool(this));
|
||||||
|
m_dragTool.reset(new DragTool(this));
|
||||||
|
|
||||||
|
m_currentTool = m_selectionTool.get();
|
||||||
|
|
||||||
|
Internal::FormEditorContext *formEditorContext = new Internal::FormEditorContext(m_formEditorWidget.data());
|
||||||
|
Core::ICore::addContextObject(formEditorContext);
|
||||||
|
|
||||||
|
connect(formEditorWidget()->zoomAction(), SIGNAL(zoomLevelChanged(double)), SLOT(updateGraphicsIndicators()));
|
||||||
|
connect(formEditorWidget()->showBoundingRectAction(), SIGNAL(toggled(bool)), scene(), SLOT(setShowBoundingRects(bool)));
|
||||||
|
}
|
||||||
|
|
||||||
void FormEditorView::nodeCreated(const ModelNode &node)
|
void FormEditorView::nodeCreated(const ModelNode &node)
|
||||||
{
|
{
|
||||||
//If the node has source for components/custom parsers we ignore it.
|
//If the node has source for components/custom parsers we ignore it.
|
||||||
@@ -246,6 +254,10 @@ void FormEditorView::nodeReparented(const ModelNode &node, const NodeAbstractPro
|
|||||||
|
|
||||||
WidgetInfo FormEditorView::widgetInfo()
|
WidgetInfo FormEditorView::widgetInfo()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (!m_formEditorWidget)
|
||||||
|
createFormEditorWidget();
|
||||||
|
|
||||||
return createWidgetInfo(m_formEditorWidget.data(), 0, "FormEditor", WidgetInfo::CentralPane, 0, tr("Form Editor"));
|
return createWidgetInfo(m_formEditorWidget.data(), 0, "FormEditor", WidgetInfo::CentralPane, 0, tr("Form Editor"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -123,6 +123,7 @@ private: //functions
|
|||||||
void setupFormEditorItemTree(const QmlItemNode &qmlItemNode);
|
void setupFormEditorItemTree(const QmlItemNode &qmlItemNode);
|
||||||
void removeNodeFromScene(const QmlItemNode &qmlItemNode);
|
void removeNodeFromScene(const QmlItemNode &qmlItemNode);
|
||||||
void hideNodeFromScene(const QmlItemNode &qmlItemNode);
|
void hideNodeFromScene(const QmlItemNode &qmlItemNode);
|
||||||
|
void createFormEditorWidget();
|
||||||
|
|
||||||
private: //variables
|
private: //variables
|
||||||
QPointer<FormEditorWidget> m_formEditorWidget;
|
QPointer<FormEditorWidget> m_formEditorWidget;
|
||||||
|
@@ -23,11 +23,13 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "designeractionmanager.h"
|
||||||
#include "formeditorwidget.h"
|
#include "formeditorwidget.h"
|
||||||
#include "qmldesignerplugin.h"
|
#include "qmldesignerplugin.h"
|
||||||
#include "designersettings.h"
|
#include "designersettings.h"
|
||||||
#include "qmldesignerconstants.h"
|
#include "qmldesignerconstants.h"
|
||||||
#include "qmldesignericons.h"
|
#include "qmldesignericons.h"
|
||||||
|
#include "viewmanager.h"
|
||||||
#include <theming.h>
|
#include <theming.h>
|
||||||
|
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
@@ -121,8 +123,17 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
|
|||||||
addAction(m_rootHeightAction.data());
|
addAction(m_rootHeightAction.data());
|
||||||
upperActions.append(m_rootHeightAction.data());
|
upperActions.append(m_rootHeightAction.data());
|
||||||
|
|
||||||
|
static const QList<Utils::Icon> icon = {
|
||||||
|
Utils::Icon({{":/baremetal/images/baremetaldevicesmall.png",
|
||||||
|
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint),
|
||||||
|
Utils::Icon({{":/baremetal/images/baremetaldevice.png",
|
||||||
|
Utils::Theme::IconsBaseColor}})};
|
||||||
|
|
||||||
|
|
||||||
m_toolBox = new ToolBox(this);
|
m_toolBox = new ToolBox(this);
|
||||||
fillLayout->addWidget(m_toolBox.data());
|
fillLayout->addWidget(m_toolBox.data());
|
||||||
|
|
||||||
|
|
||||||
m_toolBox->setLeftSideActions(upperActions);
|
m_toolBox->setLeftSideActions(upperActions);
|
||||||
|
|
||||||
m_backgroundAction = new BackgroundAction(m_toolActionGroup.data());
|
m_backgroundAction = new BackgroundAction(m_toolActionGroup.data());
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QVBoxLayout>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
|
||||||
|
@@ -77,7 +77,7 @@ int AddTabDesignerAction::priority() const
|
|||||||
|
|
||||||
ActionInterface::Type AddTabDesignerAction::type() const
|
ActionInterface::Type AddTabDesignerAction::type() const
|
||||||
{
|
{
|
||||||
return Action;
|
return ContextMenuAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AddTabDesignerAction::isVisible(const SelectionContext &selectionContext) const
|
bool AddTabDesignerAction::isVisible(const SelectionContext &selectionContext) const
|
||||||
|
@@ -54,6 +54,8 @@ class ViewManagerData
|
|||||||
public:
|
public:
|
||||||
QmlModelState savedState;
|
QmlModelState savedState;
|
||||||
Internal::DebugView debugView;
|
Internal::DebugView debugView;
|
||||||
|
DesignerActionManagerView designerActionManagerView;
|
||||||
|
NodeInstanceView nodeInstanceView;
|
||||||
ComponentView componentView;
|
ComponentView componentView;
|
||||||
FormEditorView formEditorView;
|
FormEditorView formEditorView;
|
||||||
TextEditorView textEditorView;
|
TextEditorView textEditorView;
|
||||||
@@ -61,8 +63,6 @@ public:
|
|||||||
NavigatorView navigatorView;
|
NavigatorView navigatorView;
|
||||||
PropertyEditorView propertyEditorView;
|
PropertyEditorView propertyEditorView;
|
||||||
StatesEditorView statesEditorView;
|
StatesEditorView statesEditorView;
|
||||||
NodeInstanceView nodeInstanceView;
|
|
||||||
DesignerActionManagerView designerActionManagerView;
|
|
||||||
|
|
||||||
QList<QPointer<AbstractView> > additionalViews;
|
QList<QPointer<AbstractView> > additionalViews;
|
||||||
};
|
};
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "designmodewidget.h"
|
#include "designmodewidget.h"
|
||||||
|
|
||||||
|
#include <designeractionmanager.h>
|
||||||
|
|
||||||
#include <coreplugin/outputpane.h>
|
#include <coreplugin/outputpane.h>
|
||||||
#include "qmldesignerplugin.h"
|
#include "qmldesignerplugin.h"
|
||||||
#include "crumblebar.h"
|
#include "crumblebar.h"
|
||||||
@@ -299,7 +301,14 @@ void DesignModeWidget::setup()
|
|||||||
QToolBar *toolBar = new QToolBar;
|
QToolBar *toolBar = new QToolBar;
|
||||||
toolBar->addAction(viewManager().componentViewAction());
|
toolBar->addAction(viewManager().componentViewAction());
|
||||||
toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
m_toolBar->addCenterToolBar(toolBar);
|
DesignerActionToolBar *designerToolBar = QmlDesignerPlugin::instance()->viewManager().designerActionManager().createToolBar(m_toolBar);
|
||||||
|
|
||||||
|
QmlDesignerPlugin::instance()->viewManager().designerActionManager().polishActions();
|
||||||
|
designerToolBar->layout()->addWidget(toolBar);
|
||||||
|
|
||||||
|
m_toolBar->addCenterToolBar(designerToolBar);
|
||||||
|
|
||||||
|
m_toolBar->setMinimumWidth(320);
|
||||||
|
|
||||||
m_mainSplitter = new MiniSplitter(this);
|
m_mainSplitter = new MiniSplitter(this);
|
||||||
m_mainSplitter->setObjectName("mainSplitter");
|
m_mainSplitter->setObjectName("mainSplitter");
|
||||||
|
@@ -70,7 +70,7 @@ public:
|
|||||||
|
|
||||||
Type type() const
|
Type type() const
|
||||||
{
|
{
|
||||||
return Action;
|
return ContextMenuAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -118,7 +118,7 @@ public:
|
|||||||
|
|
||||||
Type type() const
|
Type type() const
|
||||||
{
|
{
|
||||||
return Action;
|
return ContextMenuAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -89,7 +89,7 @@ public:
|
|||||||
|
|
||||||
Type type() const
|
Type type() const
|
||||||
{
|
{
|
||||||
return Action;
|
return ContextMenuAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -71,7 +71,7 @@ public:
|
|||||||
|
|
||||||
Type type() const
|
Type type() const
|
||||||
{
|
{
|
||||||
return Action;
|
return ContextMenuAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
#include "designersettings.h"
|
#include "designersettings.h"
|
||||||
|
|
||||||
|
#include <viewmanager.h>
|
||||||
|
#include <designeractionmanagerview.h>
|
||||||
|
#include <componentcore_constants.h>
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/actionmanager/command.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
@@ -39,6 +43,8 @@
|
|||||||
#include <qmljseditor/qmljseditordocument.h>
|
#include <qmljseditor/qmljseditordocument.h>
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
|
#include <utils/proxyaction.h>
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <qmljs/qmljsreformatter.h>
|
#include <qmljs/qmljsreformatter.h>
|
||||||
@@ -47,6 +53,14 @@
|
|||||||
#include "qmldesignerplugin.h"
|
#include "qmldesignerplugin.h"
|
||||||
#include "designmodewidget.h"
|
#include "designmodewidget.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
|
|
||||||
|
static void updateClipboard(QAction *action)
|
||||||
|
{
|
||||||
|
const bool dataInClipboard = !QApplication::clipboard()->text().isEmpty();
|
||||||
|
action->setEnabled(dataInClipboard);
|
||||||
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -139,6 +153,8 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Core::Command *command = nullptr;
|
||||||
|
|
||||||
//Save As
|
//Save As
|
||||||
Core::ActionManager::registerAction(&m_saveAsAction, Core::Constants::SAVEAS, qmlDesignerMainContext);
|
Core::ActionManager::registerAction(&m_saveAsAction, Core::Constants::SAVEAS, qmlDesignerMainContext);
|
||||||
connect(&m_saveAsAction, SIGNAL(triggered()), em, SLOT(saveDocumentAs()));
|
connect(&m_saveAsAction, SIGNAL(triggered()), em, SLOT(saveDocumentAs()));
|
||||||
@@ -147,6 +163,8 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
Core::ActionManager::registerAction(&m_closeCurrentEditorAction, Core::Constants::CLOSE, qmlDesignerMainContext);
|
Core::ActionManager::registerAction(&m_closeCurrentEditorAction, Core::Constants::CLOSE, qmlDesignerMainContext);
|
||||||
connect(&m_closeCurrentEditorAction, SIGNAL(triggered()), em, SLOT(slotCloseCurrentEditorOrDocument()));
|
connect(&m_closeCurrentEditorAction, SIGNAL(triggered()), em, SLOT(slotCloseCurrentEditorOrDocument()));
|
||||||
|
|
||||||
|
DesignerActionManager &designerActionManager = QmlDesignerPlugin::instance()->viewManager().designerActionManager();
|
||||||
|
|
||||||
//Close All
|
//Close All
|
||||||
Core::ActionManager::registerAction(&m_closeAllEditorsAction, Core::Constants::CLOSEALL, qmlDesignerMainContext);
|
Core::ActionManager::registerAction(&m_closeAllEditorsAction, Core::Constants::CLOSEALL, qmlDesignerMainContext);
|
||||||
connect(&m_closeAllEditorsAction, SIGNAL(triggered()), em, SLOT(closeAllEditors()));
|
connect(&m_closeAllEditorsAction, SIGNAL(triggered()), em, SLOT(closeAllEditors()));
|
||||||
@@ -156,10 +174,11 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
connect(&m_closeOtherEditorsAction, SIGNAL(triggered()), em, SLOT(closeOtherDocuments()));
|
connect(&m_closeOtherEditorsAction, SIGNAL(triggered()), em, SLOT(closeOtherDocuments()));
|
||||||
|
|
||||||
// Undo / Redo
|
// Undo / Redo
|
||||||
Core::ActionManager::registerAction(&m_undoAction, Core::Constants::UNDO, qmlDesignerMainContext);
|
command = Core::ActionManager::registerAction(&m_undoAction, Core::Constants::UNDO, qmlDesignerMainContext);
|
||||||
Core::ActionManager::registerAction(&m_redoAction, Core::Constants::REDO, qmlDesignerMainContext);
|
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 310, Utils::Icons::UNDO_TOOLBAR.icon());
|
||||||
|
command = Core::ActionManager::registerAction(&m_redoAction, Core::Constants::REDO, qmlDesignerMainContext);
|
||||||
|
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 300, Utils::Icons::REDO_TOOLBAR.icon());
|
||||||
|
|
||||||
Core::Command *command;
|
|
||||||
|
|
||||||
//GoIntoComponent
|
//GoIntoComponent
|
||||||
command = Core::ActionManager::registerAction(&m_goIntoComponentAction,
|
command = Core::ActionManager::registerAction(&m_goIntoComponentAction,
|
||||||
@@ -168,6 +187,8 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
|
|
||||||
//Edit Menu
|
//Edit Menu
|
||||||
|
|
||||||
|
m_deleteAction.setIcon(QIcon::fromTheme(QLatin1String("edit-cut"), Utils::Icons::EDIT_CLEAR_TOOLBAR.icon()));
|
||||||
|
|
||||||
Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_BACKSPACE, qmlDesignerFormEditorContext);
|
Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_BACKSPACE, qmlDesignerFormEditorContext);
|
||||||
command = Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_BACKSPACE, qmlDesignerNavigatorContext);
|
command = Core::ActionManager::registerAction(&m_deleteAction, QmlDesigner::Constants::C_BACKSPACE, qmlDesignerNavigatorContext);
|
||||||
command->setDefaultKeySequence(QKeySequence(Qt::Key_Backspace));
|
command->setDefaultKeySequence(QKeySequence(Qt::Key_Backspace));
|
||||||
@@ -181,21 +202,25 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes
|
command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes
|
||||||
if (!Utils::HostOsInfo::isMacHost())
|
if (!Utils::HostOsInfo::isMacHost())
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
|
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 280);
|
||||||
|
|
||||||
Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerFormEditorContext);
|
Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerFormEditorContext);
|
||||||
command = Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerNavigatorContext);
|
command = Core::ActionManager::registerAction(&m_cutAction, Core::Constants::CUT, qmlDesignerNavigatorContext);
|
||||||
command->setDefaultKeySequence(QKeySequence::Cut);
|
command->setDefaultKeySequence(QKeySequence::Cut);
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
|
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 260, Utils::Icons::CUT_TOOLBAR.icon());
|
||||||
|
|
||||||
Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerFormEditorContext);
|
Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerFormEditorContext);
|
||||||
command = Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerNavigatorContext);
|
command = Core::ActionManager::registerAction(&m_copyAction, Core::Constants::COPY, qmlDesignerNavigatorContext);
|
||||||
command->setDefaultKeySequence(QKeySequence::Copy);
|
command->setDefaultKeySequence(QKeySequence::Copy);
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
|
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 250, Utils::Icons::COPY_TOOLBAR.icon());
|
||||||
|
|
||||||
Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerFormEditorContext);
|
Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerFormEditorContext);
|
||||||
command = Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerNavigatorContext);
|
command = Core::ActionManager::registerAction(&m_pasteAction, Core::Constants::PASTE, qmlDesignerNavigatorContext);
|
||||||
command->setDefaultKeySequence(QKeySequence::Paste);
|
command->setDefaultKeySequence(QKeySequence::Paste);
|
||||||
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
|
||||||
|
designerActionManager.addCreatorCommand(command, ComponentCoreConstants::editCategory, 240, Utils::Icons::PASTE_TOOLBAR.icon());
|
||||||
|
|
||||||
Core::ActionManager::registerAction(&m_selectAllAction, Core::Constants::SELECTALL, qmlDesignerFormEditorContext);
|
Core::ActionManager::registerAction(&m_selectAllAction, Core::Constants::SELECTALL, qmlDesignerFormEditorContext);
|
||||||
command = Core::ActionManager::registerAction(&m_selectAllAction, Core::Constants::SELECTALL, qmlDesignerNavigatorContext);
|
command = Core::ActionManager::registerAction(&m_selectAllAction, Core::Constants::SELECTALL, qmlDesignerNavigatorContext);
|
||||||
@@ -225,6 +250,17 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
m_escapeAction.setEnabled(false);
|
m_escapeAction.setEnabled(false);
|
||||||
|
|
||||||
Core::ActionManager::registerAction(&m_hideSidebarsAction, Core::Constants::TOGGLE_SIDEBAR, qmlDesignerMainContext);
|
Core::ActionManager::registerAction(&m_hideSidebarsAction, Core::Constants::TOGGLE_SIDEBAR, qmlDesignerMainContext);
|
||||||
|
|
||||||
|
connect(designerActionManager.view(), &DesignerActionManagerView::selectionChanged, this, [this](bool itemsSelected) {
|
||||||
|
m_deleteAction.setEnabled(itemsSelected);
|
||||||
|
m_cutAction.setEnabled(itemsSelected);
|
||||||
|
m_copyAction.setEnabled(itemsSelected);
|
||||||
|
});
|
||||||
|
|
||||||
|
updateClipboard(&m_pasteAction);
|
||||||
|
connect(QApplication::clipboard(), &QClipboard::QClipboard::changed, this, [this]() {
|
||||||
|
updateClipboard(&m_pasteAction);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortCutManager::updateActions(Core::IEditor* currentEditor)
|
void ShortCutManager::updateActions(Core::IEditor* currentEditor)
|
||||||
|