summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThanos Doukoudakis <thanos.doukoudakis@isode.com>2018-07-12 22:58:02 (GMT)
committerKevin Smith <kevin.smith@isode.com>2018-07-18 17:11:33 (GMT)
commit0d5cd98d372c6b9235b55cd8d16e93647c9d017f (patch)
tree9f8ade0f540e35c49e1dd390bc3efe56de0b6b25 /Swift/QtUI/QtSingleWindow.cpp
parent0d3c4298f0818cb377fcfc8409e89fe6327ab036 (diff)
downloadswift-0d5cd98d372c6b9235b55cd8d16e93647c9d017f.zip
swift-0d5cd98d372c6b9235b55cd8d16e93647c9d017f.tar.bz2
Add support for multiple accounts
Added support for multiple accounts and a list of servers where the user can switch between the accounts. Future patches will make the list widget to use server avatars with user status. Upon startup the client will reconnect with all previous accounts. If the user log outs with any of the accounts then it will not login automatically for future sessions, the credential though will be available to the user. Upon upgrading from previous versions, the client will migrate the account that was previously marked to auto-login to the new configuration and enable it. After the migration the autologin setting will be set to false. Some of the settings and command line arguments have been made obsolete due to these changes and removed, including SSO support, which will be re-introduced in a future patch. Test-Information: Tested the changes in Windows and Linux, tested adding and removing accounts, and switching between them. Tested the new configuration for accounts, the upgrade behaviour when an account is marked/not marked to autojoin, and the migration to the new configuration. Verified that the auto-login setting is set to false after the migration, and that the migrated account can be disabled (currently only by signing out). Change-Id: I63662f80e006112fde6f418f9743e2b420e81870
Diffstat (limited to 'Swift/QtUI/QtSingleWindow.cpp')
-rw-r--r--Swift/QtUI/QtSingleWindow.cpp71
1 files changed, 50 insertions, 21 deletions
diff --git a/Swift/QtUI/QtSingleWindow.cpp b/Swift/QtUI/QtSingleWindow.cpp
index d53f247..6881c4f 100644
--- a/Swift/QtUI/QtSingleWindow.cpp
+++ b/Swift/QtUI/QtSingleWindow.cpp
@@ -6,9 +6,13 @@
#include <Swift/QtUI/QtSingleWindow.h>
+#include <QPushButton>
+#include <QVBoxLayout>
+
#include <Swiften/Base/Platform.h>
#include <Swift/QtUI/QtChatTabs.h>
+#include <Swift/QtUI/QtLoginWindow.h>
#include <Swift/QtUI/QtSettingsProvider.h>
namespace Swift {
@@ -24,6 +28,25 @@ QtSingleWindow::QtSingleWindow(QtSettingsProvider* settings) : QSplitter() {
}
connect(this, SIGNAL(splitterMoved(int, int)), this, SLOT(handleSplitterMoved(/*int, int*/)));
setChildrenCollapsible(false);
+
+ auto left = new QWidget(this);
+ list_ = new QListWidget(left);
+ auto addButton = new QPushButton("+", left);
+ QVBoxLayout* leftLayout = new QVBoxLayout();
+ leftLayout->addWidget(list_);
+ leftLayout->addWidget(addButton);
+ left->setLayout(leftLayout);
+ QSplitter::addWidget(left);
+ loginWindows_ = new QStackedWidget(this);
+ QSplitter::addWidget(loginWindows_);
+ tabs_ = new QStackedWidget(this);
+ QSplitter::addWidget(tabs_);
+ restoreSplitters();
+ setStretchFactor(0, 0);
+ setStretchFactor(1, 0);
+ setStretchFactor(2, 1);
+ connect(list_, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(handleListItemClicked(QListWidgetItem*)));
+ connect(addButton, SIGNAL(clicked()), this, SIGNAL(wantsToAddAccount()));
#ifdef SWIFTEN_PLATFORM_MACOSX
setHandleWidth(0);
#endif
@@ -33,14 +56,6 @@ QtSingleWindow::~QtSingleWindow() {
}
-void QtSingleWindow::addWidget(QWidget* widget) {
- QtChatTabs* tabs = dynamic_cast<QtChatTabs*>(widget);
- if (tabs) {
- connect(tabs, SIGNAL(onTitleChanged(const QString&)), this, SLOT(handleTabsTitleChanged(const QString&)));
- }
- QSplitter::addWidget(widget);
-}
-
void QtSingleWindow::handleTabsTitleChanged(const QString& title) {
setWindowTitle(title);
}
@@ -55,25 +70,18 @@ void QtSingleWindow::handleSplitterMoved() {
}
void QtSingleWindow::restoreSplitters() {
- QList<QVariant> variantValues = settings_->getQSettings()->value(SINGLE_WINDOW_SPLITS).toList();
- QList<int> intValues;
- for (auto&& value : variantValues) {
- intValues.append(value.toInt());
- }
- setSizes(intValues);
-}
-
-void QtSingleWindow::insertAtFront(QWidget* widget) {
- insertWidget(0, widget);
auto splitsVariant = settings_->getQSettings()->value(SINGLE_WINDOW_SPLITS);
if (splitsVariant.isValid()) {
- restoreSplitters();
+ auto variantValues = splitsVariant.toList();
+ QList<int> intValues;
+ for (auto&& value : variantValues) {
+ intValues.append(value.toInt());
+ }
+ setSizes(intValues);
}
else {
handleSplitterMoved();
}
- setStretchFactor(0, 0);
- setStretchFactor(1, 1);
}
void QtSingleWindow::handleGeometryChanged() {
@@ -89,4 +97,25 @@ void QtSingleWindow::moveEvent(QMoveEvent*) {
handleGeometryChanged();
}
+void QtSingleWindow::addAccount(QtLoginWindow* loginWindow, QtChatTabs* tabs) {
+ if (!loginWindows_->count()) {
+ connect(tabs, SIGNAL(onTitleChanged(const QString&)), this, SLOT(handleTabsTitleChanged(const QString&)));
+ }
+ loginWindows_->addWidget(loginWindow);
+ tabs_->addWidget(tabs);
+ list_->addItem(QString("Account %1").arg(loginWindows_->count()));
+}
+
+void QtSingleWindow::handleListItemClicked(QListWidgetItem* /*item*/) {
+ //FIXME: Should use a full model/view and do this properly (and render pretty things ourselves too)
+ auto currentTabs = tabs_->widget(tabs_->currentIndex());
+ disconnect(currentTabs, SIGNAL(onTitleChanged(const QString&)), this, SLOT(handleTabsTitleChanged(const QString&)));
+ loginWindows_->setCurrentIndex(list_->currentRow());
+ tabs_->setCurrentIndex(list_->currentRow());
+ currentTabs = tabs_->widget(tabs_->currentIndex());
+ connect(currentTabs, SIGNAL(onTitleChanged(const QString&)), this, SLOT(handleTabsTitleChanged(const QString&)));
+ //TODO change the title of the window.
+ handleTabsTitleChanged(QString("Swift"));
+}
+
}