qs: improve lyrics fetching feedback
This commit is contained in:
@@ -25,7 +25,7 @@ Rectangle {
|
|||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
UText {
|
UText {
|
||||||
text: LyricsService.lyrics.get(LyricsService.currentIndex)?.line || ""
|
text: LyricsService.isFetchingLyrics ? "Fetching..." : (LyricsService.lyrics.get(LyricsService.currentIndex)?.line ?? "No lyrics available")
|
||||||
family: Fonts.sans
|
family: Fonts.sans
|
||||||
pointSize: Style.fontSizeM
|
pointSize: Style.fontSizeM
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
|
|||||||
@@ -16,6 +16,13 @@ UBox {
|
|||||||
LyricsService.unregisterComponent("LyricsCard");
|
LyricsService.unregisterComponent("LyricsCard");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UText {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: LyricsService.isFetchingLyrics || LyricsService.lyrics.count === 0
|
||||||
|
text: LyricsService.isFetchingLyrics ? "Fetching..." : "No lyrics available"
|
||||||
|
color: Colors.mOnSurfaceVariant
|
||||||
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: lyricsList
|
id: lyricsList
|
||||||
|
|
||||||
@@ -25,6 +32,7 @@ UBox {
|
|||||||
model: LyricsService.lyrics
|
model: LyricsService.lyrics
|
||||||
currentIndex: LyricsService.currentIndex
|
currentIndex: LyricsService.currentIndex
|
||||||
clip: true
|
clip: true
|
||||||
|
visible: !LyricsService.isFetchingLyrics && LyricsService.lyrics.count > 0
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
if (currentIndex >= 0)
|
if (currentIndex >= 0)
|
||||||
positionViewAtIndex(currentIndex, ListView.Center);
|
positionViewAtIndex(currentIndex, ListView.Center);
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ Singleton {
|
|||||||
property var _registered: ({
|
property var _registered: ({
|
||||||
})
|
})
|
||||||
readonly property int _registeredCount: Object.keys(_registered).length
|
readonly property int _registeredCount: Object.keys(_registered).length
|
||||||
readonly property bool shouldRun: _registeredCount > 0
|
readonly property bool shouldRun: MediaService.currentPlayer && _registeredCount > 0
|
||||||
|
// readonly property bool shouldRun: MediaService.currentPlayer !== null
|
||||||
// Bar state
|
// Bar state
|
||||||
readonly property bool showLyricsBar: ShellState.lyricsState.showLyricsBar || false
|
readonly property bool showLyricsBar: ShellState.lyricsState.showLyricsBar || false
|
||||||
|
|
||||||
@@ -58,21 +59,19 @@ Singleton {
|
|||||||
return ;
|
return ;
|
||||||
|
|
||||||
root.isFetchingLyrics = true;
|
root.isFetchingLyrics = true;
|
||||||
if (!MediaService.currentPlayer) {
|
if (!MediaService.currentPlayer?.identity) {
|
||||||
root.isFetchingLyrics = false;
|
root.isFetchingLyrics = false;
|
||||||
return ;
|
return ;
|
||||||
} else if (MediaService.currentPlayer.identity.toLowerCase() === "spotify")
|
} else {
|
||||||
lyricsProcess.request("spotify");
|
lyricsProcess.request(MediaService.currentPlayer.identity.toLowerCase());
|
||||||
else if (MediaService.currentPlayer.identity.toLowerCase() === "elisa")
|
}
|
||||||
lyricsProcess.request("elisa");
|
|
||||||
else
|
|
||||||
root.isFetchingLyrics = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseLRC(text) {
|
function parseLRC(text) {
|
||||||
if (!root.shouldRun)
|
if (!root.shouldRun)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
|
// Logger.d("Lyrics", "Parsing :\n" + text);
|
||||||
const lines = text.split("\n");
|
const lines = text.split("\n");
|
||||||
let newLyrics = [];
|
let newLyrics = [];
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
@@ -165,7 +164,8 @@ Singleton {
|
|||||||
Logger.d("Lyrics", "Should run changed:", root.shouldRun);
|
Logger.d("Lyrics", "Should run changed:", root.shouldRun);
|
||||||
if (!root.shouldRun) {
|
if (!root.shouldRun) {
|
||||||
root.lyrics.clear();
|
root.lyrics.clear();
|
||||||
root.isFetchingLyrics = false;
|
root.lyricsUpdated();
|
||||||
|
root.currentIndex = -1;
|
||||||
} else {
|
} else {
|
||||||
root._requestFetchLyrics();
|
root._requestFetchLyrics();
|
||||||
}
|
}
|
||||||
@@ -229,15 +229,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
const player = this.queuedPlayer.toLowerCase();
|
const player = this.queuedPlayer.toLowerCase();
|
||||||
this.queuedPlayer = "";
|
this.queuedPlayer = "";
|
||||||
if (player === "spotify") {
|
this.command = ["lrcfetch", "fetch", "--player", player];
|
||||||
this.command = ["lrcfetch", "fetch", "--player", "spotify"];
|
|
||||||
} else if (player === "elisa") {
|
|
||||||
this.command = ["lrcfetch", "fetch", "--player", "elisa"];
|
|
||||||
} else {
|
|
||||||
root.isFetchingLyrics = false;
|
|
||||||
root.parseLRC("");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
this.running = true;
|
this.running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
||||||
Reference in New Issue
Block a user