From ca8c09b19480e6b743ef94f88ee1e7c4b1b21578 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Sun, 3 Oct 2010 13:45:33 +0100 Subject: 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 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_; -- cgit v0.10.2-6-g49f6