From 1381b1bd152e8db1da4fd0cf93ec90d3206b9815 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 --- sandbox/controls/Buttons.qml | 6 ++++++ src/StatusQ/Controls/StatusBaseButton.qml | 12 ++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sandbox/controls/Buttons.qml b/sandbox/controls/Buttons.qml index d827ff20..e88b56f4 100644 --- a/sandbox/controls/Buttons.qml +++ b/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/src/StatusQ/Controls/StatusBaseButton.qml b/src/StatusQ/Controls/StatusBaseButton.qml index 3c0e9761..07123b58 100644 --- a/src/StatusQ/Controls/StatusBaseButton.qml +++ b/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 } }