diff options
author | Anne Jan Brouwer <brouwer@annejan.com> | 2019-04-17 11:29:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-17 11:29:57 +0200 |
commit | 0789259aa59a565ba6c899a8c4e8da88fd5f5637 (patch) | |
tree | a62bf49adbdada3ffb40b261b7ae2bcbce243470 /src/configdialog.cpp | |
parent | 3698ff096cffec3541253ba1e745c389df0118c2 (diff) | |
parent | 57c24f5a7cbcfc52ec3e56be7d04421669f457b8 (diff) |
Merge pull request #421 from frawi/master
Display passwords as QR codes
Diffstat (limited to 'src/configdialog.cpp')
-rw-r--r-- | src/configdialog.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/configdialog.cpp b/src/configdialog.cpp index db72fb08..7ee438e7 100644 --- a/src/configdialog.cpp +++ b/src/configdialog.cpp @@ -62,6 +62,7 @@ ConfigDialog::ConfigDialog(MainWindow *parent) #if defined(Q_OS_WIN) || defined(__APPLE__) ui->checkBoxUseOtp->hide(); + ui->checkBoxUseQrencode->hide(); ui->label_10->hide(); #endif @@ -71,6 +72,12 @@ ConfigDialog::ConfigDialog(MainWindow *parent) tr("Pass OTP extension needs to be installed")); } + if (!isQrencodeAvailable()) { + ui->checkBoxUseQrencode->setEnabled(false); + ui->checkBoxUseQrencode->setToolTip( + tr("qrencode needs to be installed")); + } + setProfiles(QtPassSettings::getProfiles(), QtPassSettings::getProfile()); setPwgenPath(QtPassSettings::getPwgenExecutable()); setPasswordConfiguration(QtPassSettings::getPasswordConfiguration()); @@ -82,6 +89,7 @@ ConfigDialog::ConfigDialog(MainWindow *parent) useGit(QtPassSettings::isUseGit()); useOtp(QtPassSettings::isUseOtp()); + useQrencode(QtPassSettings::isUseQrencode()); usePwgen(QtPassSettings::isUsePwgen()); useTemplate(QtPassSettings::isUseTemplate()); @@ -206,6 +214,7 @@ void ConfigDialog::on_accepted() { QtPassSettings::setProfiles(getProfiles()); QtPassSettings::setUseGit(ui->checkBoxUseGit->isChecked()); QtPassSettings::setUseOtp(ui->checkBoxUseOtp->isChecked()); + QtPassSettings::setUseQrencode(ui->checkBoxUseQrencode->isChecked()); QtPassSettings::setPwgenExecutable(ui->pwgenPath->text()); QtPassSettings::setUsePwgen(ui->checkBoxUsePwgen->isChecked()); QtPassSettings::setAvoidCapitals(ui->checkBoxAvoidCapitals->isChecked()); @@ -540,6 +549,19 @@ void ConfigDialog::criticalMessage(const QString &title, const QString &text) { QMessageBox::critical(this, title, text, QMessageBox::Ok, QMessageBox::Ok); } +bool ConfigDialog::isQrencodeAvailable() { +#ifdef Q_OS_WIN + return false; +#elif defined(__APPLE__) + return false; +#else + QProcess which; + which.start("which", QStringList() << "qrencode"); + which.waitForFinished(); + return which.exitCode() == 0; +#endif +} + bool ConfigDialog::isPassOtpAvailable() { #ifdef Q_OS_WIN return false; @@ -703,6 +725,14 @@ void ConfigDialog::useOtp(bool useOtp) { } /** + * @brief ConfigDialog::useOtp set preference for using otp plugin. + * @param useOtp + */ +void ConfigDialog::useQrencode(bool useQrencode) { + ui->checkBoxUseQrencode->setChecked(useQrencode); +} + +/** * @brief ConfigDialog::on_checkBoxUseGit_clicked enable or disable related * checkboxes. */ |