summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-06-30 21:33:01 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-07-25 15:01:31 (GMT)
commit70ba4f2e4f35577a0a1544b9677e154231c98aba (patch)
tree31f804f4fc5075d0f98eb0c2c46ae7e100c28681 /Swift/QtUI
parent25ba37d0fd3ed298d5a0874718f878668a1be62e (diff)
downloadswift-contrib-70ba4f2e4f35577a0a1544b9677e154231c98aba.zip
swift-contrib-70ba4f2e4f35577a0a1544b9677e154231c98aba.tar.bz2
Initial multi-account support
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtSwift.cpp63
-rw-r--r--Swift/QtUI/QtSwift.h17
2 files changed, 56 insertions, 24 deletions
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index 3e8bc8b..57b4edf 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -47,6 +47,7 @@ po::options_description QtSwift::getOptionsDescription() {
("netbook-mode", "use netbook mode display")
("no-tabs", "don't manage chat windows in tabs")
("latency-debug", "use latency debugging")
+ ("multi-account", po::value<int>()->default_value(1), "number of accounts to open windows for")
;
return result;
}
@@ -63,22 +64,36 @@ QtSwift::QtSwift(po::variables_map options) : autoUpdater_(NULL) {
QCoreApplication::setOrganizationDomain(SWIFT_ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationVersion(buildVersion);
+ int numberOfAccounts = options["multi-account"].as<int>();
+
tabs_ = options.count("no-tabs") && !splitter_ > 0 ? NULL : new QtChatTabs();
settings_ = new QtSettingsProvider();
application_ = new PlatformApplication(SWIFT_APPLICATION_NAME);
- systemTray_ = new QtSystemTray();
- loginWindowFactory_ = new QtLoginWindowFactory(splitter_, systemTray_, settings_);
chatWindowFactory_ = new QtChatWindowFactory(splitter_, settings_, tabs_);
- rosterWindowFactory_ = new QtMainWindowFactory();
- eventWindowFactory_ = new QtEventWindowFactory(rosterWindowFactory_);
- xmlConsoleWidgetFactory_ = new QtXMLConsoleWidgetFactory(tabs_);
- chatListWindowFactory_ = new QtChatListWindowFactory(rosterWindowFactory_);
- mucSearchWindowFactory_ = new QtMUCSearchWindowFactory();
soundPlayer_ = new QtSoundPlayer();
if (splitter_) {
splitter_->show();
}
- mainController_ = new MainController(chatWindowFactory_, rosterWindowFactory_, loginWindowFactory_, eventWindowFactory_, settings_, application_, systemTray_, soundPlayer_, xmlConsoleWidgetFactory_, chatListWindowFactory_, mucSearchWindowFactory_, options.count("latency-debug") > 0);
+
+ for (int i = 0; i < numberOfAccounts; i++) {
+ QtSystemTray* systemTray = new QtSystemTray();
+ systemTrays_.push_back(systemTray);
+ QtLoginWindowFactory* loginWindowFactory = new QtLoginWindowFactory(splitter_, systemTray, settings_);
+ loginWindowFactories_.push_back(loginWindowFactory);
+ QtMainWindowFactory* rosterWindowFactory = new QtMainWindowFactory();
+ rosterWindowFactories_.push_back(rosterWindowFactory);
+ QtEventWindowFactory* eventWindowFactory = new QtEventWindowFactory(rosterWindowFactory);
+ eventWindowFactories_.push_back(eventWindowFactory);
+ QtXMLConsoleWidgetFactory* xmlConsoleWidgetFactory = new QtXMLConsoleWidgetFactory(tabs_);
+ xmlConsoleWidgetFactories_.push_back(xmlConsoleWidgetFactory);
+ QtChatListWindowFactory* chatListWindowFactory = new QtChatListWindowFactory(rosterWindowFactory);
+ chatListWindowFactories_.push_back(chatListWindowFactory);
+ QtMUCSearchWindowFactory* mucSearchWindowFactory = new QtMUCSearchWindowFactory();
+ mucSearchWindowFactories_.push_back(mucSearchWindowFactory);
+ MainController* mainController = new MainController(chatWindowFactory_, rosterWindowFactory, loginWindowFactory, eventWindowFactory, settings_, application_, systemTray, soundPlayer_, xmlConsoleWidgetFactory, chatListWindowFactory, mucSearchWindowFactory, options.count("latency-debug") > 0);
+ mainControllers_.push_back(mainController);
+ }
+
// PlatformAutoUpdaterFactory autoUpdaterFactory;
// if (autoUpdaterFactory.isSupported()) {
@@ -90,19 +105,35 @@ QtSwift::QtSwift(po::variables_map options) : autoUpdater_(NULL) {
QtSwift::~QtSwift() {
delete autoUpdater_;
delete chatWindowFactory_;
- delete rosterWindowFactory_;
- delete loginWindowFactory_;
- delete mucSearchWindowFactory_;
- delete mainController_;
+ foreach (QtMainWindowFactory* factory, rosterWindowFactories_) {
+ delete factory;
+ }
+ foreach (QtLoginWindowFactory* factory, loginWindowFactories_) {
+ delete factory;
+ }
+ foreach (MUCSearchWindowFactory* factory, mucSearchWindowFactories_) {
+ delete factory;
+ }
+ foreach (MainController* controller, mainControllers_) {
+ delete controller;
+ }
delete settings_;
delete application_;
- delete systemTray_;
+ foreach (QtSystemTray* tray, systemTrays_) {
+ delete tray;
+ }
delete tabs_;
delete splitter_;
delete soundPlayer_;
- delete xmlConsoleWidgetFactory_;
- delete eventWindowFactory_;
- delete chatListWindowFactory_;
+ foreach (QtXMLConsoleWidgetFactory* factory, xmlConsoleWidgetFactories_) {
+ delete factory;
+ }
+ foreach (QtEventWindowFactory* factory, eventWindowFactories_) {
+ delete factory;
+ }
+ foreach (QtChatListWindowFactory* factory, chatListWindowFactories_) {
+ delete factory;
+ }
}
}
diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h
index 37dd4ce..567af32 100644
--- a/Swift/QtUI/QtSwift.h
+++ b/Swift/QtUI/QtSwift.h
@@ -42,22 +42,23 @@ namespace Swift {
static po::options_description getOptionsDescription();
~QtSwift();
private:
- MainController *mainController_;
+ std::vector<MainController*> mainControllers_;
QtChatWindowFactory *chatWindowFactory_;
- QtChatListWindowFactory *chatListWindowFactory_;
- QtMainWindowFactory *rosterWindowFactory_;
- QtLoginWindowFactory *loginWindowFactory_;
- QtXMLConsoleWidgetFactory* xmlConsoleWidgetFactory_;
+ std::vector<QtMainWindowFactory*> rosterWindowFactories_;
+ std::vector<QtLoginWindowFactory*> loginWindowFactories_;
+ std::vector<QtXMLConsoleWidgetFactory*> xmlConsoleWidgetFactories_;
+ std::vector<QtEventWindowFactory*> eventWindowFactories_;
+ std::vector<QtSystemTray*> systemTrays_;
+ std::vector<QtChatListWindowFactory*> chatListWindowFactories_;
+ std::vector<QtMUCSearchWindowFactory*> mucSearchWindowFactories_;
QtEventLoop clientMainThreadCaller_;
QtSettingsProvider *settings_;
- QtSystemTray* systemTray_;
QSplitter* splitter_;
QtSoundPlayer* soundPlayer_;
QtChatTabs* tabs_;
- QtEventWindowFactory* eventWindowFactory_;
Application* application_;
AutoUpdater* autoUpdater_;
- QtMUCSearchWindowFactory* mucSearchWindowFactory_;
+
};
}