forked from qt-creator/qt-creator
DesignerActionManager: relax anchor fill condition
The anchor fill parent action is now always available (unless the anchor.fill property is already defined), to be consistent with the property editor behavior. Task-number: QDS-10434 Change-Id: Iedd0c3f0cb1131626fbd1c7b29a01ca86a971c0b Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
88dd120ee5
commit
0a2b613183
@@ -1112,6 +1112,12 @@ bool singleSelectionItemIsNotAnchoredAndSingleSelectionNotRoot(const SelectionCo
|
||||
&& singleSelectionNotRoot(context);
|
||||
}
|
||||
|
||||
bool singleSelectionItemHasNoFillAnchorAndSingleSelectionNotRoot(const SelectionContext &context)
|
||||
{
|
||||
return singleSelection(context) && !singleSelectionItemHasAnchor(context, AnchorLineFill)
|
||||
&& singleSelectionNotRoot(context);
|
||||
}
|
||||
|
||||
bool selectionNotEmptyAndHasXorYProperty(const SelectionContext &context)
|
||||
{
|
||||
return selectionNotEmpty(context)
|
||||
@@ -1528,15 +1534,15 @@ void DesignerActionManager::createDefaultDesignerActions()
|
||||
&anchorsMenuEnabled));
|
||||
|
||||
addDesignerAction(new ModelNodeAction(
|
||||
anchorsFillCommandId,
|
||||
anchorsFillDisplayName,
|
||||
Utils::Icon({{":/qmldesigner/images/anchor_fill.png", Utils::Theme::IconsBaseColor}}).icon(),
|
||||
anchorsFillToolTip,
|
||||
anchorsCategory,
|
||||
QKeySequence(QKeySequence("shift+f")),
|
||||
2,
|
||||
&anchorsFill,
|
||||
&singleSelectionItemIsNotAnchoredAndSingleSelectionNotRoot));
|
||||
anchorsFillCommandId,
|
||||
anchorsFillDisplayName,
|
||||
Utils::Icon({{":/qmldesigner/images/anchor_fill.png", Utils::Theme::IconsBaseColor}}).icon(),
|
||||
anchorsFillToolTip,
|
||||
anchorsCategory,
|
||||
QKeySequence(QKeySequence("shift+f")),
|
||||
2,
|
||||
&anchorsFill,
|
||||
&singleSelectionItemHasNoFillAnchorAndSingleSelectionNotRoot));
|
||||
|
||||
addDesignerAction(new ModelNodeAction(
|
||||
anchorsResetCommandId,
|
||||
|
@@ -68,6 +68,16 @@ bool singleSelectionItemIsNotAnchored(const SelectionContext &selectionState)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool singleSelectionItemHasAnchor(const SelectionContext &selectionState, AnchorLineType anchor)
|
||||
{
|
||||
QmlItemNode itemNode(selectionState.currentSingleSelectedNode());
|
||||
if (selectionState.isInBaseState() && itemNode.isValid()) {
|
||||
bool hasAnchor = itemNode.instanceHasAnchor(anchor);
|
||||
return hasAnchor;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool selectionHasSameParent(const SelectionContext &selectionState)
|
||||
{
|
||||
return !selectionState.selectedModelNodes().isEmpty() && itemsHaveSameParent(selectionState.selectedModelNodes());
|
||||
|
@@ -178,6 +178,7 @@ bool selectionIsEditableComponent(const SelectionContext &selectionState);
|
||||
bool singleSelectionItemIsAnchored(const SelectionContext &selectionState);
|
||||
bool singleSelectionItemIsNotAnchored(const SelectionContext &selectionState);
|
||||
bool selectionIsImported3DAsset(const SelectionContext &selectionState);
|
||||
bool singleSelectionItemHasAnchor(const SelectionContext &selectionState, AnchorLineType anchor);
|
||||
|
||||
} // namespace SelectionStateFunctors
|
||||
|
||||
|
@@ -398,6 +398,11 @@ void anchorsFill(const SelectionContext &selectionState)
|
||||
backupPropertyAndRemove(modelNode, "y");
|
||||
backupPropertyAndRemove(modelNode, "width");
|
||||
backupPropertyAndRemove(modelNode, "height");
|
||||
|
||||
node.anchors().removeMargin(AnchorLineRight);
|
||||
node.anchors().removeMargin(AnchorLineLeft);
|
||||
node.anchors().removeMargin(AnchorLineTop);
|
||||
node.anchors().removeMargin(AnchorLineBottom);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -325,6 +325,11 @@ bool QmlItemNode::hasResources() const
|
||||
return !resources().isEmpty();
|
||||
}
|
||||
|
||||
bool QmlItemNode::instanceHasAnchor(AnchorLineType sourceAnchorLineType) const
|
||||
{
|
||||
return anchors().instanceHasAnchor(sourceAnchorLineType);
|
||||
}
|
||||
|
||||
bool QmlItemNode::instanceHasAnchors() const
|
||||
{
|
||||
return anchors().instanceHasAnchors();
|
||||
|
Reference in New Issue
Block a user