From 395b9aa9cfbef865ed3dddb9d50c7d59762a3fc6 Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Wed, 12 Jan 2022 10:38:55 +0100 Subject: [PATCH] QmlDesigner: Add tool tips to disabled anchors Add tool tips to disabled anchor buttons to make clear what the reason for disabling is. Task-number: QDS-5388 Change-Id: I193ba5ced45a6cb4d90e8475fc992029f58337d3 Reviewed-by: Thomas Hartmann Reviewed-by: --- .../imports/HelperWidgets/AnchorButtons.qml | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AnchorButtons.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AnchorButtons.qml index e4eb7108d95..aae2aee51bc 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AnchorButtons.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/AnchorButtons.qml @@ -34,14 +34,24 @@ StudioControls.ButtonRow { enabled: anchorBackend.hasParent && isBaseState actionIndicatorVisible: false + function pickToolTip(defaultText) { + if (!anchorBackend.hasParent) + return qsTr("Anchors can only be applied to child items.") + else if (!isBaseState) + return qsTr("Anchors can only be applied to the base state.") + + return defaultText + } + StudioControls.ButtonGroup { id: group } AbstractButton { property bool topAnchored: anchorBackend.topAnchored + property string toolTipText: qsTr("Anchor component to the top.") checkable: true buttonIcon: StudioTheme.Constants.anchorTop - tooltip: qsTr("Anchor component to the top.") + tooltip: buttonRow.pickToolTip(toolTipText) onTopAnchoredChanged: checked = topAnchored @@ -59,10 +69,11 @@ StudioControls.ButtonRow { AbstractButton { property bool bottomAnchored: anchorBackend.bottomAnchored + property string toolTipText: qsTr("Anchor component to the bottom.") checkable: true buttonIcon: StudioTheme.Constants.anchorBottom - tooltip: qsTr("Anchor component to the bottom.") + tooltip: buttonRow.pickToolTip(toolTipText) onBottomAnchoredChanged: checked = bottomAnchored @@ -80,10 +91,11 @@ StudioControls.ButtonRow { AbstractButton { property bool leftAnchored: anchorBackend.leftAnchored + property string toolTipText: qsTr("Anchor component to the left.") checkable: true buttonIcon: StudioTheme.Constants.anchorLeft - tooltip: qsTr("Anchor component to the left.") + tooltip: buttonRow.pickToolTip(toolTipText) onLeftAnchoredChanged: checked = leftAnchored @@ -101,10 +113,11 @@ StudioControls.ButtonRow { AbstractButton { property bool rightAnchored: anchorBackend.rightAnchored + property string toolTipText: qsTr("Anchor component to the right.") checkable: true buttonIcon: StudioTheme.Constants.anchorRight - tooltip: qsTr("Anchor component to the right.") + tooltip: buttonRow.pickToolTip(toolTipText) onRightAnchoredChanged: checked = rightAnchored @@ -126,10 +139,11 @@ StudioControls.ButtonRow { AbstractButton { property bool isFilled: anchorBackend.isFilled + property string toolTipText: qsTr("Fill parent component.") checkable: true buttonIcon: StudioTheme.Constants.anchorFill - tooltip: qsTr("Fill parent component.") + tooltip: buttonRow.pickToolTip(toolTipText) onIsFilledChanged: checked = isFilled @@ -147,10 +161,11 @@ StudioControls.ButtonRow { AbstractButton { property bool verticalCentered: anchorBackend.verticalCentered + property string toolTipText: qsTr("Anchor component vertically.") checkable: true buttonIcon: StudioTheme.Constants.centerVertical - tooltip: qsTr("Anchor component vertically.") + tooltip: buttonRow.pickToolTip(toolTipText) onVerticalCenteredChanged: checked = verticalCentered @@ -169,10 +184,11 @@ StudioControls.ButtonRow { AbstractButton { property bool horizontalCentered: anchorBackend.horizontalCentered + property string toolTipText: qsTr("Anchor component horizontally.") checkable: true buttonIcon: StudioTheme.Constants.centerHorizontal - tooltip: qsTr("Anchor component horizontally.") + tooltip: buttonRow.pickToolTip(toolTipText) onHorizontalCenteredChanged: checked = horizontalCentered