fixing a typo in an include and properly making qwebkit optional
[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 /*****************************************************
215  * Connecting to the Core
216  ****************************************************/
217
218 /*** Phase One: initializing the core connection ***/
219
220 void CoreConnectDlg::connectToCore() {
221   ui.secureConnection->hide();
222   ui.connectIcon->setPixmap(BarIcon("network-disconnect"));
223   ui.connectLabel->setText(tr("Connect to %1").arg(accountData["Host"].toString()));
224   ui.coreInfoLabel->setText("");
225   ui.loginStack->setCurrentWidget(ui.loginEmptyPage);
226   ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
227   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);
228   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
229   disconnect(ui.loginButtonBox, 0, this, 0);
230   connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull()));
231
232   clientSyncer->connectToCore(accountData);
233 }
234
235 void CoreConnectDlg::initPhaseError(const QString &error) {
236   doingAutoConnect = false;
237   ui.secureConnection->hide();
238   ui.connectIcon->setPixmap(BarIcon("dialog-error"));
239   //ui.connectLabel->setBrush(QBrush("red"));
240   ui.connectLabel->setText(tr("<div style=color:red;>Connection to %1 failed!</div>").arg(accountData["Host"].toString()));
241   ui.coreInfoLabel->setText(error);
242   ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Retry|QDialogButtonBox::Cancel);
243   ui.loginButtonBox->button(QDialogButtonBox::Retry)->setFocus();
244   disconnect(ui.loginButtonBox, 0, this, 0);
245   connect(ui.loginButtonBox, SIGNAL(accepted()), this, SLOT(restartPhaseNull()));
246   connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
247 }
248
249 void CoreConnectDlg::initPhaseMsg(const QString &msg) {
250   ui.coreInfoLabel->setText(msg);
251 }
252
253 void CoreConnectDlg::encrypted(bool useSsl) {
254   if(useSsl)
255     ui.secureConnection->show();
256   else
257     ui.secureConnection->hide();
258 }
259
260 void CoreConnectDlg::initPhaseSocketState(QAbstractSocket::SocketState state) {
261   QString s;
262   QString host = accountData["Host"].toString();
263   switch(state) {
264     case QAbstractSocket::UnconnectedState: s = tr("Not connected to %1.").arg(host); break;
265     case QAbstractSocket::HostLookupState: s = tr("Looking up %1...").arg(host); break;
266     case QAbstractSocket::ConnectingState: s = tr("Connecting to %1...").arg(host); break;
267     case QAbstractSocket::ConnectedState: s = tr("Connected to %1").arg(host); break;
268     default: s = tr("Unknown connection state to %1"); break;
269   }
270   ui.connectLabel->setText(s);
271 }
272
273 void CoreConnectDlg::restartPhaseNull() {
274   doingAutoConnect = false;
275   ui.stackedWidget->setCurrentWidget(ui.accountPage);
276   clientSyncer->disconnectFromCore();
277 }
278
279 /*********************************************************
280  * Phase Two: Login
281  *********************************************************/
282
283 void CoreConnectDlg::startLogin() {
284   ui.connectIcon->setPixmap(BarIcon("network-connect"));
285   ui.loginStack->setCurrentWidget(ui.loginCredentialsPage);
286   //ui.loginStack->setMinimumSize(ui.loginStack->sizeHint()); ui.loginStack->updateGeometry();
287   ui.loginButtonBox->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
288   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDefault(true);
289   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setFocus();
290   if(!accountData["User"].toString().isEmpty()) {
291     ui.user->setText(accountData["User"].toString());
292     if(accountData["RememberPasswd"].toBool()) {
293       ui.password->setText(accountData["Password"].toString());
294       ui.rememberPasswd->setChecked(true);
295       ui.loginButtonBox->button(QDialogButtonBox::Ok)->setFocus();
296     } else {
297       ui.rememberPasswd->setChecked(false);
298       ui.password->setFocus();
299     }
300   } else ui.user->setFocus();
301   disconnect(ui.loginButtonBox, 0, this, 0);
302   connect(ui.loginButtonBox, SIGNAL(accepted()), this, SLOT(doLogin()));
303   connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull()));
304   if(doingAutoConnect) doLogin();
305 }
306
307 void CoreConnectDlg::doLogin() {
308   QVariantMap loginData;
309   loginData["User"] = ui.user->text();
310   loginData["Password"] = ui.password->text();
311   loginData["RememberPasswd"] = ui.rememberPasswd->isChecked();
312   doLogin(loginData);
313 }
314
315 void CoreConnectDlg::doLogin(const QVariantMap &loginData) {
316   disconnect(ui.loginButtonBox, 0, this, 0);
317   connect(ui.loginButtonBox, SIGNAL(accepted()), this, SLOT(doLogin()));
318   connect(ui.loginButtonBox, SIGNAL(rejected()), this, SLOT(restartPhaseNull()));
319   ui.loginStack->setCurrentWidget(ui.loginCredentialsPage);
320   ui.loginGroup->setTitle(tr("Logging in..."));
321   ui.user->setDisabled(true);
322   ui.password->setDisabled(true);
323   ui.rememberPasswd->setDisabled(true);
324   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDisabled(true);
325   accountData["User"] = loginData["User"];
326   accountData["RememberPasswd"] = loginData["RememberPasswd"];
327   if(loginData["RememberPasswd"].toBool()) accountData["Password"] = loginData["Password"];
328   else accountData.remove("Password");
329   ui.user->setText(loginData["User"].toString());
330   ui.password->setText(loginData["Password"].toString());
331   ui.rememberPasswd->setChecked(loginData["RememberPasswd"].toBool());
332   CoreAccountSettings s;
333   s.storeAccountData(account, accountData);
334   clientSyncer->loginToCore(loginData["User"].toString(), loginData["Password"].toString());
335 }
336
337 void CoreConnectDlg::setLoginWidgetStates() {
338   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setDisabled(ui.user->text().isEmpty() || ui.password->text().isEmpty());
339 }
340
341 void CoreConnectDlg::loginFailed(const QString &error) {
342   if(wizard) {
343     wizard->reject();
344   }
345   ui.connectIcon->setPixmap(BarIcon("dialog-error"));
346   ui.loginStack->setCurrentWidget(ui.loginCredentialsPage);
347   ui.loginGroup->setTitle(tr("Login"));
348   ui.user->setEnabled(true);
349   ui.password->setEnabled(true);
350   ui.rememberPasswd->setEnabled(true);
351   ui.coreInfoLabel->setText(error);
352   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
353   ui.password->setFocus();
354   doingAutoConnect = false;
355 }
356
357 void CoreConnectDlg::startCoreConfig(const QVariantList &backends) {
358   storageBackends = backends;
359   ui.loginStack->setCurrentWidget(ui.coreConfigPage);
360
361   //on_launchCoreConfigWizard_clicked();
362
363 }
364
365 void CoreConnectDlg::on_launchCoreConfigWizard_clicked() {
366   Q_ASSERT(!wizard);
367   wizard = new CoreConfigWizard(storageBackends, this);
368   connect(wizard, SIGNAL(setupCore(const QVariant &)), clientSyncer, SLOT(doCoreSetup(const QVariant &)));
369   connect(wizard, SIGNAL(loginToCore(const QVariantMap &)), this, SLOT(doLogin(const QVariantMap &)));
370   connect(clientSyncer, SIGNAL(coreSetupSuccess()), wizard, SLOT(coreSetupSuccess()));
371   connect(clientSyncer, SIGNAL(coreSetupFailed(const QString &)), wizard, SLOT(coreSetupFailed(const QString &)));
372   connect(wizard, SIGNAL(accepted()), this, SLOT(configWizardAccepted()));
373   connect(wizard, SIGNAL(rejected()), this, SLOT(configWizardRejected()));
374   connect(clientSyncer, SIGNAL(loginSuccess()), wizard, SLOT(loginSuccess()));
375   connect(clientSyncer, SIGNAL(syncFinished()), wizard, SLOT(syncFinished()));
376   wizard->show();
377 }
378
379 void CoreConnectDlg::configWizardAccepted() {
380
381   wizard->deleteLater();
382   wizard = 0;
383 }
384
385 void CoreConnectDlg::configWizardRejected() {
386
387   wizard->deleteLater();
388   wizard = 0;
389   //exit(1); // FIXME
390 }
391
392
393 /************************************************************
394  * Phase Three: Syncing
395  ************************************************************/
396
397 void CoreConnectDlg::startSync() {
398   ui.sessionProgress->setRange(0, 1);
399   ui.sessionProgress->setValue(0);
400   ui.networksProgress->setRange(0, 1);
401   ui.networksProgress->setValue(0);
402
403   ui.stackedWidget->setCurrentWidget(ui.syncPage);
404   // clean up old page
405   ui.loginGroup->setTitle(tr("Login"));
406   ui.user->setEnabled(true);
407   ui.password->setEnabled(true);
408   ui.rememberPasswd->setEnabled(true);
409   ui.loginButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
410 }
411
412 void CoreConnectDlg::coreSessionProgress(quint32 val, quint32 max) {
413   ui.sessionProgress->setRange(0, max);
414   ui.sessionProgress->setValue(val);
415
416 }
417
418 void CoreConnectDlg::coreNetworksProgress(quint32 val, quint32 max) {
419   if(max == 0) {
420     ui.networksProgress->setFormat("0/0");
421     ui.networksProgress->setRange(0, 1);
422     ui.networksProgress->setValue(1);
423   } else {
424     ui.networksProgress->setFormat("%v/%m");
425     ui.networksProgress->setRange(0, max);
426     ui.networksProgress->setValue(val);
427   }
428 }
429
430 void CoreConnectDlg::syncFinished() {
431   if(!wizard) accept();
432   else {
433     hide();
434     disconnect(wizard, 0, this, 0);
435     connect(wizard, SIGNAL(finished(int)), this, SLOT(accept()));
436   }
437 }
438
439 /*****************************************************************************************
440  * CoreAccountEditDlg
441  *****************************************************************************************/
442 CoreAccountEditDlg::CoreAccountEditDlg(AccountId id, const QVariantMap &acct, const QStringList &_existing, QWidget *parent)
443   : QDialog(parent)
444 {
445   ui.setupUi(this);
446   ui.useSsl->setIcon(SmallIcon("document-encrypt"));
447
448   existing = _existing;
449   if(id.isValid()) {
450     existing.removeAll(acct["AccountName"].toString());
451     ui.host->setText(acct["Host"].toString());
452     ui.port->setValue(acct["Port"].toUInt());
453     ui.useInternal->setChecked(acct["UseInternal"].toBool());
454     ui.accountName->setText(acct["AccountName"].toString());
455 #ifdef HAVE_SSL
456     ui.useSsl->setChecked(acct["useSsl"].toBool());
457 #else
458     ui.useSsl->setChecked(false);
459     ui.useSsl->setEnabled(false);
460 #endif
461     ui.useProxy->setChecked(acct["useProxy"].toBool());
462     ui.proxyHost->setText(acct["proxyHost"].toString());
463     ui.proxyPort->setValue(acct["proxyPort"].toUInt());
464     ui.proxyType->setCurrentIndex(acct["proxyType"].toInt() == QNetworkProxy::Socks5Proxy ? 0 : 1);
465     ui.proxyUser->setText(acct["proxyUser"].toString());
466     ui.proxyPassword->setText(acct["proxyPassword"].toString());
467   } else {
468     setWindowTitle(tr("Add Core Account"));
469 #ifndef HAVE_SSL
470     ui.useSsl->setChecked(false);
471     ui.useSsl->setEnabled(false);
472 #endif
473   }
474
475 #ifndef BUILD_MONO
476   // 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
477   ui.useInternal->setChecked(false);
478   ui.useInternal->hide();
479   ui.useRemote->hide();
480   ui.labelUseBuiltinCore->hide();
481 #endif
482 }
483
484 QVariantMap CoreAccountEditDlg::accountData() {
485   account["AccountName"] = ui.accountName->text().trimmed();
486   account["Host"] = ui.host->text().trimmed();
487   account["Port"] = ui.port->value();
488   account["UseInternal"] = ui.useInternal->isChecked();
489   account["useSsl"] = ui.useSsl->isChecked();
490   account["useProxy"] = ui.useProxy->isChecked();
491   account["proxyHost"] = ui.proxyHost->text().trimmed();
492   account["proxyPort"] = ui.proxyPort->value();
493   account["proxyType"] = ui.proxyType->currentIndex() == 0 ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy;
494   account["proxyUser"] = ui.proxyUser->text().trimmed();
495   account["proxyPassword"] = ui.proxyPassword->text().trimmed();
496   return account;
497 }
498
499 void CoreAccountEditDlg::setWidgetStates() {
500   bool ok = !ui.accountName->text().trimmed().isEmpty() && !existing.contains(ui.accountName->text()) && (ui.useInternal->isChecked() || !ui.host->text().isEmpty());
501   ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ok);
502 }
503
504 void CoreAccountEditDlg::on_host_textChanged(const QString &text) {
505   Q_UNUSED(text);
506   setWidgetStates();
507 }
508
509 void CoreAccountEditDlg::on_accountName_textChanged(const QString &text) {
510   Q_UNUSED(text);
511   setWidgetStates();
512 }
513
514 void CoreAccountEditDlg::on_useRemote_toggled(bool state) {
515   Q_UNUSED(state);
516   setWidgetStates();
517 }