forked from quickshell/quickshell
		
	service/mpris!: do not provide fallback track information
See the [!TIP] messages for more information.
This commit is contained in:
		
							parent
							
								
									e2ef7b7982
								
							
						
					
					
						commit
						abb900b7ff
					
				
					 2 changed files with 20 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -10,7 +10,6 @@
 | 
			
		|||
#include <qobject.h>
 | 
			
		||||
#include <qproperty.h>
 | 
			
		||||
#include <qstring.h>
 | 
			
		||||
#include <qstringliteral.h>
 | 
			
		||||
#include <qtmetamacros.h>
 | 
			
		||||
#include <qtypes.h>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -69,23 +68,20 @@ MprisPlayer::MprisPlayer(const QString& address, QObject* parent): QObject(paren
 | 
			
		|||
	});
 | 
			
		||||
 | 
			
		||||
	this->bTrackTitle.setBinding([this]() {
 | 
			
		||||
		const auto& title = this->bMetadata.value().value("xesam:title").toString();
 | 
			
		||||
		return title.isNull() ? QStringLiteral("Unknown Track") : title;
 | 
			
		||||
		return this->bMetadata.value().value("xesam:title").toString();
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	this->bTrackAlbum.setBinding([this]() {
 | 
			
		||||
		const auto& album = this->bMetadata.value().value("xesam:album").toString();
 | 
			
		||||
		return album.isNull() ? QStringLiteral("Unknown Album") : album;
 | 
			
		||||
		return this->bMetadata.value().value("xesam:album").toString();
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	this->bTrackArtist.setBinding([this]() {
 | 
			
		||||
		const auto& artist = this->bMetadata.value().value("xesam:artist").value<QList<QString>>();
 | 
			
		||||
		return artist.isEmpty() ? QStringLiteral("Unknown Artist") : artist.join(", ");
 | 
			
		||||
		return artist.isEmpty() ? QString() : artist.join(", ");
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	this->bTrackAlbumArtist.setBinding([this]() {
 | 
			
		||||
		const auto& artist = this->bMetadata.value().value("xesam:albumArtist").toString();
 | 
			
		||||
		return artist.isNull() ? QStringLiteral("Unknown Artist") : artist;
 | 
			
		||||
		return this->bMetadata.value().value("xesam:albumArtist").toString();
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	this->bTrackArtUrl.setBinding([this]() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -135,15 +135,27 @@ class MprisPlayer: public QObject {
 | 
			
		|||
	/// > [!WARNING] This is NOT `mpris:trackid` as that is sometimes missing or nonunique
 | 
			
		||||
	/// > in some players.
 | 
			
		||||
	Q_PROPERTY(quint32 uniqueId READ uniqueId NOTIFY uniqueIdChanged BINDABLE bindableUniqueId);
 | 
			
		||||
	/// The title of the current track, or "Unknown Track" if none was provided.
 | 
			
		||||
	/// The title of the current track, or `""` if none was provided.
 | 
			
		||||
	///
 | 
			
		||||
	/// > [!TIP] Use `player.trackTitle || "Unknown Title"` to provide a message
 | 
			
		||||
	/// > when no title is available.
 | 
			
		||||
	Q_PROPERTY(QString trackTitle READ trackTitle NOTIFY trackTitleChanged BINDABLE bindableTrackTitle);
 | 
			
		||||
	/// The current track's artist, or an empty string if none was provided.
 | 
			
		||||
	/// The current track's artist, or an `""` if none was provided.
 | 
			
		||||
	///
 | 
			
		||||
	/// > [!TIP] Use `player.trackArtist || "Unknown Artist"` to provide a message
 | 
			
		||||
	/// > when no artist is available.
 | 
			
		||||
	Q_PROPERTY(QString trackArtist READ trackArtist NOTIFY trackArtistChanged BINDABLE bindableTrackArtist);
 | 
			
		||||
	/// > [!ERROR] deprecated in favor of @@trackArtist.
 | 
			
		||||
	Q_PROPERTY(QString trackArtists READ trackArtist NOTIFY trackArtistChanged BINDABLE bindableTrackArtist);
 | 
			
		||||
	/// The current track's album, or "Unknown Album" if none was provided.
 | 
			
		||||
	/// The current track's album, or `""` if none was provided.
 | 
			
		||||
	///
 | 
			
		||||
	/// > [!TIP] Use `player.trackAlbum || "Unknown Album"` to provide a message
 | 
			
		||||
	/// > when no album is available.
 | 
			
		||||
	Q_PROPERTY(QString trackAlbum READ trackAlbum NOTIFY trackAlbumChanged BINDABLE bindableTrackAlbum);
 | 
			
		||||
	/// The current track's album artist, or "Unknown Artist" if none was provided.
 | 
			
		||||
	/// The current track's album artist, or `""` if none was provided.
 | 
			
		||||
	///
 | 
			
		||||
	/// > [!TIP] Use `player.trackAlbumArtist || "Unknown Album"` to provide a message
 | 
			
		||||
	/// > when no album artist is available.
 | 
			
		||||
	Q_PROPERTY(QString trackAlbumArtist READ trackAlbumArtist NOTIFY trackAlbumArtistChanged BINDABLE bindableTrackAlbumArtist);
 | 
			
		||||
	/// The current track's art url, or `""` if none was provided.
 | 
			
		||||
	Q_PROPERTY(QString trackArtUrl READ trackArtUrl NOTIFY trackArtUrlChanged BINDABLE bindableTrackArtUrl);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue