diff options
| author | Kevin Smith <git@kismith.co.uk> | 2009-11-26 18:26:34 (GMT) |
|---|---|---|
| committer | Kevin Smith <git@kismith.co.uk> | 2009-11-26 18:26:34 (GMT) |
| commit | 7ac33c721c12e94404cddff2b5c12b15deafe527 (patch) | |
| tree | e75f99b242bcdce3c02fc02f0c3f3b3117840d9f /Swift/QtUI/QtLoginWindow.cpp | |
| parent | eebdef9a7724ff7fa86a5d1cca37759d37bbb336 (diff) | |
| download | swift-7ac33c721c12e94404cddff2b5c12b15deafe527.zip swift-7ac33c721c12e94404cddff2b5c12b15deafe527.tar.bz2 | |
Remember the last used account.
This is the last account to be logged in with, not the last account to be logged out. If you want that, open a new ticket.
Resolves: #241
Diffstat (limited to 'Swift/QtUI/QtLoginWindow.cpp')
| -rw-r--r-- | Swift/QtUI/QtLoginWindow.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index 2fd27c6..a222e8e 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -88,96 +88,105 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { message_ = new QLabel(this); message_->setTextFormat(Qt::RichText); message_->setWordWrap(true); layout->addWidget(message_); layout->addStretch(); remember_ = new QCheckBox(tr("Remember Password?"), this); layout->addWidget(remember_); connect(loginButton_, SIGNAL(clicked()), SLOT(loginClicked())); stack_->addWidget(wrapperWidget); #ifdef SWIFTEN_PLATFORM_MACOSX menuBar_ = new QMenuBar(NULL); #else menuBar_ = menuBar(); #endif QApplication::setQuitOnLastWindowClosed(false); swiftMenu_ = new QMenu(tr("Swift"), this); QAction* aboutAction = new QAction("About Swift", this); connect(aboutAction, SIGNAL(activated()), SLOT(handleAbout())); swiftMenu_->addAction(aboutAction); toolsMenu_ = new QMenu(tr("Tools"), this); QAction* xmlConsoleAction = new QAction(tr("Show Debug Console"), this); connect(xmlConsoleAction, SIGNAL(activated()), SLOT(handleShowXMLConsole())); toolsMenu_->addAction(xmlConsoleAction); QAction* quitAction = new QAction("Quit", this); connect(quitAction, SIGNAL(activated()), SLOT(handleQuit())); swiftMenu_->addAction(quitAction); setInitialMenus(); this->show(); } /** * Move and resize the window, but respect minimum sizes. * (Like QWidget::setGeometry, only that will truncate the window * the setGeometry docs say that it shouldn't do this, but I've just seen it * maybe we can remove this method if that's a Qt bug (or I'm misusing it)). */ void QtLoginWindow::setGentleGeometry(const QRect& rect) { resize(rect.size()); move(rect.topLeft()); } +void QtLoginWindow::selectUser(const String& username) { + for (int i = 0; i < usernames_.count(); i++) { + if (P2QSTRING(username) == usernames_[i]) { + username_->setCurrentIndex(i); + break; + } + } +} + QRect QtLoginWindow::defaultPosition() { QDesktopWidget desktop; int windowWidth = 200; int windowHeight = 500; QRect screen = desktop.screenGeometry(-1); //appear on default screen windowWidth = std::min(windowWidth, screen.width()); windowHeight = std::min(windowHeight, screen.height()); int left = (screen.width() - windowWidth) / 2; int height = (screen.height() - windowHeight) / 2; return QRect(left, height, windowWidth, windowHeight); } void QtLoginWindow::addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) { QString username = P2QSTRING(defaultJID); int index = -1; for (int i = 0; i < usernames_.count(); i++) { if (username == usernames_[i]) { index = i; } } if (index == -1) { usernames_.append(username); passwords_.append(P2QSTRING(defaultPassword)); certificateFiles_.append(P2QSTRING(defaultCertificate)); username_->addItem(username); } else { usernames_[index] = username; passwords_[index] = P2QSTRING(defaultPassword); certificateFiles_[index] = P2QSTRING(defaultCertificate); } } void QtLoginWindow::handleUsernameTextChanged() { QString username = username_->currentText(); for (int i = 0; i < usernames_.count(); i++) { if (username_->currentText() == usernames_[i]) { certificateFile_ == certificateFiles_[i]; password_->setText(passwords_[i]); } } if (!certificateFile_.isEmpty()) { certificateButton_->setChecked(true); } remember_->setChecked(password_->text() != ""); } void QtLoginWindow::loggedOut() { if (stack_->count() > 1) { |
Swift