[PATCH] libkmpris: allow MultiplexerModel to show actual player name
authorFushan Wen <qydwhotmail@gmail.com>
Mon, 24 Mar 2025 12:33:47 +0000 (20:33 +0800)
committerAurélien COUDERC <coucouf@debian.org>
Mon, 21 Jul 2025 16:21:10 +0000 (18:21 +0200)
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

applets/mediacontroller/package/contents/ui/ExpandedRepresentation.qml
libkmpris/mpris2sourcemodel.cpp
libkmpris/mpris2sourcemodel.h
libkmpris/multiplexermodel.cpp

index b6b6a3edda15f02a5cd462e83949130942274a6d..7f106f29d2817454066e4ed80d54e0e16f385f69 100644 (file)
@@ -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
index 02d51dd071fd0dae2dc7e62116dda95bd33b420d..418acfdcd6438a4c81b1f7ef5c3456d61b59a5b1 100644 (file)
@@ -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<int, QByteArray> Mpris2SourceModel::roleNames() const
         {IdentityRole, QByteArrayLiteral("identity")},
         {IconNameRole, QByteArrayLiteral("iconName")},
         {KDEPidRole, QByteArrayLiteral("kdePid")},
+        {IsMultiplexerRole, QByteArrayLiteral("isMultiplexer")},
         {ContainerRole, QByteArrayLiteral("container")},
     };
 }
index 7ad885faffe27cc880146b06d0a648df45c4a8fc..6ed6ca1541583cbcdcf27f0d8def63621b47db6d 100644 (file)
@@ -55,6 +55,7 @@ public:
         IconNameRole,
         InstancePidRole,
         KDEPidRole,
+        IsMultiplexerRole,
     };
     Q_ENUM(Role)
 
index 670aa5cd34fdfc4f0c11bd9b92a86561ae75eeee..9367d4b9df2760cf9e72c97e6b28f7a4b0133a36 100644 (file)
@@ -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);
     }