From: Fushan Wen Date: Mon, 24 Mar 2025 12:33:47 +0000 (+0800) Subject: [PATCH] libkmpris: allow MultiplexerModel to show actual player name X-Git-Tag: archive/raspbian/4%6.3.6-2+rpi1^2~30 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d787be7d6147ba426f8852063625bf5d877eb3e1;p=plasma-workspace.git [PATCH] libkmpris: allow MultiplexerModel to show actual player name The lock screen needs it to show the actual player name instead of "Choose player automatically" Gbp-Pq: Name upstream_e4e0dee5_libkmpris-allow-MultiplexerModel-to-show-actual-player-name.patch --- diff --git a/applets/mediacontroller/package/contents/ui/ExpandedRepresentation.qml b/applets/mediacontroller/package/contents/ui/ExpandedRepresentation.qml index b6b6a3ed..7f106f29 100644 --- a/applets/mediacontroller/package/contents/ui/ExpandedRepresentation.qml +++ b/applets/mediacontroller/package/contents/ui/ExpandedRepresentation.qml @@ -676,7 +676,7 @@ PlasmaExtras.Representation { display: PlasmaComponents3.AbstractButton.IconOnly icon.name: model.iconName icon.height: Kirigami.Units.iconSizes.smallMedium - text: model.identity + text: model.isMultiplexer ? i18nc("@action:button", "Choose player automatically") : model.identity // Keep the delegate centered by offsetting the padding removed in the parent bottomPadding: verticalPadding + headerItem.bottomPadding topPadding: verticalPadding - headerItem.bottomPadding diff --git a/libkmpris/mpris2sourcemodel.cpp b/libkmpris/mpris2sourcemodel.cpp index 02d51dd0..418acfdc 100644 --- a/libkmpris/mpris2sourcemodel.cpp +++ b/libkmpris/mpris2sourcemodel.cpp @@ -98,6 +98,8 @@ QVariant Mpris2SourceModel::dataFromPlayer(PlayerContainer *container, int role) return container->instancePid(); case KDEPidRole: return container->kdePid(); + case IsMultiplexerRole: + return false; case ContainerRole: return QVariant::fromValue(container); default: @@ -193,6 +195,7 @@ QHash Mpris2SourceModel::roleNames() const {IdentityRole, QByteArrayLiteral("identity")}, {IconNameRole, QByteArrayLiteral("iconName")}, {KDEPidRole, QByteArrayLiteral("kdePid")}, + {IsMultiplexerRole, QByteArrayLiteral("isMultiplexer")}, {ContainerRole, QByteArrayLiteral("container")}, }; } diff --git a/libkmpris/mpris2sourcemodel.h b/libkmpris/mpris2sourcemodel.h index 7ad885fa..6ed6ca15 100644 --- a/libkmpris/mpris2sourcemodel.h +++ b/libkmpris/mpris2sourcemodel.h @@ -55,6 +55,7 @@ public: IconNameRole, InstancePidRole, KDEPidRole, + IsMultiplexerRole, }; Q_ENUM(Role) diff --git a/libkmpris/multiplexermodel.cpp b/libkmpris/multiplexermodel.cpp index 670aa5cd..9367d4b9 100644 --- a/libkmpris/multiplexermodel.cpp +++ b/libkmpris/multiplexermodel.cpp @@ -71,10 +71,10 @@ QVariant MultiplexerModel::data(const QModelIndex &index, int role) const } switch (role) { - case Mpris2SourceModel::IdentityRole: - return i18nc("@action:button", "Choose player automatically"); case Mpris2SourceModel::IconNameRole: return QStringLiteral("emblem-favorite"); + case Mpris2SourceModel::IsMultiplexerRole: + return true; default: return Mpris2SourceModel::dataFromPlayer(m_activePlayer, role); }