- coreState = 0;
- /* We show ui.internalCore in any case, because we might want to run as monolithic client anyway at another time
- if(Global::runMode == Global::Monolithic) {
- connect(ui.internalCore, SIGNAL(toggled(bool)), ui.hostEdit, SLOT(setDisabled(bool)));
- connect(ui.internalCore, SIGNAL(toggled(bool)), ui.port, SLOT(setDisabled(bool)));
- ui.internalCore->setChecked(true);
- } else {
- //ui.internalCore->hide();
- }
- */
- connect(ui.newAccount, SIGNAL(clicked()), this, SLOT(createAccount()));
- connect(ui.delAccount, SIGNAL(clicked()), this, SLOT(removeAccount()));
- connect(ui.buttonBox1, SIGNAL(accepted()), this, SLOT(doConnect()));
- connect(ui.hostEdit, SIGNAL(textChanged(const QString &)), this, SLOT(checkInputValid()));
- connect(ui.userEdit, SIGNAL(textChanged(const QString &)), this, SLOT(checkInputValid()));
- connect(ui.internalCore, SIGNAL(toggled(bool)), this, SLOT(checkInputValid()));
- connect(ui.internalCore, SIGNAL(toggled(bool)), ui.hostEdit, SLOT(setDisabled(bool)));
- connect(ui.internalCore, SIGNAL(toggled(bool)), ui.port, SLOT(setDisabled(bool)));
- connect(ui.accountList, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(accountChanged(const QString &)));
- connect(ui.autoConnect, SIGNAL(clicked(bool)), this, SLOT(autoConnectToggled(bool)));
-
- connect(Client::instance(), SIGNAL(coreConnectionMsg(const QString &)), ui.connectionStatus, SLOT(setText(const QString &)));
- connect(Client::instance(), SIGNAL(coreConnectionProgress(uint, uint)), this, SLOT(updateProgressBar(uint, uint)));
- connect(Client::instance(), SIGNAL(coreConnectionError(QString)), this, SLOT(coreConnectionError(QString)));
- connect(Client::instance(), SIGNAL(connected()), this, SLOT(coreConnected()));
-
- AccountSettings s;
- ui.accountList->addItems(s.knownAccounts());
- curacc = s.lastAccount();
- if(!ui.accountList->count()) {
- //if(doAutoConnect) reject();
-
- setAccountEditEnabled(false);
- QString newacc = QInputDialog::getText(this, tr("Create Account"), tr(
- "In order to connect to a Quassel Core, you need to create an account.<br>"
- "Please enter a name for this account now:"), QLineEdit::Normal, tr("Default"));
- if(!newacc.isEmpty()) {
- ui.accountList->addItem(newacc);
- ui.hostEdit->setText("localhost");
- ui.port->setValue(DEFAULT_PORT);
- ui.internalCore->setChecked(false);
- setAccountEditEnabled(true);
- }
- /*
- // FIXME We create a default account here that just connects to the internal core
- curacc = "Default";
- ui.accountList->addItem("Default");
- ui.internalCore->setChecked(true);
- ui.userEdit->setText("Default");
- ui.passwdEdit->setText("password");
- ui.rememberPasswd->setChecked(true);
- accountChanged(curacc);
- ui.passwdEdit->setText("password");
- ui.accountList->setCurrentIndex(0);
- ui.autoConnect->setChecked(true);
- autoConnectToggled(true);
- */
- } else {
- if(!curacc.isEmpty()) {
- //if(doAutoConnect) { qDebug() << "auto";
- // AccountSettings s;
- // int idx = ui.accountList->findText(s.autoConnectAccount());
- // if(idx < 0) reject();
- // else {
- // ui.accountList->setCurrentIndex(idx);
- // doConnect();
- // }
- //} else {
- int idx = ui.accountList->findText(curacc);
- ui.accountList->setCurrentIndex(idx);
- //}
- }
+ doingAutoConnect = false;
+
+ ui.stackedWidget->setCurrentWidget(ui.accountPage);
+ ui.accountButtonBox->setFocus();
+ ui.accountButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);
+
+ CoreAccountSettings s;
+ QString lastacc = s.lastAccount();
+ autoConnectAccount = s.autoConnectAccount();
+ accounts = s.retrieveAllAccounts();
+ ui.accountList->addItems(accounts.keys());
+ QList<QListWidgetItem *> l = ui.accountList->findItems(lastacc, Qt::MatchExactly);
+ if(l.count()) ui.accountList->setCurrentItem(l[0]);
+ else ui.accountList->setCurrentRow(0);
+
+ setAccountWidgetStates();
+
+ 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(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(accept()));
+
+ 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.isEmpty() && autoConnectAccount == ui.accountList->currentItem()->text()) {
+ doingAutoConnect = true;
+ on_accountButtonBox_accepted();