From 8e4d3c3fa97d894be50b9eb741e43b5ad852b8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Tue, 13 Sep 2022 10:01:21 +0200 Subject: [PATCH] hotfix: unbreak "pointing hand" cursor turns out we can indeed have only one MouseArea to handle both the cursor and intercepting the event in the "loading" state --- ui/StatusQ/sandbox/controls/Buttons.qml | 6 ++++++ ui/StatusQ/src/StatusQ/Controls/StatusBaseButton.qml | 12 ++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ui/StatusQ/sandbox/controls/Buttons.qml b/ui/StatusQ/sandbox/controls/Buttons.qml index d827ff2082..e88b56f460 100644 --- a/ui/StatusQ/sandbox/controls/Buttons.qml +++ b/ui/StatusQ/sandbox/controls/Buttons.qml @@ -27,12 +27,18 @@ Column { text: "Look I'm a tooltip on a button!" } onClicked: console.warn("Primary button clicked") + onPressed: console.warn("Primary button pressed") } StatusButton { text: "Button" enabled: false type: StatusBaseButton.Type.Primary + + StatusToolTip { + visible: parent.hovered + text: "Tooltip on a disabled button, should not be visible!" + } onClicked: console.warn("Primary disabled button clicked, this should not happen !!!") } diff --git a/ui/StatusQ/src/StatusQ/Controls/StatusBaseButton.qml b/ui/StatusQ/src/StatusQ/Controls/StatusBaseButton.qml index 3c0e9761ef..07123b586d 100644 --- a/ui/StatusQ/src/StatusQ/Controls/StatusBaseButton.qml +++ b/ui/StatusQ/src/StatusQ/Controls/StatusBaseButton.qml @@ -63,6 +63,8 @@ Button { } } + spacing: root.size === StatusBaseButton.Size.Large ? 6 : 4 + icon.height: 24 icon.width: 24 @@ -74,16 +76,10 @@ Button { return !root.loading && (root.hovered || root.highlighted) ? hoverColor : normalColor; return disabledColor; } - MouseArea { - anchors.fill: parent - enabled: root.enabled - acceptedButtons: Qt.NoButton - cursorShape: root.loading ? Qt.ArrowCursor : Qt.PointingHandCursor - } } contentItem: RowLayout { - spacing: root.size === StatusBaseButton.Size.Large ? 6 : 4 + spacing: root.spacing StatusIcon { Layout.preferredWidth: visible ? root.icon.width : 0 Layout.preferredHeight: visible ? root.icon.height : 0 @@ -123,8 +119,8 @@ Button { anchors.fill: parent acceptedButtons: Qt.AllButtons enabled: root.loading - hoverEnabled: enabled onPressed: mouse.accepted = true onWheel: wheel.accepted = true + cursorShape: !root.loading ? Qt.PointingHandCursor: undefined // always works; 'undefined' resets to default cursor } }