Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
coreconnectdlg.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 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  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include <QDialogButtonBox>
22 #include <QIcon>
23 #include <QVBoxLayout>
24 
25 #include "coreconnectdlg.h"
26 
27 #include "clientsettings.h"
29 
30 CoreConnectDlg::CoreConnectDlg(QWidget *parent) : QDialog(parent)
31 {
35 
37  AccountId lastAccount = s.lastAccount();
38  if (lastAccount.isValid())
39  _settingsPage->setSelectedAccount(lastAccount);
40 
41  setWindowTitle(tr("Connect to Core"));
42  setWindowIcon(QIcon::fromTheme("network-disconnect"));
43 
44  QVBoxLayout *layout = new QVBoxLayout(this);
45  layout->addWidget(_settingsPage);
46 
47  QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
48  buttonBox->setStandardButtons(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
49  layout->addWidget(buttonBox);
50 
51  connect(_settingsPage, SIGNAL(connectToCore(AccountId)), SLOT(accept()));
52  connect(buttonBox, SIGNAL(accepted()), SLOT(accept()));
53  connect(buttonBox, SIGNAL(rejected()), SLOT(reject()));
54 }
55 
56 
58 {
60 }
61 
62 
64 {
67 }
68 
69 
70 /******** CoreConnectAuthDlg ****************************************************************/
71 
73  : QDialog(parent),
74  _account(account)
75 {
76  ui.setupUi(this);
77 
78  connect(ui.user, SIGNAL(textChanged(QString)), SLOT(setButtonStates()));
79  connect(ui.password, SIGNAL(textChanged(QString)), SLOT(setButtonStates()));
80 
81  ui.label->setText(tr("Please enter your credentials for %1:").arg(account->accountName()));
82  ui.user->setText(account->user());
83  ui.password->setText(account->password());
84  ui.rememberPasswd->setChecked(account->storePassword());
85 
86  if (ui.user->text().isEmpty())
87  ui.user->setFocus();
88  else
89  ui.password->setFocus();
90 }
91 
92 
94 {
95  _account->setUser(ui.user->text());
96  _account->setPassword(ui.password->text());
97  _account->setStorePassword(ui.rememberPasswd->isChecked());
98 
100 }
101 
102 
104 {
105  bool valid = !(ui.user->text().isEmpty() || ui.password->text().isEmpty());
106  ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
107 }