Changeset View
Changeset View
Standalone View
Standalone View
plugins/pausemusic/pausemusicplugin.cpp
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 83 | if (mute) { | |||
---|---|---|---|---|---|
85 | if (isKMixMuted() == 0) { | 85 | if (isKMixMuted() == 0) { | ||
86 | muted = true; | 86 | muted = true; | ||
87 | kmixInterface.call(QStringLiteral("trigger")); | 87 | kmixInterface.call(QStringLiteral("trigger")); | ||
88 | } | 88 | } | ||
89 | } | 89 | } | ||
90 | 90 | | |||
91 | if (pause) { | 91 | if (pause) { | ||
92 | //Search for interfaces currently playing | 92 | //Search for interfaces currently playing | ||
93 | QStringList interfaces = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); | 93 | const QStringList interfaces = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); | ||
94 | Q_FOREACH (const QString& iface, interfaces) { | 94 | for (const QString& iface : interfaces) { | ||
95 | if (iface.startsWith(QLatin1String("org.mpris.MediaPlayer2"))) { | 95 | if (iface.startsWith(QLatin1String("org.mpris.MediaPlayer2"))) { | ||
96 | QDBusInterface mprisInterface(iface, QStringLiteral("/org/mpris/MediaPlayer2"), QStringLiteral("org.mpris.MediaPlayer2.Player")); | 96 | QDBusInterface mprisInterface(iface, QStringLiteral("/org/mpris/MediaPlayer2"), QStringLiteral("org.mpris.MediaPlayer2.Player")); | ||
97 | QString status = mprisInterface.property("PlaybackStatus").toString(); | 97 | QString status = mprisInterface.property("PlaybackStatus").toString(); | ||
98 | if (status == QLatin1String("Playing")) { | 98 | if (status == QLatin1String("Playing")) { | ||
99 | if (!pausedSources.contains(iface)) { | 99 | if (!pausedSources.contains(iface)) { | ||
100 | pausedSources.insert(iface); | 100 | pausedSources.insert(iface); | ||
101 | if (mprisInterface.property("CanPause").toBool()) { | 101 | if (mprisInterface.property("CanPause").toBool()) { | ||
102 | mprisInterface.asyncCall(QStringLiteral("Pause")); | 102 | mprisInterface.asyncCall(QStringLiteral("Pause")); | ||
Show All 12 Lines | 114 | if (mute && muted) { | |||
115 | QDBusInterface kmixInterface(QStringLiteral("org.kde.kmix"), QStringLiteral("/kmix/KMixWindow/actions/mute"), QStringLiteral("org.qtproject.Qt.QAction")); | 115 | QDBusInterface kmixInterface(QStringLiteral("org.kde.kmix"), QStringLiteral("/kmix/KMixWindow/actions/mute"), QStringLiteral("org.qtproject.Qt.QAction")); | ||
116 | if (isKMixMuted() > 0) { | 116 | if (isKMixMuted() > 0) { | ||
117 | kmixInterface.call(QStringLiteral("trigger")); | 117 | kmixInterface.call(QStringLiteral("trigger")); | ||
118 | } | 118 | } | ||
119 | muted = false; | 119 | muted = false; | ||
120 | } | 120 | } | ||
121 | 121 | | |||
122 | if (pause && !pausedSources.empty()) { | 122 | if (pause && !pausedSources.empty()) { | ||
123 | Q_FOREACH (const QString& iface, pausedSources) { | 123 | for (const QString& iface : qAsConst(pausedSources)) { | ||
124 | QDBusInterface mprisInterface(iface, QStringLiteral("/org/mpris/MediaPlayer2"), QStringLiteral("org.mpris.MediaPlayer2.Player")); | 124 | QDBusInterface mprisInterface(iface, QStringLiteral("/org/mpris/MediaPlayer2"), QStringLiteral("org.mpris.MediaPlayer2.Player")); | ||
125 | mprisInterface.asyncCall(QStringLiteral("PlayPause")); | 125 | mprisInterface.asyncCall(QStringLiteral("PlayPause")); | ||
126 | } | 126 | } | ||
127 | pausedSources.clear(); | 127 | pausedSources.clear(); | ||
128 | } | 128 | } | ||
129 | 129 | | |||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | return true; | 132 | return true; | ||
133 | 133 | | |||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | #include "pausemusicplugin.moc" | 136 | #include "pausemusicplugin.moc" |