First working version of internal core connection.
[quassel.git] / src / qtui / coreconnectdlg.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #include <QDebug>
22 #include <QMessageBox>
23 #include <QNetworkProxy>
24
25 #include "coreconnectdlg.h"
26
27 #include "clientsettings.h"
28 #include "clientsyncer.h"
29 #include "coreconfigwizard.h"
30 #include "iconloader.h"
31
32 CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent)
33   : QDialog(parent)
34 {
35   ui.setupUi(this);
36   ui.editAccount->setIcon(SmallIcon("document-properties"));
37   ui.addAccount->setIcon(SmallIcon("list-add"));
38   ui.deleteAccount->setIcon(SmallIcon("list-remove"));
39   ui.connectIcon->setPixmap(BarIcon("network-disconnect"));
40   ui.secureConnection->setPixmap(SmallIcon("document-encrypt"));
41
42   // make it look more native under Mac OS X:
43   setWindowFlags(Qt::Sheet);
44
45   clientSyncer = new ClientSyncer(this);
46   wizard = 0;
47
48   doingAutoConnect = false;
49
50   ui.stackedWidget->setCurrentWidget(ui.accountPage);
51
52   CoreAccountSettings s;
53   AccountId lastacc = s.lastAccount();
54   autoConnectAccount = s.autoConnectAccount();
55   QListWidgetItem *currentItem = 0;
56   foreach(AccountId id, s.knownAccounts()) {
57     if(!id.isValid()) continue;
58     QVariantMap data = s.retrieveAccountData(id);
59     data["AccountId"] = QVariant::fromValue<AccountId>(id);
60     accounts[id] = data;
61     QListWidgetItem *item = new QListWidgetItem(data["AccountName"].toString(), ui.accountList);
62     item->setData(Qt::UserRole, QVariant::fromValue<AccountId>(id));
63     if(id == lastacc) currentItem = item;
64   }
65   if(currentItem) ui.accountList->setCurrentItem(currentItem);
66   else ui.accountList->setCurrentRow(0);
67
68   setAccountWidgetStates();
69
70   ui.accountButtonBox->button(QDialogButtonBox::Ok)->setFocus();
71   //ui.accountButtonBox->button(QDialogButtonBox::Ok)->setAutoDefault(true);
72
73   connect(clientSyncer, SIGNAL(socketStateChanged(QAbstractSocket::SocketState)),this, SLOT(initPhaseSocketState(QAbstractSocket::SocketState)));
74   connect(clientSyncer, SIGNAL(connectionError(const QString &)), this, SLOT(initPhaseError(const QString &)));
75   connect(clientSyncer, SIGNAL(connectionMsg(const QString &)), this, SLOT(initPhaseMsg(const QString &)));
76   connect(clientSyncer, SIGNAL(encrypted(bool)), this, SLOT(encrypted(bool)));
77   connect(clientSyncer, SIGNAL(startLogin()), this, SLOT(startLogin()));
78   connect(clientSyncer, SIGNAL(loginFailed(const QString &)), this, SLOT(loginFailed(const QString &)));
79   connect(clientSyncer, SIGNAL(loginSuccess()), this, SLOT(startSync()));
80   connect(clientSyncer, SIGNAL(startCoreSetup(const QVariantList &)), this, SLOT(startCoreConfig(const QVariantList &)));
81   connect(clientSyncer, SIGNAL(sessionProgress(quint32, quint32)), this, SLOT(coreSessionProgress(quint32, quint32)));
82   connect(clientSyncer, SIGNAL(networksProgress(quint32, quint32)), this, SLOT(coreNetworksProgress(quint32, quint32)));
83   connect(clientSyncer, SIGNAL(syncFinished()), this, SLOT(syncFinished()));
84
85   connect(ui.user, SIGNAL(textChanged(const QString &)), this, SLOT(setLoginWidgetStates()));
86   connect(ui.password, SIGNAL(textChanged(const QString &)), this, SLOT(setLoginWidgetStates()));
87
88   connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull()));
89   connect(ui.syncButtonBox->button(QDialogButtonBox::Abort), SIGNAL(clicked()), this, SLOT(restartPhaseNull()));
90
91   if(autoconnect && ui.accountList->count() && autoConnectAccount.isValid()
92      && autoConnectAccount == ui.accountList->currentItem()->data(Qt::UserRole).value<AccountId>()) {
93     doingAutoConnect = true;
94     on_accountButtonBox_accepted();
95   }
96 }
97
98 CoreConnectDlg::~CoreConnectDlg() {
99   if(ui.accountList->selectedItems().count()) {
100     CoreAccountSettings s;
101     s.setLastAccount(ui.accountList->selectedItems()[0]->data(Qt::UserRole).value<AccountId>());
102   }
103 }
104
105
106 /****************************************************
107  * Account Management
108  ***************************************************/
109
110 void CoreConnectDlg::on_accountList_itemSelectionChanged() {
111   setAccountWidgetStates();
112 }
113
114 void CoreConnectDlg::setAccountWidgetStates() {
115   QList<QListWidgetItem *> selectedItems = ui.accountList->selectedItems();
116   ui.editAccount->setEnabled(selectedItems.count());
117   ui.deleteAccount->setEnabled(selectedItems.count());
118   ui.autoConnect->setEnabled(selectedItems.count());
119   if(selectedItems.count()) {
120     ui.autoConnect->setChecked(selectedItems[0]->data(Qt::UserRole).value<AccountId>() == autoConnectAccount);
121   }
122   ui.accountButtonBox->button(QDialogButtonBox::Ok)->setEnabled(ui.accountList->count());
123 }
124
125 void CoreConnectDlg::on_autoConnect_clicked(bool state) {
126   if(!state) {
127     autoConnectAccount = 0;
128   } else {
129     if(ui.accountList->selectedItems().count()) {
130       autoConnectAccount = ui.accountList->selectedItems()[0]->data(Qt::UserRole).value<AccountId>();
131     } else {
132       qWarning() << "Checked auto connect without an enabled item!";  // should never happen!
133       autoConnectAccount = 0;
134     }
135   }
136   setAccountWidgetStates();
137 }
138
139 void CoreConnectDlg::on_addAccount_clicked() {
140   QStringList existing;
141   for(int i = 0; i < ui.accountList->count(); i++) existing << ui.accountList->item(i)->text();
142   CoreAccountEditDlg dlg(0, QVariantMap(), existing, this);
143   if(dlg.exec() == QDialog::Accepted) {
144     // find free ID
145     AccountId id = accounts.count() + 1;
146     for(AccountId i = 1; i <= accounts.count(); i++) {
147       if(!accounts.keys().contains(i)) {
148         id = i;
149         break;
150       }
151     }
152     QVariantMap data = dlg.accountData();
153     data["AccountId"] = QVariant::fromValue<AccountId>(id);
154     accounts[id] = data;
155     QListWidgetItem *item = new QListWidgetItem(data["AccountName"].toString(), ui.accountList);
156     item->setData(Qt::UserRole, QVariant::fromValue<AccountId>(id));
157     ui.accountList->setCurrentItem(item);
158   }
159 }
160
161 void CoreConnectDlg::on_editAccount_clicked() {
162   QStringList existing;
163   for(int i = 0; i < ui.accountList->count(); i++) existing << ui.accountList->item(i)->text();
164   AccountId id = ui.accountList->currentItem()->data(Qt::UserRole).value<AccountId>();
165   QVariantMap acct = accounts[id];
166   CoreAccountEditDlg dlg(id, acct, existing, this);
167   if(dlg.exec() == QDialog::Accepted) {
168     QVariantMap data = dlg.accountData();
169     ui.accountList->currentItem()->setText(data["AccountName"].toString());
170     accounts[id] = data;
171   }
172 }
173
174 void CoreConnectDlg::on_deleteAccount_clicked() {
175   AccountId id = ui.accountList->currentItem()->data(Qt::UserRole).value<AccountId>();
176   int ret = QMessageBox::question(this, tr("Remove Account Settings"),
177                                   tr("Do you really want to remove your local settings for this Quassel Core account?<br>"
178                                   "Note: This will <em>not</em> remove or change any data on the Core itself!"),
179                                   QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
180   if(ret == QMessageBox::Yes) {
181     int idx = ui.accountList->currentRow();
182     delete ui.accountList->takeItem(idx);
183     ui.accountList->setCurrentRow(qMin(idx, ui.accountList->count()-1));
184     accounts[id]["Delete"] = true;  // we only flag this here, actual deletion happens on accept!
185     setAccountWidgetStates();
186   }
187 }
188
189 void CoreConnectDlg::on_accountList_itemDoubleClicked(QListWidgetItem *item) {
190   Q_UNUSED(item);
191   on_accountButtonBox_accepted();
192 }
193
194 void CoreConnectDlg::on_accountButtonBox_accepted() {
195   // save accounts
196   CoreAccountSettings s;
197   foreach(QVariantMap acct, accounts.values()) {
198     AccountId id = acct["AccountId"].value<AccountId>();
199     if(acct.contains("Delete")) {
200       s.removeAccount(id);
201     } else {
202       s.storeAccountData(id, acct);
203     }
204   }
205   s.setAutoConnectAccount(autoConnectAccount);
206
207   ui.stackedWidget->setCurrentWidget(ui.loginPage);
208   account = ui.accountList->currentItem()->data(Qt::UserRole).value<AccountId>();
209   accountData = accounts[account];
210   s.setLastAccount(account);
211   connectToCore();
212 }
213
214 void CoreConnectDlg::on_useInternalCore_clicked() {
215   clientSyncer->useInternalCore();
216   startSync();
217 }
218
219 /*****************************************************
220  * Connecting to the Core
221  ****************************************************/
222
223 /*** Phase One: initializing the core connection ***/
224
225 void CoreConnectDlg::connectToCore() {
226   ui.secureConnection->hide();
227   ui.connectIcon->setPixmap(BarIcon("network-disconnect"));
228   ui.connectLabel->setText(tr("Connect to %1").arg(accountData["Host"].toString()));
229   ui.coreInfoLabel->setText("");
230   ui.loginStack->setCurrentWidget(ui.loginEmptyPage);
231   ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
232   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);
233   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
234   disconnect(ui.loginButtonBox, 0, this, 0);
235   connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull()));
236
237   clientSyncer->connectToCore(accountData);
238 }
239
240 void CoreConnectDlg::initPhaseError(const QString &error) {
241   doingAutoConnect = false;
242   ui.secureConnection->hide();
243   ui.connectIcon->setPixmap(BarIcon("dialog-error"));
244   //ui.connectLabel->setBrush(QBrush("red"));
245   ui.connectLabel->setText(tr("<div style=color:red;>Connection to %1 failed!</div>").arg(accountData["Host"].toString()));
246   ui.coreInfoLabel->setText(error);
247   ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Retry|QDialogButtonBox::Cancel);
248   ui.loginButtonBox->button(QDialogButtonBox::Retry)->setFocus();
249   disconnect(ui.loginButtonBox, 0, this, 0);
250   connect(ui.loginButtonBox, SIGNAL(accepted()), this, SLOT(restartPhaseNull()));
251   connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
252 }
253
254 void CoreConnectDlg::initPhaseMsg(const QString &msg) {
255   ui.coreInfoLabel->setText(msg);
256 }
257
258 void CoreConnectDlg::encrypted(bool useSsl) {
259   if(useSsl)
260     ui.secureConnection->show();
261   else
262     ui.secureConnection->hide();
263 }
264
265 void CoreConnectDlg::initPhaseSocketState(QAbstractSocket::SocketState state) {
266   QString s;
267   QString host = accountData["Host"].toString();
268   switch(state) {
269     case QAbstractSocket::UnconnectedState: s = tr("Not connected to %1.").arg(host); break;
270     case QAbstractSocket::HostLookupState: s = tr("Looking up %1...").arg(host); break;
271     case QAbstractSocket::ConnectingState: s = tr("Connecting to %1...").arg(host); break;
272     case QAbstractSocket::ConnectedState: s = tr("Connected to %1").arg(host); break;
273     default: s = tr("Unknown connection state to %1"); break;
274   }
275   ui.connectLabel->setText(s);
276 }
277
278 void CoreConnectDlg::restartPhaseNull() {
279   doingAutoConnect = false;
280   ui.stackedWidget->setCurrentWidget(ui.accountPage);
281   clientSyncer->disconnectFromCore();
282 }
283
284 /*********************************************************
285  * Phase Two: Login
286  *********************************************************/
287
288 void CoreConnectDlg::startLogin() {
289   ui.connectIcon->setPixmap(BarIcon("network-connect"));
290   ui.loginStack->setCurrentWidget(ui.loginCredentialsPage);
291   //ui.loginStack->setMinimumSize(ui.loginStack->sizeHint()); ui.loginStack->updateGeometry();
292   ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
293   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);
294   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setFocus();
295   if(!accountData["User"].toString().isEmpty()) {
296     ui.user->setText(accountData["User"].toString());
297     if(accountData["RememberPasswd"].toBool()) {
298       ui.password->setText(accountData["Password"].toString());
299       ui.rememberPasswd->setChecked(true);
300       ui.loginButtonBox->button(QDialogButtonBox::Ok)->setFocus();
301     } else {
302       ui.rememberPasswd->setChecked(false);
303       ui.password->setFocus();
304     }
305   } else ui.user->setFocus();
306   disconnect(ui.loginButtonBox, 0, this, 0);
307   connect(ui.loginButtonBox, SIGNAL(accepted()), this, SLOT(doLogin()));
308   connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull()));
309   if(doingAutoConnect) doLogin();
310 }
311
312 void CoreConnectDlg::doLogin() {
313   QVariantMap loginData;
314   loginData["User"] = ui.user->text();
315   loginData["Password"] = ui.password->text();
316   loginData["RememberPasswd"] = ui.rememberPasswd->isChecked();
317   doLogin(loginData);
318 }
319
320 void CoreConnectDlg::doLogin(const QVariantMap &loginData) {
321   disconnect(ui.loginButtonBox, 0, this, 0);
322   connect(ui.loginButtonBox, SIGNAL(accepted()), this, SLOT(doLogin()));
323   connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull()));
324   ui.loginStack->setCurrentWidget(ui.loginCredentialsPage);
325   ui.loginGroup->setTitle(tr("Logging in..."));
326   ui.user->setDisabled(true);
327   ui.password->setDisabled(true);
328   ui.rememberPasswd->setDisabled(true);
329   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
330   accountData["User"] = loginData["User"];
331   accountData["RememberPasswd"] = loginData["RememberPasswd"];
332   if(loginData["RememberPasswd"].toBool()) accountData["Password"] = loginData["Password"];
333   else accountData.remove("Password");
334   ui.user->setText(loginData["User"].toString());
335   ui.password->setText(loginData["Password"].toString());
336   ui.rememberPasswd->setChecked(loginData["RememberPasswd"].toBool());
337   CoreAccountSettings s;
338   s.storeAccountData(account, accountData);
339   clientSyncer->loginToCore(loginData["User"].toString(), loginData["Password"].toString());
340 }
341
342 void CoreConnectDlg::setLoginWidgetStates() {
343   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDisabled(ui.user->text().isEmpty() || ui.password->text().isEmpty());
344 }
345
346 void CoreConnectDlg::loginFailed(const QString &error) {
347   if(wizard) {
348     wizard->reject();
349   }
350   ui.connectIcon->setPixmap(BarIcon("dialog-error"));
351   ui.loginStack->setCurrentWidget(ui.loginCredentialsPage);
352   ui.loginGroup->setTitle(tr("Login"));
353   ui.user->setEnabled(true);
354   ui.password->setEnabled(true);
355   ui.rememberPasswd->setEnabled(true);
356   ui.coreInfoLabel->setText(error);
357   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
358   ui.password->setFocus();
359   doingAutoConnect = false;
360 }
361
362 void CoreConnectDlg::startCoreConfig(const QVariantList &backends) {
363   storageBackends = backends;
364   ui.loginStack->setCurrentWidget(ui.coreConfigPage);
365
366   //on_launchCoreConfigWizard_clicked();
367
368 }
369
370 void CoreConnectDlg::on_launchCoreConfigWizard_clicked() {
371   Q_ASSERT(!wizard);
372   wizard = new CoreConfigWizard(storageBackends, this);
373   connect(wizard, SIGNAL(setupCore(const QVariant &)), clientSyncer, SLOT(doCoreSetup(const QVariant &)));
374   connect(wizard, SIGNAL(loginToCore(const QVariantMap &)), this, SLOT(doLogin(const QVariantMap &)));
375   connect(clientSyncer, SIGNAL(coreSetupSuccess()), wizard, SLOT(coreSetupSuccess()));
376   connect(clientSyncer, SIGNAL(coreSetupFailed(const QString &)), wizard, SLOT(coreSetupFailed(const QString &)));
377   connect(wizard, SIGNAL(accepted()), this, SLOT(configWizardAccepted()));
378   connect(wizard, SIGNAL(rejected()), this, SLOT(configWizardRejected()));
379   connect(clientSyncer, SIGNAL(loginSuccess()), wizard, SLOT(loginSuccess()));
380   connect(clientSyncer, SIGNAL(syncFinished()), wizard, SLOT(syncFinished()));
381   wizard->show();
382 }
383
384 void CoreConnectDlg::configWizardAccepted() {
385
386   wizard->deleteLater();
387   wizard = 0;
388 }
389
390 void CoreConnectDlg::configWizardRejected() {
391
392   wizard->deleteLater();
393   wizard = 0;
394   //exit(1); // FIXME
395 }
396
397
398 /************************************************************
399  * Phase Three: Syncing
400  ************************************************************/
401
402 void CoreConnectDlg::startSync() {
403   ui.sessionProgress->setRange(0, 1);
404   ui.sessionProgress->setValue(0);
405   ui.networksProgress->setRange(0, 1);
406   ui.networksProgress->setValue(0);
407
408   ui.stackedWidget->setCurrentWidget(ui.syncPage);
409   // clean up old page
410   ui.loginGroup->setTitle(tr("Login"));
411   ui.user->setEnabled(true);
412   ui.password->setEnabled(true);
413   ui.rememberPasswd->setEnabled(true);
414   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
415 }
416
417 void CoreConnectDlg::coreSessionProgress(quint32 val, quint32 max) {
418   ui.sessionProgress->setRange(0, max);
419   ui.sessionProgress->setValue(val);
420
421 }
422
423 void CoreConnectDlg::coreNetworksProgress(quint32 val, quint32 max) {
424   if(max == 0) {
425     ui.networksProgress->setFormat("0/0");
426     ui.networksProgress->setRange(0, 1);
427     ui.networksProgress->setValue(1);
428   } else {
429     ui.networksProgress->setFormat("%v/%m");
430     ui.networksProgress->setRange(0, max);
431     ui.networksProgress->setValue(val);
432   }
433 }
434
435 void CoreConnectDlg::syncFinished() {
436   if(!wizard) accept();
437   else {
438     hide();
439     disconnect(wizard, 0, this, 0);
440     connect(wizard, SIGNAL(finished(int)), this, SLOT(accept()));
441   }
442 }
443
444 /*****************************************************************************************
445  * CoreAccountEditDlg
446  *****************************************************************************************/
447 CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, const QStringList &_existing, QWidget *parent)
448   : QDialog(parent)
449 {
450   ui.setupUi(this);
451   ui.useSsl->setIcon(SmallIcon("document-encrypt"));
452
453   existing = _existing;
454   if(id.isValid()) {
455     existing.removeAll(acct["AccountName"].toString());
456     ui.host->setText(acct["Host"].toString());
457     ui.port->setValue(acct["Port"].toUInt());
458     ui.useInternal->setChecked(acct["UseInternal"].toBool());
459     ui.accountName->setText(acct["AccountName"].toString());
460 #ifdef HAVE_SSL
461     ui.useSsl->setChecked(acct["useSsl"].toBool());
462 #else
463     ui.useSsl->setChecked(false);
464     ui.useSsl->setEnabled(false);
465 #endif
466     ui.useProxy->setChecked(acct["useProxy"].toBool());
467     ui.proxyHost->setText(acct["proxyHost"].toString());
468     ui.proxyPort->setValue(acct["proxyPort"].toUInt());
469     ui.proxyType->setCurrentIndex(acct["proxyType"].toInt() == QNetworkProxy::Socks5Proxy ? 0 : 1);
470     ui.proxyUser->setText(acct["proxyUser"].toString());
471     ui.proxyPassword->setText(acct["proxyPassword"].toString());
472   } else {
473     setWindowTitle(tr("Add Core Account"));
474 #ifndef HAVE_SSL
475     ui.useSsl->setChecked(false);
476     ui.useSsl->setEnabled(false);
477 #endif
478   }
479
480 #ifndef BUILD_MONO
481   // 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
482   ui.useInternal->setChecked(false);
483   ui.useInternal->hide();
484   ui.useRemote->hide();
485   ui.labelUseBuiltinCore->hide();
486 #endif
487 }
488
489 QVariantMap CoreAccountEditDlg::accountData() {
490   account["AccountName"] = ui.accountName->text().trimmed();
491   account["Host"] = ui.host->text().trimmed();
492   account["Port"] = ui.port->value();
493   account["UseInternal"] = ui.useInternal->isChecked();
494   account["useSsl"] = ui.useSsl->isChecked();
495   account["useProxy"] = ui.useProxy->isChecked();
496   account["proxyHost"] = ui.proxyHost->text().trimmed();
497   account["proxyPort"] = ui.proxyPort->value();
498   account["proxyType"] = ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy;
499   account["proxyUser"] = ui.proxyUser->text().trimmed();
500   account["proxyPassword"] = ui.proxyPassword->text().trimmed();
501   return account;
502 }
503
504 void CoreAccountEditDlg::setWidgetStates() {
505   bool ok = !ui.accountName->text().trimmed().isEmpty() && !existing.contains(ui.accountName->text()) && (ui.useInternal->isChecked() || !ui.host->text().isEmpty());
506   ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
507 }
508
509 void CoreAccountEditDlg::on_host_textChanged(const QString &text) {
510   Q_UNUSED(text);
511   setWidgetStates();
512 }
513
514 void CoreAccountEditDlg::on_accountName_textChanged(const QString &text) {
515   Q_UNUSED(text);
516   setWidgetStates();
517 }
518
519 void CoreAccountEditDlg::on_useRemote_toggled(bool state) {
520   Q_UNUSED(state);
521   setWidgetStates();
522 }