aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/componentcore
diff options
context:
space:
mode:
authorHenning Gruendl <henning.gruendl@qt.io>2020-10-28 09:32:44 +0100
committerHenning Gründl <henning.gruendl@qt.io>2020-10-28 16:43:30 +0000
commitc019860809ea6de728c88c9e6aef65c2320e06bc (patch)
tree3762dddb7daf6ecef868f9da337c6ed26221ed9e /src/plugins/qmldesigner/components/componentcore
parentb30b2f481c5671f2d89a91b0869c09060260b28d (diff)
QmlDesigner: Update the Stack (z) context menu
* Rename arrange menu and items * Remove the "Reset z property" item * Add reverse item and functionality * Fix some related typos and formatting Task-number: QDS-2938 Change-Id: I0e706aefdaed99b28faae4b307146847a54a24ed Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'src/plugins/qmldesigner/components/componentcore')
-rw-r--r--src/plugins/qmldesigner/components/componentcore/componentcore_constants.h15
-rw-r--r--src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp56
-rw-r--r--src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp23
-rw-r--r--src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h1
4 files changed, 56 insertions, 39 deletions
diff --git a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h
index 6186575e43..7de6c4fe64 100644
--- a/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h
+++ b/src/plugins/qmldesigner/components/componentcore/componentcore_constants.h
@@ -34,7 +34,7 @@ namespace ComponentCoreConstants {
const char rootCategory[] = "";
const char selectionCategory[] = "Selection";
-const char stackCategory[] = "Stack (z)";
+const char arrangeCategory[] = "Arrange";
const char qmlPreviewCategory[] = "QmlPreview";
const char editCategory[] = "Edit";
const char anchorsCategory[] = "Anchors";
@@ -52,6 +52,7 @@ const char toBackCommandId[] = "ToBack";
const char raiseCommandId[] = "Raise";
const char lowerCommandId[] = "Lower";
const char resetZCommandId[] = "ResetZ";
+const char reverseCommandId[] = "Reverse";
const char resetSizeCommandId[] = "ResetSize";
const char resetPositionCommandId[] = "ResetPosition";
const char visiblityCommandId[] = "ToggleVisiblity";
@@ -90,7 +91,7 @@ const char fitSelectionToScreenCommandId[] = "FitSelectionToScreen";
const char selectionCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Selection");
const char flowConnectionCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Connect");
const char selectEffectDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Select Effect");
-const char stackCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Stack (z)");
+const char arrangeCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Arrange");
const char editCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Edit");
const char anchorsCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Anchors");
const char positionCategoryDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Position");
@@ -105,11 +106,11 @@ const char copySelectionDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMen
const char pasteSelectionDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Paste");
const char deleteSelectionDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Delete Selection");
-const char toFrontDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "To Front");
-const char toBackDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "To Back");
+const char toFrontDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Bring to Front");
+const char toBackDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Send to Back");
-const char raiseDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Raise");
-const char lowerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Lower");
+const char raiseDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Bring Forward");
+const char lowerDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Send Backward");
const char undoDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Undo");
const char redoDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Redo");
@@ -129,6 +130,8 @@ const char setIdDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Set
const char resetZDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reset z Property");
+const char reverseDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reverse");
+
const char anchorsFillDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Fill");
const char anchorsResetDisplayName[] = QT_TRANSLATE_NOOP("QmlDesignerContextMenu", "Reset");
diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
index ea34b091cd..f7953e2fbe 100644
--- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp
@@ -594,6 +594,11 @@ bool selectionHasSameParentAndInBaseState(const SelectionContext &context)
return selectionHasSameParent(context) && inBaseState(context);
}
+bool multiSelectionAndHasSameParent(const SelectionContext &context)
+{
+ return multiSelection(context) && selectionHasSameParent(context);
+}
+
bool isNotInLayout(const SelectionContext &context)
{
if (selectionNotEmpty(context)) {
@@ -914,8 +919,8 @@ void DesignerActionManager::createDefaultDesignerActions()
prioritySelectionCategory));
addDesignerAction(new ActionGroup(
- stackCategoryDisplayName,
- stackCategory,
+ arrangeCategoryDisplayName,
+ arrangeCategory,
priorityStackCategory,
&selectionNotEmpty));
@@ -923,28 +928,19 @@ void DesignerActionManager::createDefaultDesignerActions()
toFrontCommandId,
toFrontDisplayName,
{},
- stackCategory,
+ arrangeCategory,
QKeySequence(),
200,
&toFront,
&singleSelection));
addDesignerAction(new ModelNodeContextMenuAction(
- toBackCommandId,
- toBackDisplayName,
- {},
- stackCategory,
- QKeySequence(),
- 180,
- &toBack,
- &singleSelection));
-
- addDesignerAction(new ModelNodeContextMenuAction(
- raiseCommandId, raiseDisplayName,
+ raiseCommandId,
+ raiseDisplayName,
Utils::Icon({{":/qmldesigner/icon/designeractions/images/raise.png", Utils::Theme::IconsBaseColor}}).icon(),
- stackCategory,
+ arrangeCategory,
QKeySequence(),
- 160,
+ 180,
&raise,
&raiseAvailable));
@@ -952,23 +948,31 @@ void DesignerActionManager::createDefaultDesignerActions()
lowerCommandId,
lowerDisplayName,
Utils::Icon({{":/qmldesigner/icon/designeractions/images/lower.png", Utils::Theme::IconsBaseColor}}).icon(),
- stackCategory,
+ arrangeCategory,
QKeySequence(),
- 140,
+ 160,
&lower,
&lowerAvailable));
- addDesignerAction(new SeperatorDesignerAction(stackCategory, 120));
+ addDesignerAction(new ModelNodeContextMenuAction(
+ toBackCommandId,
+ toBackDisplayName,
+ {},
+ arrangeCategory,
+ QKeySequence(),
+ 140,
+ &toBack,
+ &singleSelection));
addDesignerAction(new ModelNodeContextMenuAction(
- resetZCommandId,
- resetZDisplayName,
+ reverseCommandId,
+ reverseDisplayName,
{},
- stackCategory,
+ arrangeCategory,
QKeySequence(),
100,
- &resetZ,
- &selectionNotEmptyAndHasZProperty));
+ &reverse,
+ &multiSelectionAndHasSameParent));
addDesignerAction(new ActionGroup(editCategoryDisplayName, editCategory, priorityEditCategory, &selectionNotEmpty));
@@ -979,7 +983,9 @@ void DesignerActionManager::createDefaultDesignerActions()
resetPositionDisplayName,
Utils::Icon({{":/utils/images/pan.png", Utils::Theme::IconsBaseColor},
{":/utils/images/iconoverlay_reset.png", Utils::Theme::IconsStopToolBarColor}}).icon(),
- resetPositionTooltip, editCategory, QKeySequence("Ctrl+d"),
+ resetPositionTooltip,
+ editCategory,
+ QKeySequence("Ctrl+d"),
200,
&resetPosition,
&selectionNotEmptyAndHasXorYProperty));
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
index f76542d378..7bda65bf1a 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
@@ -206,9 +206,9 @@ void toBack(const SelectionContext &selectionState)
}
}
-enum OderAction {RaiseItem, LowerItem};
+enum OrderAction {RaiseItem, LowerItem};
-void changeOrder(const SelectionContext &selectionState, OderAction orderAction)
+void changeOrder(const SelectionContext &selectionState, OrderAction orderAction)
{
if (!selectionState.view())
return;
@@ -221,13 +221,12 @@ void changeOrder(const SelectionContext &selectionState, OderAction orderAction)
if (!modelNode.parentProperty().isNodeListProperty())
return;
- selectionState.view()->executeInTransaction("DesignerActionManager|raise",[orderAction, selectionState, modelNode](){
+ selectionState.view()->executeInTransaction("DesignerActionManager|changeOrder", [orderAction, selectionState, modelNode]() {
ModelNode modelNode = selectionState.currentSingleSelectedNode();
NodeListProperty parentProperty = modelNode.parentProperty().toNodeListProperty();
const int index = parentProperty.indexOf(modelNode);
if (orderAction == RaiseItem) {
-
if (index < parentProperty.count() - 1)
parentProperty.slide(index, index + 1);
} else if (orderAction == LowerItem) {
@@ -244,7 +243,6 @@ void raise(const SelectionContext &selectionState)
void lower(const SelectionContext &selectionState)
{
-
changeOrder(selectionState, LowerItem);
}
@@ -344,8 +342,8 @@ void resetZ(const SelectionContext &selectionState)
if (!selectionState.view())
return;
- selectionState.view()->executeInTransaction("DesignerActionManager|resetZ",[selectionState](){
- foreach (ModelNode node, selectionState.selectedModelNodes()) {
+ selectionState.view()->executeInTransaction("DesignerActionManager|resetZ", [selectionState](){
+ for (ModelNode node : selectionState.selectedModelNodes()) {
QmlItemNode itemNode(node);
if (itemNode.isValid())
itemNode.removeProperty("z");
@@ -353,6 +351,16 @@ void resetZ(const SelectionContext &selectionState)
});
}
+void reverse(const SelectionContext &selectionState)
+{
+ if (!selectionState.view())
+ return;
+
+ selectionState.view()->executeInTransaction("DesignerActionManager|reverse", [selectionState](){
+ NodeListProperty::reverseModelNodes(selectionState.selectedModelNodes());
+ });
+}
+
static inline void backupPropertyAndRemove(const ModelNode &node, const PropertyName &propertyName)
{
if (node.hasVariantProperty(propertyName)) {
@@ -366,7 +374,6 @@ static inline void backupPropertyAndRemove(const ModelNode &node, const Property
}
}
-
static inline void restoreProperty(const ModelNode &node, const PropertyName &propertyName)
{
if (node.hasAuxiliaryData(auxDataString + propertyName))
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h
index d22e673c80..aa43933224 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.h
@@ -52,6 +52,7 @@ void resetPosition(const SelectionContext &selectionState);
void goIntoComponentOperation(const SelectionContext &selectionState);
void setId(const SelectionContext &selectionState);
void resetZ(const SelectionContext &selectionState);
+void reverse(const SelectionContext &selectionState);
void anchorsFill(const SelectionContext &selectionState);
void anchorsReset(const SelectionContext &selectionState);
void layoutRowPositioner(const SelectionContext &selectionState);