parent
24816fb0d9
commit
f21373bcb0
3 changed files with 25 additions and 3 deletions
|
|
@ -260,13 +260,14 @@ Item {
|
||||||
id: lyric
|
id: lyric
|
||||||
|
|
||||||
required property string modelData
|
required property string modelData
|
||||||
|
required property int index
|
||||||
property real effectScale: ListView.isCurrentItem ? 1 : 0
|
property real effectScale: ListView.isCurrentItem ? 1 : 0
|
||||||
|
|
||||||
anchors.left: ListView.view?.contentItem.left
|
anchors.left: lyrics.contentItem.left
|
||||||
anchors.right: ListView.view?.contentItem.right
|
anchors.right: lyrics.contentItem.right
|
||||||
|
|
||||||
text: modelData || ". . ."
|
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
|
font: Tokens.font.body.medium
|
||||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||||
|
|
||||||
|
|
@ -284,6 +285,19 @@ Item {
|
||||||
type: Anim.SlowEffects
|
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 {
|
Behavior on opacity {
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,13 @@ int Lyrics::indexForTime(qreal time) const {
|
||||||
return static_cast<int>(lo - 1);
|
return static_cast<int>(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) {
|
void Lyrics::setTrack(const QString& artist, const QString& title, const QString& album, qreal duration) {
|
||||||
const QString a = artist.trimmed();
|
const QString a = artist.trimmed();
|
||||||
const QString t = title.trimmed();
|
const QString t = title.trimmed();
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ public:
|
||||||
[[nodiscard]] QString trackTitle() const;
|
[[nodiscard]] QString trackTitle() const;
|
||||||
|
|
||||||
[[nodiscard]] Q_INVOKABLE int indexForTime(qreal time) const;
|
[[nodiscard]] Q_INVOKABLE int indexForTime(qreal time) const;
|
||||||
|
[[nodiscard]] Q_INVOKABLE qreal timeForIndex(int index) const;
|
||||||
Q_INVOKABLE void setTrack(
|
Q_INVOKABLE void setTrack(
|
||||||
const QString& artist, const QString& title, const QString& album = {}, qreal duration = 0.0);
|
const QString& artist, const QString& title, const QString& album = {}, qreal duration = 0.0);
|
||||||
Q_INVOKABLE void clearTrack();
|
Q_INVOKABLE void clearTrack();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue