aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--src/plugins/General/kdenotify/kdenotify.cpp25
-rw-r--r--src/plugins/General/kdenotify/kdenotify.h2
-rw-r--r--src/plugins/General/kdenotify/settingsdialog.cpp22
-rw-r--r--src/plugins/General/kdenotify/settingsdialog.h2
-rw-r--r--src/plugins/General/kdenotify/settingsdialog.ui37
5 files changed, 59 insertions, 29 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());
+}
diff --git a/src/plugins/General/kdenotify/kdenotify.h b/src/plugins/General/kdenotify/kdenotify.h
index b82dd1e5d..b08636110 100644
--- a/src/plugins/General/kdenotify/kdenotify.h
+++ b/src/plugins/General/kdenotify/kdenotify.h
@@ -55,6 +55,8 @@ private:
private slots:
void showMetaData();
void notificationClosed(uint id, uint reason);
+ void onVolumeChanged(int percent);
+ void onMutedChanged(bool muted);
};
#endif // KDENOTIFY_H
diff --git a/src/plugins/General/kdenotify/settingsdialog.cpp b/src/plugins/General/kdenotify/settingsdialog.cpp
index 3aadcd9fb..8b365033e 100644
--- a/src/plugins/General/kdenotify/settingsdialog.cpp
+++ b/src/plugins/General/kdenotify/settingsdialog.cpp
@@ -28,32 +28,34 @@
SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent),
- ui(new Ui::SettingsDialog)
+ m_ui(new Ui::SettingsDialog)
{
- ui->setupUi(this);
+ m_ui->setupUi(this);
QSettings settings(Qmmp::configFile(),QSettings::IniFormat);
settings.beginGroup("Kde_Notifier");
- ui->notifyDelaySpinBox->setValue(settings.value("notify_duration",5000).toInt()/1000);
- ui->showCoversCheckBox->setChecked(settings.value("show_covers",true).toBool());
- ui->updateNotifyCheckBox->setChecked(settings.value("update_notify",true).toBool());
+ m_ui->notifyDelaySpinBox->setValue(settings.value("notify_duration",5000).toInt()/1000);
+ m_ui->showCoversCheckBox->setChecked(settings.value("show_covers",true).toBool());
+ m_ui->updateNotifyCheckBox->setChecked(settings.value("update_notify",true).toBool());
+ m_ui->volumeCheckBox->setChecked(settings.value("volume_notification", false).toBool());
m_template = settings.value("template", DEFAULT_TEMPLATE).toString();
settings.endGroup();
}
SettingsDialog::~SettingsDialog()
{
- delete ui;
+ delete m_ui;
}
void SettingsDialog::accept()
{
QSettings settings(Qmmp::configFile(),QSettings::IniFormat);
settings.beginGroup("Kde_Notifier");
- settings.setValue("notify_duration",ui->notifyDelaySpinBox->value()*1000);
- settings.setValue("show_covers",ui->showCoversCheckBox->isChecked());
+ settings.setValue("notify_duration",m_ui->notifyDelaySpinBox->value()*1000);
+ settings.setValue("show_covers",m_ui->showCoversCheckBox->isChecked());
settings.setValue("template",m_template);
- settings.setValue("update_notify",ui->updateNotifyCheckBox->isChecked());
+ settings.setValue("update_notify",m_ui->updateNotifyCheckBox->isChecked());
+ settings.setValue("volume_notification", m_ui->volumeCheckBox->isChecked());
settings.endGroup();
QDialog::accept();
}
@@ -63,7 +65,7 @@ void SettingsDialog::changeEvent(QEvent *e)
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
- ui->retranslateUi(this);
+ m_ui->retranslateUi(this);
break;
default:
break;
diff --git a/src/plugins/General/kdenotify/settingsdialog.h b/src/plugins/General/kdenotify/settingsdialog.h
index fb15f50ad..41497055f 100644
--- a/src/plugins/General/kdenotify/settingsdialog.h
+++ b/src/plugins/General/kdenotify/settingsdialog.h
@@ -45,7 +45,7 @@ protected:
void changeEvent(QEvent *e) override;
private:
- Ui::SettingsDialog *ui;
+ Ui::SettingsDialog *m_ui;
QString m_template;
};
diff --git a/src/plugins/General/kdenotify/settingsdialog.ui b/src/plugins/General/kdenotify/settingsdialog.ui
index 023bfd649..4c549bc2b 100644
--- a/src/plugins/General/kdenotify/settingsdialog.ui
+++ b/src/plugins/General/kdenotify/settingsdialog.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>370</width>
- <height>241</height>
+ <width>413</width>
+ <height>326</height>
</rect>
</property>
<property name="windowTitle">
@@ -46,16 +46,10 @@
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QSpinBox" name="notifyDelaySpinBox">
- <property name="suffix">
- <string>s</string>
- </property>
- <property name="maximum">
- <number>100</number>
- </property>
- <property name="value">
- <number>10</number>
+ <item row="1" column="0" colspan="3">
+ <widget class="QCheckBox" name="updateNotifyCheckBox">
+ <property name="text">
+ <string>Update visible notification instead create new</string>
</property>
</widget>
</item>
@@ -72,10 +66,23 @@
</property>
</spacer>
</item>
- <item row="1" column="0" colspan="3">
- <widget class="QCheckBox" name="updateNotifyCheckBox">
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="notifyDelaySpinBox">
+ <property name="suffix">
+ <string>s</string>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="3">
+ <widget class="QCheckBox" name="volumeCheckBox">
<property name="text">
- <string>Update visible notification instead create new</string>
+ <string>Volume change notification</string>
</property>
</widget>
</item>