fix(ui): address main window KDE HIG findings

This commit was merged in pull request #4.
This commit is contained in:
tri committed 2026-11-07 20:08:28 +07:00
1 parent 0cd03335f7
commit 0bfaf3c9db
8 files changed
+248 -157

No files matched your search

+17 -25
View File
@@ -7,49 +7,41 @@ import QtQuick.Controls
import org.kde.kirigami as Kirigami
import org.kde.ki18n
// Flat volume bar with the value written on it, as in Haruna.
// Use the desktop style's handle and hover/focus feedback.
Slider {
id: root
required property MpvItem mpv
Accessible.name: KI18n.i18nc("@label:slider", "Volume")
Accessible.description: root.mpv.mute ? KI18n.i18nc("@info volume muted", "Muted") : KI18n.i18nc("@info volume percentage", "%1%", Math.round(value))
from: 0
to: root.mpv.volumeMax
implicitWidth: 100
implicitHeight: 25
implicitWidth: Kirigami.Units.gridUnit * 5
wheelEnabled: true
stepSize: QtPotatoSettings.volumeStep
focusPolicy: Qt.NoFocus
leftPadding: 0
rightPadding: 0
focusPolicy: Qt.StrongFocus
handle: Item { visible: false }
background: Rectangle {
color: Kirigami.Theme.alternateBackgroundColor
scale: root.mirrored ? -1 : 1
Rectangle {
width: root.visualPosition * parent.width
height: parent.height
color: Kirigami.Theme.highlightColor
// Let the Slider consume navigation keys before window playback shortcuts.
Keys.onShortcutOverride: event => {
if (event.modifiers === Qt.NoModifier && [Qt.Key_Left, Qt.Key_Right, Qt.Key_Up, Qt.Key_Down, Qt.Key_Home, Qt.Key_End].includes(event.key)) {
event.accepted = true
}
}
Keys.onPressed: event => {
if (event.modifiers === Qt.NoModifier && (event.key === Qt.Key_Home || event.key === Qt.Key_End)) {
value = event.key === Qt.Key_Home ? from : to
moved()
event.accepted = true
}
}
onMoved: root.mpv.volume = Math.round(value)
// Follow mpv, but not while the user drags (dragging replaces a plain binding).
// Follow mpv, but not while the user drags.
Binding on value {
value: root.mpv.volume
when: !root.pressed
restoreMode: Binding.RestoreNone
}
Label {
anchors.centerIn: root
text: root.mpv.mute ? KI18n.i18nc("@info volume muted", "Muted") : Math.round(root.value)
color: "#fff"
style: Text.Outline
styleColor: "#111"
}
}