added checkbox to disable password storage

This commit is contained in:
Max-Wilhelm Bruker 2012-03-03 15:54:50 +01:00
parent a27bc20887
commit 2487476fcc
2 changed files with 9 additions and 1 deletions

View file

@ -1,6 +1,7 @@
#include <QSettings>
#include <QLabel>
#include <QPushButton>
#include <QCheckBox>
#include <QGridLayout>
#include <QHBoxLayout>
#include "dlg_connect.h"
@ -28,6 +29,9 @@ DlgConnect::DlgConnect(QWidget *parent)
passwordLabel->setBuddy(passwordEdit);
passwordEdit->setEchoMode(QLineEdit::Password);
savePasswordCheckBox = new QCheckBox(tr("&Save password"));
savePasswordCheckBox->setChecked(settings.value("save_password", 1).toInt());
okButton = new QPushButton(tr("&OK"));
okButton->setDefault(true);
cancelButton = new QPushButton(tr("&Cancel"));
@ -41,6 +45,7 @@ DlgConnect::DlgConnect(QWidget *parent)
grid->addWidget(playernameEdit, 2, 1);
grid->addWidget(passwordLabel, 3, 0);
grid->addWidget(passwordEdit, 3, 1);
grid->addWidget(savePasswordCheckBox, 4, 0, 1, 2);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch();
@ -67,7 +72,8 @@ void DlgConnect::actOk()
settings.setValue("hostname", hostEdit->text());
settings.setValue("port", portEdit->text());
settings.setValue("playername", playernameEdit->text());
settings.setValue("password", passwordEdit->text());
settings.setValue("password", savePasswordCheckBox->isChecked() ? passwordEdit->text() : QString());
settings.setValue("save_password", savePasswordCheckBox->isChecked() ? 1 : 0);
settings.endGroup();
accept();

View file

@ -6,6 +6,7 @@
class QLabel;
class QPushButton;
class QCheckBox;
class DlgConnect : public QDialog {
Q_OBJECT
@ -20,6 +21,7 @@ private slots:
private:
QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel;
QLineEdit *hostEdit, *portEdit, *playernameEdit, *passwordEdit;
QCheckBox *savePasswordCheckBox;
QPushButton *okButton, *cancelButton;
};