summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2016-10-12 20:13:30 +0200
committerAnne Jan Brouwer <brouwer@annejan.com>2016-10-12 20:13:30 +0200
commitfc47c2db66dbe8e8548d29bd4b7a0a8e669c6fb4 (patch)
treef5d7ada7d8cf0bb05ed1834e6f3e4b87b557e5c9
parente025eaa24de13725891d7566c940f8b5a3d6a4a9 (diff)
Init length and selected, minor cleanup / style
-rw-r--r--configdialog.cpp19
-rw-r--r--mainwindow.cpp7
-rw-r--r--mainwindow.h23
-rw-r--r--passworddialog.cpp21
4 files changed, 42 insertions, 28 deletions
diff --git a/configdialog.cpp b/configdialog.cpp
index 015a7df0..0c3f79e1 100644
--- a/configdialog.cpp
+++ b/configdialog.cpp
@@ -849,7 +849,7 @@ QString ConfigDialog::getPasswordChars() {
* password characters template combobox
* @return
*/
-void ConfigDialog::setPwdTemplateSelector(int selection){
+void ConfigDialog::setPwdTemplateSelector(int selection) {
ui->passwordCharTemplateSelector->setCurrentIndex(selection);
}
@@ -858,31 +858,32 @@ void ConfigDialog::setPwdTemplateSelector(int selection){
* password characters template combobox
* @return
*/
-int ConfigDialog::getPwdTemplateSelector(){
+int ConfigDialog::getPwdTemplateSelector() {
return ui->passwordCharTemplateSelector->currentIndex();
}
/**
- * @brief ConfigDialog::on_passwordCharTemplateSelector_activated sets the passwordChar Template
+ * @brief ConfigDialog::on_passwordCharTemplateSelector_activated sets the
+ * passwordChar Template
* combo box to the desired entry
* @param entry of
*/
-void ConfigDialog::on_passwordCharTemplateSelector_activated(int index){
+void ConfigDialog::on_passwordCharTemplateSelector_activated(int index) {
ui->lineEditPasswordChars->setText(mainWindow->pwdConfig.Characters[index]);
- if (index != 3){
+ if (index != 3) {
ui->lineEditPasswordChars->setEnabled(false);
- }
- else {
+ } else {
ui->lineEditPasswordChars->setEnabled(true);
}
}
/**
- * @brief ConfigDialog::setLineEditEnabled enabling/disabling the textbox with the
+ * @brief ConfigDialog::setLineEditEnabled enabling/disabling the textbox with
+ * the
* password characters
* @param b enable/disable
*/
-void ConfigDialog::setLineEditEnabled(bool b){
+void ConfigDialog::setLineEditEnabled(bool b) {
ui->lineEditPasswordChars->setEnabled(b);
}
diff --git a/mainwindow.cpp b/mainwindow.cpp
index f585ed82..380af194 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -456,8 +456,8 @@ void MainWindow::config() {
d->useSymbols(useSymbols);
d->setPasswordLength(pwdConfig.length);
d->setPwdTemplateSelector(pwdConfig.selected);
- if (pwdConfig.selected!=3)
- d->setLineEditEnabled(false);
+ if (pwdConfig.selected != 3)
+ d->setLineEditEnabled(false);
d->setPasswordChars(pwdConfig.Characters[pwdConfig.selected]);
d->useTemplate(useTemplate);
d->setTemplate(passTemplate);
@@ -1880,8 +1880,7 @@ QString MainWindow::generatePassword(int length, clipBoardType selection) {
QString args = QString("-1 ") + (lessRandom ? "" : "--secure ") +
(avoidCapitals ? "--no-capitalize " : "--capitalize ") +
(avoidNumbers ? "--no-numerals " : "--numerals ") +
- (useSymbols ? "--symbols " : "") +
- QString::number(length);
+ (useSymbols ? "--symbols " : "") + QString::number(length);
currentAction = PWGEN;
executeWrapper(pwgenExecutable, args);
process->waitForFinished(1000);
diff --git a/mainwindow.h b/mainwindow.h
index 6262a279..a68dfd68 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -36,17 +36,22 @@ struct UserInfo;
\struct passwordConfiguration
\brief holds the Password configuration settings
*/
-struct passwordConfiguration{
- int selected;
- int length;
+struct passwordConfiguration {
+ int selected = 0;
+ int length = 16;
QString Characters[4];
- passwordConfiguration(){
+ passwordConfiguration() {
length = 16;
- enum selected {ALLCHARS, ALPHABETICAL, ALPHANUMERIC, CUSTOM};
- Characters[ALLCHARS] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()_-+={}[]|:;<>,.?"; /*AllChars*/
- Characters[ALPHABETICAL] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; /*Only Alphabetical*/
- Characters[ALPHANUMERIC] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; /*Alphabetical and Numerical*/
- Characters[CUSTOM] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()_-+={}[]|:;<>,.?"; /*Custom*/
+ enum selected { ALLCHARS, ALPHABETICAL, ALPHANUMERIC, CUSTOM };
+ Characters[ALLCHARS] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&"
+ "*()_-+={}[]|:;<>,.?"; /*AllChars*/
+ Characters[ALPHABETICAL] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu"
+ "vwxyz"; /*Only Alphabetical*/
+ Characters[ALPHANUMERIC] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu"
+ "vwxyz1234567890"; /*Alphabetical and Numerical*/
+ Characters[CUSTOM] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1"
+ "234567890~!@#$%^&*()_-+={}[]|:;<>,.?"; /*Custom*/
}
};
diff --git a/passworddialog.cpp b/passworddialog.cpp
index 3b9ba291..70619290 100644
--- a/passworddialog.cpp
+++ b/passworddialog.cpp
@@ -14,7 +14,6 @@ PasswordDialog::PasswordDialog(MainWindow *parent)
templating = false;
allFields = false;
ui->setupUi(this);
-
}
/**
@@ -40,9 +39,9 @@ void PasswordDialog::on_checkBoxShow_stateChanged(int arg1) {
*/
void PasswordDialog::on_createPasswordButton_clicked() {
ui->widget->setEnabled(false);
- ui->lineEditPassword->setText(mainWindow->generatePassword(\
- ui->spinBox_pwdLength->value(), \
- (MainWindow::clipBoardType) ui->passwordTemplateSwitch->currentIndex()));
+ ui->lineEditPassword->setText(mainWindow->generatePassword(
+ ui->spinBox_pwdLength->value(),
+ (MainWindow::clipBoardType)ui->passwordTemplateSwitch->currentIndex()));
ui->widget->setEnabled(true);
}
@@ -156,6 +155,16 @@ void PasswordDialog::templateAll(bool templateAll) { allFields = templateAll; }
*/
void PasswordDialog::useTemplate(bool useTemplate) { templating = useTemplate; }
-void PasswordDialog::setLength(int l) {ui->spinBox_pwdLength->setValue(l); }
+/**
+ * @brief PasswordDialog::setLength
+ * @param l
+ */
+void PasswordDialog::setLength(int l) { ui->spinBox_pwdLength->setValue(l); }
-void PasswordDialog::setPasswordCharTemplate(int t) {ui->passwordTemplateSwitch->setCurrentIndex(t);}
+/**
+ * @brief PasswordDialog::setPasswordCharTemplate
+ * @param t
+ */
+void PasswordDialog::setPasswordCharTemplate(int t) {
+ ui->passwordTemplateSwitch->setCurrentIndex(t);
+}