diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-01-29 17:07:27 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-01-29 17:07:27 +0000 |
| commit | ab030aa3915a48a7590a194bd680157958be4d54 (patch) | |
| tree | 5ab24364aac95e201db323072330393829dc85ca /src/plugins/General/scrobbler/settingsdialog.cpp | |
| parent | f24e948ba5117ec92a148b78222269d4905916bc (diff) | |
| download | qmmp-ab030aa3915a48a7590a194bd680157958be4d54.tar.gz qmmp-ab030aa3915a48a7590a194bd680157958be4d54.tar.bz2 qmmp-ab030aa3915a48a7590a194bd680157958be4d54.zip | |
lastfm scrobbler: enabled 'check session' button
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3194 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/scrobbler/settingsdialog.cpp')
| -rw-r--r-- | src/plugins/General/scrobbler/settingsdialog.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/General/scrobbler/settingsdialog.cpp b/src/plugins/General/scrobbler/settingsdialog.cpp index 29ff3b8b5..c5ca85cc7 100644 --- a/src/plugins/General/scrobbler/settingsdialog.cpp +++ b/src/plugins/General/scrobbler/settingsdialog.cpp @@ -30,6 +30,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent) m_lastfmAuth = new LastfmAuth(this); connect(m_lastfmAuth, SIGNAL(tokenRequestFinished(int)), SLOT(processTokenResponse(int))); connect(m_lastfmAuth, SIGNAL(sessionRequestFinished(int)), SLOT(processSessionResponse(int))); + connect(m_lastfmAuth, SIGNAL(checkSessionFinished(int)), SLOT(processCheckResponse(int))); QSettings settings(Qmmp::configFile(), QSettings::IniFormat); settings.beginGroup("Scrobbler"); m_ui.lastfmGroupBox->setChecked(settings.value("use_lastfm", false).toBool()); @@ -58,11 +59,13 @@ void SettingsDialog::accept() void SettingsDialog::on_newSessionButton_lastfm_clicked() { + m_ui.newSessionButton_lastfm->setEnabled(false); m_lastfmAuth->getToken(); } void SettingsDialog::processTokenResponse(int error) { + m_ui.newSessionButton_lastfm->setEnabled(true); switch(error) { case LastfmAuth::NO_ERROR: @@ -71,6 +74,7 @@ void SettingsDialog::processTokenResponse(int error) tr("1. Wait for browser startup.") + "\n" + tr("2. Allow Qmmp to scrobble tracks to your Last.fm account.") + "\n" + tr("3. Press \"OK\".")); + m_ui.newSessionButton_lastfm->setEnabled(false); m_lastfmAuth->getSession(); break; case LastfmAuth::NETWORK_ERROR: @@ -84,6 +88,7 @@ void SettingsDialog::processTokenResponse(int error) void SettingsDialog::processSessionResponse(int error) { + m_ui.newSessionButton_lastfm->setEnabled(true); switch(error) { case LastfmAuth::NO_ERROR: @@ -103,3 +108,32 @@ void SettingsDialog::processSessionResponse(int error) QMessageBox::warning(this, tr("Error"), tr("Unable to register new session.")); } } + +void SettingsDialog::on_checkButton_lastfm_clicked() +{ + if(!m_ui.sessionLineEdit_lastfm->text().isEmpty()) + { + m_ui.checkButton_lastfm->setEnabled(false); + m_lastfmAuth->checkSession(m_ui.sessionLineEdit_lastfm->text()); + } +} + +void SettingsDialog::processCheckResponse(int error) +{ + m_ui.checkButton_lastfm->setEnabled(true); + switch(error) + { + case LastfmAuth::NO_ERROR: + { + QMessageBox::information(this, tr("Message"), tr("Permission granted.")); + m_ui.sessionLineEdit_lastfm->setText(m_lastfmAuth->session()); + break; + } + case LastfmAuth::NETWORK_ERROR: + QMessageBox::warning(this, tr("Error"), tr("Network error.")); + break; + case LastfmAuth::LASTFM_ERROR: + default: + QMessageBox::warning(this, tr("Error"), tr("Permission denied.")); + } +} |
