diff options
-rw-r--r-- | Swift/Controllers/Chat/ChatsManager.cpp | 1 | ||||
-rw-r--r-- | Swift/Controllers/Chat/MUCController.cpp | 1 | ||||
-rw-r--r-- | Swift/Controllers/MainController.cpp | 30 | ||||
-rw-r--r-- | Swift/Controllers/MainController.h | 2 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/LoginWindow.h | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtChatTabs.cpp | 10 | ||||
-rw-r--r-- | Swift/QtUI/QtChatTabs.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindowFactory.cpp | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtLoginWindow.cpp | 15 | ||||
-rw-r--r-- | Swift/QtUI/QtLoginWindow.h | 3 |
10 files changed, 54 insertions, 17 deletions
diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index db340ac..61d9bb4 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -138,7 +138,6 @@ void ChatsManager::setEnabled(bool enabled) { void ChatsManager::handleChatRequest(const String &contact) { ChatController* controller = getChatControllerOrFindAnother(JID(contact)); - controller->showChatWindow(); controller->activateChatWindow(); } diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index a1ca9cc..c726b7b 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -47,7 +47,6 @@ MUCController::MUCController ( muc_->onOccupantPresenceChange.connect(boost::bind(&MUCController::handleOccupantPresenceChange, this, _1)); muc_->onOccupantLeft.connect(boost::bind(&MUCController::handleOccupantLeft, this, _1, _2, _3)); chatWindow_->convertToMUC(); - chatWindow_->show(); if (avatarManager_ != NULL) { avatarChangedConnection_ = (avatarManager_->onAvatarChanged.connect(boost::bind(&MUCController::handleAvatarChanged, this, _1, _2))); } diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 8c43921..f18bd5a 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -73,19 +73,36 @@ MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowF systemTrayController_ = new SystemTrayController(eventController_, systemTray); loginWindow_ = loginWindowFactory_->createLoginWindow(uiEventStream_); soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings, uiEventStream_); + + String selectedLoginJID = settings_->getStringSetting("lastLoginJID"); + bool loginAutomatically = settings_->getBoolSetting("loginAutomatically", false); + String cachedPassword; + String cachedCertificate; foreach (String profile, settings->getAvailableProfiles()) { ProfileSettingsProvider* profileSettings = new ProfileSettingsProvider(profile, settings); - loginWindow_->addAvailableAccount(profileSettings->getStringSetting("jid"), profileSettings->getStringSetting("pass"), profileSettings->getStringSetting("certificate")); + String password = profileSettings->getStringSetting("pass"); + String certificate = profileSettings->getStringSetting("certificate"); + String jid = profileSettings->getStringSetting("jid"); + loginWindow_->addAvailableAccount(jid, password, certificate); + if (jid == selectedLoginJID) { + cachedPassword = password; + cachedCertificate = certificate; + } delete profileSettings; } - loginWindow_->selectUser(settings_->getStringSetting("lastLoginJID")); - loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4)); + loginWindow_->selectUser(selectedLoginJID); + loginWindow_->setLoginAutomatically(loginAutomatically); + loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4, _5)); loginWindow_->onCancelLoginRequest.connect(boost::bind(&MainController::handleCancelLoginRequest, this)); idleDetector_.setIdleTimeSeconds(600); idleDetector_.onIdleChanged.connect(boost::bind(&MainController::handleInputIdleChanged, this, _1)); xmlConsoleController_ = new XMLConsoleController(uiEventStream_, xmlConsoleWidgetFactory); + + if (loginAutomatically) { + handleLoginRequest(selectedLoginJID, cachedPassword, cachedCertificate, true, true); + } } MainController::~MainController() { @@ -127,6 +144,7 @@ void MainController::resetClient() { } void MainController::handleConnected() { + loginWindow_->setIsLoggingIn(false); //FIXME: this freshLogin thing is temporary so I can see what's what before I split into a seperate method. bool freshLogin = rosterController_ == NULL; if (freshLogin) { @@ -254,13 +272,15 @@ void MainController::handleInputIdleChanged(bool idle) { } } -void MainController::handleLoginRequest(const String &username, const String &password, const String& certificateFile, bool remember) { +void MainController::handleLoginRequest(const String &username, const String &password, const String& certificateFile, bool remember, bool loginAutomatically) { loginWindow_->setMessage(""); + loginWindow_->setIsLoggingIn(true); ProfileSettingsProvider* profileSettings = new ProfileSettingsProvider(username, settings_); profileSettings->storeString("jid", username); profileSettings->storeString("certificate", certificateFile); - profileSettings->storeString("pass", remember ? password : ""); + profileSettings->storeString("pass", (remember || loginAutomatically) ? password : ""); settings_->storeString("lastLoginJID", username); + settings_->storeBool("loginAutomatically", loginAutomatically); loginWindow_->addAvailableAccount(profileSettings->getStringSetting("jid"), profileSettings->getStringSetting("pass"), profileSettings->getStringSetting("certificate")); delete profileSettings; jid_ = JID(username); diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 75a8e5a..a098ee2 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -62,7 +62,7 @@ namespace Swift { private: void resetClient(); void handleConnected(); - void handleLoginRequest(const String& username, const String& password, const String& certificateFile, bool remember); + void handleLoginRequest(const String& username, const String& password, const String& certificateFile, bool remember, bool loginAutomatically); void handleCancelLoginRequest(); void handleChangeStatusRequest(StatusShow::Type show, const String &statusText); void handleError(const ClientError& error); diff --git a/Swift/Controllers/UIInterfaces/LoginWindow.h b/Swift/Controllers/UIInterfaces/LoginWindow.h index d165125..1eecaaa 100644 --- a/Swift/Controllers/UIInterfaces/LoginWindow.h +++ b/Swift/Controllers/UIInterfaces/LoginWindow.h @@ -15,8 +15,10 @@ namespace Swift { virtual void morphInto(MainWindow *mainWindow) = 0; virtual void loggedOut() = 0; virtual void setMessage(const String&) = 0; + virtual void setIsLoggingIn(bool loggingIn) = 0; virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) = 0; - boost::signal<void (const String&, const String&, const String& /* certificateFile */, bool)> onLoginRequest; + boost::signal<void (const String&, const String&, const String& /* certificateFile */, bool /* remember password*/, bool /* login automatically */)> onLoginRequest; + virtual void setLoginAutomatically(bool loginAutomatically) = 0; boost::signal<void ()> onCancelLoginRequest; }; } diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp index 67cd8ae..8ce4ac8 100644 --- a/Swift/QtUI/QtChatTabs.cpp +++ b/Swift/QtUI/QtChatTabs.cpp @@ -49,6 +49,7 @@ void QtChatTabs::handleWidgetShown() { if (!widget) { return; } + checkForFirstShow(); if (tabs_->indexOf(widget) >= 0) { return; } @@ -59,10 +60,11 @@ void QtChatTabs::handleWidgetShown() { void QtChatTabs::handleWantsToActivate() { QtTabbable* widget = qobject_cast<QtTabbable*>(sender()); Q_ASSERT(widget); - Q_ASSERT(tabs_->indexOf(widget) >= 0); //Un-minimize and bring to front. setWindowState(windowState() & ~Qt::WindowMinimized); setWindowState(windowState() | Qt::WindowActive); + show(); + widget->show(); tabs_->setCurrentWidget(widget); widget->setFocus(); activateWindow(); @@ -124,4 +126,10 @@ void QtChatTabs::moveEvent(QMoveEvent*) { emit geometryChanged(); } +void QtChatTabs::checkForFirstShow() { + if (!isVisible()) { + showMinimized(); + } +} + } diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h index 12ab3b8..1869b41 100644 --- a/Swift/QtUI/QtChatTabs.h +++ b/Swift/QtUI/QtChatTabs.h @@ -30,6 +30,7 @@ namespace Swift { void handleWidgetShown(); void handleWantsToActivate(); private: + void checkForFirstShow(); QtTabWidget* tabs_; }; } diff --git a/Swift/QtUI/QtChatWindowFactory.cpp b/Swift/QtUI/QtChatWindowFactory.cpp index ff927c9..ba1719e 100644 --- a/Swift/QtUI/QtChatWindowFactory.cpp +++ b/Swift/QtUI/QtChatWindowFactory.cpp @@ -26,10 +26,6 @@ QtChatWindowFactory::QtChatWindowFactory(QtTreeWidgetFactory *treeWidgetFactory, ChatWindow* QtChatWindowFactory::createChatWindow(const JID &contact) { QtChatWindow *chatWindow = new QtChatWindow(P2QSTRING(contact.toString()), treeWidgetFactory_); tabs_->addTab(chatWindow); - if (!tabs_->isVisible()) { - tabs_->showMinimized(); - //tabs_->minimise(); - } //chatWindow->show(); return chatWindow; } diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index ff2a50b..a73da52 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -98,6 +98,9 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { layout->addStretch(); remember_ = new QCheckBox(tr("Remember Password?"), this); layout->addWidget(remember_); + loginAutomatically_ = new QCheckBox(tr("Login Automatically?"), this); + layout->addWidget(loginAutomatically_); + connect(loginButton_, SIGNAL(clicked()), SLOT(loginClicked())); stack_->addWidget(wrapperWidget); #ifdef SWIFTEN_PLATFORM_MACOSX @@ -218,10 +221,16 @@ void QtLoginWindow::loggedOut() { setEnabled(true); } +void QtLoginWindow::setIsLoggingIn(bool loggingIn) { + setEnabled(!loggingIn); +} + void QtLoginWindow::loginClicked() { - setEnabled(false); - message_->setText(""); - onLoginRequest(Q2PSTRING(username_->currentText()), Q2PSTRING(password_->text()), Q2PSTRING(certificateFile_), remember_->isChecked()); + onLoginRequest(Q2PSTRING(username_->currentText()), Q2PSTRING(password_->text()), Q2PSTRING(certificateFile_), remember_->isChecked(), loginAutomatically_->isChecked()); +} + +void QtLoginWindow::setLoginAutomatically(bool loginAutomatically) { + loginAutomatically_->setChecked(loginAutomatically); } void QtLoginWindow::handleCertficateChecked(bool checked) { diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index 69327e9..b609b64 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -28,6 +28,8 @@ namespace Swift { virtual void loggedOut(); virtual void setMessage(const String& message); virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate); + virtual void setLoginAutomatically(bool loginAutomatically); + virtual void setIsLoggingIn(bool loggingIn); static QRect defaultPosition(); void setGentleGeometry(const QRect&); void selectUser(const String& user); @@ -56,6 +58,7 @@ namespace Swift { QLineEdit* password_; QPushButton* loginButton_; QCheckBox* remember_; + QCheckBox* loginAutomatically_; QStackedWidget* stack_; QLabel* message_; QString certificateFile_; |