diff --git a/src/internet/groovesharksettingspage.cpp b/src/internet/groovesharksettingspage.cpp
index 614b997f9..73ca261af 100644
--- a/src/internet/groovesharksettingspage.cpp
+++ b/src/internet/groovesharksettingspage.cpp
@@ -15,11 +15,11 @@
along with Clementine. If not, see .
*/
-#include "groovesharksettingspage.h"
-
-#include "core/network.h"
#include "groovesharkservice.h"
+#include "groovesharksettingspage.h"
#include "internetmodel.h"
+#include "core/logging.h"
+#include "core/network.h"
#include "ui_groovesharksettingspage.h"
#include "ui/iconloader.h"
@@ -49,7 +49,6 @@ GroovesharkSettingsPage::GroovesharkSettingsPage(SettingsDialog* dialog)
ui_->login_state->AddCredentialField(ui_->username);
ui_->login_state->AddCredentialField(ui_->password);
ui_->login_state->AddCredentialGroup(ui_->account_group);
-
}
GroovesharkSettingsPage::~GroovesharkSettingsPage() {
@@ -113,7 +112,6 @@ void GroovesharkSettingsPage::UpdateLoginState() {
ui_->login_state->SetAccountTypeText(tr("A Grooveshark Anywhere account is required."));
break;
}
- //ui_->login_state->SetAccountTypeText(tr("A Grooveshark Anywhere account is required."));
}
void GroovesharkSettingsPage::Logout() {
diff --git a/src/translations/translations.pot b/src/translations/translations.pot
index b32801f79..04f0ebc69 100644
--- a/src/translations/translations.pot
+++ b/src/translations/translations.pot
@@ -220,7 +220,7 @@ msgid "1 track"
msgstr ""
#: ../bin/src/ui_magnatunedownloaddialog.h:143
-#: ../bin/src/ui_magnatunesettingspage.h:170
+#: ../bin/src/ui_magnatunesettingspage.h:174
msgid "128k MP3"
msgstr ""
@@ -240,7 +240,7 @@ msgid ""
"that section will be hidden if the token is empty.
"
msgstr ""
-#: internet/groovesharksettingspage.cpp:113
+#: internet/groovesharksettingspage.cpp:112
msgid "A Grooveshark Anywhere account is required."
msgstr ""
@@ -301,7 +301,7 @@ msgid "About Qt..."
msgstr ""
#: ../bin/src/ui_groovesharksettingspage.h:113
-#: ../bin/src/ui_magnatunesettingspage.h:151
+#: ../bin/src/ui_magnatunesettingspage.h:155
#: ../bin/src/ui_spotifysettingspage.h:209
#: ../bin/src/ui_remotesettingspage.h:203
#: ../bin/src/ui_lastfmsettingspage.h:145
@@ -677,7 +677,7 @@ msgstr ""
#: internet/digitallyimportedsettingspage.cpp:82
#: internet/magnatunesettingspage.cpp:113 internet/lastfmservice.cpp:432
-#: internet/lastfmsettingspage.cpp:79 remote/remotesettingspage.cpp:113
+#: internet/lastfmsettingspage.cpp:78 remote/remotesettingspage.cpp:113
msgid "Authentication failed"
msgstr ""
@@ -1430,7 +1430,7 @@ msgstr ""
msgid "Download directory"
msgstr ""
-#: ../bin/src/ui_magnatunesettingspage.h:157
+#: ../bin/src/ui_magnatunesettingspage.h:161
msgid "Download membership"
msgstr ""
@@ -1645,7 +1645,7 @@ msgstr ""
msgid "Expand"
msgstr ""
-#: widgets/loginstatewidget.cpp:112
+#: widgets/loginstatewidget.cpp:142
#, qt-format
msgid "Expires on %1"
msgstr ""
@@ -1675,7 +1675,7 @@ msgid "F8"
msgstr ""
#: ../bin/src/ui_magnatunedownloaddialog.h:140
-#: ../bin/src/ui_magnatunesettingspage.h:167
+#: ../bin/src/ui_magnatunesettingspage.h:171
#: ../bin/src/ui_transcodersettingspage.h:161
msgid "FLAC"
msgstr ""
@@ -2011,7 +2011,7 @@ msgstr ""
msgid "Hypnotoad"
msgstr ""
-#: ../bin/src/ui_magnatunesettingspage.h:155
+#: ../bin/src/ui_magnatunesettingspage.h:159
msgid "I don't have a Magnatune account"
msgstr ""
@@ -2389,7 +2389,7 @@ msgstr ""
#: ../bin/src/ui_digitallyimportedsettingspage.h:163
#: ../bin/src/ui_groovesharksettingspage.h:116
-#: ../bin/src/ui_magnatunesettingspage.h:160
+#: ../bin/src/ui_magnatunesettingspage.h:164
#: ../bin/src/ui_spotifysettingspage.h:212
#: ../bin/src/ui_remotesettingspage.h:205
#: ../bin/src/ui_lastfmsettingspage.h:147
@@ -2450,7 +2450,7 @@ msgstr ""
msgid "MPC"
msgstr ""
-#: internet/magnatuneservice.cpp:99 ../bin/src/ui_magnatunesettingspage.h:150
+#: internet/magnatuneservice.cpp:99 ../bin/src/ui_magnatunesettingspage.h:154
msgid "Magnatune"
msgstr ""
@@ -2507,7 +2507,7 @@ msgstr ""
msgid "Medium (512x512)"
msgstr ""
-#: ../bin/src/ui_magnatunesettingspage.h:152
+#: ../bin/src/ui_magnatunesettingspage.h:156
msgid "Membership type"
msgstr ""
@@ -2763,7 +2763,7 @@ msgid "Ogg Speex"
msgstr ""
#: core/song.cpp:139 ../bin/src/ui_magnatunedownloaddialog.h:139
-#: ../bin/src/ui_magnatunesettingspage.h:166
+#: ../bin/src/ui_magnatunesettingspage.h:170
msgid "Ogg Vorbis"
msgstr ""
@@ -2863,7 +2863,7 @@ msgid "Party"
msgstr ""
#: ../bin/src/ui_groovesharksettingspage.h:115
-#: ../bin/src/ui_magnatunesettingspage.h:161
+#: ../bin/src/ui_magnatunesettingspage.h:165
#: ../bin/src/ui_spotifysettingspage.h:211
#: ../bin/src/ui_networkproxysettingspage.h:169
msgid "Password"
@@ -3004,7 +3004,7 @@ msgid "Pre-amp"
msgstr ""
#: ../bin/src/ui_digitallyimportedsettingspage.h:166
-#: ../bin/src/ui_magnatunesettingspage.h:162
+#: ../bin/src/ui_magnatunesettingspage.h:166
#: ../bin/src/ui_spotifysettingspage.h:217 ../bin/src/ui_settingsdialog.h:115
#: ../bin/src/ui_lastfmsettingspage.h:149
msgid "Preferences"
@@ -3018,7 +3018,7 @@ msgstr ""
msgid "Preferred album art filenames (comma separated)"
msgstr ""
-#: ../bin/src/ui_magnatunesettingspage.h:163
+#: ../bin/src/ui_magnatunesettingspage.h:167
msgid "Preferred audio format"
msgstr ""
@@ -3815,7 +3815,7 @@ msgstr ""
msgid "Stream"
msgstr ""
-#: ../bin/src/ui_magnatunesettingspage.h:156
+#: ../bin/src/ui_magnatunesettingspage.h:160
msgid "Streaming membership"
msgstr ""
@@ -4235,7 +4235,7 @@ msgid "User interface"
msgstr ""
#: ../bin/src/ui_groovesharksettingspage.h:114
-#: ../bin/src/ui_magnatunesettingspage.h:159
+#: ../bin/src/ui_magnatunesettingspage.h:163
#: ../bin/src/ui_spotifysettingspage.h:210
#: ../bin/src/ui_networkproxysettingspage.h:168
msgid "Username"
@@ -4246,7 +4246,7 @@ msgid "Using the menu to add a song will..."
msgstr ""
#: ../bin/src/ui_magnatunedownloaddialog.h:142
-#: ../bin/src/ui_magnatunesettingspage.h:169
+#: ../bin/src/ui_magnatunesettingspage.h:173
msgid "VBR MP3"
msgstr ""
@@ -4298,7 +4298,7 @@ msgid "Vorbis"
msgstr ""
#: ../bin/src/ui_magnatunedownloaddialog.h:141
-#: ../bin/src/ui_magnatunesettingspage.h:168
+#: ../bin/src/ui_magnatunesettingspage.h:172
msgid "WAV"
msgstr ""
@@ -4414,12 +4414,12 @@ msgstr ""
msgid "You are not signed in."
msgstr ""
-#: widgets/loginstatewidget.cpp:69
+#: widgets/loginstatewidget.cpp:75
#, qt-format
msgid "You are signed in as %1."
msgstr ""
-#: widgets/loginstatewidget.cpp:67
+#: widgets/loginstatewidget.cpp:73
msgid "You are signed in."
msgstr ""
@@ -4456,7 +4456,7 @@ msgid ""
"wiki for more information.\n"
msgstr ""
-#: internet/groovesharksettingspage.cpp:105
+#: internet/groovesharksettingspage.cpp:104
msgid "You do not have a Grooveshark Anywhere account."
msgstr ""
@@ -4494,7 +4494,7 @@ msgstr ""
msgid "Your Google credentials were incorrect"
msgstr ""
-#: internet/lastfmsettingspage.cpp:79
+#: internet/lastfmsettingspage.cpp:78
msgid "Your Last.fm credentials were incorrect"
msgstr ""
@@ -4522,7 +4522,7 @@ msgstr ""
msgid "Your scrobbles: %1"
msgstr ""
-#: internet/groovesharksettingspage.cpp:109
+#: internet/groovesharksettingspage.cpp:108
#: internet/spotifysettingspage.cpp:154
msgid "Your username or password was incorrect."
msgstr ""
diff --git a/src/widgets/loginstatewidget.cpp b/src/widgets/loginstatewidget.cpp
index e4e23ceae..d302549af 100644
--- a/src/widgets/loginstatewidget.cpp
+++ b/src/widgets/loginstatewidget.cpp
@@ -21,10 +21,13 @@
#include
#include
+#include
+#include
LoginStateWidget::LoginStateWidget(QWidget* parent)
: QWidget(parent),
- ui_(new Ui_LoginStateWidget)
+ ui_(new Ui_LoginStateWidget),
+ state_(LoggedOut)
{
ui_->setupUi(this);
ui_->signed_in->hide();
@@ -59,6 +62,9 @@ void LoginStateWidget::SetAccountTypeVisible(bool visible) {
}
void LoginStateWidget::SetLoggedIn(State state, const QString& account_name) {
+ State last_state = state_;
+ state_ = state;
+
ui_->signed_in->setVisible(state == LoggedIn);
ui_->signed_out->setVisible(state != LoggedIn);
ui_->busy->setVisible(state == LoginInProgress);
@@ -72,6 +78,30 @@ void LoginStateWidget::SetLoggedIn(State state, const QString& account_name) {
widget->setVisible(state != LoggedIn);
widget->setEnabled(state != LoginInProgress);
}
+
+ if (state == LoggedOut && last_state == LoginInProgress) {
+ // A login just failed - give focus back to the last crediental field
+ // (usually password). We have to do this after control gets back to the
+ // event loop because the user might have just closed a dialog and our
+ // widget might not be active yet.
+ QTimer::singleShot(0, this, SLOT(FocusLastCredentialField()));
+ }
+}
+
+void LoginStateWidget::FocusLastCredentialField() {
+ if (!credential_fields_.isEmpty()) {
+ QObject* object = credential_fields_.last();
+ QWidget* widget = qobject_cast(object);
+ QLineEdit* line_edit = qobject_cast(object);
+
+ if (widget) {
+ widget->setFocus();
+ }
+
+ if (line_edit) {
+ line_edit->selectAll();
+ }
+ }
}
void LoginStateWidget::HideLoggedInState() {
diff --git a/src/widgets/loginstatewidget.h b/src/widgets/loginstatewidget.h
index 1651b1a69..71dc0912f 100644
--- a/src/widgets/loginstatewidget.h
+++ b/src/widgets/loginstatewidget.h
@@ -66,10 +66,13 @@ signals:
private slots:
void Logout();
+ void FocusLastCredentialField();
private:
Ui_LoginStateWidget* ui_;
+ State state_;
+
QList credential_fields_;
QList credential_groups_;
};