Only enable main window rate button when LastFM is disabled (#6778)
This commit is contained in:
parent
d3e3270227
commit
3a4d7f3a3d
|
@ -1169,27 +1169,31 @@ void MainWindow::MediaPlaying() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool enable_play_pause = !(item->options() & PlaylistItem::PauseDisabled);
|
const bool enable_play_pause = !(item->options() &
|
||||||
|
PlaylistItem::PauseDisabled);
|
||||||
ui_->action_play_pause->setEnabled(enable_play_pause);
|
ui_->action_play_pause->setEnabled(enable_play_pause);
|
||||||
|
|
||||||
bool can_seek = !(item->options() & PlaylistItem::SeekDisabled);
|
const bool can_seek = !(item->options() &
|
||||||
|
PlaylistItem::SeekDisabled);
|
||||||
ui_->track_slider->SetCanSeek(can_seek);
|
ui_->track_slider->SetCanSeek(can_seek);
|
||||||
|
|
||||||
// We now always enable Love when playing since it works for local files
|
|
||||||
ui_->action_love->setEnabled(true);
|
|
||||||
|
|
||||||
// Set the rate/love icon
|
// Set the rate/love icon
|
||||||
if (item->IsLocalLibraryItem()) {
|
if (IsLastFmEnabled()) {
|
||||||
|
ui_->action_love->setIcon(IconLoader::Load("love", IconLoader::Lastfm));
|
||||||
|
ui_->action_love->setEnabled(true);
|
||||||
|
}
|
||||||
|
else if (item->IsLocalLibraryItem()) {
|
||||||
ui_->action_love->setIcon(IconLoader::Load("rate-enabled",
|
ui_->action_love->setIcon(IconLoader::Load("rate-enabled",
|
||||||
IconLoader::Base));
|
IconLoader::Base));
|
||||||
|
ui_->action_love->setEnabled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui_->action_love->setIcon(IconLoader::Load("love", IconLoader::Lastfm));
|
ui_->action_love->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBLASTFM
|
#ifdef HAVE_LIBLASTFM
|
||||||
bool enable_love = app_->scrobbler()->IsScrobblingEnabled();
|
|
||||||
if (tray_icon_) {
|
if (tray_icon_) {
|
||||||
|
const bool enable_love = app_->scrobbler()->IsScrobblingEnabled();
|
||||||
tray_icon_->LastFMButtonLoveStateChanged(enable_love);
|
tray_icon_->LastFMButtonLoveStateChanged(enable_love);
|
||||||
tray_icon_->SetPlaying(enable_play_pause, enable_love);
|
tray_icon_->SetPlaying(enable_play_pause, enable_love);
|
||||||
}
|
}
|
||||||
|
@ -1603,23 +1607,28 @@ void MainWindow::ScrobbledRadioStream() {
|
||||||
|
|
||||||
void MainWindow::Love() {
|
void MainWindow::Love() {
|
||||||
Playlist* active_playlist = app_->playlist_manager()->active();
|
Playlist* active_playlist = app_->playlist_manager()->active();
|
||||||
PlaylistItemPtr item = active_playlist->current_item();
|
const PlaylistItemPtr item = active_playlist->current_item();
|
||||||
if (!item) {
|
if (!item) {
|
||||||
// Don't make a big deal about it
|
// Don't make a big deal about it
|
||||||
qLog(Warning) << "Love: nothing playing so can't love it";
|
qLog(Warning) << "Love: nothing playing so can't love it";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->IsLocalLibraryItem()) {
|
if (IsLastFmEnabled()) {
|
||||||
|
#ifdef HAVE_LIBLASTFM
|
||||||
|
app_->scrobbler()->Love();
|
||||||
|
ui_->action_love->setEnabled(false);
|
||||||
|
if (tray_icon_) tray_icon_->LastFMButtonLoveStateChanged(false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (item->IsLocalLibraryItem()) {
|
||||||
const Song& song = item->Metadata();
|
const Song& song = item->Metadata();
|
||||||
if (!song.is_valid() || song.id() == -1) return;
|
if (!song.is_valid() || song.id() == -1) return;
|
||||||
love_dialog_->SetSong(song);
|
love_dialog_->SetSong(song);
|
||||||
love_dialog_->show();
|
love_dialog_->show();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
app_->scrobbler()->Love();
|
qLog(Warning) << "Love: unable to love or rate";
|
||||||
ui_->action_love->setEnabled(false);
|
|
||||||
if (tray_icon_) tray_icon_->LastFMButtonLoveStateChanged(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2956,11 +2965,19 @@ void MainWindow::SetToggleScrobblingIcon(bool value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWindow::IsLastFmEnabled() {
|
||||||
|
#ifdef HAVE_LIBLASTFM
|
||||||
|
return ui_->action_toggle_scrobbling->isVisible() &&
|
||||||
|
app_->scrobbler()->IsScrobblingEnabled() &&
|
||||||
|
app_->scrobbler()->IsAuthenticated();
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBLASTFM
|
#ifdef HAVE_LIBLASTFM
|
||||||
void MainWindow::CachedToScrobble() {
|
void MainWindow::CachedToScrobble() {
|
||||||
const bool last_fm_enabled = ui_->action_toggle_scrobbling->isVisible() &&
|
const bool last_fm_enabled = IsLastFmEnabled();
|
||||||
app_->scrobbler()->IsScrobblingEnabled() &&
|
|
||||||
app_->scrobbler()->IsAuthenticated();
|
|
||||||
|
|
||||||
app_->playlist_manager()->active()->set_lastfm_status(
|
app_->playlist_manager()->active()->set_lastfm_status(
|
||||||
Playlist::LastFM_Scrobbled);
|
Playlist::LastFM_Scrobbled);
|
||||||
|
|
|
@ -223,9 +223,9 @@ signals:
|
||||||
void SetToggleScrobblingIcon(bool value);
|
void SetToggleScrobblingIcon(bool value);
|
||||||
#ifdef HAVE_LIBLASTFM
|
#ifdef HAVE_LIBLASTFM
|
||||||
void ScrobblingEnabledChanged(bool value);
|
void ScrobblingEnabledChanged(bool value);
|
||||||
void Love();
|
|
||||||
void ScrobbledRadioStream();
|
void ScrobbledRadioStream();
|
||||||
#endif
|
#endif
|
||||||
|
void Love();
|
||||||
|
|
||||||
void TaskCountChanged(int count);
|
void TaskCountChanged(int count);
|
||||||
|
|
||||||
|
@ -253,6 +253,7 @@ signals:
|
||||||
const QPersistentModelIndex& index);
|
const QPersistentModelIndex& index);
|
||||||
|
|
||||||
void ShowCoverManager();
|
void ShowCoverManager();
|
||||||
|
bool IsLastFmEnabled();
|
||||||
#ifdef HAVE_LIBLASTFM
|
#ifdef HAVE_LIBLASTFM
|
||||||
void CachedToScrobble();
|
void CachedToScrobble();
|
||||||
void ScrobbleError(int value);
|
void ScrobbleError(int value);
|
||||||
|
|
Loading…
Reference in New Issue