Skip to content

Commit abb900b

Browse files
committed
service/mpris!: do not provide fallback track information
See the [!TIP] messages for more information.
1 parent e2ef7b7 commit abb900b

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/services/mpris/player.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <qobject.h>
1111
#include <qproperty.h>
1212
#include <qstring.h>
13-
#include <qstringliteral.h>
1413
#include <qtmetamacros.h>
1514
#include <qtypes.h>
1615

@@ -69,23 +68,20 @@ MprisPlayer::MprisPlayer(const QString& address, QObject* parent): QObject(paren
6968
});
7069

7170
this->bTrackTitle.setBinding([this]() {
72-
const auto& title = this->bMetadata.value().value("xesam:title").toString();
73-
return title.isNull() ? QStringLiteral("Unknown Track") : title;
71+
return this->bMetadata.value().value("xesam:title").toString();
7472
});
7573

7674
this->bTrackAlbum.setBinding([this]() {
77-
const auto& album = this->bMetadata.value().value("xesam:album").toString();
78-
return album.isNull() ? QStringLiteral("Unknown Album") : album;
75+
return this->bMetadata.value().value("xesam:album").toString();
7976
});
8077

8178
this->bTrackArtist.setBinding([this]() {
8279
const auto& artist = this->bMetadata.value().value("xesam:artist").value<QList<QString>>();
83-
return artist.isEmpty() ? QStringLiteral("Unknown Artist") : artist.join(", ");
80+
return artist.isEmpty() ? QString() : artist.join(", ");
8481
});
8582

8683
this->bTrackAlbumArtist.setBinding([this]() {
87-
const auto& artist = this->bMetadata.value().value("xesam:albumArtist").toString();
88-
return artist.isNull() ? QStringLiteral("Unknown Artist") : artist;
84+
return this->bMetadata.value().value("xesam:albumArtist").toString();
8985
});
9086

9187
this->bTrackArtUrl.setBinding([this]() {

src/services/mpris/player.hpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,27 @@ class MprisPlayer: public QObject {
135135
/// > [!WARNING] This is NOT `mpris:trackid` as that is sometimes missing or nonunique
136136
/// > in some players.
137137
Q_PROPERTY(quint32 uniqueId READ uniqueId NOTIFY uniqueIdChanged BINDABLE bindableUniqueId);
138-
/// The title of the current track, or "Unknown Track" if none was provided.
138+
/// The title of the current track, or `""` if none was provided.
139+
///
140+
/// > [!TIP] Use `player.trackTitle || "Unknown Title"` to provide a message
141+
/// > when no title is available.
139142
Q_PROPERTY(QString trackTitle READ trackTitle NOTIFY trackTitleChanged BINDABLE bindableTrackTitle);
140-
/// The current track's artist, or an empty string if none was provided.
143+
/// The current track's artist, or an `""` if none was provided.
144+
///
145+
/// > [!TIP] Use `player.trackArtist || "Unknown Artist"` to provide a message
146+
/// > when no artist is available.
141147
Q_PROPERTY(QString trackArtist READ trackArtist NOTIFY trackArtistChanged BINDABLE bindableTrackArtist);
142148
/// > [!ERROR] deprecated in favor of @@trackArtist.
143149
Q_PROPERTY(QString trackArtists READ trackArtist NOTIFY trackArtistChanged BINDABLE bindableTrackArtist);
144-
/// The current track's album, or "Unknown Album" if none was provided.
150+
/// The current track's album, or `""` if none was provided.
151+
///
152+
/// > [!TIP] Use `player.trackAlbum || "Unknown Album"` to provide a message
153+
/// > when no album is available.
145154
Q_PROPERTY(QString trackAlbum READ trackAlbum NOTIFY trackAlbumChanged BINDABLE bindableTrackAlbum);
146-
/// The current track's album artist, or "Unknown Artist" if none was provided.
155+
/// The current track's album artist, or `""` if none was provided.
156+
///
157+
/// > [!TIP] Use `player.trackAlbumArtist || "Unknown Album"` to provide a message
158+
/// > when no album artist is available.
147159
Q_PROPERTY(QString trackAlbumArtist READ trackAlbumArtist NOTIFY trackAlbumArtistChanged BINDABLE bindableTrackAlbumArtist);
148160
/// The current track's art url, or `""` if none was provided.
149161
Q_PROPERTY(QString trackArtUrl READ trackArtUrl NOTIFY trackArtUrlChanged BINDABLE bindableTrackArtUrl);

0 commit comments

Comments
 (0)