fix: stabilize hover controls

This commit is contained in:
2026-05-23 13:52:26 +00:00
parent 4551a63c32
commit 01ddf659d7
2 changed files with 30 additions and 4 deletions
+26 -4
View File
@@ -44,6 +44,8 @@ MouseArea {
readonly property int effectiveSeparatorHeight: Math.max(0, Math.min(100, configuredSeparatorHeight)) readonly property int effectiveSeparatorHeight: Math.max(0, Math.min(100, configuredSeparatorHeight))
readonly property var effectiveLabelLines: (configuredLabelText || "").split(/\r?\n/) readonly property var effectiveLabelLines: (configuredLabelText || "").split(/\r?\n/)
readonly property bool hasTrackInfo: player.ready && (((player.title || "").trim().length > 0) || ((player.artists || "").trim().length > 0)) readonly property bool hasTrackInfo: player.ready && (((player.title || "").trim().length > 0) || ((player.artists || "").trim().length > 0))
readonly property bool rawHoverActive: rootHoverHandler.hovered
readonly property bool controlsHoverActive: rawHoverActive || hoverExitTimer.running
readonly property bool nowPlayingLabelsVisible: { readonly property bool nowPlayingLabelsVisible: {
if (effectiveLabelVisibilityMode === "always") if (effectiveLabelVisibilityMode === "always")
return true; return true;
@@ -55,7 +57,14 @@ MouseArea {
} }
focus: true focus: true
acceptedButtons: Qt.NoButton
hoverEnabled: true hoverEnabled: true
onRawHoverActiveChanged: {
if (rawHoverActive)
hoverExitTimer.stop();
else
hoverExitTimer.restart();
}
Keys.onPressed: (event) => { Keys.onPressed: (event) => {
if (!event.modifiers) { if (!event.modifiers) {
event.accepted = true; event.accepted = true;
@@ -70,6 +79,18 @@ MouseArea {
} }
} }
HoverHandler {
id: rootHoverHandler
margin: 12
}
Timer {
id: hoverExitTimer
interval: 300
}
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
visible: mediaControlsMouseArea.usesCustomBackground visible: mediaControlsMouseArea.usesCustomBackground
@@ -92,7 +113,7 @@ MouseArea {
states: [ states: [
State { State {
name: "buttonsVisible" name: "buttonsVisible"
when: mediaControlsMouseArea.containsMouse when: mediaControlsMouseArea.controlsHoverActive
PropertyChanges { PropertyChanges {
target: nowPlayingLabels target: nowPlayingLabels
@@ -102,7 +123,7 @@ MouseArea {
}, },
State { State {
name: "buttonsHidden" name: "buttonsHidden"
when: !mediaControlsMouseArea.containsMouse when: !mediaControlsMouseArea.controlsHoverActive
PropertyChanges { PropertyChanges {
target: nowPlayingLabels target: nowPlayingLabels
@@ -151,8 +172,9 @@ MouseArea {
id: mediaControls id: mediaControls
Layout.alignment: mediaControlsMouseArea.labelsOnRight ? Qt.AlignLeft : Qt.AlignRight Layout.alignment: mediaControlsMouseArea.labelsOnRight ? Qt.AlignLeft : Qt.AlignRight
opacity: mediaControlsMouseArea.containsMouse && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea ? 1 : 0 enabled: mediaControlsMouseArea.controlsHoverActive
visible: opacity > 0 && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea opacity: mediaControlsMouseArea.controlsHoverActive && mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea ? 1 : 0
visible: mediaControlsMouseArea.nowPlayingLabelsVisible && !mediaControlsMouseArea.hideNowPlayingArea
QQC2.Button { QQC2.Button {
Layout.preferredWidth: buttonSize Layout.preferredWidth: buttonSize
+4
View File
@@ -68,6 +68,8 @@ PlasmoidItem {
} }
fullRepresentation: Representation { fullRepresentation: Representation {
width: root.width
height: root.height
Layout.minimumWidth: Kirigami.Units.gridUnit * 25 Layout.minimumWidth: Kirigami.Units.gridUnit * 25
Layout.minimumHeight: Kirigami.Units.gridUnit * 5 Layout.minimumHeight: Kirigami.Units.gridUnit * 5
Layout.preferredWidth: root.width Layout.preferredWidth: root.width
@@ -92,6 +94,8 @@ PlasmoidItem {
} }
compactRepresentation: Representation { compactRepresentation: Representation {
width: root.width
height: root.height
Layout.minimumWidth: Kirigami.Units.gridUnit * 25 Layout.minimumWidth: Kirigami.Units.gridUnit * 25
Layout.minimumHeight: Kirigami.Units.gridUnit * 5 Layout.minimumHeight: Kirigami.Units.gridUnit * 5
Layout.preferredWidth: root.width Layout.preferredWidth: root.width