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