feat(lyrics): add seek-to-line on clicking lyrics line (#3823)

This commit is contained in:
apollo79
2026-10-19 12:53:45 -04:00
committed by GitHub
parent fcb74f5884
commit 7bcbc34c57
3 changed files with 24 additions and 0 deletions
@@ -340,6 +340,18 @@ FocusScope {
}
}
}
StateLayer {
anchors.fill: parent
enabled: root.controller.canSeekLines
stateColor: Theme.onSurfaceVariant
cornerRadius: Theme.cornerRadius
onClicked: {
root.following = true;
root.forceActiveFocus(Qt.MouseFocusReason);
root.controller.seekToLine(lyric.index);
}
}
}
}
@@ -90,6 +90,7 @@ Item {
}
Item {
y: (root.implicitHeight - height) / 2
width: parent.width
height: Math.ceil(line.implicitHeight * root.textScale)
+11
View File
@@ -20,6 +20,7 @@ QtObject {
property bool enabled: false
readonly property bool available: DMSService.capabilities.includes("lyrics")
readonly property bool canSeekLines: synced && (player?.canSeek ?? false) && duration > 0
readonly property string fileUrl: url.startsWith("file://") ? url : ""
readonly property string trackKey: track ? JSON.stringify([track.key, track.title, track.artist, track.album, fileUrl, MediaOptions.enabledLyricsProviders]) : ""
readonly property int duration: Math.round(track?.length ?? 0)
@@ -371,6 +372,16 @@ QtObject {
state = "ready";
}
function seekToLine(index) {
if (!synced || duration <= 0 || !player?.canSeek)
return false;
const line = lines[index];
if (!line || !Number.isFinite(line.t))
return false;
player.position = Math.max(0.1, Math.min(line.t, duration * 0.99));
return true;
}
function currentTime() {
if (!anchorPlaying)
return anchorPosition;