Update mute button in tray icon

This commit is contained in:
Arnaud Bienner 2011-06-22 21:50:25 +00:00
parent 4864d24e42
commit 47ad50dc41
4 changed files with 12 additions and 1 deletions

View File

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

View File

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

View File

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

View File

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