Verified Commit 1a1f672c authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

dataengines/mpris2: Delete Multiplexer when there is no player

When all players are closed, media player applet on the
desktop still shows a track from the last player, and
player control buttons are still clickable but have no effect.

Add a new signal named `playerListEmptied()`. When the proxy list is empty,
the signal is emitted and `m_multiplexer` is scheduled to be deleted, so
the media player applet on the desktop can indicate the right status of
no player opened.

BUG: 446098
FIXED-IN: 5.24
parent ac565420
Pipeline #103663 passed with stage
in 8 minutes and 42 seconds
......@@ -177,6 +177,8 @@ void Mpris2Engine::createMultiplexer()
++i;
}
addSource(m_multiplexer.data());
// Don't delete sourceName because currentData refers to it
connect(m_multiplexer, &Multiplexer::playerListEmptied, m_multiplexer, &Multiplexer::deleteLater, Qt::UniqueConnection);
}
K_PLUGIN_CLASS_WITH_JSON(Mpris2Engine, "plasma-dataengine-mpris2.json")
......
......@@ -126,6 +126,11 @@ void Multiplexer::removePlayer(const QString &name)
if (name == m_activeName) {
setBestActive();
}
// When there is no player opened
if (m_proxies.empty()) {
Q_EMIT playerListEmptied();
}
}
PlayerContainer *Multiplexer::activePlayer() const
......
......@@ -28,6 +28,13 @@ public:
Q_SIGNALS:
void activePlayerChanged(PlayerContainer *container);
/**
* There is no player opened.
*
* @since 5.24
*/
void playerListEmptied();
private Q_SLOTS:
void playerUpdated(const QString &name, const Plasma::DataEngine::Data &data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment