23 #include "passworddlg.h" 25 #include "ui_passworddlg.h" 27 #include "configuration/passwordscfg.h" 28 #include "configuration/serverpassword.h" 29 #include "gui/helpers/comboboxex.h" 30 #include "serverapi/server.h" 34 DClass<PasswordDlg> :
public Ui::PasswordDlg
48 d->cboConnectPassEx =
new ComboBoxEx(*d->cboConnectPassword);
49 d->cboIngamePassEx =
new ComboBoxEx(*d->cboIngamePassword);
52 applyInputsVisibility();
56 setMinimumHeight(height());
57 setMaximumHeight(height());
62 PasswordDlg::~PasswordDlg()
64 delete d->cboConnectPassEx;
67 void PasswordDlg::accept()
73 void PasswordDlg::applyInputsVisibility()
75 d->connectPasswordWidget->setVisible(d->server->isLocked());
76 d->ingamePasswordWidget->setVisible(d->server->isLockedInGame());
79 QString PasswordDlg::connectPassword()
const 81 return d->cboConnectPassword->currentText();
84 QString PasswordDlg::inGamePassword()
const 86 return d->cboIngamePassword->currentText();
89 void PasswordDlg::loadConfiguration()
92 if (cfg.isHidingPasswords())
94 d->cboConnectPassword->lineEdit()->setEchoMode(QLineEdit::Password);
95 d->cboIngamePassword->lineEdit()->setEchoMode(QLineEdit::Password);
97 d->remember->setChecked(cfg.isRememberingConnectPhrase());
98 setPasswords(cfg.serverPhrases());
100 d->server.data(), ServerPasswordType::CONNECT).phrase());
102 d->server.data(), ServerPasswordType::INGAME).phrase());
105 void PasswordDlg::removeCurrentConnectPassword()
108 QString phrase = d->cboConnectPassword->currentText();
109 cfg.removeServerPhrase(d->cboConnectPassword->currentText());
111 d->cboIngamePassEx->removeItem(phrase);
112 if (!d->cboConnectPassEx->removeCurrentItem())
114 d->cboConnectPassword->clearEditText();
115 d->cboConnectPassword->setFocus();
119 void PasswordDlg::removeCurrentIngamePassword()
122 QString phrase = d->cboIngamePassword->currentText();
123 cfg.removeServerPhrase(d->cboIngamePassword->currentText());
125 d->cboConnectPassEx->removeItem(phrase);
126 if (!d->cboIngamePassEx->removeCurrentItem())
128 d->cboIngamePassword->clearEditText();
129 d->cboIngamePassword->setFocus();
133 void PasswordDlg::saveConfiguration()
136 cfg.setRememberConnectPhrase(d->remember->isChecked());
137 if (d->remember->isChecked())
139 cfg.
saveServerPhrase(connectPassword(), d->server.data(), ServerPasswordType::CONNECT);
140 cfg.
saveServerPhrase(inGamePassword(), d->server.data(), ServerPasswordType::INGAME);
144 void PasswordDlg::setCurrentConnectPassword(
const QString &password)
146 d->cboConnectPassEx->setCurrentOrAddNewAndSelect(password);
149 void PasswordDlg::setCurrentIngamePassword(
const QString &password)
151 d->cboIngamePassEx->setCurrentOrAddNewAndSelect(password);
154 void PasswordDlg::setPasswords(
const QStringList &passwords)
156 d->cboConnectPassEx->setItemsSorted(passwords);
157 d->cboIngamePassEx->setItemsSorted(passwords);
Convenience methods for combo box.
void saveServerPhrase(const QString &phrase, const Server *server, const QString &type)
Stores server phrase in persistence along its use case.
ServerPassword suggestPassword(const Server *server, const QString &type)
Suggests best password basing on several criteria.