nosignal-shell/modules/dashboard/LyricsView.qml
八奈見 レイ ffe90bd077
dashboard: add synced lyrics to media tab (#1197)
* lyrics: rewrite model

* lyrics: cleanup code

* lyrics: some minor layouting

* lyrics: add fade shaders

* lyrics: use appearance values from config

* lyrics: formatting

* lyrics: update readme

* lyrics: fix jumping, redo netease backend (resused from another one of projects)

* lyrics: fix netease searches, remove credit lines

* lyrics: add RequestIds

* lyrics: formatting

* lyrics: lyricsDir path cleanup

* lyrics: make empty lines not take up much space

* lyrics: make empty lines not take up any space

* Lyrics: Use QNetworkAccessManager instead of XMLHttpRequest

also added ability to set request headers and ability to reset cookies for requests.cpp

* lyrics: cleanup old code

* lyrics: toggle lyrics by clicking the album art

* lyrics: sanitize non-breaking spaces

* lyrics: add a menu to select lyrics and manually search for them

* lyrics: remove LrcLib backend

* lyrics: change focus to when dashboard is opened instead of the lyricMenu

* lyrics: improve UI

* lyrics: improve UI more ig

* lyrics: extract LyricsView and LyricMenu into separate components

* lyrics: cleanup old files

* lyrics: refactor LyricsService

* lyrics: restore ComponentBehavior: Bound in lyrics components

* lyrics: change SongID to real to fix integer overflow

* lyrics: add animations to the lyricMenu

* lyrics: fix manual search fields not auto updating

* lyrics: fix jerks when switching tracks

* lyrics: create lyrics directory if it doesn't exist

* lyrics: silence logs, fix binding loops, fix index out of range errors

* lyrics: only request keyboard focus when lyric menu is open

* config: add option to enable/disable the lyrics

* format + silence fileview errors

* fix merge

* anim and lsp fixes + format

---------

Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
2026-03-19 22:38:36 +11:00

114 lines
3.3 KiB
QML

import qs.components
import qs.components.containers
import qs.services
import qs.config
import Quickshell
import QtQuick
import QtQuick.Effects
StyledListView {
id: root
readonly property bool lyricsActuallyVisible: LyricsService.lyricsVisible && LyricsService.model.count != 0
clip: true
model: LyricsService.model
currentIndex: LyricsService.currentIndex
visible: lyricsActuallyVisible || hideTimer.running
onLyricsActuallyVisibleChanged: {
if (!lyricsActuallyVisible)
hideTimer.restart();
}
Timer {
id: hideTimer
interval: 300 // long enough to bridge the track switch gap
running: false
repeat: false
}
preferredHighlightBegin: height / 2 - 30
preferredHighlightEnd: height / 2 + 30
highlightRangeMode: ListView.ApplyRange
highlightFollowsCurrentItem: true
highlightMoveDuration: LyricsService.isManualSeeking ? 0 : Appearance.anim.durations.normal
layer.enabled: true
layer.effect: ShaderEffect {
required property Item source
property real fadeMargin: 0.5
fragmentShader: Quickshell.shellPath("assets/shaders/fade.frag.qsb")
}
onModelChanged: {
if (model && model.count > 0) {
Qt.callLater(() => positionViewAtIndex(currentIndex, ListView.Center));
}
}
delegate: Item {
id: delegateRoot
width: ListView.view.width
required property string lyricLine
required property real time
required property int index
readonly property bool hasContent: lyricLine && lyricLine.trim().length > 0
height: hasContent ? (lyricText.contentHeight + Appearance.spacing.large) : 0
property bool isCurrent: ListView.isCurrentItem
MultiEffect {
id: effect
anchors.fill: lyricText
source: lyricText
scale: lyricText.scale
enabled: delegateRoot.isCurrent
visible: delegateRoot.isCurrent
blurEnabled: true
blur: 0.4
shadowEnabled: true
shadowColor: Colours.palette.m3primary
shadowOpacity: 0.5
shadowBlur: 0.6
shadowHorizontalOffset: 0
shadowVerticalOffset: 0
autoPaddingEnabled: true
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: LyricsService.jumpTo(delegateRoot.index, delegateRoot.time)
}
Text {
id: lyricText
text: delegateRoot.lyricLine ? delegateRoot.lyricLine.replace(/\u00A0/g, " ") : ""
width: parent.width * 0.85
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap
font.pointSize: Appearance.font.size.normal
color: delegateRoot.isCurrent ? Colours.palette.m3primary : Colours.palette.m3onSurfaceVariant
font.bold: delegateRoot.isCurrent
scale: delegateRoot.isCurrent ? 1.15 : 1.0
Behavior on color {
CAnim {
duration: Appearance.anim.durations.small
}
}
Behavior on scale {
Anim {
duration: Appearance.anim.durations.small
}
}
}
}
}