diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5e931cdc5..447bf1e9e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -193,7 +193,7 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent) connect(player_, SIGNAL(Stopped()), osd_, SLOT(Stopped())); connect(player_, SIGNAL(VolumeChanged(int)), osd_, SLOT(VolumeChanged(int))); connect(player_, SIGNAL(VolumeChanged(int)), ui_.volume, SLOT(setValue(int))); - connect(player_, SIGNAL(ForceShowOSD(Song)), osd_, SLOT(SongChanged(Song))); + connect(player_, SIGNAL(ForceShowOSD(Song)), SLOT(ForceShowOSD(Song))); connect(playlist_, SIGNAL(CurrentSongChanged(Song)), osd_, SLOT(SongChanged(Song))); connect(playlist_, SIGNAL(CurrentSongChanged(Song)), player_, SLOT(CurrentMetadataChanged(Song))); connect(playlist_, SIGNAL(PlaylistChanged()), player_, SLOT(PlaylistChanged())); @@ -946,3 +946,8 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) { if (options.show_osd()) player_->ShowOSD(); } + +void MainWindow::ForceShowOSD(const Song &song) { + osd_->ForceShowNextNotification(); + osd_->SongChanged(song); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 5897d9a4f..29128b66b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -80,6 +80,7 @@ class MainWindow : public QMainWindow { void MediaStopped(); void MediaPaused(); void MediaPlaying(); + void ForceShowOSD(const Song& song); void PlaylistRightClick(const QPoint& global_pos, const QModelIndex& index); void PlaylistPlay(); diff --git a/src/osd.cpp b/src/osd.cpp index 87ca5778a..4437a3e05 100644 --- a/src/osd.cpp +++ b/src/osd.cpp @@ -30,6 +30,7 @@ OSD::OSD(QSystemTrayIcon* tray_icon, QObject* parent) behaviour_(Native), show_on_volume_change_(false), show_art_(true), + force_show_next_(false), pretty_popup_(new OSDPretty) { ReloadSettings(); @@ -106,12 +107,16 @@ void OSD::ShowMessage(const QString& summary, tray_icon_->showMessage(summary, message, QSystemTrayIcon::NoIcon, timeout_msec_); break; + case Disabled: + if (!force_show_next_) + break; + force_show_next_ = false; + // fallthrough case Pretty: pretty_popup_->SetMessage(summary, message, image); pretty_popup_->show(); break; - case Disabled: default: break; } diff --git a/src/osd.h b/src/osd.h index 624bc3001..8193838df 100644 --- a/src/osd.h +++ b/src/osd.h @@ -60,6 +60,7 @@ class OSD : public QObject { public slots: void ReloadSettings(); + void ForceShowNextNotification() { force_show_next_ = true; } void SongChanged(const Song& song); void Paused(); void Stopped(); @@ -78,6 +79,9 @@ class OSD : public QObject { const QString& icon = QString(), const QImage& image = QImage()); + private slots: + void CallFinished(QDBusPendingCallWatcher* watcher); + private: QSystemTrayIcon* tray_icon_; int timeout_msec_; @@ -85,6 +89,8 @@ class OSD : public QObject { bool show_on_volume_change_; bool show_art_; + bool force_show_next_; + OSDPretty* pretty_popup_; #ifdef Q_OS_DARWIN @@ -97,8 +103,6 @@ class OSD : public QObject { uint notification_id_; QDateTime last_notification_time_; #endif - private slots: - void CallFinished(QDBusPendingCallWatcher* watcher); }; #endif // OSD_H