diff options
author | Anne Jan Brouwer <annejan@noprotocol.com> | 2015-07-16 22:58:29 +0200 |
---|---|---|
committer | Anne Jan Brouwer <annejan@noprotocol.com> | 2015-07-16 22:58:29 +0200 |
commit | b52a13bb18c12f36eafda0c2b3baea25b9a3f3f2 (patch) | |
tree | 3ddcefb71dfb3dca536b27db0e35ad151fa1bb94 | |
parent | 35e7a8036bb16fd33b6a5e8d7544089fb5008b1f (diff) |
pwgen boilerplating stuff
-rw-r--r-- | dialog.cpp | 71 | ||||
-rw-r--r-- | dialog.h | 9 | ||||
-rw-r--r-- | dialog.ui | 32 | ||||
-rw-r--r-- | mainwindow.cpp | 17 | ||||
-rw-r--r-- | mainwindow.h | 4 |
5 files changed, 125 insertions, 8 deletions
@@ -623,3 +623,74 @@ void Dialog::setPwgenPath(QString pwgen) { ui->pwgenPath->setText(pwgen); } + +/** + * @brief Dialog::on_checkBoxUsPwgen_clicked + */ +void Dialog::on_checkBoxUsePwgen_clicked() +{ + ui->checkBoxUseSymbols->setEnabled(ui->checkBoxUsePwgen->isChecked()); + ui->lineEditPasswordChars->setEnabled(!ui->checkBoxUsePwgen->isChecked()); + ui->labelPasswordChars->setEnabled(!ui->checkBoxUsePwgen->isChecked()); +} + +/** + * @brief Dialog::usePwgen + * @param usePwgen + */ +void Dialog::usePwgen(bool usePwgen) { + ui->checkBoxUsePwgen->setChecked(usePwgen); + on_checkBoxUsePwgen_clicked(); +} + +/** + * @brief Dialog::useSymbols + * @param useSymbols + */ +void Dialog::useSymbols(bool useSymbols) { + ui->checkBoxUseSymbols->setChecked(useSymbols); +} + +/** + * @brief Dialog::setPasswordLength + * @param pwLen + */ +void Dialog::setPasswordLength(int pwLen) { + ui->spinBoxPasswordLength->setValue(pwLen); +} + +void Dialog::setPasswordChars(QString pwChars) { + ui->lineEditPasswordChars->setText(pwChars); +} + +/** + * @brief Dialog::usePwgen + * @return + */ +bool Dialog::usePwgen() { + return ui->checkBoxUsePwgen->isChecked(); +} + +/** + * @brief Dialog::useSymbols + * @return + */ +bool Dialog::useSymbols() { + return ui->checkBoxUseSymbols->isChecked(); +} + +/** + * @brief Dialog::getPasswordLength + * @return + */ +int Dialog::getPasswordLength() { + return ui->spinBoxPasswordLength->value(); +} + +/** + * @brief Dialog::getPasswordChars + * @return + */ +QString Dialog::getPasswordChars() { + return ui->lineEditPasswordChars->text(); +} @@ -55,6 +55,14 @@ public: bool useGit(); QString getPwgenPath(); void setPwgenPath(QString); + void usePwgen(bool); + void useSymbols(bool); + void setPasswordLength(int); + void setPasswordChars(QString); + bool usePwgen(); + bool useSymbols(); + int getPasswordLength(); + QString getPasswordChars(); protected: void closeEvent(QCloseEvent *event); @@ -73,6 +81,7 @@ private slots: void on_deleteButton_clicked(); void on_checkBoxUseTrayIcon_clicked(); void on_checkBoxUseGit_clicked(); + void on_checkBoxUsePwgen_clicked(); private: QScopedPointer<Ui::Dialog> ui; @@ -213,14 +213,20 @@ <item> <widget class="QSpinBox" name="spinBoxPasswordLength"> <property name="enabled"> - <bool>false</bool> + <bool>true</bool> + </property> + <property name="minimum"> + <number>8</number> + </property> + <property name="value"> + <number>16</number> </property> </widget> </item> <item> <widget class="QLabel" name="labelLength"> <property name="enabled"> - <bool>false</bool> + <bool>true</bool> </property> <property name="text"> <string>Characters</string> @@ -237,9 +243,9 @@ </widget> </item> <item row="3" column="0"> - <widget class="QCheckBox" name="checkBoxUsPwgen"> + <widget class="QCheckBox" name="checkBoxUsePwgen"> <property name="enabled"> - <bool>false</bool> + <bool>true</bool> </property> <property name="text"> <string>Use pwgen</string> @@ -256,7 +262,14 @@ <item row="0" column="3"> <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QSpinBox" name="spinBoxAutoclearSeconds"/> + <widget class="QSpinBox" name="spinBoxAutoclearSeconds"> + <property name="minimum"> + <number>5</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> </item> <item> <widget class="QLabel" name="labelSeconds"> @@ -308,7 +321,7 @@ <item row="3" column="1"> <widget class="QCheckBox" name="checkBoxUseSymbols"> <property name="enabled"> - <bool>false</bool> + <bool>true</bool> </property> <property name="text"> <string>Include special symbols </string> @@ -325,14 +338,17 @@ <item row="4" column="1" colspan="3"> <widget class="QLineEdit" name="lineEditPasswordChars"> <property name="enabled"> - <bool>false</bool> + <bool>true</bool> + </property> + <property name="text"> + <string>ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789</string> </property> </widget> </item> <item row="4" column="0"> <widget class="QLabel" name="labelPasswordChars"> <property name="enabled"> - <bool>false</bool> + <bool>true</bool> </property> <property name="text"> <string>Use characters</string> diff --git a/mainwindow.cpp b/mainwindow.cpp index 3d769b73..004f0481 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -216,6 +216,11 @@ bool MainWindow::checkConfig() { } } + usePwgen = (settings.value("usePwgen") == "true"); + useSymbols = (settings.value("useSymbols") == "true"); + passwordLength = settings.value("passwordLength").toInt(); + passwordChars = settings.value("passwordChars").toString(); + useTrayIcon = settings.value("useTrayIcon").toBool(); hideOnClose = settings.value("hideOnClose").toBool(); @@ -319,6 +324,10 @@ void MainWindow::config() { d->setProfiles(profiles, profile); d->useGit(useGit); d->setPwgenPath(pwgenExecutable); + d->usePwgen(usePwgen); + d->useSymbols(useSymbols); + d->setPasswordLength(passwordLength); + d->setPasswordChars(passwordChars); d->wizard(); // does shit if (d->exec()) { @@ -339,6 +348,10 @@ void MainWindow::config() { profiles = d->getProfiles(); useGit = d->useGit(); pwgenExecutable = d->getPwgenPath(); + usePwgen = d->usePwgen(); + useSymbols = d->useSymbols(); + passwordLength = d->getPasswordLength(); + passwordChars = d->getPasswordChars(); QSettings &settings(getSettings()); @@ -357,6 +370,10 @@ void MainWindow::config() { settings.setValue("hideOnClose", hideOnClose ? "true" : "false"); settings.setValue("useGit", useGit ? "true" : "false"); settings.setValue("pwgenExecutable", pwgenExecutable); + settings.setValue("usePwgen", usePwgen ? "true" : "false"); + settings.setValue("useGit", useSymbols ? "useSymbols" : "false"); + settings.setValue("passwordLength", passwordLength); + settings.setValue("passwordChars", passwordChars); if (!profiles.isEmpty()) { settings.beginGroup("profiles"); diff --git a/mainwindow.h b/mainwindow.h index 0693a576..c8f0b88f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -114,6 +114,10 @@ private: bool useTrayIcon; bool hideOnClose; bool useGit; + bool usePwgen; + bool useSymbols; + int passwordLength; + QString passwordChars; void updateText(); void executePass(QString, QString = QString()); void executeWrapper(QString, QString, QString = QString()); |