X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fcoreconnectdlg.cpp;h=f44ba0f4264164d7e971ce4cb83157bfcf820a6a;hp=3f6d120816f7bd520ece8213a25adb3aaaea1d0d;hb=f448828fb29f3d23d9306f777cd264a13fde0e9a;hpb=7420347c74eee96531879e62fbadb1c787fcbde9 diff --git a/src/qtui/coreconnectdlg.cpp b/src/qtui/coreconnectdlg.cpp index 3f6d1208..f44ba0f4 100644 --- a/src/qtui/coreconnectdlg.cpp +++ b/src/qtui/coreconnectdlg.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel IRC Team * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -24,13 +24,16 @@ #include "coreconnectdlg.h" +#include "client.h" #include "clientsettings.h" #include "clientsyncer.h" #include "coreconfigwizard.h" #include "iconloader.h" +#include "quassel.h" CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) - : QDialog(parent) + : QDialog(parent), + _internalAccountId(0) { ui.setupUi(this); ui.editAccount->setIcon(SmallIcon("document-properties")); @@ -39,10 +42,18 @@ CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) ui.connectIcon->setPixmap(BarIcon("network-disconnect")); ui.secureConnection->setPixmap(SmallIcon("document-encrypt")); + if(Quassel::runMode() != Quassel::Monolithic) { + ui.useInternalCore->hide(); + } + // make it look more native under Mac OS X: setWindowFlags(Qt::Sheet); clientSyncer = new ClientSyncer(this); + Client::registerClientSyncer(clientSyncer); +// connect(this, SIGNAL(newClientSyncer(ClientSyncer *)), Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *))); +// emit newClientSyncer(clientSyncer); // announce the new client syncer via the client. + wizard = 0; doingAutoConnect = false; @@ -56,6 +67,10 @@ CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) foreach(AccountId id, s.knownAccounts()) { if(!id.isValid()) continue; QVariantMap data = s.retrieveAccountData(id); + if(data.contains("InternalAccount") && data["InternalAccount"].toBool()) { + _internalAccountId = id; + continue; + } data["AccountId"] = QVariant::fromValue(id); accounts[id] = data; QListWidgetItem *item = new QListWidgetItem(data["AccountName"].toString(), ui.accountList); @@ -73,7 +88,6 @@ CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) 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(encrypted(bool)), this, SLOT(encrypted(bool))); 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())); @@ -81,6 +95,7 @@ CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent) 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(syncFinished()), this, SLOT(syncFinished())); + connect(clientSyncer, SIGNAL(encrypted()), ui.secureConnection, SLOT(show())); connect(ui.user, SIGNAL(textChanged(const QString &)), this, SLOT(setLoginWidgetStates())); connect(ui.password, SIGNAL(textChanged(const QString &)), this, SLOT(setLoginWidgetStates())); @@ -141,14 +156,7 @@ void CoreConnectDlg::on_addAccount_clicked() { for(int i = 0; i < ui.accountList->count(); i++) existing << ui.accountList->item(i)->text(); CoreAccountEditDlg dlg(0, QVariantMap(), existing, this); if(dlg.exec() == QDialog::Accepted) { - // find free ID - AccountId id = accounts.count() + 1; - for(AccountId i = 1; i <= accounts.count(); i++) { - if(!accounts.keys().contains(i)) { - id = i; - break; - } - } + AccountId id = findFreeAccountId(); QVariantMap data = dlg.accountData(); data["AccountId"] = QVariant::fromValue(id); accounts[id] = data; @@ -211,6 +219,11 @@ void CoreConnectDlg::on_accountButtonBox_accepted() { connectToCore(); } +void CoreConnectDlg::on_useInternalCore_clicked() { + clientSyncer->useInternalCore(); + ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Cancel); +} + /***************************************************** * Connecting to the Core ****************************************************/ @@ -250,13 +263,6 @@ void CoreConnectDlg::initPhaseMsg(const QString &msg) { ui.coreInfoLabel->setText(msg); } -void CoreConnectDlg::encrypted(bool useSsl) { - if(useSsl) - ui.secureConnection->show(); - else - ui.secureConnection->hide(); -} - void CoreConnectDlg::initPhaseSocketState(QAbstractSocket::SocketState state) { QString s; QString host = accountData["Host"].toString(); @@ -406,7 +412,8 @@ void CoreConnectDlg::startSync() { ui.user->setEnabled(true); ui.password->setEnabled(true); ui.rememberPasswd->setEnabled(true); - ui.loginButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true); + if(ui.loginButtonBox->standardButtons() & QDialogButtonBox::Ok) // in mono mode we don't show an Ok Button + ui.loginButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true); } void CoreConnectDlg::coreSessionProgress(quint32 val, quint32 max) { @@ -436,6 +443,13 @@ void CoreConnectDlg::syncFinished() { } } +AccountId CoreConnectDlg::findFreeAccountId() { + for(AccountId i = 1;; i++) { + if(!accounts.contains(i) && i != _internalAccountId) + return i; + } +} + /***************************************************************************************** * CoreAccountEditDlg *****************************************************************************************/ @@ -447,10 +461,11 @@ CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, co existing = _existing; if(id.isValid()) { + account = acct; + existing.removeAll(acct["AccountName"].toString()); ui.host->setText(acct["Host"].toString()); ui.port->setValue(acct["Port"].toUInt()); - ui.useInternal->setChecked(acct["UseInternal"].toBool()); ui.accountName->setText(acct["AccountName"].toString()); #ifdef HAVE_SSL ui.useSsl->setChecked(acct["useSsl"].toBool()); @@ -471,21 +486,12 @@ CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, co ui.useSsl->setEnabled(false); #endif } - -#ifndef BUILD_MONO - // if we don't have a mono build we hide the option to use the internal connection and force the setting to use remote host - ui.useInternal->setChecked(false); - ui.useInternal->hide(); - ui.useRemote->hide(); - ui.labelUseBuiltinCore->hide(); -#endif } QVariantMap CoreAccountEditDlg::accountData() { account["AccountName"] = ui.accountName->text().trimmed(); account["Host"] = ui.host->text().trimmed(); account["Port"] = ui.port->value(); - account["UseInternal"] = ui.useInternal->isChecked(); account["useSsl"] = ui.useSsl->isChecked(); account["useProxy"] = ui.useProxy->isChecked(); account["proxyHost"] = ui.proxyHost->text().trimmed(); @@ -497,7 +503,7 @@ QVariantMap CoreAccountEditDlg::accountData() { } void CoreAccountEditDlg::setWidgetStates() { - bool ok = !ui.accountName->text().trimmed().isEmpty() && !existing.contains(ui.accountName->text()) && (ui.useInternal->isChecked() || !ui.host->text().isEmpty()); + bool ok = !ui.accountName->text().trimmed().isEmpty() && !existing.contains(ui.accountName->text()) && !ui.host->text().isEmpty(); ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok); } @@ -510,8 +516,3 @@ void CoreAccountEditDlg::on_accountName_textChanged(const QString &text) { Q_UNUSED(text); setWidgetStates(); } - -void CoreAccountEditDlg::on_useRemote_toggled(bool state) { - Q_UNUSED(state); - setWidgetStates(); -}