mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-08 08:11:36 +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:
parent
9993342ead
commit
f7d99ad720
@ -10,7 +10,8 @@ OSD::OSD(QSystemTrayIcon* tray_icon, QObject* parent)
|
||||
: QObject(parent),
|
||||
tray_icon_(tray_icon),
|
||||
timeout_(5000),
|
||||
behaviour_(Native)
|
||||
behaviour_(Native),
|
||||
show_on_volume_change_(false)
|
||||
{
|
||||
ReloadSettings();
|
||||
Init();
|
||||
@ -21,6 +22,7 @@ void OSD::ReloadSettings() {
|
||||
s.beginGroup(kSettingsGroup);
|
||||
behaviour_ = OSD::Behaviour(s.value("Behaviour", Native).toInt());
|
||||
timeout_ = s.value("Timeout", 5000).toInt();
|
||||
show_on_volume_change_ = s.value("ShowOnVolumeChange", false).toBool();
|
||||
|
||||
if (!SupportsNativeNotifications() && behaviour_ == Native)
|
||||
behaviour_ = TrayPopup;
|
||||
@ -54,6 +56,9 @@ void OSD::Stopped() {
|
||||
}
|
||||
|
||||
void OSD::VolumeChanged(int value) {
|
||||
if (!show_on_volume_change_)
|
||||
return;
|
||||
|
||||
ShowMessage(QCoreApplication::applicationName(), tr("Volume %1%").arg(value));
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ class OSD : public QObject {
|
||||
QSystemTrayIcon* tray_icon_;
|
||||
int timeout_;
|
||||
Behaviour behaviour_;
|
||||
bool show_on_volume_change_;
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
NotifyNotification* notification_;
|
||||
|
@ -68,6 +68,7 @@ void SettingsDialog::accept() {
|
||||
s.beginGroup(OSD::kSettingsGroup);
|
||||
s.setValue("Behaviour", int(osd_behaviour));
|
||||
s.setValue("Timeout", ui_.notifications_duration->value() * 1000);
|
||||
s.setValue("ShowOnVolumeChange", ui_.notifications_volume->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
QDialog::accept();
|
||||
@ -112,9 +113,12 @@ void SettingsDialog::showEvent(QShowEvent*) {
|
||||
break;
|
||||
}
|
||||
ui_.notifications_duration->setValue(s.value("Timeout", 5000).toInt() / 1000);
|
||||
ui_.notifications_volume->setChecked(s.value("ShowOnVolumeChange", false).toBool());
|
||||
s.endGroup();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
<string>Playback</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../data/data.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/media-playback-start-32.png</normaloff>:/media-playback-start-32.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
@ -60,7 +60,7 @@
|
||||
<string>Notifications</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../data/data.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/lightbulb.png</normaloff>:/lightbulb.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
@ -69,7 +69,7 @@
|
||||
<string>Music Library</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../data/data.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/library.png</normaloff>:/library.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
@ -78,7 +78,7 @@
|
||||
<string>Last.fm</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../data/data.qrc">
|
||||
<iconset>
|
||||
<normaloff>:/last.fm/as.png</normaloff>:/last.fm/as.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
@ -99,7 +99,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="playback_page">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
@ -273,6 +273,13 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</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>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
@ -349,9 +356,7 @@
|
||||
<tabstop>fadeout_duration</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../data/data.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>list</sender>
|
||||
|
Loading…
Reference in New Issue
Block a user