aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/kdenotify/kdenotify.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2021-11-20 15:15:37 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2021-11-20 15:15:37 +0000
commitc60e619e4dd489cd05dde007bb3305126cdcf8ad (patch)
tree7df0d2f6d7aad7c36343054ff337814438d82c46 /src/plugins/General/kdenotify/kdenotify.cpp
parent1c213e06a7b87414a95ed08db22112828a9e4bc1 (diff)
downloadqmmp-c60e619e4dd489cd05dde007bb3305126cdcf8ad.tar.gz
qmmp-c60e619e4dd489cd05dde007bb3305126cdcf8ad.tar.bz2
qmmp-c60e619e4dd489cd05dde007bb3305126cdcf8ad.zip
kdenotify: added volume change notification
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@10392 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/kdenotify/kdenotify.cpp')
-rw-r--r--src/plugins/General/kdenotify/kdenotify.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/plugins/General/kdenotify/kdenotify.cpp b/src/plugins/General/kdenotify/kdenotify.cpp
index 782a0dce3..e9021407f 100644
--- a/src/plugins/General/kdenotify/kdenotify.cpp
+++ b/src/plugins/General/kdenotify/kdenotify.cpp
@@ -29,7 +29,7 @@
#include <QImage>
#include <QApplication>
#include <QVariant>
-
+#include <QStandardPaths>
#include <qmmpui/metadataformatter.h>
#include <qmmp/soundcore.h>
#include <qmmp/metadatamanager.h>
@@ -69,7 +69,6 @@ KdeNotify::KdeNotify(QObject *parent) : QObject(parent),m_useFreedesktopSpec(fal
m_template = settings.value("template", DEFAULT_TEMPLATE).toString();
m_template.remove("\n");
m_updateNotify = settings.value("update_notify",true).toBool();
- settings.endGroup();
m_currentNotifyId = 0;
if(m_updateNotify)
@@ -85,6 +84,13 @@ KdeNotify::KdeNotify(QObject *parent) : QObject(parent),m_useFreedesktopSpec(fal
connect(timer,SIGNAL(timeout()),SLOT(showMetaData()));
connect(SoundCore::instance(),SIGNAL(trackInfoChanged()),timer, SLOT(start()));
}
+
+ if(settings.value("volume_notification", false).toBool())
+ {
+ connect(SoundCore::instance(), SIGNAL(volumeChanged(int)), SLOT(onVolumeChanged(int)));
+ connect(SoundCore::instance(), SIGNAL(mutedChanged(bool)), SLOT(onMutedChanged(bool)));
+ }
+ settings.endGroup();
}
KdeNotify::~KdeNotify()
@@ -117,7 +123,7 @@ QList<QVariant> KdeNotify::prepareNotification()
args.append("Qmmp"); //app-name
args.append(m_currentNotifyId); //replaces-id;
if(!m_useFreedesktopSpec)
- args.append(""); //event-id
+ args.append(QString()); //event-id
args.append(m_imagesDir + "/app-icon.png"); //app-icon(path to icon on disk)
args.append(tr("Qmmp now playing:")); //summary (notification title)
@@ -177,3 +183,16 @@ void KdeNotify::notificationClosed(uint id, uint reason)
if(m_currentNotifyId == id)
m_currentNotifyId = 0;
}
+
+void KdeNotify::onVolumeChanged(int percent)
+{
+ QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), QStringLiteral("/org/kde/osdService"),
+ QStringLiteral("org.kde.osdService"), QStringLiteral("mediaPlayerVolumeChanged"));
+ msg.setArguments({ percent, "Qmmp", "qmmp-simple" });
+ QDBusConnection::sessionBus().asyncCall(msg);
+}
+
+void KdeNotify::onMutedChanged(bool muted)
+{
+ onVolumeChanged(muted ? 0 : SoundCore::instance()->volume());
+}