From f21373bcb031b8ab114153dafdf994f4f286f3bb Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Mon, 8 Jun 2026 16:20:12 +1000 Subject: [PATCH] feat: add seek to lyrics Closes #1524 --- modules/dashboard/media/LyricList.qml | 20 +++++++++++++++++--- plugin/src/Caelestia/Services/lyrics.cpp | 7 +++++++ plugin/src/Caelestia/Services/lyrics.hpp | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/modules/dashboard/media/LyricList.qml b/modules/dashboard/media/LyricList.qml index 0d44293c..c7fa7d25 100644 --- a/modules/dashboard/media/LyricList.qml +++ b/modules/dashboard/media/LyricList.qml @@ -260,13 +260,14 @@ Item { id: lyric required property string modelData + required property int index property real effectScale: ListView.isCurrentItem ? 1 : 0 - anchors.left: ListView.view?.contentItem.left - anchors.right: ListView.view?.contentItem.right + anchors.left: lyrics.contentItem.left + anchors.right: lyrics.contentItem.right text: modelData || ". . ." - color: ListView.isCurrentItem ? Colours.palette.m3primary : Colours.palette.m3outline + color: ListView.isCurrentItem ? Colours.palette.m3primary : mouse.containsMouse ? Colours.palette.m3onSurface : Colours.palette.m3outline font: Tokens.font.body.medium wrapMode: Text.WrapAtWordBoundaryOrAnywhere @@ -284,6 +285,19 @@ Item { type: Anim.SlowEffects } } + + MouseArea { + id: mouse + + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + onClicked: { + const p = Players.active; + if (p) + p.position = Lyrics.timeForIndex(lyric.index); + } + } } Behavior on opacity { diff --git a/plugin/src/Caelestia/Services/lyrics.cpp b/plugin/src/Caelestia/Services/lyrics.cpp index 7490b7ac..cf266eb1 100644 --- a/plugin/src/Caelestia/Services/lyrics.cpp +++ b/plugin/src/Caelestia/Services/lyrics.cpp @@ -223,6 +223,13 @@ int Lyrics::indexForTime(qreal time) const { return static_cast(lo - 1); } +qreal Lyrics::timeForIndex(int index) const { + if (index < 0 || index >= m_lines.size()) { + return -1.0; + } + return m_lines.at(index).time + m_offset; +} + void Lyrics::setTrack(const QString& artist, const QString& title, const QString& album, qreal duration) { const QString a = artist.trimmed(); const QString t = title.trimmed(); diff --git a/plugin/src/Caelestia/Services/lyrics.hpp b/plugin/src/Caelestia/Services/lyrics.hpp index e06e8696..41597504 100644 --- a/plugin/src/Caelestia/Services/lyrics.hpp +++ b/plugin/src/Caelestia/Services/lyrics.hpp @@ -51,6 +51,7 @@ public: [[nodiscard]] QString trackTitle() const; [[nodiscard]] Q_INVOKABLE int indexForTime(qreal time) const; + [[nodiscard]] Q_INVOKABLE qreal timeForIndex(int index) const; Q_INVOKABLE void setTrack( const QString& artist, const QString& title, const QString& album = {}, qreal duration = 0.0); Q_INVOKABLE void clearTrack();