diff options
author | Claudio Maradonna <penguyman@stronzi.org> | 2018-04-28 15:00:44 +0200 |
---|---|---|
committer | Claudio Maradonna <penguyman@stronzi.org> | 2018-04-28 15:00:44 +0200 |
commit | 627c1ea0a19cd177e195dc64c2ea636e2ea77fb2 (patch) | |
tree | 1b4ea4d1098b062ce73e01bf2d785566ae7e1986 | |
parent | 172189b7ae775a6c04a542107e6d08ee86bd15fb (diff) |
Some refactors. Some fixes with error with Pass process
-rw-r--r-- | src/configdialog.cpp | 79 | ||||
-rw-r--r-- | src/configdialog.h | 9 | ||||
-rw-r--r-- | src/passworddialog.cpp | 1 |
3 files changed, 34 insertions, 55 deletions
diff --git a/src/configdialog.cpp b/src/configdialog.cpp index 91b648d1..f31f8662 100644 --- a/src/configdialog.cpp +++ b/src/configdialog.cpp @@ -95,11 +95,9 @@ ConfigDialog::~ConfigDialog() { */ void ConfigDialog::setGitPath(QString path) { ui->gitPath->setText(path); + ui->checkBoxUseGit->setEnabled(!path.isEmpty()); if (path.isEmpty()) { useGit(false); - ui->checkBoxUseGit->setEnabled(false); - } else { - ui->checkBoxUseGit->setEnabled(true); } } @@ -109,13 +107,8 @@ void ConfigDialog::setGitPath(QString path) { * @param usePass */ void ConfigDialog::usePass(bool usePass) { - if (usePass) { - ui->radioButtonNative->setChecked(false); - ui->radioButtonPass->setChecked(true); - } else { - ui->radioButtonNative->setChecked(true); - ui->radioButtonPass->setChecked(false); - } + ui->radioButtonNative->setChecked(!usePass); + ui->radioButtonPass->setChecked(usePass); setGroupBoxState(); } @@ -176,13 +169,9 @@ void ConfigDialog::on_radioButtonPass_clicked() { setGroupBoxState(); } * @brief ConfigDialog::setGroupBoxState update checkboxes. */ void ConfigDialog::setGroupBoxState() { - if (ui->radioButtonPass->isChecked()) { - ui->groupBoxNative->setEnabled(false); - ui->groupBoxPass->setEnabled(true); - } else { - ui->groupBoxNative->setEnabled(true); - ui->groupBoxPass->setEnabled(false); - } + bool state = ui->radioButtonPass->isChecked(); + ui->groupBoxNative->setEnabled(!state); + ui->groupBoxPass->setEnabled(state); } /** @@ -196,7 +185,7 @@ QString ConfigDialog::selectExecutable() { if (dialog.exec()) return dialog.selectedFiles().first(); else - return ""; + return QString(); } /** @@ -211,7 +200,7 @@ QString ConfigDialog::selectFolder() { if (dialog.exec()) return dialog.selectedFiles().first(); else - return ""; + return QString(); } /** @@ -220,13 +209,14 @@ QString ConfigDialog::selectFolder() { */ void ConfigDialog::on_toolButtonGit_clicked() { QString git = selectExecutable(); - if (!git.isEmpty()) { + bool state = !git.isEmpty(); + if (state) { ui->gitPath->setText(git); - ui->checkBoxUseGit->setEnabled(true); } else { useGit(false); - ui->checkBoxUseGit->setEnabled(false); } + + ui->checkBoxUseGit->setEnabled(state); } /** @@ -262,25 +252,18 @@ void ConfigDialog::on_toolButtonStore_clicked() { * @param index of selectbox (0 = no clipboard). */ void ConfigDialog::on_comboBoxClipboard_activated(int index) { - if (index > 0) { - ui->checkBoxSelection->setEnabled(true); - ui->checkBoxAutoclear->setEnabled(true); - ui->checkBoxHidePassword->setEnabled(true); - ui->checkBoxHideContent->setEnabled(true); - if (ui->checkBoxAutoclear->isChecked()) { - ui->spinBoxAutoclearSeconds->setEnabled(true); - ui->labelSeconds->setEnabled(true); - } else { - ui->spinBoxAutoclearSeconds->setEnabled(false); - ui->labelSeconds->setEnabled(false); - } + bool state = index > 0; + + ui->checkBoxSelection->setEnabled(state); + ui->checkBoxAutoclear->setEnabled(state); + ui->checkBoxHidePassword->setEnabled(state); + ui->checkBoxHideContent->setEnabled(state); + if (state) { + ui->spinBoxAutoclearSeconds->setEnabled(ui->checkBoxAutoclear->isChecked()); + ui->labelSeconds->setEnabled(ui->checkBoxAutoclear->isChecked()); } else { - ui->checkBoxSelection->setEnabled(false); - ui->checkBoxAutoclear->setEnabled(false); ui->spinBoxAutoclearSeconds->setEnabled(false); ui->labelSeconds->setEnabled(false); - ui->checkBoxHidePassword->setEnabled(false); - ui->checkBoxHideContent->setEnabled(false); } } @@ -289,13 +272,9 @@ void ConfigDialog::on_comboBoxClipboard_activated(int index) { * options based on autoclear use. */ void ConfigDialog::on_checkBoxAutoclearPanel_clicked() { - if (ui->checkBoxAutoclearPanel->isChecked()) { - ui->spinBoxAutoclearPanelSeconds->setEnabled(true); - ui->labelPanelSeconds->setEnabled(true); - } else { - ui->spinBoxAutoclearPanelSeconds->setEnabled(false); - ui->labelPanelSeconds->setEnabled(false); - } + bool state = ui->checkBoxAutoclearPanel->isChecked(); + ui->spinBoxAutoclearPanelSeconds->setEnabled(state); + ui->labelPanelSeconds->setEnabled(state); } /** @@ -562,13 +541,9 @@ void ConfigDialog::useTrayIcon(bool useSystray) { * related checkboxes. */ void ConfigDialog::on_checkBoxUseTrayIcon_clicked() { - if (ui->checkBoxUseTrayIcon->isChecked()) { - ui->checkBoxHideOnClose->setEnabled(true); - ui->checkBoxStartMinimized->setEnabled(true); - } else { - ui->checkBoxStartMinimized->setEnabled(false); - ui->checkBoxHideOnClose->setEnabled(false); - } + bool state = ui->checkBoxUseTrayIcon->isChecked(); + ui->checkBoxHideOnClose->setEnabled(state); + ui->checkBoxStartMinimized->setEnabled(state); } /** diff --git a/src/configdialog.h b/src/configdialog.h index 48b8b47f..855ef8e8 100644 --- a/src/configdialog.h +++ b/src/configdialog.h @@ -27,9 +27,6 @@ public: explicit ConfigDialog(MainWindow *parent); ~ConfigDialog(); - void setGitPath(QString); - void setProfiles(QHash<QString, QString>, QString); - void usePass(bool usePass); void useClipboard(Enums::clipBoardType); void useSelection(bool useSelection); void useAutoclear(bool useAutoclear); @@ -72,12 +69,18 @@ private slots: private: QScopedPointer<Ui::ConfigDialog> ui; + + void setGitPath(QString); + void setProfiles(QHash<QString, QString>, QString); + void usePass(bool usePass); + void setGroupBoxState(); QString selectExecutable(); QString selectFolder(); // QMessageBox::critical with hack to avoid crashes with // Qt 5.4.1 when QApplication::exec was not yet called void criticalMessage(const QString &title, const QString &text); + MainWindow *mainWindow; }; diff --git a/src/passworddialog.cpp b/src/passworddialog.cpp index 7c052660..23768dae 100644 --- a/src/passworddialog.cpp +++ b/src/passworddialog.cpp @@ -51,6 +51,7 @@ PasswordDialog::PasswordDialog(const QString &file, const bool &isNew, setLength(m_passConfig.length); setPasswordCharTemplate(m_passConfig.selected); + connect(QtPassSettings::getPass(), &Pass::processErrorExit, this, &PasswordDialog::close); connect(this, &PasswordDialog::accepted, this, &PasswordDialog::on_accepted); connect(this, &PasswordDialog::rejected, this, &PasswordDialog::on_rejected); } |