1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-24 00:11:43 +01:00

Make it an option whether to show the OSD when the volume changes, and disable it by default.

Fixes issue #31
This commit is contained in:
David Sansome 2010-02-27 00:48:27 +00:00
parent 9993342ead
commit f7d99ad720
4 changed files with 25 additions and 10 deletions

View File

@ -10,7 +10,8 @@ OSD::OSD(QSystemTrayIcon* tray_icon, QObject* parent)
: QObject(parent), : QObject(parent),
tray_icon_(tray_icon), tray_icon_(tray_icon),
timeout_(5000), timeout_(5000),
behaviour_(Native) behaviour_(Native),
show_on_volume_change_(false)
{ {
ReloadSettings(); ReloadSettings();
Init(); Init();
@ -21,6 +22,7 @@ void OSD::ReloadSettings() {
s.beginGroup(kSettingsGroup); s.beginGroup(kSettingsGroup);
behaviour_ = OSD::Behaviour(s.value("Behaviour", Native).toInt()); behaviour_ = OSD::Behaviour(s.value("Behaviour", Native).toInt());
timeout_ = s.value("Timeout", 5000).toInt(); timeout_ = s.value("Timeout", 5000).toInt();
show_on_volume_change_ = s.value("ShowOnVolumeChange", false).toBool();
if (!SupportsNativeNotifications() && behaviour_ == Native) if (!SupportsNativeNotifications() && behaviour_ == Native)
behaviour_ = TrayPopup; behaviour_ = TrayPopup;
@ -54,6 +56,9 @@ void OSD::Stopped() {
} }
void OSD::VolumeChanged(int value) { void OSD::VolumeChanged(int value) {
if (!show_on_volume_change_)
return;
ShowMessage(QCoreApplication::applicationName(), tr("Volume %1%").arg(value)); ShowMessage(QCoreApplication::applicationName(), tr("Volume %1%").arg(value));
} }

View File

@ -60,6 +60,7 @@ class OSD : public QObject {
QSystemTrayIcon* tray_icon_; QSystemTrayIcon* tray_icon_;
int timeout_; int timeout_;
Behaviour behaviour_; Behaviour behaviour_;
bool show_on_volume_change_;
#ifdef Q_WS_X11 #ifdef Q_WS_X11
NotifyNotification* notification_; NotifyNotification* notification_;

View File

@ -68,6 +68,7 @@ void SettingsDialog::accept() {
s.beginGroup(OSD::kSettingsGroup); s.beginGroup(OSD::kSettingsGroup);
s.setValue("Behaviour", int(osd_behaviour)); s.setValue("Behaviour", int(osd_behaviour));
s.setValue("Timeout", ui_.notifications_duration->value() * 1000); s.setValue("Timeout", ui_.notifications_duration->value() * 1000);
s.setValue("ShowOnVolumeChange", ui_.notifications_volume->isChecked());
s.endGroup(); s.endGroup();
QDialog::accept(); QDialog::accept();
@ -112,9 +113,12 @@ void SettingsDialog::showEvent(QShowEvent*) {
break; break;
} }
ui_.notifications_duration->setValue(s.value("Timeout", 5000).toInt() / 1000); ui_.notifications_duration->setValue(s.value("Timeout", 5000).toInt() / 1000);
ui_.notifications_volume->setChecked(s.value("ShowOnVolumeChange", false).toBool());
s.endGroup(); s.endGroup();
} }
void SettingsDialog::NotificationTypeChanged() { void SettingsDialog::NotificationTypeChanged() {
ui_.notifications_options->setEnabled(!ui_.notifications_none->isChecked()); bool enabled = !ui_.notifications_none->isChecked();
ui_.notifications_options->setEnabled(enabled);
ui_.notifications_volume->setEnabled(enabled);
} }

View File

@ -51,7 +51,7 @@
<string>Playback</string> <string>Playback</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../data/data.qrc"> <iconset>
<normaloff>:/media-playback-start-32.png</normaloff>:/media-playback-start-32.png</iconset> <normaloff>:/media-playback-start-32.png</normaloff>:/media-playback-start-32.png</iconset>
</property> </property>
</item> </item>
@ -60,7 +60,7 @@
<string>Notifications</string> <string>Notifications</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../data/data.qrc"> <iconset>
<normaloff>:/lightbulb.png</normaloff>:/lightbulb.png</iconset> <normaloff>:/lightbulb.png</normaloff>:/lightbulb.png</iconset>
</property> </property>
</item> </item>
@ -69,7 +69,7 @@
<string>Music Library</string> <string>Music Library</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../data/data.qrc"> <iconset>
<normaloff>:/library.png</normaloff>:/library.png</iconset> <normaloff>:/library.png</normaloff>:/library.png</iconset>
</property> </property>
</item> </item>
@ -78,7 +78,7 @@
<string>Last.fm</string> <string>Last.fm</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../data/data.qrc"> <iconset>
<normaloff>:/last.fm/as.png</normaloff>:/last.fm/as.png</iconset> <normaloff>:/last.fm/as.png</normaloff>:/last.fm/as.png</iconset>
</property> </property>
</item> </item>
@ -99,7 +99,7 @@
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="playback_page"> <widget class="QWidget" name="playback_page">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -273,6 +273,13 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="notifications_volume">
<property name="text">
<string>Show a notification when I change the volume</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_3"> <spacer name="verticalSpacer_3">
<property name="orientation"> <property name="orientation">
@ -349,9 +356,7 @@
<tabstop>fadeout_duration</tabstop> <tabstop>fadeout_duration</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources/>
<include location="../data/data.qrc"/>
</resources>
<connections> <connections>
<connection> <connection>
<sender>list</sender> <sender>list</sender>