From 7ec2fd482ed9a1385b68e1efd9cfd7c6a889eb80 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Mon, 12 Oct 2020 16:03:12 +0200 Subject: [PATCH] QmlDesigner: Show anchors menu only if applicable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I09e6e14f96b62b561027694ebc5a73b51c6ab8d8 Reviewed-by: Henning Gründl Reviewed-by: Thomas Hartmann --- .../componentcore/designeractionmanager.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index 2d9c19279c2..96d08e5baef 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -574,11 +574,6 @@ bool multiSelection(const SelectionContext &context) return !singleSelection(context) && selectionNotEmpty(context); } -bool singleSelectionAndInBaseState(const SelectionContext &context) -{ - return singleSelection(context) && inBaseState(context); -} - bool multiSelectionAndInBaseState(const SelectionContext &context) { return multiSelection(context) && inBaseState(context); @@ -887,6 +882,12 @@ bool raiseAvailable(const SelectionContext &selectionState) return parentProperty.indexOf(modelNode) < parentProperty.count() - 1; } +bool anchorsMenuEnabled(const SelectionContext &context) +{ + return singleSelectionItemIsNotAnchoredAndSingleSelectionNotRoot(context) + || singleSelectionItemIsAnchored(context); +} + void DesignerActionManager::createDefaultDesignerActions() { using namespace SelectionContextFunctors; @@ -1001,11 +1002,10 @@ void DesignerActionManager::createDefaultDesignerActions() &setVisible, &singleSelectedItem)); - addDesignerAction(new ActionGroup( - anchorsCategoryDisplayName, - anchorsCategory, - priorityAnchorsCategory, - &singleSelectionAndInBaseState)); + addDesignerAction(new ActionGroup(anchorsCategoryDisplayName, + anchorsCategory, + priorityAnchorsCategory, + &anchorsMenuEnabled)); addDesignerAction(new ModelNodeAction( anchorsFillCommandId,