Show the OSD when --show-osd is used even if the osd is disabled in the settings dialog. See issue #95

This commit is contained in:
David Sansome 2010-04-13 20:45:40 +00:00
parent aaa1ef8a7f
commit 3b1188838b
4 changed files with 19 additions and 4 deletions

View File

@ -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);
}

View File

@ -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();

View File

@ -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;
}

View File

@ -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