From 47ad50dc41f967722d3db16bfb209aaba81d863e Mon Sep 17 00:00:00 2001 From: Arnaud Bienner Date: Wed, 22 Jun 2011 21:50:25 +0000 Subject: [PATCH] Update mute button in tray icon --- src/ui/mainwindow.cpp | 1 + src/ui/qtsystemtrayicon.cpp | 9 ++++++++- src/ui/qtsystemtrayicon.h | 2 ++ src/ui/systemtrayicon.h | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index bc8598e10..80cc7bb34 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -899,6 +899,7 @@ void MainWindow::MediaPlaying() { void MainWindow::VolumeChanged(int volume) { ui_->action_mute->setChecked(!volume); + tray_icon_->MuteButtonStateChanged(!volume); } void MainWindow::SongChanged(const Song& song) { diff --git a/src/ui/qtsystemtrayicon.cpp b/src/ui/qtsystemtrayicon.cpp index 9a8638426..75e40b715 100644 --- a/src/ui/qtsystemtrayicon.cpp +++ b/src/ui/qtsystemtrayicon.cpp @@ -35,6 +35,7 @@ QtSystemTrayIcon::QtSystemTrayIcon(QObject* parent) action_play_pause_(NULL), action_stop_(NULL), action_stop_after_this_track_(NULL), + action_mute_(NULL), action_love_(NULL), action_ban_(NULL) { @@ -111,7 +112,9 @@ void QtSystemTrayIcon::SetupMenu( menu_->addAction(next->icon(), next->text(), next, SLOT(trigger())); menu_->addSeparator(); - menu_->addAction(mute->icon(), mute->text(), mute, SLOT(trigger())); + action_mute_ = menu_->addAction(mute->icon(), mute->text(), mute, SLOT(trigger())); + action_mute_->setCheckable(true); + action_mute_->setChecked(mute->isChecked()); menu_->addSeparator(); #ifdef HAVE_LIBLASTFM @@ -215,6 +218,10 @@ void QtSystemTrayIcon::LastFMButtonBanStateChanged(bool value) { #endif } +void QtSystemTrayIcon::MuteButtonStateChanged(bool value) { + if (action_mute_) + action_mute_->setChecked(value); +} bool QtSystemTrayIcon::IsVisible() const { return tray_->isVisible(); diff --git a/src/ui/qtsystemtrayicon.h b/src/ui/qtsystemtrayicon.h index 94455d04b..3a4b64e4e 100644 --- a/src/ui/qtsystemtrayicon.h +++ b/src/ui/qtsystemtrayicon.h @@ -50,6 +50,7 @@ protected: void LastFMButtonVisibilityChanged(bool value); void LastFMButtonLoveStateChanged(bool value); void LastFMButtonBanStateChanged(bool value); + void MuteButtonStateChanged(bool value); // QObject bool eventFilter(QObject *, QEvent *); @@ -63,6 +64,7 @@ private: QAction* action_play_pause_; QAction* action_stop_; QAction* action_stop_after_this_track_; + QAction* action_mute_; QAction* action_love_; QAction* action_ban_; diff --git a/src/ui/systemtrayicon.h b/src/ui/systemtrayicon.h index 58024bc19..defe5d533 100644 --- a/src/ui/systemtrayicon.h +++ b/src/ui/systemtrayicon.h @@ -59,6 +59,7 @@ class SystemTrayIcon : public QObject { virtual void LastFMButtonVisibilityChanged(bool value) {} virtual void LastFMButtonLoveStateChanged(bool value) {} virtual void LastFMButtonBanStateChanged(bool value) {} + virtual void MuteButtonStateChanged(bool value) {} signals: void ChangeVolume(int delta);