forked from qt-creator/qt-creator
QmlDesigner: Move positioning using Positioners
Move positioning using Positioners to another context menu categeory. The fact that we have Layouts and Positioners in Qt Quick and both do something quite similar is something we cannot change. I also do not like to remove Positioners from the designer, because they have use cases. But having both in the same context menu was a mistake I think. So I moved the Positioner operations into their own menu/category. The plan is to add a toolbar (eventually), but only support layouts in the toolbar to minimize confusion. Change-Id: I5a6abebca209eb43cac7404e12aa998c466cd62d Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
91dbd9c2d8
commit
cad4ee7116
@@ -43,12 +43,14 @@ const char selectionCategory[] = "Selection";
|
|||||||
const char stackCategory[] = "Stack (z)";
|
const char stackCategory[] = "Stack (z)";
|
||||||
const char editCategory[] = "Edit";
|
const char editCategory[] = "Edit";
|
||||||
const char anchorsCategory[] = "Anchors";
|
const char anchorsCategory[] = "Anchors";
|
||||||
|
const char positionCategory[] = "Position";
|
||||||
const char layoutCategory[] = "Layout";
|
const char layoutCategory[] = "Layout";
|
||||||
|
|
||||||
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");
|
||||||
const char anchorsCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Anchors");
|
const char anchorsCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Anchors");
|
||||||
|
const char positionCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position");
|
||||||
const char layoutCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout");
|
const char layoutCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout");
|
||||||
|
|
||||||
const char selectParentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select Parent: %1");
|
const char selectParentDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select Parent: %1");
|
||||||
@@ -84,10 +86,10 @@ const char resetZDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Re
|
|||||||
const char anchorsFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill");
|
const char anchorsFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill");
|
||||||
const char anchorsResetDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reset");
|
const char anchorsResetDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reset");
|
||||||
|
|
||||||
const char layoutColumnPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout in Column (Positioner)");
|
const char layoutColumnPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position in Column");
|
||||||
const char layoutRowPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout in Row (Positioner)");
|
const char layoutRowPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position in Row");
|
||||||
const char layoutGridPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout in Grid (Positioner)");
|
const char layoutGridPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position in Grid");
|
||||||
const char layoutFlowPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Layout in Flow (Positioner)");
|
const char layoutFlowPositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position in Flow");
|
||||||
const char removePositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Remove Positioner");
|
const char removePositionerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Remove Positioner");
|
||||||
const char removeLayoutDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Remove Layout");
|
const char removeLayoutDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Remove Layout");
|
||||||
|
|
||||||
@@ -104,6 +106,7 @@ const int prioritySelectionCategory = 200;
|
|||||||
const int priorityStackCategory = 180;
|
const int priorityStackCategory = 180;
|
||||||
const int priorityEditCategory = 160;
|
const int priorityEditCategory = 160;
|
||||||
const int priorityAnchorsCategory = 140;
|
const int priorityAnchorsCategory = 140;
|
||||||
|
const int priorityPositionCategory = 130;
|
||||||
const int priorityLayoutCategory = 120;
|
const int priorityLayoutCategory = 120;
|
||||||
const int priorityTopLevelSeperator = 100;
|
const int priorityTopLevelSeperator = 100;
|
||||||
const int priorityCustomActions = 80;
|
const int priorityCustomActions = 80;
|
||||||
|
|||||||
@@ -34,6 +34,9 @@
|
|||||||
#include <nodemetainfo.h>
|
#include <nodemetainfo.h>
|
||||||
#include "designeractionmanagerview.h"
|
#include "designeractionmanagerview.h"
|
||||||
|
|
||||||
|
#include <documentmanager.h>
|
||||||
|
#include <qmldesignerplugin.h>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
static inline QString captionForModelNode(const ModelNode &modelNode)
|
static inline QString captionForModelNode(const ModelNode &modelNode)
|
||||||
@@ -249,24 +252,15 @@ bool isNotInLayout(const SelectionContext &context)
|
|||||||
|
|
||||||
bool selectionCanBeLayouted(const SelectionContext &context)
|
bool selectionCanBeLayouted(const SelectionContext &context)
|
||||||
{
|
{
|
||||||
return selectionHasSameParentAndInBaseState(context)
|
return multiSelection(context)
|
||||||
|
&& selectionHasSameParentAndInBaseState(context)
|
||||||
&& inBaseState(context)
|
&& inBaseState(context)
|
||||||
&& isNotInLayout(context);
|
&& isNotInLayout(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasQtQuickLayoutImport(const SelectionContext &context)
|
bool selectionCanBeLayoutedAndQtQuickLayoutPossible(const SelectionContext &context)
|
||||||
{
|
{
|
||||||
if (context.view() && context.view()->model()) {
|
return selectionCanBeLayouted(context) && context.view()->majorQtQuickVersion() > 1;
|
||||||
Import import = Import::createLibraryImport(QStringLiteral("QtQuick.Layouts"), QStringLiteral("1.0"));
|
|
||||||
return context.view()->model()->hasImport(import, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool selectionCanBeLayoutedAndasQtQuickLayoutImport(const SelectionContext &context)
|
|
||||||
{
|
|
||||||
return selectionCanBeLayouted(context) && hasQtQuickLayoutImport(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool selectionNotEmptyAndHasZProperty(const SelectionContext &context)
|
bool selectionNotEmptyAndHasZProperty(const SelectionContext &context)
|
||||||
@@ -360,9 +354,31 @@ bool isPositioner(const SelectionContext &context)
|
|||||||
bool layoutOptionVisible(const SelectionContext &context)
|
bool layoutOptionVisible(const SelectionContext &context)
|
||||||
{
|
{
|
||||||
return multiSelectionAndInBaseState(context)
|
return multiSelectionAndInBaseState(context)
|
||||||
|| singleSelectionAndInQtQuickLayout(context);
|
|| singleSelectionAndInQtQuickLayout(context)
|
||||||
|
|| isLayout(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool positionOptionVisible(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
return multiSelectionAndInBaseState(context)
|
||||||
|
|| isPositioner(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool singleSelectedAndUiFile(const SelectionContext &context)
|
||||||
|
{
|
||||||
|
if (!singleSelection(context))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
DesignDocument *designDocument = QmlDesignerPlugin::instance()->documentManager().currentDesignDocument();
|
||||||
|
|
||||||
|
if (!designDocument)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return designDocument->fileName().toFileInfo().completeSuffix()
|
||||||
|
== QLatin1String("ui.qml");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DesignerActionManager::createDefaultDesignerActions()
|
void DesignerActionManager::createDefaultDesignerActions()
|
||||||
{
|
{
|
||||||
using namespace SelectionContextFunctors;
|
using namespace SelectionContextFunctors;
|
||||||
@@ -399,8 +415,11 @@ void DesignerActionManager::createDefaultDesignerActions()
|
|||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction
|
||||||
(anchorsResetDisplayName, anchorsCategory, 180, &anchorsReset, &singleSelectionItemIsAnchored));
|
(anchorsResetDisplayName, anchorsCategory, 180, &anchorsReset, &singleSelectionItemIsAnchored));
|
||||||
|
|
||||||
|
addDesignerAction(new ActionGroup(positionCategoryDisplayName, positionCategory,
|
||||||
|
priorityPositionCategory, &positionOptionVisible));
|
||||||
addDesignerAction(new ActionGroup(layoutCategoryDisplayName, layoutCategory,
|
addDesignerAction(new ActionGroup(layoutCategoryDisplayName, layoutCategory,
|
||||||
priorityLayoutCategory, &layoutOptionVisible));
|
priorityLayoutCategory, &layoutOptionVisible));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction
|
||||||
(removePositionerDisplayName,
|
(removePositionerDisplayName,
|
||||||
positionCategory,
|
positionCategory,
|
||||||
@@ -408,37 +427,38 @@ void DesignerActionManager::createDefaultDesignerActions()
|
|||||||
&removePositioner,
|
&removePositioner,
|
||||||
&isPositioner,
|
&isPositioner,
|
||||||
&isPositioner));
|
&isPositioner));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction
|
||||||
(layoutRowPositionerDisplayName,
|
(layoutRowPositionerDisplayName,
|
||||||
layoutCategory,
|
positionCategory,
|
||||||
200,
|
200,
|
||||||
&layoutRowPositioner,
|
&layoutRowPositioner,
|
||||||
&selectionCanBeLayouted,
|
&selectionCanBeLayouted,
|
||||||
selectionCanBeLayouted));
|
&selectionCanBeLayouted));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction
|
||||||
(layoutColumnPositionerDisplayName,
|
(layoutColumnPositionerDisplayName,
|
||||||
layoutCategory,
|
positionCategory,
|
||||||
180,
|
180,
|
||||||
&layoutColumnPositioner,
|
&layoutColumnPositioner,
|
||||||
&selectionCanBeLayouted,
|
&selectionCanBeLayouted,
|
||||||
selectionCanBeLayouted));
|
&selectionCanBeLayouted));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction
|
||||||
(layoutGridPositionerDisplayName,
|
(layoutGridPositionerDisplayName,
|
||||||
layoutCategory,
|
positionCategory,
|
||||||
160,
|
160,
|
||||||
&layoutGridPositioner,
|
&layoutGridPositioner,
|
||||||
&selectionCanBeLayouted,
|
&selectionCanBeLayouted,
|
||||||
selectionCanBeLayouted));
|
&selectionCanBeLayouted));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction
|
||||||
(layoutFlowPositionerDisplayName,
|
(layoutFlowPositionerDisplayName,
|
||||||
layoutCategory,
|
positionCategory,
|
||||||
140,
|
140,
|
||||||
&layoutFlowPositioner,
|
&layoutFlowPositioner,
|
||||||
&selectionCanBeLayouted,
|
&selectionCanBeLayouted,
|
||||||
selectionCanBeLayouted));
|
&selectionCanBeLayouted));
|
||||||
|
|
||||||
addDesignerAction(new SeperatorDesignerAction(layoutCategory, 120));
|
addDesignerAction(new SeperatorDesignerAction(layoutCategory, 120));
|
||||||
|
|
||||||
@@ -455,40 +475,40 @@ void DesignerActionManager::createDefaultDesignerActions()
|
|||||||
layoutCategory,
|
layoutCategory,
|
||||||
100,
|
100,
|
||||||
&layoutRowLayout,
|
&layoutRowLayout,
|
||||||
&selectionCanBeLayoutedAndasQtQuickLayoutImport,
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible,
|
||||||
&selectionCanBeLayoutedAndasQtQuickLayoutImport));
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction
|
||||||
(layoutColumnLayoutDisplayName,
|
(layoutColumnLayoutDisplayName,
|
||||||
layoutCategory,
|
layoutCategory,
|
||||||
80,
|
80,
|
||||||
&layoutColumnLayout,
|
&layoutColumnLayout,
|
||||||
&selectionCanBeLayoutedAndasQtQuickLayoutImport,
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible,
|
||||||
&selectionCanBeLayoutedAndasQtQuickLayoutImport));
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
||||||
|
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction
|
||||||
(layoutGridLayoutDisplayName,
|
(layoutGridLayoutDisplayName,
|
||||||
layoutCategory,
|
layoutCategory,
|
||||||
60,
|
60,
|
||||||
&layoutGridLayout,
|
&layoutGridLayout,
|
||||||
&selectionCanBeLayoutedAndasQtQuickLayoutImport,
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible,
|
||||||
&selectionCanBeLayoutedAndasQtQuickLayoutImport));
|
&selectionCanBeLayoutedAndQtQuickLayoutPossible));
|
||||||
|
|
||||||
addDesignerAction(new FillWidthModelNodeAction
|
addDesignerAction(new FillWidthModelNodeAction
|
||||||
(layoutFillWidthDisplayName,
|
(layoutFillWidthDisplayName,
|
||||||
layoutCategory,
|
layoutCategory,
|
||||||
40,
|
40,
|
||||||
&setFillWidth,
|
&setFillWidth,
|
||||||
singleSelectionAndInQtQuickLayout,
|
&singleSelectionAndInQtQuickLayout,
|
||||||
singleSelectionAndInQtQuickLayout));
|
&singleSelectionAndInQtQuickLayout));
|
||||||
|
|
||||||
addDesignerAction(new FillHeightModelNodeAction
|
addDesignerAction(new FillHeightModelNodeAction
|
||||||
(layoutFillHeightDisplayName,
|
(layoutFillHeightDisplayName,
|
||||||
layoutCategory,
|
layoutCategory,
|
||||||
20,
|
20,
|
||||||
&setFillHeight,
|
&setFillHeight,
|
||||||
singleSelectionAndInQtQuickLayout,
|
&singleSelectionAndInQtQuickLayout,
|
||||||
singleSelectionAndInQtQuickLayout));
|
&singleSelectionAndInQtQuickLayout));
|
||||||
|
|
||||||
addDesignerAction(new SeperatorDesignerAction(rootCategory, priorityTopLevelSeperator));
|
addDesignerAction(new SeperatorDesignerAction(rootCategory, priorityTopLevelSeperator));
|
||||||
addDesignerAction(new ModelNodeAction
|
addDesignerAction(new ModelNodeAction
|
||||||
|
|||||||
Reference in New Issue
Block a user