diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-10-03 12:45:33 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-10-03 12:45:33 (GMT) |
commit | ca8c09b19480e6b743ef94f88ee1e7c4b1b21578 (patch) | |
tree | 128c1b0108cbfe819f00e36011f5e39bc887f621 /Swift | |
parent | b07fa48455c9187538d371ea87fbed9cf44f8089 (diff) | |
download | swift-ca8c09b19480e6b743ef94f88ee1e7c4b1b21578.zip swift-ca8c09b19480e6b743ef94f88ee1e7c4b1b21578.tar.bz2 |
Allow cancelling logins.
Note that until 588 is fixed, this can cause crashes.
Release-Notes: It's now possible to cancel a login in progress.
Resolves: #100
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/QtUI/QtLoginWindow.cpp | 17 | ||||
-rw-r--r-- | Swift/QtUI/QtLoginWindow.h | 1 |
2 files changed, 15 insertions, 3 deletions
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index 1796b0e..655e3b9 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -240,15 +240,26 @@ void QtLoginWindow::loggedOut() { stack_->removeWidget(current); } setInitialMenus(); - setEnabled(true); + setIsLoggingIn(false); } void QtLoginWindow::setIsLoggingIn(bool loggingIn) { - setEnabled(!loggingIn); + /* Change the for loop as well if you add to this.*/ + QWidget* widgets[4] = {username_, password_, remember_, loginAutomatically_}; + loginButton_->setText(loggingIn ? "Cancel" : "Connect"); + for (int i = 0; i < 4; i++) { + widgets[i]->setEnabled(!loggingIn); + } + } void QtLoginWindow::loginClicked() { - onLoginRequest(Q2PSTRING(username_->currentText()), Q2PSTRING(password_->text()), Q2PSTRING(certificateFile_), remember_->isChecked(), loginAutomatically_->isChecked()); + if (username_->isEnabled()) { + onLoginRequest(Q2PSTRING(username_->currentText()), Q2PSTRING(password_->text()), Q2PSTRING(certificateFile_), remember_->isChecked(), loginAutomatically_->isChecked()); + } else { + qDebug() << "Cancelling login"; + onCancelLoginRequest(); + } } void QtLoginWindow::setLoginAutomatically(bool loginAutomatically) { diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index c7b35c7..c84033a 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -63,6 +63,7 @@ namespace Swift { QComboBox* username_; QLineEdit* password_; QPushButton* loginButton_; + /* If you add a widget here, change setLoggingIn as well.*/ QCheckBox* remember_; QCheckBox* loginAutomatically_; QStackedWidget* stack_; |