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