QtPass 1.4.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
configdialog.cpp
Go to the documentation of this file.
1#include "configdialog.h"
2#include "keygendialog.h"
3#include "mainwindow.h"
4#include "qtpasssettings.h"
5#include "ui_configdialog.h"
6#include "util.h"
7#include <QClipboard>
8#include <QDir>
9#include <QFileDialog>
10#include <QMessageBox>
11#include <QPushButton>
12#include <QSystemTrayIcon>
13#include <QTableWidgetItem>
14#ifdef Q_OS_WIN
15#include <windows.h>
16#endif
17
18#ifdef QT_DEBUG
19#include "debughelper.h"
20#endif
21
27 : QDialog(parent), ui(new Ui::ConfigDialog) {
28 mainWindow = parent;
29 ui->setupUi(this);
30
31 ui->passPath->setText(QtPassSettings::getPassExecutable());
33 ui->gpgPath->setText(QtPassSettings::getGpgExecutable());
34 ui->storePath->setText(QtPassSettings::getPassStore());
35
36 ui->spinBoxAutoclearSeconds->setValue(QtPassSettings::getAutoclearSeconds());
37 ui->spinBoxAutoclearPanelSeconds->setValue(
39 ui->checkBoxHidePassword->setChecked(QtPassSettings::isHidePassword());
40 ui->checkBoxHideContent->setChecked(QtPassSettings::isHideContent());
41 ui->checkBoxUseMonospace->setChecked(QtPassSettings::isUseMonospace());
42 ui->checkBoxDisplayAsIs->setChecked(QtPassSettings::isDisplayAsIs());
43 ui->checkBoxNoLineWrapping->setChecked(QtPassSettings::isNoLineWrapping());
44 ui->checkBoxAddGPGId->setChecked(QtPassSettings::isAddGPGId(true));
45
46 if (QSystemTrayIcon::isSystemTrayAvailable()) {
47 ui->checkBoxHideOnClose->setChecked(QtPassSettings::isHideOnClose());
48 ui->checkBoxStartMinimized->setChecked(QtPassSettings::isStartMinimized());
49 } else {
50 ui->checkBoxUseTrayIcon->setEnabled(false);
51 ui->checkBoxUseTrayIcon->setToolTip(tr("System tray is not available"));
52 ui->checkBoxHideOnClose->setEnabled(false);
53 ui->checkBoxStartMinimized->setEnabled(false);
54 }
55
56 ui->checkBoxAvoidCapitals->setChecked(QtPassSettings::isAvoidCapitals());
57 ui->checkBoxAvoidNumbers->setChecked(QtPassSettings::isAvoidNumbers());
58 ui->checkBoxLessRandom->setChecked(QtPassSettings::isLessRandom());
59 ui->checkBoxUseSymbols->setChecked(QtPassSettings::isUseSymbols());
60 ui->plainTextEditTemplate->setPlainText(QtPassSettings::getPassTemplate());
61 ui->checkBoxTemplateAllFields->setChecked(
63 ui->checkBoxAutoPull->setChecked(QtPassSettings::isAutoPull());
64 ui->checkBoxAutoPush->setChecked(QtPassSettings::isAutoPush());
65 ui->checkBoxAlwaysOnTop->setChecked(QtPassSettings::isAlwaysOnTop());
66
67#if defined(Q_OS_WIN)
68 ui->checkBoxUseOtp->hide();
69 ui->checkBoxUseQrencode->hide();
70 ui->label_10->hide();
71#endif
72
73 if (!isPassOtpAvailable()) {
74 ui->checkBoxUseOtp->setEnabled(false);
75 ui->checkBoxUseOtp->setToolTip(
76 tr("Pass OTP extension needs to be installed"));
77 }
78
79 if (!isQrencodeAvailable()) {
80 ui->checkBoxUseQrencode->setEnabled(false);
81 ui->checkBoxUseQrencode->setToolTip(tr("qrencode needs to be installed"));
82 }
83
87
93
96
99
100 ui->profileTable->verticalHeader()->hide();
101 ui->profileTable->horizontalHeader()->setSectionResizeMode(
102 1, QHeaderView::Stretch);
103 ui->label->setText(ui->label->text() + VERSION);
104 ui->comboBoxClipboard->clear();
105
106 ui->comboBoxClipboard->addItem(tr("No Clipboard"));
107 ui->comboBoxClipboard->addItem(tr("Always copy to clipboard"));
108 ui->comboBoxClipboard->addItem(tr("On-demand copy to clipboard"));
109
110 int currentIndex = QtPassSettings::getClipBoardTypeRaw();
111 ui->comboBoxClipboard->setCurrentIndex(currentIndex);
112 on_comboBoxClipboard_activated(currentIndex);
113
114 QClipboard *clip = QApplication::clipboard();
115 if (!clip->supportsSelection()) {
116 useSelection(false);
117 ui->checkBoxSelection->setVisible(false);
118 } else {
120 }
121
122 if (Util::checkConfig()) {
123 // Show Programs tab, which is likely
124 // what the user needs to fix now.
125 ui->tabWidget->setCurrentIndex(1);
126 }
127
128 connect(ui->profileTable, &QTableWidget::itemChanged, this,
129 &ConfigDialog::onProfileTableItemChanged);
130 connect(this, &ConfigDialog::accepted, this, &ConfigDialog::on_accepted);
131}
132
138 QtPassSettings::setGitExecutable(ui->gitPath->text());
139 QtPassSettings::setGpgExecutable(ui->gpgPath->text());
140 QtPassSettings::setPassExecutable(ui->passPath->text());
141}
142
148void ConfigDialog::setGitPath(QString path) {
149 ui->gitPath->setText(path);
150 ui->checkBoxUseGit->setEnabled(!path.isEmpty());
151 if (path.isEmpty()) {
152 useGit(false);
153 }
154}
155
161void ConfigDialog::usePass(bool usePass) {
162 ui->radioButtonNative->setChecked(!usePass);
163 ui->radioButtonPass->setChecked(usePass);
164 setGroupBoxState();
165}
166
167void ConfigDialog::validate(QTableWidgetItem *item) {
168 bool status = true;
169
170 if (item == nullptr) {
171 for (int i = 0; i < ui->profileTable->rowCount(); i++) {
172 for (int j = 0; j < ui->profileTable->columnCount(); j++) {
173 QTableWidgetItem *_item = ui->profileTable->item(i, j);
174
175 if (_item->text().isEmpty() && j != 2) {
176 _item->setBackground(Qt::red);
177 status = false;
178 break;
179 }
180 }
181
182 if (!status)
183 break;
184 }
185 } else {
186 if (item->text().isEmpty() && item->column() != 2) {
187 item->setBackground(Qt::red);
188 status = false;
189 }
190 }
191
192 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status);
193}
194
195void ConfigDialog::on_accepted() {
196 QtPassSettings::setPassExecutable(ui->passPath->text());
197 QtPassSettings::setGitExecutable(ui->gitPath->text());
198 QtPassSettings::setGpgExecutable(ui->gpgPath->text());
200 Util::normalizeFolderPath(ui->storePath->text()));
201 QtPassSettings::setUsePass(ui->radioButtonPass->isChecked());
202 QtPassSettings::setClipBoardType(ui->comboBoxClipboard->currentIndex());
203 QtPassSettings::setUseSelection(ui->checkBoxSelection->isChecked());
204 QtPassSettings::setUseAutoclear(ui->checkBoxAutoclear->isChecked());
205 QtPassSettings::setAutoclearSeconds(ui->spinBoxAutoclearSeconds->value());
206 QtPassSettings::setUseAutoclearPanel(ui->checkBoxAutoclearPanel->isChecked());
208 ui->spinBoxAutoclearPanelSeconds->value());
209 QtPassSettings::setHidePassword(ui->checkBoxHidePassword->isChecked());
210 QtPassSettings::setHideContent(ui->checkBoxHideContent->isChecked());
211 QtPassSettings::setUseMonospace(ui->checkBoxUseMonospace->isChecked());
212 QtPassSettings::setDisplayAsIs(ui->checkBoxDisplayAsIs->isChecked());
213 QtPassSettings::setNoLineWrapping(ui->checkBoxNoLineWrapping->isChecked());
214 QtPassSettings::setAddGPGId(ui->checkBoxAddGPGId->isChecked());
215 QtPassSettings::setUseTrayIcon(ui->checkBoxUseTrayIcon->isEnabled() &&
216 ui->checkBoxUseTrayIcon->isChecked());
217 QtPassSettings::setHideOnClose(ui->checkBoxHideOnClose->isEnabled() &&
218 ui->checkBoxHideOnClose->isChecked());
219 QtPassSettings::setStartMinimized(ui->checkBoxStartMinimized->isEnabled() &&
220 ui->checkBoxStartMinimized->isChecked());
222 QtPassSettings::setUseGit(ui->checkBoxUseGit->isChecked());
223 QtPassSettings::setUseOtp(ui->checkBoxUseOtp->isChecked());
224 QtPassSettings::setUseQrencode(ui->checkBoxUseQrencode->isChecked());
225 QtPassSettings::setPwgenExecutable(ui->pwgenPath->text());
226 QtPassSettings::setUsePwgen(ui->checkBoxUsePwgen->isChecked());
227 QtPassSettings::setAvoidCapitals(ui->checkBoxAvoidCapitals->isChecked());
228 QtPassSettings::setAvoidNumbers(ui->checkBoxAvoidNumbers->isChecked());
229 QtPassSettings::setLessRandom(ui->checkBoxLessRandom->isChecked());
230 QtPassSettings::setUseSymbols(ui->checkBoxUseSymbols->isChecked());
232 QtPassSettings::setUseTemplate(ui->checkBoxUseTemplate->isChecked());
233 QtPassSettings::setPassTemplate(ui->plainTextEditTemplate->toPlainText());
235 ui->checkBoxTemplateAllFields->isChecked());
236 QtPassSettings::setAutoPush(ui->checkBoxAutoPush->isChecked());
237 QtPassSettings::setAutoPull(ui->checkBoxAutoPull->isChecked());
238 QtPassSettings::setAlwaysOnTop(ui->checkBoxAlwaysOnTop->isChecked());
239
241}
242
243void ConfigDialog::on_autodetectButton_clicked() {
244 QString pass = Util::findBinaryInPath("pass");
245 if (!pass.isEmpty())
246 ui->passPath->setText(pass);
247 usePass(!pass.isEmpty());
248 QString gpg = Util::findBinaryInPath("gpg2");
249 if (gpg.isEmpty())
250 gpg = Util::findBinaryInPath("gpg");
251 if (!gpg.isEmpty())
252 ui->gpgPath->setText(gpg);
253 QString git = Util::findBinaryInPath("git");
254 if (!git.isEmpty())
255 ui->gitPath->setText(git);
256 QString pwgen = Util::findBinaryInPath("pwgen");
257 if (!pwgen.isEmpty())
258 ui->pwgenPath->setText(pwgen);
259}
260
265void ConfigDialog::on_radioButtonNative_clicked() { setGroupBoxState(); }
266
271void ConfigDialog::on_radioButtonPass_clicked() { setGroupBoxState(); }
272
277QStringList ConfigDialog::getSecretKeys() {
278 QList<UserInfo> keys = QtPassSettings::getPass()->listKeys("", true);
279 QStringList names;
280
281 if (keys.empty())
282 return names;
283
284 foreach (const UserInfo &sec, keys)
285 names << sec.name;
286
287 return names;
288}
289
293void ConfigDialog::setGroupBoxState() {
294 bool state = ui->radioButtonPass->isChecked();
295 ui->groupBoxNative->setEnabled(!state);
296 ui->groupBoxPass->setEnabled(state);
297}
298
303QString ConfigDialog::selectExecutable() {
304 QFileDialog dialog(this);
305 dialog.setFileMode(QFileDialog::ExistingFile);
306 dialog.setOption(QFileDialog::ReadOnly);
307 if (dialog.exec())
308 return dialog.selectedFiles().constFirst();
309
310 return QString();
311}
312
317QString ConfigDialog::selectFolder() {
318 QFileDialog dialog(this);
319 dialog.setFileMode(QFileDialog::Directory);
320 dialog.setFilter(QDir::NoFilter);
321 dialog.setOption(QFileDialog::ShowDirsOnly);
322 if (dialog.exec())
323 return dialog.selectedFiles().constFirst();
324
325 return QString();
326}
327
332void ConfigDialog::on_toolButtonGit_clicked() {
333 QString git = selectExecutable();
334 bool state = !git.isEmpty();
335 if (state) {
336 ui->gitPath->setText(git);
337 } else {
338 useGit(false);
339 }
340
341 ui->checkBoxUseGit->setEnabled(state);
342}
343
347void ConfigDialog::on_toolButtonGpg_clicked() {
348 QString gpg = selectExecutable();
349 if (!gpg.isEmpty())
350 ui->gpgPath->setText(gpg);
351}
352
356void ConfigDialog::on_toolButtonPass_clicked() {
357 QString pass = selectExecutable();
358 if (!pass.isEmpty())
359 ui->passPath->setText(pass);
360}
361
366void ConfigDialog::on_toolButtonStore_clicked() {
367 QString store = selectFolder();
368 if (!store.isEmpty()) // TODO(annejan) call check
369 ui->storePath->setText(store);
370}
371
376void ConfigDialog::on_comboBoxClipboard_activated(int index) {
377 bool state = index > 0;
378
379 ui->checkBoxSelection->setEnabled(state);
380 ui->checkBoxAutoclear->setEnabled(state);
381 ui->checkBoxHidePassword->setEnabled(state);
382 ui->checkBoxHideContent->setEnabled(state);
383 if (state) {
384 ui->spinBoxAutoclearSeconds->setEnabled(ui->checkBoxAutoclear->isChecked());
385 ui->labelSeconds->setEnabled(ui->checkBoxAutoclear->isChecked());
386 } else {
387 ui->spinBoxAutoclearSeconds->setEnabled(false);
388 ui->labelSeconds->setEnabled(false);
389 }
390}
391
396void ConfigDialog::on_checkBoxAutoclearPanel_clicked() {
397 bool state = ui->checkBoxAutoclearPanel->isChecked();
398 ui->spinBoxAutoclearPanelSeconds->setEnabled(state);
399 ui->labelPanelSeconds->setEnabled(state);
400}
401
407void ConfigDialog::useSelection(bool useSelection) {
408 ui->checkBoxSelection->setChecked(useSelection);
409 on_checkBoxSelection_clicked();
410}
411
417void ConfigDialog::useAutoclear(bool useAutoclear) {
418 ui->checkBoxAutoclear->setChecked(useAutoclear);
419 on_checkBoxAutoclear_clicked();
420}
421
427void ConfigDialog::useAutoclearPanel(bool useAutoclearPanel) {
428 ui->checkBoxAutoclearPanel->setChecked(useAutoclearPanel);
429 on_checkBoxAutoclearPanel_clicked();
430}
431
436void ConfigDialog::on_checkBoxSelection_clicked() {
437 on_comboBoxClipboard_activated(ui->comboBoxClipboard->currentIndex());
438}
439
444void ConfigDialog::on_checkBoxAutoclear_clicked() {
445 on_comboBoxClipboard_activated(ui->comboBoxClipboard->currentIndex());
446}
447
455void ConfigDialog::genKey(QString batch, QDialog *dialog) {
456 mainWindow->generateKeyPair(batch, dialog);
457}
458
465void ConfigDialog::setProfiles(QHash<QString, QHash<QString, QString>> profiles,
466 QString currentProfile) {
467 // dbg()<< profiles;
468 if (profiles.contains("")) {
469 profiles.remove("");
470 // remove weird "" key value pairs
471 }
472
473 ui->profileTable->setRowCount(profiles.count());
474 QHashIterator<QString, QHash<QString, QString>> i(profiles);
475 int n = 0;
476 while (i.hasNext()) {
477 i.next();
478 if (!i.value().isEmpty() && !i.key().isEmpty()) {
479 ui->profileTable->setItem(n, 0, new QTableWidgetItem(i.key()));
480 ui->profileTable->setItem(n, 1,
481 new QTableWidgetItem(i.value().value("path")));
482 ui->profileTable->setItem(
483 n, 2, new QTableWidgetItem(i.value().value("signingKey")));
484 // dbg()<< "naam:" + i.key();
485 if (i.key() == currentProfile)
486 ui->profileTable->selectRow(n);
487 }
488 ++n;
489 }
490}
491
496QHash<QString, QHash<QString, QString>> ConfigDialog::getProfiles() {
497 QHash<QString, QHash<QString, QString>> profiles;
498 // Check?
499 for (int i = 0; i < ui->profileTable->rowCount(); ++i) {
500 QHash<QString, QString> profile;
501 QTableWidgetItem *pathItem = ui->profileTable->item(i, 1);
502 if (nullptr != pathItem) {
503 QTableWidgetItem *item = ui->profileTable->item(i, 0);
504 if (item == nullptr) {
505 continue;
506 }
507 profile["path"] = pathItem->text();
508 QTableWidgetItem *signingKeyItem = ui->profileTable->item(i, 2);
509 if (nullptr != signingKeyItem) {
510 profile["signingKey"] = signingKeyItem->text();
511 }
512 profiles.insert(item->text(), profile);
513 }
514 }
515 return profiles;
516}
517
521void ConfigDialog::on_addButton_clicked() {
522 int n = ui->profileTable->rowCount();
523 ui->profileTable->insertRow(n);
524 ui->profileTable->setItem(n, 0, new QTableWidgetItem());
525 ui->profileTable->setItem(n, 1, new QTableWidgetItem(ui->storePath->text()));
526 ui->profileTable->setItem(n, 2, new QTableWidgetItem());
527 ui->profileTable->selectRow(n);
528 ui->deleteButton->setEnabled(true);
529
530 validate();
531}
532
536void ConfigDialog::on_deleteButton_clicked() {
537 QSet<int> selectedRows; // we use a set to prevent doubles
538 QList<QTableWidgetItem *> itemList = ui->profileTable->selectedItems();
539 if (itemList.count() == 0) {
540 QMessageBox::warning(this, tr("No profile selected"),
541 tr("No profile selected to delete"));
542 return;
543 }
544 QTableWidgetItem *item;
545 foreach (item, itemList)
546 selectedRows.insert(item->row());
547 // get a list, and sort it big to small
548 QList<int> rows = selectedRows.values();
549 std::sort(rows.begin(), rows.end());
550 // now actually do the removing:
551 foreach (int row, rows)
552 ui->profileTable->removeRow(row);
553 if (ui->profileTable->rowCount() < 1)
554 ui->deleteButton->setEnabled(false);
555
556 validate();
557}
558
565void ConfigDialog::criticalMessage(const QString &title, const QString &text) {
566 QMessageBox::critical(this, title, text, QMessageBox::Ok, QMessageBox::Ok);
567}
568
569bool ConfigDialog::isQrencodeAvailable() {
570#ifdef Q_OS_WIN
571 return false;
572#else
573 QProcess which;
574 which.start("which", QStringList() << "qrencode");
575 which.waitForFinished();
577 which.readAllStandardOutput().trimmed());
578 return which.exitCode() == 0;
579#endif
580}
581
582bool ConfigDialog::isPassOtpAvailable() {
583#ifdef Q_OS_WIN
584 return false;
585#else
586 return true;
587#endif
588}
589
596 on_autodetectButton_clicked();
597 bool clean = false;
598
599 QString gpg = ui->gpgPath->text();
600 if (!gpg.startsWith("wsl ") && !QFile(gpg).exists()) {
601 criticalMessage(
602 tr("GnuPG not found"),
603#ifdef Q_OS_WIN
604#ifdef WINSTORE
605 tr("Please install GnuPG on your system.<br>Install "
606 "<strong>Ubuntu</strong> from the Microsoft Store to get it.<br>"
607 "If you already did so, make sure you started it once and<br>"
608 "click \"Autodetect\" in the next dialog.")
609#else
610 tr("Please install GnuPG on your system.<br>Install "
611 "<strong>Ubuntu</strong> from the Microsoft Store<br>or <a "
612 "href=\"https://www.gnupg.org/download/#sec-1-2\">download</a> it "
613 "from GnuPG.org")
614#endif
615#else
616 tr("Please install GnuPG on your system.<br>Install "
617 "<strong>gpg</strong> using your favorite package manager<br>or "
618 "<a "
619 "href=\"https://www.gnupg.org/download/#sec-1-2\">download</a> it "
620 "from GnuPG.org")
621#endif
622 );
623 clean = true;
624 }
625
626 QStringList names = getSecretKeys();
627
628#ifdef QT_DEBUG
629 dbg() << names;
630#endif
631
632 if ((gpg.startsWith("wsl ") || QFile(gpg).exists()) && names.empty()) {
633 KeygenDialog d(this);
634 if (!d.exec())
635 return;
636 }
637
638 QString passStore = ui->storePath->text();
639
640 if (!QFile(passStore).exists()) {
641 // TODO(annejan) pass version?
642 if (QMessageBox::question(
643 this, tr("Create password-store?"),
644 tr("Would you like to create a password-store at %1?")
645 .arg(passStore),
646 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
647 QDir().mkdir(passStore);
648#ifdef Q_OS_WIN
649 SetFileAttributes(passStore.toStdWString().c_str(),
650 FILE_ATTRIBUTE_HIDDEN);
651#endif
652 if (ui->checkBoxUseGit->isChecked())
653 emit mainWindow->passGitInitNeeded();
654 mainWindow->userDialog(passStore);
655 }
656 }
657
658 if (!QFile(QDir(passStore).filePath(".gpg-id")).exists()) {
659#ifdef QT_DEBUG
660 dbg() << ".gpg-id file does not exist";
661#endif
662 if (!clean) {
663 criticalMessage(tr("Password store not initialised"),
664 tr("The folder %1 doesn't seem to be a password store or "
665 "is not yet initialised.")
666 .arg(passStore));
667 }
668 while (!QFile(passStore).exists()) {
669 on_toolButtonStore_clicked();
670 // allow user to cancel
671 if (passStore == ui->storePath->text())
672 return;
673 passStore = ui->storePath->text();
674 }
675 if (!QFile(passStore + ".gpg-id").exists()) {
676#ifdef QT_DEBUG
677 dbg() << ".gpg-id file still does not exist :/";
678#endif
679 // appears not to be store
680 // init yes / no ?
681 mainWindow->userDialog(passStore);
682 }
683 }
684
685 ui->checkBoxHidePassword->setCheckState(Qt::Checked);
686}
687
693void ConfigDialog::useTrayIcon(bool useSystray) {
694 if (QSystemTrayIcon::isSystemTrayAvailable()) {
695 ui->checkBoxUseTrayIcon->setChecked(useSystray);
696 ui->checkBoxHideOnClose->setEnabled(useSystray);
697 ui->checkBoxStartMinimized->setEnabled(useSystray);
698
699 if (!useSystray) {
700 ui->checkBoxHideOnClose->setChecked(false);
701 ui->checkBoxStartMinimized->setChecked(false);
702 }
703 }
704}
705
710void ConfigDialog::on_checkBoxUseTrayIcon_clicked() {
711 bool state = ui->checkBoxUseTrayIcon->isChecked();
712 ui->checkBoxHideOnClose->setEnabled(state);
713 ui->checkBoxStartMinimized->setEnabled(state);
714}
715
720void ConfigDialog::closeEvent(QCloseEvent *event) {
721 // TODO(annejan) save window size or something?
722 event->accept();
723}
724
729void ConfigDialog::useGit(bool useGit) {
730 ui->checkBoxUseGit->setChecked(useGit);
731 on_checkBoxUseGit_clicked();
732}
733
738void ConfigDialog::useOtp(bool useOtp) {
739 ui->checkBoxUseOtp->setChecked(useOtp);
740}
741
746void ConfigDialog::useQrencode(bool useQrencode) {
747 ui->checkBoxUseQrencode->setChecked(useQrencode);
748}
749
754void ConfigDialog::on_checkBoxUseGit_clicked() {
755 ui->checkBoxAddGPGId->setEnabled(ui->checkBoxUseGit->isChecked());
756 ui->checkBoxAutoPull->setEnabled(ui->checkBoxUseGit->isChecked());
757 ui->checkBoxAutoPush->setEnabled(ui->checkBoxUseGit->isChecked());
758}
759
764void ConfigDialog::on_toolButtonPwgen_clicked() {
765 QString pwgen = selectExecutable();
766 if (!pwgen.isEmpty()) {
767 ui->pwgenPath->setText(pwgen);
768 ui->checkBoxUsePwgen->setEnabled(true);
769 } else {
770 ui->checkBoxUsePwgen->setEnabled(false);
771 ui->checkBoxUsePwgen->setChecked(false);
772 }
773}
774
780void ConfigDialog::setPwgenPath(QString pwgen) {
781 ui->pwgenPath->setText(pwgen);
782 if (pwgen.isEmpty()) {
783 ui->checkBoxUsePwgen->setChecked(false);
784 ui->checkBoxUsePwgen->setEnabled(false);
785 }
786 on_checkBoxUsePwgen_clicked();
787}
788
793void ConfigDialog::on_checkBoxUsePwgen_clicked() {
794 bool usePwgen = ui->checkBoxUsePwgen->isChecked();
795 ui->checkBoxAvoidCapitals->setEnabled(usePwgen);
796 ui->checkBoxAvoidNumbers->setEnabled(usePwgen);
797 ui->checkBoxLessRandom->setEnabled(usePwgen);
798 ui->checkBoxUseSymbols->setEnabled(usePwgen);
799 ui->lineEditPasswordChars->setEnabled(!usePwgen);
800 ui->labelPasswordChars->setEnabled(!usePwgen);
801 ui->passwordCharTemplateSelector->setEnabled(!usePwgen);
802}
803
811void ConfigDialog::usePwgen(bool usePwgen) {
812 if (ui->pwgenPath->text().isEmpty())
813 usePwgen = false;
814 ui->checkBoxUsePwgen->setChecked(usePwgen);
815 on_checkBoxUsePwgen_clicked();
816}
817
819 const PasswordConfiguration &config) {
820 ui->spinBoxPasswordLength->setValue(config.length);
821 ui->passwordCharTemplateSelector->setCurrentIndex(config.selected);
823 ui->lineEditPasswordChars->setEnabled(false);
824 ui->lineEditPasswordChars->setText(config.Characters[config.selected]);
825}
826
829 config.length = ui->spinBoxPasswordLength->value();
830 config.selected = static_cast<PasswordConfiguration::characterSet>(
831 ui->passwordCharTemplateSelector->currentIndex());
833 ui->lineEditPasswordChars->text();
834 return config;
835}
836
843void ConfigDialog::on_passwordCharTemplateSelector_activated(int index) {
844 ui->lineEditPasswordChars->setText(
845 QtPassSettings::getPasswordConfiguration().Characters[index]);
846 if (index == 3) {
847 ui->lineEditPasswordChars->setEnabled(true);
848 } else {
849 ui->lineEditPasswordChars->setEnabled(false);
850 }
851}
852
857void ConfigDialog::on_checkBoxUseTemplate_clicked() {
858 ui->plainTextEditTemplate->setEnabled(ui->checkBoxUseTemplate->isChecked());
859 ui->checkBoxTemplateAllFields->setEnabled(
860 ui->checkBoxUseTemplate->isChecked());
861}
862
863void ConfigDialog::onProfileTableItemChanged(QTableWidgetItem *item) {
864 validate(item);
865}
866
871void ConfigDialog::useTemplate(bool useTemplate) {
872 ui->checkBoxUseTemplate->setChecked(useTemplate);
873 on_checkBoxUseTemplate_clicked();
874}
The ConfigDialog handles the configuration interface.
Definition: configdialog.h:24
void setPasswordConfiguration(const PasswordConfiguration &config)
PasswordConfiguration getPasswordConfiguration()
void useOtp(bool useOtp)
ConfigDialog::useOtp set preference for using otp plugin.
void genKey(QString, QDialog *)
ConfigDialog::genKey tunnel function to make MainWindow generate a gpg key pair.
~ConfigDialog()
ConfigDialog::~ConfigDialog config destructor, makes sure the mainWindow knows about git,...
void useGit(bool useGit)
ConfigDialog::useGit set preference for using git.
void useAutoclearPanel(bool useAutoclearPanel)
ConfigDialog::useAutoclearPanel set the panel autoclear use from MainWindow.
QHash< QString, QHash< QString, QString > > getProfiles()
ConfigDialog::getProfiles return profile list.
void useAutoclear(bool useAutoclear)
ConfigDialog::useAutoclear set the clipboard autoclear use from MainWindow.
void useQrencode(bool useQrencode)
ConfigDialog::useOtp set preference for using otp plugin.
void useTemplate(bool useTemplate)
ConfigDialog::useTemplate set preference for using templates.
ConfigDialog(MainWindow *parent)
ConfigDialog::ConfigDialog this sets up the configuration screen.
void closeEvent(QCloseEvent *event)
ConfigDialog::closeEvent close this window.
void useTrayIcon(bool useSystray)
ConfigDialog::useTrayIcon set preference for using trayicon. Enable or disable related checkboxes acc...
void usePwgen(bool usePwgen)
ConfigDialog::usePwgen set preference for using pwgen (can be overruled buy empty pwgenPath)....
void wizard()
ConfigDialog::wizard first-time use wizard.
void setPwgenPath(QString)
ConfigDialog::setPwgenPath set pwgen executable path. Enable or disable related options in the interf...
void useSelection(bool useSelection)
ConfigDialog::useSelection set the clipboard type use from MainWindow.
Handles GPG keypair generation.
Definition: keygendialog.h:16
The MainWindow class does way too much, not only is it a switchboard, configuration handler and more,...
Definition: mainwindow.h:37
void passGitInitNeeded()
void generateKeyPair(QString, QDialog *)
MainWindow::generateKeyPair internal gpg keypair generator . .
Definition: mainwindow.cpp:753
void userDialog(QString="")
MainWindow::userDialog see MainWindow::onUsers()
Definition: mainwindow.cpp:709
QList< UserInfo > listKeys(QStringList keystrings, bool secret=false)
Pass::listKeys list users.
Definition: pass.cpp:130
static void setStartMinimized(const bool &startMinimized)
static bool isUseAutoclearPanel(const bool &defaultValue=QVariant().toBool())
static void setAutoclearPanelSeconds(const int &autoClearPanelSeconds)
static void setPassExecutable(const QString &passExecutable)
static bool isUseSymbols(const bool &defaultValue=QVariant().toBool())
static void setHidePassword(const bool &hidePassword)
static bool isUseTemplate(const bool &defaultValue=QVariant().toBool())
static void setPwgenExecutable(const QString &pwgenExecutable)
static bool isTemplateAllFields(const bool &defaultValue=QVariant().toBool())
static int getAutoclearPanelSeconds(const int &defaultValue=QVariant().toInt())
static void setUseTrayIcon(const bool &useTrayIcon)
static bool isUseOtp(const bool &defaultValue=QVariant().toBool())
static bool isLessRandom(const bool &defaultValue=QVariant().toBool())
static void setPassStore(const QString &passStore)
static void setPasswordConfiguration(const PasswordConfiguration &config)
static bool isUseGit(const bool &defaultValue=QVariant().toBool())
static void setHideOnClose(const bool &hideOnClose)
static bool isUsePass(const bool &defaultValue=QVariant().toBool())
static bool isAlwaysOnTop(const bool &defaultValue=QVariant().toBool())
static QString getPassTemplate(const QString &defaultValue=QVariant().toString())
static void setGitExecutable(const QString &gitExecutable)
static void setUseOtp(const bool &useOtp)
static int getAutoclearSeconds(const int &defaultValue=QVariant().toInt())
static void setProfiles(const QHash< QString, QHash< QString, QString > > &profiles)
static QString getProfile(const QString &defaultValue=QVariant().toString())
static void setUsePwgen(const bool &usePwgen)
static bool isHideOnClose(const bool &defaultValue=QVariant().toBool())
static bool isAvoidNumbers(const bool &defaultValue=QVariant().toBool())
static QString getPwgenExecutable(const QString &defaultValue=QVariant().toString())
static bool isAutoPull(const bool &defaultValue=QVariant().toBool())
static bool isUseTrayIcon(const bool &defaultValue=QVariant().toBool())
static bool isDisplayAsIs(const bool &defaultValue=QVariant().toBool())
static QHash< QString, QHash< QString, QString > > getProfiles()
static void setUseTemplate(const bool &useTemplate)
static bool isUsePwgen(const bool &defaultValue=QVariant().toBool())
static bool isAvoidCapitals(const bool &defaultValue=QVariant().toBool())
static void setAutoPull(const bool &autoPull)
static void setPassTemplate(const QString &passTemplate)
static void setGpgExecutable(const QString &gpgExecutable)
static bool isStartMinimized(const bool &defaultValue=QVariant().toBool())
static void setVersion(const QString &version)
static void setUseAutoclear(const bool &useAutoclear)
static void setAlwaysOnTop(const bool &alwaysOnTop)
static QString getGpgExecutable(const QString &defaultValue=QVariant().toString())
static void setDisplayAsIs(const bool &displayAsIs)
static void setUseMonospace(const bool &useMonospace)
static Pass * getPass()
static void setAvoidCapitals(const bool &avoidCapitals)
static PasswordConfiguration getPasswordConfiguration()
static void setQrencodeExecutable(const QString &qrencodeExecutable)
static void setAddGPGId(const bool &addGPGId)
static void setUsePass(const bool &usePass)
static bool isUseMonospace(const bool &defaultValue=QVariant().toBool())
static bool isUseQrencode(const bool &defaultValue=QVariant().toBool())
static int getClipBoardTypeRaw(const Enums::clipBoardType &defaultvalue=Enums::CLIPBOARD_NEVER)
static bool isAutoPush(const bool &defaultValue=QVariant().toBool())
static bool isHideContent(const bool &defaultValue=QVariant().toBool())
static QString getPassStore(const QString &defaultValue=QVariant().toString())
static void setUseAutoclearPanel(const bool &useAutoclearPanel)
static void setAutoclearSeconds(const int &autoClearSeconds)
static void setNoLineWrapping(const bool &noLineWrapping)
static void setUseQrencode(const bool &useQrencode)
static bool isNoLineWrapping(const bool &defaultValue=QVariant().toBool())
static void setAvoidNumbers(const bool &avoidNumbers)
static void setAutoPush(const bool &autoPush)
static void setClipBoardType(const int &clipBoardType)
static bool isUseAutoclear(const bool &defaultValue=QVariant().toBool())
static void setLessRandom(const bool &lessRandom)
static void setHideContent(const bool &hideContent)
static QString getPassExecutable(const QString &defaultValue=QVariant().toString())
static QString getGitExecutable(const QString &defaultValue=QVariant().toString())
static void setUseSelection(const bool &useSelection)
static void setTemplateAllFields(const bool &templateAllFields)
static void setUseSymbols(const bool &useSymbols)
static bool isAddGPGId(const bool &defaultValue=QVariant().toBool())
static bool isHidePassword(const bool &defaultValue=QVariant().toBool())
static bool isUseSelection(const bool &defaultValue=QVariant().toBool())
static void setUseGit(const bool &useGit)
static bool checkConfig()
Util::checkConfig do we have prequisite settings?
Definition: util.cpp:142
static QString normalizeFolderPath(QString path)
Util::normalizeFolderPath let's always end folders with a QDir::separator()
Definition: util.cpp:79
static QString findBinaryInPath(QString binary)
Util::findBinaryInPath search for executables.
Definition: util.cpp:90
#define dbg()
Definition: debughelper.h:7
Definition: configdialog.h:9
Holds the Password configuration settings.
int length
Length of the password.
enum PasswordConfiguration::characterSet selected
characterSet
The selected character set.
QString Characters[CHARSETS_COUNT]
The different character sets.
Stores key info lines including validity, creation date and more.
Definition: userinfo.h:11
QString name
UserInfo::name full name.
Definition: userinfo.h:32