Show album art in the kdeconnect-app

This commit is contained in:
Albert Vaca Cintora
2025-12-11 00:55:48 +01:00
parent eb2a519633
commit 3445ad4842
4 changed files with 38 additions and 0 deletions

View File

@@ -80,6 +80,23 @@ Kirigami.Page
}
Item { Layout.fillHeight: true }
Item {
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
Layout.preferredHeight: 240
Layout.preferredWidth: 240
width: 240; height: 240
Image {
id: albumArt
anchors.centerIn: parent
width: 220; height: 220
fillMode: Image.PreserveAspectFit
source: root.pluginInterface.localAlbumArtUrl
visible: !!root.pluginInterface.localAlbumArtUrl && root.pluginInterface.localAlbumArtUrl.length > 0
smooth: true
}
}
ComboBox {
Layout.fillWidth: true
model: root.pluginInterface.playerList

View File

@@ -142,6 +142,7 @@ class KDECONNECTINTERFACES_EXPORT MprisDbusInterface : public OrgKdeKdeconnectDe
Q_PROPERTY(QString title READ title NOTIFY propertiesChangedProxy)
Q_PROPERTY(QString artist READ artist NOTIFY propertiesChangedProxy)
Q_PROPERTY(QString album READ album NOTIFY propertiesChangedProxy)
Q_PROPERTY(QString localAlbumArtUrl READ localAlbumArtUrl NOTIFY propertiesChangedProxy)
Q_PROPERTY(QStringList playerList READ playerList NOTIFY propertiesChangedProxy)
Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY propertiesChangedProxy)

View File

@@ -19,6 +19,16 @@
K_PLUGIN_CLASS_WITH_JSON(MprisRemotePlugin, "kdeconnect_mprisremote.json")
MprisRemotePlugin::MprisRemotePlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
{
connect(AlbumArtCache::instance(), &AlbumArtCache::albumArtFetched, this, [this](const QString &player) {
if (player == m_currentPlayer) {
Q_EMIT propertiesChanged();
}
});
}
void MprisRemotePlugin::receivePacket(const NetworkPacket &np)
{
if (np.type() != PACKET_TYPE_MPRIS)
@@ -181,6 +191,12 @@ QString MprisRemotePlugin::artist() const
return player ? player->artist() : QString();
}
QString MprisRemotePlugin::localAlbumArtUrl() const
{
auto player = m_players.value(m_currentPlayer);
return player ? player->localAlbumArtUrl().toString() : QString();
}
bool MprisRemotePlugin::canSeek() const
{
auto player = m_players.value(m_currentPlayer);

View File

@@ -28,11 +28,14 @@ class MprisRemotePlugin : public KdeConnectPlugin
Q_PROPERTY(QString title READ title NOTIFY propertiesChanged)
Q_PROPERTY(QString artist READ artist NOTIFY propertiesChanged)
Q_PROPERTY(QString album READ album NOTIFY propertiesChanged)
Q_PROPERTY(QString localAlbumArtUrl READ localAlbumArtUrl NOTIFY propertiesChanged)
Q_PROPERTY(bool canSeek READ canSeek NOTIFY propertiesChanged)
public:
using KdeConnectPlugin::KdeConnectPlugin;
explicit MprisRemotePlugin(QObject *parent, const QVariantList &args);
long position() const;
int volume() const;
int length() const;
@@ -42,6 +45,7 @@ public:
QString title() const;
QString artist() const;
QString album() const;
QString localAlbumArtUrl() const;
bool canSeek() const;
void setVolume(int volume);