Make scrobbler show error dialog for all errors when option is on

This commit is contained in:
Jonas Kvinge
2020-05-26 17:51:23 +02:00
parent 2521954bd9
commit 5dbdde3f2b
5 changed files with 11 additions and 9 deletions

View File

@@ -48,7 +48,7 @@ AudioScrobbler::AudioScrobbler(Application *app, QObject *parent) :
love_button_(false), love_button_(false),
submit_delay_(0), submit_delay_(0),
prefer_albumartist_(false), prefer_albumartist_(false),
show_auth_error_(false) show_error_dialog_(false)
{ {
scrobbler_services_->AddService(new LastFMScrobbler(app_, scrobbler_services_)); scrobbler_services_->AddService(new LastFMScrobbler(app_, scrobbler_services_));
@@ -75,7 +75,7 @@ void AudioScrobbler::ReloadSettings() {
love_button_ = s.value("love_button", false).toBool(); love_button_ = s.value("love_button", false).toBool();
submit_delay_ = s.value("submit", 0).toInt(); submit_delay_ = s.value("submit", 0).toInt();
prefer_albumartist_ = s.value("albumartist", false).toBool(); prefer_albumartist_ = s.value("albumartist", false).toBool();
show_auth_error_ = s.value("show_auth_error", true).toBool(); show_error_dialog_ = s.value("show_error_dialog", true).toBool();
s.endGroup(); s.endGroup();
emit ScrobblingEnabledChanged(enabled_); emit ScrobblingEnabledChanged(enabled_);

View File

@@ -46,7 +46,7 @@ class AudioScrobbler : public QObject {
bool LoveButton() const { return love_button_; } bool LoveButton() const { return love_button_; }
int SubmitDelay() const { return submit_delay_; } int SubmitDelay() const { return submit_delay_; }
bool PreferAlbumArtist() const { return prefer_albumartist_; } bool PreferAlbumArtist() const { return prefer_albumartist_; }
bool ShowAuthError() const { return show_auth_error_; } bool ShowErrorDialog() const { return show_error_dialog_; }
void UpdateNowPlaying(const Song &song); void UpdateNowPlaying(const Song &song);
void ClearPlaying(); void ClearPlaying();
@@ -86,7 +86,7 @@ class AudioScrobbler : public QObject {
bool love_button_; bool love_button_;
int submit_delay_; int submit_delay_;
bool prefer_albumartist_; bool prefer_albumartist_;
bool show_auth_error_; bool show_error_dialog_;
}; };

View File

@@ -525,7 +525,7 @@ void ScrobblingAPI20::Scrobble(const Song &song) {
if (app_->scrobbler()->IsOffline()) return; if (app_->scrobbler()->IsOffline()) return;
if (!IsAuthenticated()) { if (!IsAuthenticated()) {
if (app_->scrobbler()->ShowAuthError()) { emit ErrorMessage(tr("Scrobbler %1 is not authenticated!").arg(name_)); } if (app_->scrobbler()->ShowErrorDialog()) { emit ErrorMessage(tr("Scrobbler %1 is not authenticated!").arg(name_)); }
return; return;
} }
@@ -987,6 +987,8 @@ void ScrobblingAPI20::Error(const QString &error, const QVariant &debug) {
qLog(Error) << name_ << error; qLog(Error) << name_ << error;
if (debug.isValid()) qLog(Debug) << debug; if (debug.isValid()) qLog(Debug) << debug;
if (app_->scrobbler()->ShowErrorDialog()) { emit ErrorMessage(tr("Scrobbler %1 error: %2").arg(name_).arg(error)); }
} }
QString ScrobblingAPI20::ErrorString(const ScrobbleErrorCode error) const { QString ScrobblingAPI20::ErrorString(const ScrobbleErrorCode error) const {

View File

@@ -94,7 +94,7 @@ void ScrobblerSettingsPage::Load() {
ui_->checkbox_offline->setChecked(scrobbler_->IsOffline()); ui_->checkbox_offline->setChecked(scrobbler_->IsOffline());
ui_->spinbox_submit->setValue(scrobbler_->SubmitDelay()); ui_->spinbox_submit->setValue(scrobbler_->SubmitDelay());
ui_->checkbox_albumartist->setChecked(scrobbler_->PreferAlbumArtist()); ui_->checkbox_albumartist->setChecked(scrobbler_->PreferAlbumArtist());
ui_->checkbox_show_auth_error->setChecked(scrobbler_->ShowAuthError()); ui_->checkbox_show_error_dialog->setChecked(scrobbler_->ShowErrorDialog());
ui_->checkbox_lastfm_enable->setChecked(lastfmscrobbler_->IsEnabled()); ui_->checkbox_lastfm_enable->setChecked(lastfmscrobbler_->IsEnabled());
ui_->checkbox_lastfm_https->setChecked(lastfmscrobbler_->IsUseHTTPS()); ui_->checkbox_lastfm_https->setChecked(lastfmscrobbler_->IsUseHTTPS());
@@ -122,7 +122,7 @@ void ScrobblerSettingsPage::Save() {
s.setValue("offline", ui_->checkbox_offline->isChecked()); s.setValue("offline", ui_->checkbox_offline->isChecked());
s.setValue("submit", ui_->spinbox_submit->value()); s.setValue("submit", ui_->spinbox_submit->value());
s.setValue("albumartist", ui_->checkbox_albumartist->isChecked()); s.setValue("albumartist", ui_->checkbox_albumartist->isChecked());
s.setValue("show_auth_error", ui_->checkbox_show_auth_error->isChecked()); s.setValue("show_error_dialog", ui_->checkbox_show_error_dialog->isChecked());
s.endGroup(); s.endGroup();
s.beginGroup(LastFMScrobbler::kSettingsGroup); s.beginGroup(LastFMScrobbler::kSettingsGroup);

View File

@@ -110,9 +110,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkbox_show_auth_error"> <widget class="QCheckBox" name="checkbox_show_error_dialog">
<property name="text"> <property name="text">
<string>Show error dialog if scrobbler is enabled without being authenticated</string> <string>Show dialog for errors</string>
</property> </property>
</widget> </widget>
</item> </item>