Correct update lastfm's love/ban actions in tray icon

This commit is contained in:
Arnaud Bienner 2011-04-21 22:19:28 +00:00
parent 880579ee24
commit be1ee059f2
4 changed files with 37 additions and 0 deletions

View File

@ -818,6 +818,8 @@ void MainWindow::MediaStopped() {
ui_->action_ban->setEnabled(false);
ui_->action_love->setEnabled(false);
tray_icon_->LastFMButtonLoveStateChanged(false);
tray_icon_->LastFMButtonBanStateChanged(false);
track_position_timer_->stop();
ui_->track_slider->SetStopped();
@ -855,6 +857,8 @@ void MainWindow::MediaPlaying() {
ui_->action_ban->setEnabled(enable_ban);
ui_->action_love->setEnabled(enable_love);
tray_icon_->LastFMButtonBanStateChanged(enable_ban);
tray_icon_->LastFMButtonLoveStateChanged(enable_love);
tray_icon_->SetPlaying(enable_play_pause, enable_ban, enable_love);
@ -911,7 +915,9 @@ void MainWindow::ScrobblingEnabledChanged(bool value) {
bool is_lastfm = (player_->GetCurrentItem()->options() & PlaylistItem::LastFMControls);
ui_->action_ban->setEnabled(value && is_lastfm);
tray_icon_->LastFMButtonBanStateChanged(value && is_lastfm);
ui_->action_love->setEnabled(value);
tray_icon_->LastFMButtonLoveStateChanged(value);
}
#endif
@ -919,6 +925,7 @@ void MainWindow::LastFMButtonVisibilityChanged(bool value) {
ui_->action_ban->setVisible(value);
ui_->action_love->setVisible(value);
ui_->last_fm_controls->setVisible(value);
tray_icon_->LastFMButtonVisibilityChanged(value);
}
void MainWindow::ScrobbleButtonVisibilityChanged(bool value) {
@ -1105,11 +1112,13 @@ void MainWindow::UpdateTrackPosition() {
#ifdef HAVE_LIBLASTFM
void MainWindow::ScrobbledRadioStream() {
ui_->action_love->setEnabled(true);
tray_icon_->LastFMButtonLoveStateChanged(true);
}
void MainWindow::Love() {
RadioModel::Service<LastFMService>()->Love();
ui_->action_love->setEnabled(false);
tray_icon_->LastFMButtonLoveStateChanged(false);
}
#endif

View File

@ -117,8 +117,10 @@ void QtSystemTrayIcon::SetupMenu(
#ifdef HAVE_LIBLASTFM
action_love_ = menu_->addAction(love->icon(), love->text(), love, SLOT(trigger()));
action_love_->setVisible(love->isVisible());
action_love_->setEnabled(love->isEnabled());
action_ban_ = menu_->addAction(ban->icon(), ban->text(), ban, SLOT(trigger()));
action_ban_->setVisible(ban->isVisible());
action_ban_->setEnabled(ban->isEnabled());
#endif
menu_->addSeparator();
@ -194,6 +196,26 @@ void QtSystemTrayIcon::SetStopped() {
#endif
}
void QtSystemTrayIcon::LastFMButtonVisibilityChanged(bool value) {
#ifdef HAVE_LIBLASTFM
action_ban_->setVisible(value);
action_love_->setVisible(value);
#endif
}
void QtSystemTrayIcon::LastFMButtonLoveStateChanged(bool value) {
#ifdef HAVE_LIBLASTFM
action_love_->setEnabled(value);
#endif
}
void QtSystemTrayIcon::LastFMButtonBanStateChanged(bool value) {
#ifdef HAVE_LIBLASTFM
action_ban_->setEnabled(value);
#endif
}
bool QtSystemTrayIcon::IsVisible() const {
return tray_->isVisible();
}

View File

@ -47,6 +47,9 @@ protected:
void SetPlaying(bool enable_play_pause = false, bool enable_ban = false,
bool enable_love = false);
void SetStopped();
void LastFMButtonVisibilityChanged(bool value);
void LastFMButtonLoveStateChanged(bool value);
void LastFMButtonBanStateChanged(bool value);
// QObject
bool eventFilter(QObject *, QEvent *);

View File

@ -56,6 +56,9 @@ class SystemTrayIcon : public QObject {
virtual void SetPlaying(bool enable_play_pause = false,
bool enable_ban = false, bool enable_love = false);
virtual void SetStopped();
virtual void LastFMButtonVisibilityChanged(bool value) {}
virtual void LastFMButtonLoveStateChanged(bool value) {}
virtual void LastFMButtonBanStateChanged(bool value) {}
signals:
void ChangeVolume(int delta);