X-Git-Url: https://vaikene.ee/gitweb/pswgen09.html?a=blobdiff_plain;f=src%2Fapps%2FPswGen%2FGUI%2Fgui.cpp;h=9ab2645b9bb745b5aa61ab95bbb0a5a8beecb64c;hb=38c2779e95311f1d9dac4a9d9469b0489b395333;hp=1ced109fa27cb869ec691d7568d3c0378dd8cb79;hpb=388264abc0442ea0e4c6dca6812cb755053c79d5;p=evaf
diff --git a/src/apps/PswGen/GUI/gui.cpp b/src/apps/PswGen/GUI/gui.cpp
index 1ced109..9ab2645 100644
--- a/src/apps/PswGen/GUI/gui.cpp
+++ b/src/apps/PswGen/GUI/gui.cpp
@@ -3,7 +3,7 @@
* @brief GUI for the PswGen application
* @author Enar Vaikene
*
- * Copyright (c) 2011 Enar Vaikene
+ * Copyright (c) 2011-2012 Enar Vaikene
*
* This file is part of the eVaf C++ cross-platform application development framework.
*
@@ -111,24 +111,35 @@ bool Module::init(QString const & args)
g->addWidget(wName, 1, 1, 1, 2);
panel->setFocusProxy(wName);
- l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR));
+ l = new QLabel(tr("&Suffix:", VER_MODULE_NAME_STR));
l->setAlignment(Qt::AlignRight);
g->addWidget(l, 2, 0);
+ wSuffix = new QLineEdit;
+ l->setBuddy(wSuffix);
+ g->addWidget(wSuffix, 2, 1, 1, 2);
+
+ l = new QLabel(tr("&Length of the password:", VER_MODULE_NAME_STR));
+ l->setAlignment(Qt::AlignRight);
+ g->addWidget(l, 3, 0);
+
wLength = new QSpinBox;
l->setBuddy(wLength);
wLength->setRange(0, mGenerator->maxLength());
wLength->setValue(DefaultPasswordLength);
wLength->setSpecialValueText(tr("Maximum", VER_MODULE_NAME_STR));
- g->addWidget(wLength, 2, 1);
+ g->addWidget(wLength, 3, 1);
+
+ wAlNum = new QCheckBox(tr("&Alpha-Numeric only", VER_MODULE_NAME_STR));
+ g->addWidget(wAlNum, 3, 2);
l = new QLabel(tr("Password:"));
l->setAlignment(Qt::AlignRight);
- g->addWidget(l, 3, 0);
+ g->addWidget(l, 4, 0);
wPassword = new QLineEdit;
wPassword->setReadOnly(true);
- g->addWidget(wPassword, 3, 1, 1, 2);
+ g->addWidget(wPassword, 4, 1, 1, 2);
v->addStretch();
@@ -176,8 +187,11 @@ void Module::textChanged(QString const &)
wGenerate->setDisabled(wMasterPassword->text().isEmpty() || wName->text().isEmpty());
if (!wName->text().isEmpty() && mStorage) {
QExplicitlySharedDataPointer data = mStorage->query(wName->text());
- if (data)
+ if (data) {
wLength->setValue(data->length());
+ wSuffix->setText(data->suffix());
+ wAlNum->setChecked(data->flags() & uint(iGenerator::ALPHANUMERIC));
+ }
}
}
@@ -185,14 +199,27 @@ void Module::generateClicked()
{
if (wMasterPassword->text().isEmpty() || wName->text().isEmpty())
return;
- wPassword->setText(mGenerator->generatePassword(wName->text(), wMasterPassword->text(), wLength->value()));
+ uint flags = 0;
+ if (wAlNum->isChecked())
+ flags |= iGenerator::ALPHANUMERIC;
+ wPassword->setText(mGenerator->generatePassword(wName->text() + wSuffix->text(),
+ wMasterPassword->text(),
+ wLength->value(),
+ flags));
wCopy->setEnabled(true);
if (mStorage) {
QExplicitlySharedDataPointer data = mStorage->query(wName->text());
- if (!data)
- data = new Storage::Data(wName->text(), wLength->value());
- else
+ if (!data) {
+ data = new Storage::Data(wName->text(), wSuffix->text(), wLength->value());
+ }
+ else {
+ data->setSuffix(wSuffix->text());
data->setLength(wLength->value());
+ if (wAlNum->isChecked())
+ data->setFlags(data->flags() | iGenerator::ALPHANUMERIC);
+ else
+ data->setFlags(data->flags() & ~uint(iGenerator::ALPHANUMERIC));
+ }
mStorage->save(wName->text(), data);
}
}