diff --git a/app/qml/mpris.qml b/app/qml/mpris.qml index 3a5d244ce..00fb3f95c 100644 --- a/app/qml/mpris.qml +++ b/app/qml/mpris.qml @@ -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 diff --git a/interfaces/dbusinterfaces.h b/interfaces/dbusinterfaces.h index bd918307f..1bd4f2a3b 100644 --- a/interfaces/dbusinterfaces.h +++ b/interfaces/dbusinterfaces.h @@ -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) diff --git a/plugins/mprisremote/mprisremoteplugin.cpp b/plugins/mprisremote/mprisremoteplugin.cpp index c7d8dae63..ebe6c525a 100644 --- a/plugins/mprisremote/mprisremoteplugin.cpp +++ b/plugins/mprisremote/mprisremoteplugin.cpp @@ -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); diff --git a/plugins/mprisremote/mprisremoteplugin.h b/plugins/mprisremote/mprisremoteplugin.h index 1c4025293..00df67124 100644 --- a/plugins/mprisremote/mprisremoteplugin.h +++ b/plugins/mprisremote/mprisremoteplugin.h @@ -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);