+ doingAutoConnect = false;
+
+ ui.stackedWidget->setCurrentWidget(ui.accountPage);
+
+ CoreAccountSettings s;
+ AccountId lastacc = s.lastAccount();
+ autoConnectAccount = s.autoConnectAccount();
+ QListWidgetItem *currentItem = 0;
+ foreach(AccountId id, s.knownAccounts()) {
+ if(!id.isValid()) continue;
+ QVariantMap data = s.retrieveAccountData(id);
+ accounts[id] = data;
+ QListWidgetItem *item = new QListWidgetItem(data["AccountName"].toString(), ui.accountList);
+ item->setData(Qt::UserRole, QVariant::fromValue<AccountId>(id));
+ if(id == lastacc) currentItem = item;
+ }
+ if(currentItem) ui.accountList->setCurrentItem(currentItem);
+ else ui.accountList->setCurrentRow(0);
+
+ setAccountWidgetStates();
+
+ ui.accountButtonBox->button(QDialogButtonBox::Ok)->setFocus();
+ //ui.accountButtonBox->button(QDialogButtonBox::Ok)->setAutoDefault(true);
+
+ connect(clientSyncer, SIGNAL(socketStateChanged(QAbstractSocket::SocketState)),this, SLOT(initPhaseSocketState(QAbstractSocket::SocketState)));
+ connect(clientSyncer, SIGNAL(connectionError(const QString &)), this, SLOT(initPhaseError(const QString &)));
+ connect(clientSyncer, SIGNAL(connectionMsg(const QString &)), this, SLOT(initPhaseMsg(const QString &)));
+ connect(clientSyncer, SIGNAL(startLogin()), this, SLOT(startLogin()));
+ connect(clientSyncer, SIGNAL(loginFailed(const QString &)), this, SLOT(loginFailed(const QString &)));
+ connect(clientSyncer, SIGNAL(loginSuccess()), this, SLOT(startSync()));
+ connect(clientSyncer, SIGNAL(startCoreSetup(const QVariantList &)), this, SLOT(startCoreConfig(const QVariantList &)));
+ connect(clientSyncer, SIGNAL(sessionProgress(quint32, quint32)), this, SLOT(coreSessionProgress(quint32, quint32)));
+ connect(clientSyncer, SIGNAL(networksProgress(quint32, quint32)), this, SLOT(coreNetworksProgress(quint32, quint32)));
+ connect(clientSyncer, SIGNAL(channelsProgress(quint32, quint32)), this, SLOT(coreChannelsProgress(quint32, quint32)));
+ connect(clientSyncer, SIGNAL(ircUsersProgress(quint32, quint32)), this, SLOT(coreIrcUsersProgress(quint32, quint32)));
+ connect(clientSyncer, SIGNAL(syncFinished()), this, SLOT(syncFinished()));
+
+ connect(ui.user, SIGNAL(textChanged(const QString &)), this, SLOT(setLoginWidgetStates()));
+ connect(ui.password, SIGNAL(textChanged(const QString &)), this, SLOT(setLoginWidgetStates()));
+
+ connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull()));
+ connect(ui.syncButtonBox->button(QDialogButtonBox::Abort), SIGNAL(clicked()), this, SLOT(restartPhaseNull()));
+
+ if(autoconnect && ui.accountList->count() && autoConnectAccount.isValid()
+ && autoConnectAccount == ui.accountList->currentItem()->data(Qt::UserRole).value<AccountId>()) {
+ doingAutoConnect = true;
+ on_accountButtonBox_accepted();
+ }
+}
+
+CoreConnectDlg::~CoreConnectDlg() {
+ if(ui.accountList->selectedItems().count()) {
+ CoreAccountSettings s;
+ s.setLastAccount(ui.accountList->selectedItems()[0]->data(Qt::UserRole).value<AccountId>());
+ }
+}
+
+
+/****************************************************
+ * Account Management
+ ***************************************************/
+
+void CoreConnectDlg::on_accountList_itemSelectionChanged() {
+ setAccountWidgetStates();
+}
+
+void CoreConnectDlg::setAccountWidgetStates() {
+ QList<QListWidgetItem *> selectedItems = ui.accountList->selectedItems();
+ ui.editAccount->setEnabled(selectedItems.count());
+ ui.deleteAccount->setEnabled(selectedItems.count());
+ ui.autoConnect->setEnabled(selectedItems.count());
+ if(selectedItems.count()) {
+ ui.autoConnect->setChecked(selectedItems[0]->data(Qt::UserRole).value<AccountId>() == autoConnectAccount);
+ }
+ ui.accountButtonBox->button(QDialogButtonBox::Ok)->setEnabled(ui.accountList->count());
+}
+
+void CoreConnectDlg::on_autoConnect_clicked(bool state) {
+ if(!state) {
+ autoConnectAccount = 0;