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
This commit is contained in:
Lukáš Tinkl 2022-09-13 10:01:21 +02:00 committed by Lukáš Tinkl
parent f89b0a8c6f
commit 1381b1bd15
2 changed files with 10 additions and 8 deletions

View File

@ -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 !!!")
}

View File

@ -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
}
}