QtPass  1.3.2
Multi-platform GUI for pass, the standard unix password manager.
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 <QClipboard>
7 #include <QDir>
8 #include <QFileDialog>
9 #include <QMessageBox>
10 #include <QPushButton>
11 #include <QSystemTrayIcon>
12 #include <QTableWidgetItem>
13 #ifdef Q_OS_WIN
14 #include <windows.h>
15 #endif
16 
17 #ifdef QT_DEBUG
18 #include "debughelper.h"
19 #endif
20 
26  : QDialog(parent), ui(new Ui::ConfigDialog) {
27  mainWindow = parent;
28  ui->setupUi(this);
29 
30  ui->passPath->setText(QtPassSettings::getPassExecutable());
32  ui->gpgPath->setText(QtPassSettings::getGpgExecutable());
33  ui->storePath->setText(QtPassSettings::getPassStore());
34 
35  ui->spinBoxAutoclearSeconds->setValue(QtPassSettings::getAutoclearSeconds());
36  ui->spinBoxAutoclearPanelSeconds->setValue(
38  ui->checkBoxHidePassword->setChecked(QtPassSettings::isHidePassword());
39  ui->checkBoxHideContent->setChecked(QtPassSettings::isHideContent());
40  ui->checkBoxAddGPGId->setChecked(QtPassSettings::isAddGPGId(true));
41 
42  if (QSystemTrayIcon::isSystemTrayAvailable()) {
43  ui->checkBoxHideOnClose->setChecked(QtPassSettings::isHideOnClose());
44  ui->checkBoxStartMinimized->setChecked(QtPassSettings::isStartMinimized());
45  } else {
46  ui->checkBoxUseTrayIcon->setEnabled(false);
47  ui->checkBoxUseTrayIcon->setToolTip(tr("System tray is not available"));
48  ui->checkBoxHideOnClose->setEnabled(false);
49  ui->checkBoxStartMinimized->setEnabled(false);
50  }
51 
52  ui->checkBoxAvoidCapitals->setChecked(QtPassSettings::isAvoidCapitals());
53  ui->checkBoxAvoidNumbers->setChecked(QtPassSettings::isAvoidNumbers());
54  ui->checkBoxLessRandom->setChecked(QtPassSettings::isLessRandom());
55  ui->checkBoxUseSymbols->setChecked(QtPassSettings::isUseSymbols());
56  ui->plainTextEditTemplate->setPlainText(QtPassSettings::getPassTemplate());
57  ui->checkBoxTemplateAllFields->setChecked(
59  ui->checkBoxAutoPull->setChecked(QtPassSettings::isAutoPull());
60  ui->checkBoxAutoPush->setChecked(QtPassSettings::isAutoPush());
61  ui->checkBoxAlwaysOnTop->setChecked(QtPassSettings::isAlwaysOnTop());
62 
63 #if defined(Q_OS_WIN) || defined(__APPLE__)
64  ui->checkBoxUseOtp->hide();
65  ui->checkBoxUseQrencode->hide();
66  ui->label_10->hide();
67 #endif
68 
69  if (!isPassOtpAvailable()) {
70  ui->checkBoxUseOtp->setEnabled(false);
71  ui->checkBoxUseOtp->setToolTip(
72  tr("Pass OTP extension needs to be installed"));
73  }
74 
75  if (!isQrencodeAvailable()) {
76  ui->checkBoxUseQrencode->setEnabled(false);
77  ui->checkBoxUseQrencode->setToolTip(tr("qrencode needs to be installed"));
78  }
79 
83 
84  usePass(QtPassSettings::isUsePass());
89 
92 
95 
96  ui->profileTable->verticalHeader()->hide();
97  ui->profileTable->horizontalHeader()->setStretchLastSection(true);
98  ui->label->setText(ui->label->text() + VERSION);
99  ui->comboBoxClipboard->clear();
100 
101  ui->comboBoxClipboard->addItem(tr("No Clipboard"));
102  ui->comboBoxClipboard->addItem(tr("Always copy to clipboard"));
103  ui->comboBoxClipboard->addItem(tr("On-demand copy to clipboard"));
104 
105  int currentIndex = QtPassSettings::getClipBoardTypeRaw();
106  ui->comboBoxClipboard->setCurrentIndex(currentIndex);
107  on_comboBoxClipboard_activated(currentIndex);
108 
109  QClipboard *clip = QApplication::clipboard();
110  if (!clip->supportsSelection()) {
111  useSelection(false);
112  ui->checkBoxSelection->setVisible(false);
113  } else {
115  }
116 
117  if (Util::checkConfig()) {
118  // Show Programs tab, which is likely
119  // what the user needs to fix now.
120  ui->tabWidget->setCurrentIndex(1);
121  }
122 
123  connect(ui->profileTable, &QTableWidget::itemChanged, this,
124  &ConfigDialog::onProfileTableItemChanged);
125  connect(this, &ConfigDialog::accepted, this, &ConfigDialog::on_accepted);
126 }
127 
133  QtPassSettings::setGitExecutable(ui->gitPath->text());
134  QtPassSettings::setGpgExecutable(ui->gpgPath->text());
135  QtPassSettings::setPassExecutable(ui->passPath->text());
136 }
137 
143 void ConfigDialog::setGitPath(QString path) {
144  ui->gitPath->setText(path);
145  ui->checkBoxUseGit->setEnabled(!path.isEmpty());
146  if (path.isEmpty()) {
147  useGit(false);
148  }
149 }
150 
156 void ConfigDialog::usePass(bool usePass) {
157  ui->radioButtonNative->setChecked(!usePass);
158  ui->radioButtonPass->setChecked(usePass);
159  setGroupBoxState();
160 }
161 
162 void ConfigDialog::validate(QTableWidgetItem *item) {
163  bool status = true;
164 
165  if (item == nullptr) {
166  for (int i = 0; i < ui->profileTable->rowCount(); i++) {
167  for (int j = 0; j < ui->profileTable->columnCount(); j++) {
168  QTableWidgetItem *_item = ui->profileTable->item(i, j);
169 
170  if (_item->text().isEmpty()) {
171  _item->setBackground(Qt::red);
172  status = false;
173  break;
174  }
175  }
176 
177  if (!status)
178  break;
179  }
180  } else {
181  if (item->text().isEmpty()) {
182  item->setBackground(Qt::red);
183  status = false;
184  }
185  }
186 
187  ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status);
188 }
189 
190 void ConfigDialog::on_accepted() {
191  QtPassSettings::setPassExecutable(ui->passPath->text());
192  QtPassSettings::setGitExecutable(ui->gitPath->text());
193  QtPassSettings::setGpgExecutable(ui->gpgPath->text());
195  Util::normalizeFolderPath(ui->storePath->text()));
196  QtPassSettings::setUsePass(ui->radioButtonPass->isChecked());
197  QtPassSettings::setClipBoardType(ui->comboBoxClipboard->currentIndex());
198  QtPassSettings::setUseSelection(ui->checkBoxSelection->isChecked());
199  QtPassSettings::setUseAutoclear(ui->checkBoxAutoclear->isChecked());
200  QtPassSettings::setAutoclearSeconds(ui->spinBoxAutoclearSeconds->value());
201  QtPassSettings::setUseAutoclearPanel(ui->checkBoxAutoclearPanel->isChecked());
203  ui->spinBoxAutoclearPanelSeconds->value());
204  QtPassSettings::setHidePassword(ui->checkBoxHidePassword->isChecked());
205  QtPassSettings::setHideContent(ui->checkBoxHideContent->isChecked());
206  QtPassSettings::setAddGPGId(ui->checkBoxAddGPGId->isChecked());
207  QtPassSettings::setUseTrayIcon(ui->checkBoxUseTrayIcon->isEnabled() &&
208  ui->checkBoxUseTrayIcon->isChecked());
209  QtPassSettings::setHideOnClose(ui->checkBoxHideOnClose->isEnabled() &&
210  ui->checkBoxHideOnClose->isChecked());
211  QtPassSettings::setStartMinimized(ui->checkBoxStartMinimized->isEnabled() &&
212  ui->checkBoxStartMinimized->isChecked());
214  QtPassSettings::setUseGit(ui->checkBoxUseGit->isChecked());
215  QtPassSettings::setUseOtp(ui->checkBoxUseOtp->isChecked());
216  QtPassSettings::setUseQrencode(ui->checkBoxUseQrencode->isChecked());
217  QtPassSettings::setPwgenExecutable(ui->pwgenPath->text());
218  QtPassSettings::setUsePwgen(ui->checkBoxUsePwgen->isChecked());
219  QtPassSettings::setAvoidCapitals(ui->checkBoxAvoidCapitals->isChecked());
220  QtPassSettings::setAvoidNumbers(ui->checkBoxAvoidNumbers->isChecked());
221  QtPassSettings::setLessRandom(ui->checkBoxLessRandom->isChecked());
222  QtPassSettings::setUseSymbols(ui->checkBoxUseSymbols->isChecked());
224  QtPassSettings::setUseTemplate(ui->checkBoxUseTemplate->isChecked());
225  QtPassSettings::setPassTemplate(ui->plainTextEditTemplate->toPlainText());
227  ui->checkBoxTemplateAllFields->isChecked());
228  QtPassSettings::setAutoPush(ui->checkBoxAutoPush->isChecked());
229  QtPassSettings::setAutoPull(ui->checkBoxAutoPull->isChecked());
230  QtPassSettings::setAlwaysOnTop(ui->checkBoxAlwaysOnTop->isChecked());
231 
233 }
234 
235 void ConfigDialog::on_autodetectButton_clicked() {
236  QString pass = Util::findBinaryInPath("pass");
237  if (!pass.isEmpty())
238  ui->passPath->setText(pass);
239  usePass(!pass.isEmpty());
240  QString gpg = Util::findBinaryInPath("gpg2");
241  if (gpg.isEmpty())
242  gpg = Util::findBinaryInPath("gpg");
243  if (!gpg.isEmpty())
244  ui->gpgPath->setText(gpg);
245  QString git = Util::findBinaryInPath("git");
246  if (!git.isEmpty())
247  ui->gitPath->setText(git);
248  QString pwgen = Util::findBinaryInPath("pwgen");
249  if (!pwgen.isEmpty())
250  ui->pwgenPath->setText(pwgen);
251 }
252 
257 void ConfigDialog::on_radioButtonNative_clicked() { setGroupBoxState(); }
258 
263 void ConfigDialog::on_radioButtonPass_clicked() { setGroupBoxState(); }
264 
269 QStringList ConfigDialog::getSecretKeys() {
270  QList<UserInfo> keys = QtPassSettings::getPass()->listKeys("", true);
271  QStringList names;
272 
273  if (keys.empty())
274  return names;
275 
276  foreach (const UserInfo &sec, keys)
277  names << sec.name;
278 
279  return names;
280 }
281 
285 void ConfigDialog::setGroupBoxState() {
286  bool state = ui->radioButtonPass->isChecked();
287  ui->groupBoxNative->setEnabled(!state);
288  ui->groupBoxPass->setEnabled(state);
289 }
290 
295 QString ConfigDialog::selectExecutable() {
296  QFileDialog dialog(this);
297  dialog.setFileMode(QFileDialog::ExistingFile);
298  dialog.setOption(QFileDialog::ReadOnly);
299  if (dialog.exec())
300  return dialog.selectedFiles().first();
301 
302  return QString();
303 }
304 
309 QString ConfigDialog::selectFolder() {
310  QFileDialog dialog(this);
311  dialog.setFileMode(QFileDialog::Directory);
312  dialog.setFilter(QDir::NoFilter);
313  dialog.setOption(QFileDialog::ShowDirsOnly);
314  if (dialog.exec())
315  return dialog.selectedFiles().first();
316 
317  return QString();
318 }
319 
324 void ConfigDialog::on_toolButtonGit_clicked() {
325  QString git = selectExecutable();
326  bool state = !git.isEmpty();
327  if (state) {
328  ui->gitPath->setText(git);
329  } else {
330  useGit(false);
331  }
332 
333  ui->checkBoxUseGit->setEnabled(state);
334 }
335 
339 void ConfigDialog::on_toolButtonGpg_clicked() {
340  QString gpg = selectExecutable();
341  if (!gpg.isEmpty())
342  ui->gpgPath->setText(gpg);
343 }
344 
348 void ConfigDialog::on_toolButtonPass_clicked() {
349  QString pass = selectExecutable();
350  if (!pass.isEmpty())
351  ui->passPath->setText(pass);
352 }
353 
358 void ConfigDialog::on_toolButtonStore_clicked() {
359  QString store = selectFolder();
360  if (!store.isEmpty()) // TODO(annejan) call check
361  ui->storePath->setText(store);
362 }
363 
368 void ConfigDialog::on_comboBoxClipboard_activated(int index) {
369  bool state = index > 0;
370 
371  ui->checkBoxSelection->setEnabled(state);
372  ui->checkBoxAutoclear->setEnabled(state);
373  ui->checkBoxHidePassword->setEnabled(state);
374  ui->checkBoxHideContent->setEnabled(state);
375  if (state) {
376  ui->spinBoxAutoclearSeconds->setEnabled(ui->checkBoxAutoclear->isChecked());
377  ui->labelSeconds->setEnabled(ui->checkBoxAutoclear->isChecked());
378  } else {
379  ui->spinBoxAutoclearSeconds->setEnabled(false);
380  ui->labelSeconds->setEnabled(false);
381  }
382 }
383 
388 void ConfigDialog::on_checkBoxAutoclearPanel_clicked() {
389  bool state = ui->checkBoxAutoclearPanel->isChecked();
390  ui->spinBoxAutoclearPanelSeconds->setEnabled(state);
391  ui->labelPanelSeconds->setEnabled(state);
392 }
393 
399 void ConfigDialog::useSelection(bool useSelection) {
400  ui->checkBoxSelection->setChecked(useSelection);
401  on_checkBoxSelection_clicked();
402 }
403 
409 void ConfigDialog::useAutoclear(bool useAutoclear) {
410  ui->checkBoxAutoclear->setChecked(useAutoclear);
411  on_checkBoxAutoclear_clicked();
412 }
413 
419 void ConfigDialog::useAutoclearPanel(bool useAutoclearPanel) {
420  ui->checkBoxAutoclearPanel->setChecked(useAutoclearPanel);
421  on_checkBoxAutoclearPanel_clicked();
422 }
423 
428 void ConfigDialog::on_checkBoxSelection_clicked() {
429  on_comboBoxClipboard_activated(ui->comboBoxClipboard->currentIndex());
430 }
431 
436 void ConfigDialog::on_checkBoxAutoclear_clicked() {
437  on_comboBoxClipboard_activated(ui->comboBoxClipboard->currentIndex());
438 }
439 
447 void ConfigDialog::genKey(QString batch, QDialog *dialog) {
448  mainWindow->generateKeyPair(batch, dialog);
449 }
450 
457 void ConfigDialog::setProfiles(QHash<QString, QString> profiles,
458  QString profile) {
459  // dbg()<< profiles;
460  if (profiles.contains("")) {
461  profiles.remove("");
462  // remove weird "" key value pairs
463  }
464 
465  ui->profileTable->setRowCount(profiles.count());
466  QHashIterator<QString, QString> i(profiles);
467  int n = 0;
468  while (i.hasNext()) {
469  i.next();
470  if (!i.value().isEmpty() && !i.key().isEmpty()) {
471  ui->profileTable->setItem(n, 0, new QTableWidgetItem(i.key()));
472  ui->profileTable->setItem(n, 1, new QTableWidgetItem(i.value()));
473  // dbg()<< "naam:" + i.key();
474  if (i.key() == profile)
475  ui->profileTable->selectRow(n);
476  }
477  ++n;
478  }
479 }
480 
485 QHash<QString, QString> ConfigDialog::getProfiles() {
486  QHash<QString, QString> profiles;
487  // Check?
488  for (int i = 0; i < ui->profileTable->rowCount(); ++i) {
489  QTableWidgetItem *pathItem = ui->profileTable->item(i, 1);
490  if (nullptr != pathItem) {
491  QTableWidgetItem *item = ui->profileTable->item(i, 0);
492  if (item == nullptr) {
493  continue;
494  }
495  profiles.insert(item->text(), pathItem->text());
496  }
497  }
498  return profiles;
499 }
500 
504 void ConfigDialog::on_addButton_clicked() {
505  int n = ui->profileTable->rowCount();
506  ui->profileTable->insertRow(n);
507  ui->profileTable->setItem(n, 0, new QTableWidgetItem());
508  ui->profileTable->setItem(n, 1, new QTableWidgetItem(ui->storePath->text()));
509  ui->profileTable->selectRow(n);
510  ui->deleteButton->setEnabled(true);
511 
512  validate();
513 }
514 
518 void ConfigDialog::on_deleteButton_clicked() {
519  QSet<int> selectedRows; // we use a set to prevent doubles
520  QList<QTableWidgetItem *> itemList = ui->profileTable->selectedItems();
521  if (itemList.count() == 0) {
522  QMessageBox::warning(this, tr("No profile selected"),
523  tr("No profile selected to delete"));
524  return;
525  }
526  QTableWidgetItem *item;
527  foreach (item, itemList)
528  selectedRows.insert(item->row());
529  // get a list, and sort it big to small
530  QList<int> rows = selectedRows.values();
531  std::sort(rows.begin(), rows.end());
532  // now actually do the removing:
533  foreach (int row, rows)
534  ui->profileTable->removeRow(row);
535  if (ui->profileTable->rowCount() < 1)
536  ui->deleteButton->setEnabled(false);
537 
538  validate();
539 }
540 
547 void ConfigDialog::criticalMessage(const QString &title, const QString &text) {
548  QMessageBox::critical(this, title, text, QMessageBox::Ok, QMessageBox::Ok);
549 }
550 
551 bool ConfigDialog::isQrencodeAvailable() {
552 #ifdef Q_OS_WIN
553  return false;
554 #elif defined(__APPLE__)
555  return false;
556 #else
557  QProcess which;
558  which.start("which", QStringList() << "qrencode");
559  which.waitForFinished();
560  return which.exitCode() == 0;
561 #endif
562 }
563 
564 bool ConfigDialog::isPassOtpAvailable() {
565 #ifdef Q_OS_WIN
566  return false;
567 #elif defined(__APPLE__)
568  return false;
569 #else
570  return true;
571 #endif
572 }
573 
580  on_autodetectButton_clicked();
581  bool clean = false;
582 
583  QString gpg = ui->gpgPath->text();
584  if (!gpg.startsWith("wsl ") && !QFile(gpg).exists()) {
585  criticalMessage(
586  tr("GnuPG not found"),
587 #ifdef Q_OS_WIN
588 #ifdef WINSTORE
589  tr("Please install GnuPG on your system.<br>Install "
590  "<strong>Ubuntu</strong> from the Microsoft Store to get it.<br>"
591  "If you already did so, make sure you started it once and<br>"
592  "click \"Autodetect\" in the next dialog.")
593 #else
594  tr("Please install GnuPG on your system.<br>Install "
595  "<strong>Ubuntu</strong> from the Microsoft Store<br>or <a "
596  "href=\"https://www.gnupg.org/download/#sec-1-2\">download</a> it "
597  "from GnuPG.org")
598 #endif
599 #else
600  tr("Please install GnuPG on your system.<br>Install "
601  "<strong>gpg</strong> using your favorite package manager<br>or "
602  "<a "
603  "href=\"https://www.gnupg.org/download/#sec-1-2\">download</a> it "
604  "from GnuPG.org")
605 #endif
606  );
607  clean = true;
608  }
609 
610  QStringList names = getSecretKeys();
611 
612 #ifdef QT_DEBUG
613  dbg() << names;
614 #endif
615 
616  if ((gpg.startsWith("wsl ") || QFile(gpg).exists()) && names.empty()) {
617  KeygenDialog d(this);
618  if (!d.exec())
619  return;
620  }
621 
622  QString passStore = ui->storePath->text();
623 
624  if (!QFile(passStore).exists()) {
625  // TODO(annejan) pass version?
626  if (QMessageBox::question(
627  this, tr("Create password-store?"),
628  tr("Would you like to create a password-store at %1?")
629  .arg(passStore),
630  QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
631  QDir().mkdir(passStore);
632 #ifdef Q_OS_WIN
633  SetFileAttributes(passStore.toStdWString().c_str(),
634  FILE_ATTRIBUTE_HIDDEN);
635 #endif
636  if (ui->checkBoxUseGit->isChecked())
637  emit mainWindow->passGitInitNeeded();
638  mainWindow->userDialog(passStore);
639  }
640  }
641 
642  if (!QFile(QDir(passStore).filePath(".gpg-id")).exists()) {
643 #ifdef QT_DEBUG
644  dbg() << ".gpg-id file does not exist";
645 #endif
646  if (!clean) {
647  criticalMessage(tr("Password store not initialised"),
648  tr("The folder %1 doesn't seem to be a password store or "
649  "is not yet initialised.")
650  .arg(passStore));
651  }
652  while (!QFile(passStore).exists()) {
653  on_toolButtonStore_clicked();
654  // allow user to cancel
655  if (passStore == ui->storePath->text())
656  return;
657  passStore = ui->storePath->text();
658  }
659  if (!QFile(passStore + ".gpg-id").exists()) {
660 #ifdef QT_DEBUG
661  dbg() << ".gpg-id file still does not exist :/";
662 #endif
663  // appears not to be store
664  // init yes / no ?
665  mainWindow->userDialog(passStore);
666  }
667  }
668 }
669 
675 void ConfigDialog::useTrayIcon(bool useSystray) {
676  if (QSystemTrayIcon::isSystemTrayAvailable()) {
677  ui->checkBoxUseTrayIcon->setChecked(useSystray);
678  ui->checkBoxHideOnClose->setEnabled(useSystray);
679  ui->checkBoxStartMinimized->setEnabled(useSystray);
680 
681  if (!useSystray) {
682  ui->checkBoxHideOnClose->setChecked(false);
683  ui->checkBoxStartMinimized->setChecked(false);
684  }
685  }
686 }
687 
692 void ConfigDialog::on_checkBoxUseTrayIcon_clicked() {
693  bool state = ui->checkBoxUseTrayIcon->isChecked();
694  ui->checkBoxHideOnClose->setEnabled(state);
695  ui->checkBoxStartMinimized->setEnabled(state);
696 }
697 
702 void ConfigDialog::closeEvent(QCloseEvent *event) {
703  // TODO(annejan) save window size or something?
704  event->accept();
705 }
706 
711 void ConfigDialog::useGit(bool useGit) {
712  ui->checkBoxUseGit->setChecked(useGit);
713  on_checkBoxUseGit_clicked();
714 }
715 
720 void ConfigDialog::useOtp(bool useOtp) {
721  ui->checkBoxUseOtp->setChecked(useOtp);
722 }
723 
728 void ConfigDialog::useQrencode(bool useQrencode) {
729  ui->checkBoxUseQrencode->setChecked(useQrencode);
730 }
731 
736 void ConfigDialog::on_checkBoxUseGit_clicked() {
737  ui->checkBoxAddGPGId->setEnabled(ui->checkBoxUseGit->isChecked());
738  ui->checkBoxAutoPull->setEnabled(ui->checkBoxUseGit->isChecked());
739  ui->checkBoxAutoPush->setEnabled(ui->checkBoxUseGit->isChecked());
740 }
741 
746 void ConfigDialog::on_toolButtonPwgen_clicked() {
747  QString pwgen = selectExecutable();
748  if (!pwgen.isEmpty()) {
749  ui->pwgenPath->setText(pwgen);
750  ui->checkBoxUsePwgen->setEnabled(true);
751  } else {
752  ui->checkBoxUsePwgen->setEnabled(false);
753  ui->checkBoxUsePwgen->setChecked(false);
754  }
755 }
756 
762 void ConfigDialog::setPwgenPath(QString pwgen) {
763  ui->pwgenPath->setText(pwgen);
764  if (pwgen.isEmpty()) {
765  ui->checkBoxUsePwgen->setChecked(false);
766  ui->checkBoxUsePwgen->setEnabled(false);
767  }
768  on_checkBoxUsePwgen_clicked();
769 }
770 
775 void ConfigDialog::on_checkBoxUsePwgen_clicked() {
776  bool usePwgen = ui->checkBoxUsePwgen->isChecked();
777  ui->checkBoxAvoidCapitals->setEnabled(usePwgen);
778  ui->checkBoxAvoidNumbers->setEnabled(usePwgen);
779  ui->checkBoxLessRandom->setEnabled(usePwgen);
780  ui->checkBoxUseSymbols->setEnabled(usePwgen);
781  ui->lineEditPasswordChars->setEnabled(!usePwgen);
782  ui->labelPasswordChars->setEnabled(!usePwgen);
783  ui->passwordCharTemplateSelector->setEnabled(!usePwgen);
784 }
785 
793 void ConfigDialog::usePwgen(bool usePwgen) {
794  if (ui->pwgenPath->text().isEmpty())
795  usePwgen = false;
796  ui->checkBoxUsePwgen->setChecked(usePwgen);
797  on_checkBoxUsePwgen_clicked();
798 }
799 
801  const PasswordConfiguration &config) {
802  ui->spinBoxPasswordLength->setValue(config.length);
803  ui->passwordCharTemplateSelector->setCurrentIndex(config.selected);
805  ui->lineEditPasswordChars->setEnabled(false);
806  ui->lineEditPasswordChars->setText(config.Characters[config.selected]);
807 }
808 
810  PasswordConfiguration config;
811  config.length = ui->spinBoxPasswordLength->value();
812  config.selected = static_cast<PasswordConfiguration::characterSet>(
813  ui->passwordCharTemplateSelector->currentIndex());
815  ui->lineEditPasswordChars->text();
816  return config;
817 }
818 
825 void ConfigDialog::on_passwordCharTemplateSelector_activated(int index) {
826  ui->lineEditPasswordChars->setText(
827  QtPassSettings::getPasswordConfiguration().Characters[index]);
828  if (index == 3) {
829  ui->lineEditPasswordChars->setEnabled(true);
830  } else {
831  ui->lineEditPasswordChars->setEnabled(false);
832  }
833 }
834 
839 void ConfigDialog::on_checkBoxUseTemplate_clicked() {
840  ui->plainTextEditTemplate->setEnabled(ui->checkBoxUseTemplate->isChecked());
841  ui->checkBoxTemplateAllFields->setEnabled(
842  ui->checkBoxUseTemplate->isChecked());
843 }
844 
845 void ConfigDialog::onProfileTableItemChanged(QTableWidgetItem *item) {
846  validate(item);
847 }
848 
853 void ConfigDialog::useTemplate(bool useTemplate) {
854  ui->checkBoxUseTemplate->setChecked(useTemplate);
855  on_checkBoxUseTemplate_clicked();
856 }
QtPassSettings::getGitExecutable
static QString getGitExecutable(const QString &defaultValue=QVariant().toString())
Definition: qtpasssettings.cpp:305
QtPassSettings::getClipBoardTypeRaw
static int getClipBoardTypeRaw(const Enums::clipBoardType &defaultvalue=Enums::CLIPBOARD_NEVER)
Definition: qtpasssettings.cpp:163
QtPassSettings::setUseSymbols
static void setUseSymbols(const bool &useSymbols)
Definition: qtpasssettings.cpp:449
ConfigDialog::setPasswordConfiguration
void setPasswordConfiguration(const PasswordConfiguration &config)
Definition: configdialog.cpp:800
Util::normalizeFolderPath
static QString normalizeFolderPath(QString path)
Util::normalizeFolderPath let's always end folders with a QDir::separator()
Definition: util.cpp:79
QtPassSettings::setStartMinimized
static void setStartMinimized(const bool &startMinimized)
Definition: qtpasssettings.cpp:488
QtPassSettings::setAutoclearSeconds
static void setAutoclearSeconds(const int &autoClearSeconds)
Definition: qtpasssettings.cpp:201
ConfigDialog::useTemplate
void useTemplate(bool useTemplate)
ConfigDialog::useTemplate set preference for using templates.
Definition: configdialog.cpp:853
QtPassSettings::isLessRandom
static bool isLessRandom(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:435
QtPassSettings::setUsePass
static void setUsePass(const bool &usePass)
Definition: qtpasssettings.cpp:154
PasswordConfiguration::characterSet
characterSet
The selected character set.
Definition: passwordconfiguration.h:14
QtPassSettings::getPwgenExecutable
static QString getPwgenExecutable(const QString &defaultValue=QVariant().toString())
Definition: qtpasssettings.cpp:323
ConfigDialog::useQrencode
void useQrencode(bool useQrencode)
ConfigDialog::useOtp set preference for using otp plugin.
Definition: configdialog.cpp:728
keygendialog.h
MainWindow::userDialog
void userDialog(QString="")
MainWindow::userDialog see MainWindow::onUsers()
Definition: mainwindow.cpp:686
QtPassSettings::isHideOnClose
static bool isHideOnClose(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:474
PasswordConfiguration::CUSTOM
@ CUSTOM
Definition: passwordconfiguration.h:18
ConfigDialog::useOtp
void useOtp(bool useOtp)
ConfigDialog::useOtp set preference for using otp plugin.
Definition: configdialog.cpp:720
PasswordConfiguration::length
int length
Length of the password.
Definition: passwordconfiguration.h:24
QtPassSettings::getPassTemplate
static QString getPassTemplate(const QString &defaultValue=QVariant().toString())
Definition: qtpasssettings.cpp:519
QtPassSettings::isUseTrayIcon
static bool isUseTrayIcon(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:465
Pass::listKeys
QList< UserInfo > listKeys(QStringList keystrings, bool secret=false)
Pass::listKeys list users.
Definition: pass.cpp:128
QtPassSettings::getGpgExecutable
static QString getGpgExecutable(const QString &defaultValue=QVariant().toString())
Definition: qtpasssettings.cpp:314
QtPassSettings::getPassExecutable
static QString getPassExecutable(const QString &defaultValue=QVariant().toString())
Definition: qtpasssettings.cpp:296
QtPassSettings::getPasswordConfiguration
static PasswordConfiguration getPasswordConfiguration()
Definition: qtpasssettings.cpp:35
ConfigDialog::useGit
void useGit(bool useGit)
ConfigDialog::useGit set preference for using git.
Definition: configdialog.cpp:711
Util::findBinaryInPath
static QString findBinaryInPath(QString binary)
Util::findBinaryInPath search for executables.
Definition: util.cpp:90
ConfigDialog::getProfiles
QHash< QString, QString > getProfiles()
ConfigDialog::getProfiles return profile list.
Definition: configdialog.cpp:485
QtPassSettings::isUsePwgen
static bool isUsePwgen(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:408
debughelper.h
ConfigDialog::useTrayIcon
void useTrayIcon(bool useSystray)
ConfigDialog::useTrayIcon set preference for using trayicon. Enable or disable related checkboxes acc...
Definition: configdialog.cpp:675
QtPassSettings::setUsePwgen
static void setUsePwgen(const bool &usePwgen)
Definition: qtpasssettings.cpp:413
KeygenDialog
Handles GPG keypair generation.
Definition: keygendialog.h:16
QtPassSettings::isUseAutoclearPanel
static bool isUseAutoclearPanel(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:206
ConfigDialog::genKey
void genKey(QString, QDialog *)
ConfigDialog::genKey tunnel function to make MainWindow generate a gpg key pair.
Definition: configdialog.cpp:447
QtPassSettings::setUseTrayIcon
static void setUseTrayIcon(const bool &useTrayIcon)
Definition: qtpasssettings.cpp:470
ConfigDialog::wizard
void wizard()
ConfigDialog::wizard first-time use wizard.
Definition: configdialog.cpp:578
QtPassSettings::setAvoidCapitals
static void setAvoidCapitals(const bool &avoidCapitals)
Definition: qtpasssettings.cpp:422
QtPassSettings::isAddGPGId
static bool isAddGPGId(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:245
QtPassSettings::setVersion
static void setVersion(const QString &version)
Definition: qtpasssettings.cpp:104
QtPassSettings::isTemplateAllFields
static bool isTemplateAllFields(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:537
QtPassSettings::isAutoPush
static bool isAutoPush(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:510
QtPassSettings::setHideOnClose
static void setHideOnClose(const bool &hideOnClose)
Definition: qtpasssettings.cpp:479
QtPassSettings::setUseSelection
static void setUseSelection(const bool &useSelection)
Definition: qtpasssettings.cpp:183
QtPassSettings::setTemplateAllFields
static void setTemplateAllFields(const bool &templateAllFields)
Definition: qtpasssettings.cpp:542
QtPassSettings::isUsePass
static bool isUsePass(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:149
QtPassSettings::setUseAutoclearPanel
static void setUseAutoclearPanel(const bool &useAutoclearPanel)
Definition: qtpasssettings.cpp:211
ConfigDialog::setPwgenPath
void setPwgenPath(QString)
ConfigDialog::setPwgenPath set pwgen executable path. Enable or disable related options in the interf...
Definition: configdialog.cpp:762
QtPassSettings::setProfiles
static void setProfiles(const QHash< QString, QString > &profiles)
Definition: qtpasssettings.cpp:75
ConfigDialog
The ConfigDialog handles the configuration interface.
Definition: configdialog.h:24
ConfigDialog::closeEvent
void closeEvent(QCloseEvent *event)
ConfigDialog::closeEvent close this window.
Definition: configdialog.cpp:702
QtPassSettings::getPass
static Pass * getPass()
Definition: qtpasssettings.cpp:87
QtPassSettings::isStartMinimized
static bool isStartMinimized(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:483
PasswordConfiguration::selected
enum PasswordConfiguration::characterSet selected
QtPassSettings::isHideContent
static bool isHideContent(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:236
QtPassSettings::setClipBoardType
static void setClipBoardType(const int &clipBoardType)
Definition: qtpasssettings.cpp:174
QtPassSettings::setHidePassword
static void setHidePassword(const bool &hidePassword)
Definition: qtpasssettings.cpp:232
QtPassSettings::getProfile
static QString getProfile(const QString &defaultValue=QVariant().toString())
Definition: qtpasssettings.cpp:374
QtPassSettings::setAddGPGId
static void setAddGPGId(const bool &addGPGId)
Definition: qtpasssettings.cpp:250
QtPassSettings::isUseTemplate
static bool isUseTemplate(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:528
QtPassSettings::setAutoPush
static void setAutoPush(const bool &autoPush)
Definition: qtpasssettings.cpp:515
MainWindow::generateKeyPair
void generateKeyPair(QString, QDialog *)
MainWindow::generateKeyPair internal gpg keypair generator . .
Definition: mainwindow.cpp:730
QtPassSettings::isUseGit
static bool isUseGit(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:383
QtPassSettings::setUseTemplate
static void setUseTemplate(const bool &useTemplate)
Definition: qtpasssettings.cpp:533
ConfigDialog::ConfigDialog
ConfigDialog(MainWindow *parent)
ConfigDialog::ConfigDialog this sets up the configuration screen.
Definition: configdialog.cpp:25
QtPassSettings::isAutoPull
static bool isAutoPull(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:501
QtPassSettings::setAlwaysOnTop
static void setAlwaysOnTop(const bool &alwaysOnTop)
Definition: qtpasssettings.cpp:497
QtPassSettings::setPwgenExecutable
static void setPwgenExecutable(const QString &pwgenExecutable)
Definition: qtpasssettings.cpp:328
QtPassSettings::isUseQrencode
static bool isUseQrencode(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:398
QtPassSettings::isAvoidCapitals
static bool isAvoidCapitals(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:417
ConfigDialog::~ConfigDialog
~ConfigDialog()
ConfigDialog::~ConfigDialog config destructor, makes sure the mainWindow knows about git,...
Definition: configdialog.cpp:132
QtPassSettings::isAvoidNumbers
static bool isAvoidNumbers(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:426
QtPassSettings::setPasswordConfiguration
static void setPasswordConfiguration(const PasswordConfiguration &config)
Definition: qtpasssettings.cpp:52
QtPassSettings::getAutoclearPanelSeconds
static int getAutoclearPanelSeconds(const int &defaultValue=QVariant().toInt())
Definition: qtpasssettings.cpp:216
Ui
Definition: configdialog.h:9
QtPassSettings::setPassExecutable
static void setPassExecutable(const QString &passExecutable)
Definition: qtpasssettings.cpp:301
ConfigDialog::useSelection
void useSelection(bool useSelection)
ConfigDialog::useSelection set the clipboard type use from MainWindow.
Definition: configdialog.cpp:399
QtPassSettings::setHideContent
static void setHideContent(const bool &hideContent)
Definition: qtpasssettings.cpp:241
QtPassSettings::setGitExecutable
static void setGitExecutable(const QString &gitExecutable)
Definition: qtpasssettings.cpp:310
Util::checkConfig
static bool checkConfig()
Util::checkConfig do we have prequisite settings?
Definition: util.cpp:142
UserInfo::name
QString name
UserInfo::name full name.
Definition: userinfo.h:32
QtPassSettings::setAutoPull
static void setAutoPull(const bool &autoPull)
Definition: qtpasssettings.cpp:506
configdialog.h
QtPassSettings::isUseSymbols
static bool isUseSymbols(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:444
QtPassSettings::setPassStore
static void setPassStore(const QString &passStore)
Definition: qtpasssettings.cpp:275
QtPassSettings::isUseSelection
static bool isUseSelection(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:178
QtPassSettings::setUseOtp
static void setUseOtp(const bool &useOtp)
Definition: qtpasssettings.cpp:394
QtPassSettings::setPassTemplate
static void setPassTemplate(const QString &passTemplate)
Definition: qtpasssettings.cpp:524
QtPassSettings::isUseAutoclear
static bool isUseAutoclear(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:187
PasswordConfiguration
Holds the Password configuration settings.
Definition: passwordconfiguration.h:10
PasswordConfiguration::Characters
QString Characters[CHARSETS_COUNT]
The different character sets.
Definition: passwordconfiguration.h:28
ConfigDialog::useAutoclearPanel
void useAutoclearPanel(bool useAutoclearPanel)
ConfigDialog::useAutoclearPanel set the panel autoclear use from MainWindow.
Definition: configdialog.cpp:419
ConfigDialog::usePwgen
void usePwgen(bool usePwgen)
ConfigDialog::usePwgen set preference for using pwgen (can be overruled buy empty pwgenPath)....
Definition: configdialog.cpp:793
QtPassSettings::getProfiles
static QHash< QString, QString > getProfiles()
Definition: qtpasssettings.cpp:61
QtPassSettings::getAutoclearSeconds
static int getAutoclearSeconds(const int &defaultValue=QVariant().toInt())
Definition: qtpasssettings.cpp:196
dbg
#define dbg()
Definition: debughelper.h:7
QtPassSettings::setLessRandom
static void setLessRandom(const bool &lessRandom)
Definition: qtpasssettings.cpp:440
QtPassSettings::setUseQrencode
static void setUseQrencode(const bool &useQrencode)
Definition: qtpasssettings.cpp:404
MainWindow::passGitInitNeeded
void passGitInitNeeded()
UserInfo
Stores key info lines including validity, creation date and more.
Definition: userinfo.h:11
QtPassSettings::setUseGit
static void setUseGit(const bool &useGit)
Definition: qtpasssettings.cpp:386
QtPassSettings::isUseOtp
static bool isUseOtp(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:390
QtPassSettings::setUseAutoclear
static void setUseAutoclear(const bool &useAutoclear)
Definition: qtpasssettings.cpp:192
MainWindow
The MainWindow class does way too much, not only is it a switchboard, configuration handler and more,...
Definition: mainwindow.h:39
QtPassSettings::getPassStore
static QString getPassStore(const QString &defaultValue=QVariant().toString())
Definition: qtpasssettings.cpp:254
QtPassSettings::setAvoidNumbers
static void setAvoidNumbers(const bool &avoidNumbers)
Definition: qtpasssettings.cpp:431
QtPassSettings::isHidePassword
static bool isHidePassword(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:227
mainwindow.h
ConfigDialog::getPasswordConfiguration
PasswordConfiguration getPasswordConfiguration()
Definition: configdialog.cpp:809
ConfigDialog::useAutoclear
void useAutoclear(bool useAutoclear)
ConfigDialog::useAutoclear set the clipboard autoclear use from MainWindow.
Definition: configdialog.cpp:409
QtPassSettings::isAlwaysOnTop
static bool isAlwaysOnTop(const bool &defaultValue=QVariant().toBool())
Definition: qtpasssettings.cpp:492
qtpasssettings.h
QtPassSettings::setGpgExecutable
static void setGpgExecutable(const QString &gpgExecutable)
Definition: qtpasssettings.cpp:319
QtPassSettings::setAutoclearPanelSeconds
static void setAutoclearPanelSeconds(const int &autoClearPanelSeconds)
Definition: qtpasssettings.cpp:221