Skip to content

Commit 0f98bf2

Browse files
committed
Improve AppButton hover and press visuals
1 parent 80a95d4 commit 0f98bf2

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/view/qml/Components/AppButton.qml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import QtQuick 2.15
1717
import QtQuick.Controls 2.15
18+
import QtQuick.Controls.Universal 2.15
1819

1920
// Qt's own AbstractButton press/release detection intermittently drops clicks on some Qt 6.10
2021
// installs while the audio engine is running; a plain MouseArea's simpler grab never does, which is
@@ -23,8 +24,30 @@ import QtQuick.Controls 2.15
2324
// press before Button's own handling ever sees it, so this never double-fires.
2425
Button {
2526
id: root
27+
// Since the overlay eats the press before Button's own handling ever sees it, `pressed` (and so
28+
// the default `down`) never goes true on its own -- rebinding `down` to the overlay's own pressed
29+
// state is what gets the style's normal pressed-color feedback back. `hovered` has no equivalent
30+
// override (it is read-only), so the background below reads the overlay's containsMouse directly
31+
// instead of relying on the Control's own -- apparently also overlay-blocked -- hover tracking.
32+
down: mouseArea.pressed
33+
background: Rectangle {
34+
implicitWidth: 32
35+
implicitHeight: 32
36+
visible: !root.flat || root.down || root.checked || root.highlighted
37+
color: root.down ? root.Universal.baseMediumLowColor : root.enabled && (root.highlighted || root.checked) ? root.Universal.accent : root.Universal.baseLowColor
38+
Rectangle {
39+
anchors.fill: parent
40+
color: "transparent"
41+
visible: root.enabled && mouseArea.containsMouse
42+
border.width: 2
43+
border.color: root.Universal.baseMediumLowColor
44+
}
45+
}
2646
MouseArea {
47+
id: mouseArea
2748
anchors.fill: parent
49+
hoverEnabled: true
50+
cursorShape: Qt.PointingHandCursor
2851
onClicked: root.clicked()
2952
}
3053
}

0 commit comments

Comments
 (0)