X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fircconnectionwizard.cpp;h=1210b5c985f6c6e8daf71d37a8037517ea67a1ba;hp=e952c86314d57a9abbae61f35ce9884d03b895c7;hb=e2188dc438be6f3eb0d9cdf47d28821aefe9835e;hpb=da86ee7178494e6e5404887ddac98d5e107cc747 diff --git a/src/qtui/ircconnectionwizard.cpp b/src/qtui/ircconnectionwizard.cpp index e952c863..1210b5c9 100644 --- a/src/qtui/ircconnectionwizard.cpp +++ b/src/qtui/ircconnectionwizard.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "ircconnectionwizard.h" @@ -23,142 +23,152 @@ #include "client.h" #include "identityeditwidget.h" #include "simplenetworkeditor.h" +#include "presetnetworks.h" #include IrcConnectionWizard::IrcConnectionWizard(QWidget *parent, Qt::WindowFlags flags) - : QWizard(parent, flags), - _introductionPage(0), - _identityPage(0), - _networkPage(0) + : QWizard(parent, flags) { + _introductionPage = createIntroductionPage(this); + _identityPage = new IdentityPage(this); + _networkPage = new NetworkPage(this); - _introductionPage = createIntroductionPage(this); - _identityPage = new IdentityPage(this); - _networkPage = new NetworkPage(this); + addPage(_introductionPage); + addPage(_identityPage); + addPage(_networkPage); + setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); - addPage(_introductionPage); - addPage(_identityPage); - addPage(_networkPage); + setOptions(options() | (QWizard::WizardOptions)(QWizard::NoDefaultButton | QWizard::CancelButtonOnLeft)); + setOption(QWizard::NoCancelButton, false); - setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); - - setOptions(options() | (QWizard::WizardOptions)(QWizard::NoDefaultButton | QWizard::CancelButtonOnLeft)); - setOption(QWizard::NoCancelButton, false); - - connect(button(QWizard::FinishButton), SIGNAL(clicked()), this, SLOT(finishClicked())); - setButtonText(QWizard::FinishButton, tr("Save && Connect")); + connect(button(QWizard::FinishButton), SIGNAL(clicked()), this, SLOT(finishClicked())); + setButtonText(QWizard::FinishButton, tr("Save && Connect")); } -QWizardPage *IrcConnectionWizard::createIntroductionPage(QWidget *parent) { - QWizardPage *page = new QWizardPage(parent); - page->setTitle(QObject::tr("Welcome to Quassel IRC")); - QLabel *label = new QLabel(QObject::tr("This Wizard will help you setting up your default identity and your irc network connection. " - "You can abort this wizard in any step, if you want to setup your identity and IRC connection in more detail." - "This can be done in the settings."), page); - label->setWordWrap(true); +QWizardPage *IrcConnectionWizard::createIntroductionPage(QWidget *parent) +{ + auto *page = new QWizardPage(parent); + page->setTitle(QObject::tr("Welcome to Quassel IRC")); + + QLabel *label = new QLabel(QObject::tr("This wizard will help you to set up your default identity and your IRC network connection.
" + "This only covers basic settings. You can cancel this wizard any time and use the settings dialog for more detailed changes."), page); + label->setWordWrap(true); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(label); - page->setLayout(layout); - return page; + auto *layout = new QVBoxLayout; + layout->addWidget(label); + page->setLayout(layout); + return page; } -void IrcConnectionWizard::finishClicked() { - CertIdentity *identity = static_cast(_identityPage)->identity(); - if(identity->id().isValid()) { - Client::updateIdentity(identity->id(), identity->toVariantMap()); - identityReady(identity->id()); - } else { - connect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(identityReady(IdentityId))); - Client::createIdentity(*identity); - } + +void IrcConnectionWizard::finishClicked() +{ + CertIdentity *identity = static_cast(_identityPage)->identity(); + if (identity->id().isValid()) { + Client::updateIdentity(identity->id(), identity->toVariantMap()); + identityReady(identity->id()); + } + else { + connect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(identityReady(IdentityId))); + Client::createIdentity(*identity); + } } -void IrcConnectionWizard::identityReady(IdentityId id) { - disconnect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(identityReady(IdentityId))); - NetworkPage *networkPage = static_cast(_networkPage); - NetworkInfo networkInfo = networkPage->networkInfo(); - QStringList channels = networkPage->channelList(); - networkInfo.identity = id; - connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(networkReady(NetworkId))); - Client::createNetwork(networkInfo, channels); + +void IrcConnectionWizard::identityReady(IdentityId id) +{ + disconnect(Client::instance(), SIGNAL(identityCreated(IdentityId)), this, SLOT(identityReady(IdentityId))); + auto *networkPage = static_cast(_networkPage); + NetworkInfo networkInfo = networkPage->networkInfo(); + QStringList channels = networkPage->channelList(); + networkInfo.identity = id; + connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(networkReady(NetworkId))); + Client::createNetwork(networkInfo, channels); } -void IrcConnectionWizard::networkReady(NetworkId id) { - disconnect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(networkReady(NetworkId))); - const Network *net = Client::network(id); - Q_ASSERT(net); - net->requestConnect(); - deleteLater(); + +void IrcConnectionWizard::networkReady(NetworkId id) +{ + disconnect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(networkReady(NetworkId))); + const Network *net = Client::network(id); + Q_ASSERT(net); + net->requestConnect(); + deleteLater(); } + // ============================== // Wizard Pages // ============================== // Identity Page IdentityPage::IdentityPage(QWidget *parent) - : QWizardPage(parent), - _identityEditWidget(new IdentityEditWidget(this)), - _identity(0) + : QWizardPage(parent), + _identityEditWidget(new IdentityEditWidget(this)) { - setTitle(tr("Setup Identity")); - - if(Client::identityIds().isEmpty()) { - _identity = new CertIdentity(-1, this); - _identity->setToDefaults(); - _identity->setIdentityName(tr("Default Identity")); - } else { - _identity = new CertIdentity(*Client::identity(Client::identityIds().first()), this); - } - - _identityEditWidget->displayIdentity(_identity); - _identityEditWidget->showAdvanced(false); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(_identityEditWidget); - setLayout(layout); + setTitle(tr("Setup Identity")); + + if (Client::identityIds().isEmpty()) { + _identity = new CertIdentity(-1, this); + _identity->setToDefaults(); + _identity->setIdentityName(tr("Default Identity")); + } + else { + _identity = new CertIdentity(*Client::identity(Client::identityIds().first()), this); + } + + _identityEditWidget->displayIdentity(_identity); + _identityEditWidget->showAdvanced(false); + auto *layout = new QVBoxLayout; + layout->addWidget(_identityEditWidget); + setLayout(layout); } -CertIdentity *IdentityPage::identity() { - _identityEditWidget->saveToIdentity(_identity); - return _identity; + +CertIdentity *IdentityPage::identity() +{ + _identityEditWidget->saveToIdentity(_identity); + return _identity; } // Network Page NetworkPage::NetworkPage(QWidget *parent) - : QWizardPage(parent), + : QWizardPage(parent), _networkEditor(new SimpleNetworkEditor(this)) { - - QStringList defaultNets = Network::presetNetworks(true); - if(!defaultNets.isEmpty()) { - NetworkInfo info = Network::networkInfoFromPreset(defaultNets[0]); - if(!info.networkName.isEmpty()) { - _networkInfo = info; - _channelList = Network::presetDefaultChannels(defaultNets[0]); + QStringList defaultNets = PresetNetworks::names(true); + if (!defaultNets.isEmpty()) { + NetworkInfo info = PresetNetworks::networkInfo(defaultNets[0]); + if (!info.networkName.isEmpty()) { + _networkInfo = info; + _channelList = PresetNetworks::defaultChannels(defaultNets[0]); + } } - } - _networkEditor->displayNetworkInfo(_networkInfo); - _networkEditor->setDefaultChannels(_channelList); + _networkEditor->displayNetworkInfo(_networkInfo); + _networkEditor->setDefaultChannels(_channelList); - setTitle(tr("Setup Network Connection")); + setTitle(tr("Setup Network Connection")); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(_networkEditor); - setLayout(layout); + auto *layout = new QVBoxLayout; + layout->addWidget(_networkEditor); + setLayout(layout); } -NetworkInfo NetworkPage::networkInfo() { - _networkEditor->saveToNetworkInfo(_networkInfo); - return _networkInfo; + +NetworkInfo NetworkPage::networkInfo() +{ + _networkEditor->saveToNetworkInfo(_networkInfo); + return _networkInfo; } -QStringList NetworkPage::channelList() { - _channelList = _networkEditor->defaultChannels(); - return _channelList; + +QStringList NetworkPage::channelList() +{ + _channelList = _networkEditor->defaultChannels(); + return _channelList; }