Merge branch 'stable'
This commit is contained in:
commit
25944356fc
2 changed files with 22 additions and 7 deletions
|
@ -42,21 +42,33 @@ MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args
|
||||||
: KdeConnectPlugin(parent, args)
|
: KdeConnectPlugin(parent, args)
|
||||||
, prevVolume(-1)
|
, prevVolume(-1)
|
||||||
{
|
{
|
||||||
m_watcher = new QDBusServiceWatcher("org.mpris.MediaPlayer2", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this);
|
m_watcher = new QDBusServiceWatcher(QString(), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this);
|
||||||
|
|
||||||
connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &MprisControlPlugin::addPlayer);
|
connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &MprisControlPlugin::addPlayer);
|
||||||
connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &MprisControlPlugin::removePlayer);
|
connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &MprisControlPlugin::removePlayer);
|
||||||
|
|
||||||
//Add existing interfaces
|
//Add existing interfaces
|
||||||
QStringList interfaces = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
|
QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
|
||||||
Q_FOREACH (const QString& iface, interfaces) {
|
Q_FOREACH (const QString& service, services) {
|
||||||
if (iface.startsWith("org.mpris.MediaPlayer2")) {
|
addService(service);
|
||||||
addPlayer(iface);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MprisControlPlugin::addService(const QString& service)
|
||||||
|
{
|
||||||
|
if (service.startsWith(QLatin1String("org.mpris.MediaPlayer2"))) {
|
||||||
|
addPlayer(service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MprisControlPlugin::removeService(const QString& service)
|
||||||
|
{
|
||||||
|
if (service.startsWith(QLatin1String("org.mpris.MediaPlayer2"))) {
|
||||||
|
removePlayer(service);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MprisControlPlugin::addPlayer(const QString& service)
|
void MprisControlPlugin::addPlayer(const QString& service)
|
||||||
{
|
{
|
||||||
QDBusInterface mprisInterface(service, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2");
|
QDBusInterface mprisInterface(service, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2");
|
||||||
|
|
|
@ -49,6 +49,9 @@ private Q_SLOTS:
|
||||||
void seeked(qlonglong);
|
void seeked(qlonglong);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void addService(const QString& service);
|
||||||
|
void removeService(const QString& service);
|
||||||
|
|
||||||
void addPlayer(const QString& ifaceName);
|
void addPlayer(const QString& ifaceName);
|
||||||
void removePlayer(const QString& ifaceName);
|
void removePlayer(const QString& ifaceName);
|
||||||
void sendPlayerList();
|
void sendPlayerList();
|
||||||
|
|
Loading…
Reference in a new issue