QtPass  1.2.3
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() == true) {
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->label_10->hide();
66 #endif
67 
68  if (!isPassOtpAvailable()) {
69  ui->checkBoxUseOtp->setEnabled(false);
70  ui->checkBoxUseOtp->setToolTip(
71  tr("Pass OTP extension needs to be installed"));
72  }
73 
77 
78  usePass(QtPassSettings::isUsePass());
83 
85 
88 
89  ui->profileTable->verticalHeader()->hide();
90  ui->profileTable->horizontalHeader()->setStretchLastSection(true);
91  ui->label->setText(ui->label->text() + VERSION);
92  ui->comboBoxClipboard->clear();
93 
94  ui->comboBoxClipboard->addItem(tr("No Clipboard"));
95  ui->comboBoxClipboard->addItem(tr("Always copy to clipboard"));
96  ui->comboBoxClipboard->addItem(tr("On-demand copy to clipboard"));
97 
98  int currentIndex = QtPassSettings::getClipBoardTypeRaw();
99  ui->comboBoxClipboard->setCurrentIndex(currentIndex);
100  on_comboBoxClipboard_activated(currentIndex);
101 
102  QClipboard *clip = QApplication::clipboard();
103  if (!clip->supportsSelection()) {
104  useSelection(false);
105  ui->checkBoxSelection->setVisible(false);
106  } else {
108  }
109 
110  if (Util::checkConfig()) {
111  // Show Programs tab, which is likely
112  // what the user needs to fix now.
113  ui->tabWidget->setCurrentIndex(1);
114  }
115 
116  connect(ui->profileTable, &QTableWidget::itemChanged, this,
117  &ConfigDialog::onProfileTableItemChanged);
118  connect(this, &ConfigDialog::accepted, this, &ConfigDialog::on_accepted);
119 }
120 
126  QtPassSettings::setGitExecutable(ui->gitPath->text());
127  QtPassSettings::setGpgExecutable(ui->gpgPath->text());
128  QtPassSettings::setPassExecutable(ui->passPath->text());
129 }
130 
136 void ConfigDialog::setGitPath(QString path) {
137  ui->gitPath->setText(path);
138  ui->checkBoxUseGit->setEnabled(!path.isEmpty());
139  if (path.isEmpty()) {
140  useGit(false);
141  }
142 }
143 
149 void ConfigDialog::usePass(bool usePass) {
150  ui->radioButtonNative->setChecked(!usePass);
151  ui->radioButtonPass->setChecked(usePass);
152  setGroupBoxState();
153 }
154 
155 void ConfigDialog::validate(QTableWidgetItem *item) {
156  bool status = true;
157 
158  if (item == nullptr) {
159  for (int i = 0; i < ui->profileTable->rowCount(); i++) {
160  for (int j = 0; j < ui->profileTable->columnCount(); j++) {
161  QTableWidgetItem *_item = ui->profileTable->item(i, j);
162 
163  if (_item->text().isEmpty()) {
164  _item->setBackgroundColor(Qt::red);
165  status = false;
166  break;
167  }
168  }
169 
170  if (!status)
171  break;
172  }
173  } else {
174  if (item->text().isEmpty()) {
175  item->setBackgroundColor(Qt::red);
176  status = false;
177  }
178  }
179 
180  ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status);
181 }
182 
183 void ConfigDialog::on_accepted() {
184  QtPassSettings::setPassExecutable(ui->passPath->text());
185  QtPassSettings::setGitExecutable(ui->gitPath->text());
186  QtPassSettings::setGpgExecutable(ui->gpgPath->text());
188  Util::normalizeFolderPath(ui->storePath->text()));
189  QtPassSettings::setUsePass(ui->radioButtonPass->isChecked());
190  QtPassSettings::setClipBoardType(ui->comboBoxClipboard->currentIndex());
191  QtPassSettings::setUseSelection(ui->checkBoxSelection->isChecked());
192  QtPassSettings::setUseAutoclear(ui->checkBoxAutoclear->isChecked());
193  QtPassSettings::setAutoclearSeconds(ui->spinBoxAutoclearSeconds->value());
194  QtPassSettings::setUseAutoclearPanel(ui->checkBoxAutoclearPanel->isChecked());
196  ui->spinBoxAutoclearPanelSeconds->value());
197  QtPassSettings::setHidePassword(ui->checkBoxHidePassword->isChecked());
198  QtPassSettings::setHideContent(ui->checkBoxHideContent->isChecked());
199  QtPassSettings::setAddGPGId(ui->checkBoxAddGPGId->isChecked());
200  QtPassSettings::setUseTrayIcon(ui->checkBoxUseTrayIcon->isEnabled() &&
201  ui->checkBoxUseTrayIcon->isChecked());
202  QtPassSettings::setHideOnClose(ui->checkBoxHideOnClose->isEnabled() &&
203  ui->checkBoxHideOnClose->isChecked());
204  QtPassSettings::setStartMinimized(ui->checkBoxStartMinimized->isEnabled() &&
205  ui->checkBoxStartMinimized->isChecked());
207  QtPassSettings::setUseGit(ui->checkBoxUseGit->isChecked());
208  QtPassSettings::setUseOtp(ui->checkBoxUseOtp->isChecked());
209  QtPassSettings::setPwgenExecutable(ui->pwgenPath->text());
210  QtPassSettings::setUsePwgen(ui->checkBoxUsePwgen->isChecked());
211  QtPassSettings::setAvoidCapitals(ui->checkBoxAvoidCapitals->isChecked());
212  QtPassSettings::setAvoidNumbers(ui->checkBoxAvoidNumbers->isChecked());
213  QtPassSettings::setLessRandom(ui->checkBoxLessRandom->isChecked());
214  QtPassSettings::setUseSymbols(ui->checkBoxUseSymbols->isChecked());
216  QtPassSettings::setUseTemplate(ui->checkBoxUseTemplate->isChecked());
217  QtPassSettings::setPassTemplate(ui->plainTextEditTemplate->toPlainText());
219  ui->checkBoxTemplateAllFields->isChecked());
220  QtPassSettings::setAutoPush(ui->checkBoxAutoPush->isChecked());
221  QtPassSettings::setAutoPull(ui->checkBoxAutoPull->isChecked());
222  QtPassSettings::setAlwaysOnTop(ui->checkBoxAlwaysOnTop->isChecked());
223 
225 }
226 
227 void ConfigDialog::on_autodetectButton_clicked() {
228  QString pass = Util::findBinaryInPath("pass");
229  if (!pass.isEmpty())
230  ui->passPath->setText(pass);
231  usePass(!pass.isEmpty());
232  QString gpg = Util::findBinaryInPath("gpg2");
233  if (gpg.isEmpty())
234  gpg = Util::findBinaryInPath("gpg");
235  if (!gpg.isEmpty())
236  ui->gpgPath->setText(gpg);
237  QString git = Util::findBinaryInPath("git");
238  if (!git.isEmpty())
239  ui->gitPath->setText(git);
240  QString pwgen = Util::findBinaryInPath("pwgen");
241  if (!pwgen.isEmpty())
242  ui->pwgenPath->setText(pwgen);
243 }
244 
249 void ConfigDialog::on_radioButtonNative_clicked() { setGroupBoxState(); }
250 
255 void ConfigDialog::on_radioButtonPass_clicked() { setGroupBoxState(); }
256 
261 QStringList ConfigDialog::getSecretKeys() {
262  QList<UserInfo> keys = QtPassSettings::getPass()->listKeys("", true);
263  QStringList names;
264 
265  if (keys.size() == 0)
266  return names;
267 
268  foreach (const UserInfo &sec, keys)
269  names << sec.name;
270 
271  return names;
272 }
273 
277 void ConfigDialog::setGroupBoxState() {
278  bool state = ui->radioButtonPass->isChecked();
279  ui->groupBoxNative->setEnabled(!state);
280  ui->groupBoxPass->setEnabled(state);
281 }
282 
287 QString ConfigDialog::selectExecutable() {
288  QFileDialog dialog(this);
289  dialog.setFileMode(QFileDialog::ExistingFile);
290  dialog.setOption(QFileDialog::ReadOnly);
291  if (dialog.exec())
292  return dialog.selectedFiles().first();
293  else
294  return QString();
295 }
296 
301 QString ConfigDialog::selectFolder() {
302  QFileDialog dialog(this);
303  dialog.setFileMode(QFileDialog::Directory);
304  dialog.setFilter(QDir::NoFilter);
305  dialog.setOption(QFileDialog::ShowDirsOnly);
306  if (dialog.exec())
307  return dialog.selectedFiles().first();
308  else
309  return QString();
310 }
311 
316 void ConfigDialog::on_toolButtonGit_clicked() {
317  QString git = selectExecutable();
318  bool state = !git.isEmpty();
319  if (state) {
320  ui->gitPath->setText(git);
321  } else {
322  useGit(false);
323  }
324 
325  ui->checkBoxUseGit->setEnabled(state);
326 }
327 
331 void ConfigDialog::on_toolButtonGpg_clicked() {
332  QString gpg = selectExecutable();
333  if (!gpg.isEmpty())
334  ui->gpgPath->setText(gpg);
335 }
336 
340 void ConfigDialog::on_toolButtonPass_clicked() {
341  QString pass = selectExecutable();
342  if (!pass.isEmpty())
343  ui->passPath->setText(pass);
344 }
345 
350 void ConfigDialog::on_toolButtonStore_clicked() {
351  QString store = selectFolder();
352  if (!store.isEmpty()) // TODO(annejan) call check
353  ui->storePath->setText(store);
354 }
355 
360 void ConfigDialog::on_comboBoxClipboard_activated(int index) {
361  bool state = index > 0;
362 
363  ui->checkBoxSelection->setEnabled(state);
364  ui->checkBoxAutoclear->setEnabled(state);
365  ui->checkBoxHidePassword->setEnabled(state);
366  ui->checkBoxHideContent->setEnabled(state);
367  if (state) {
368  ui->spinBoxAutoclearSeconds->setEnabled(ui->checkBoxAutoclear->isChecked());
369  ui->labelSeconds->setEnabled(ui->checkBoxAutoclear->isChecked());
370  } else {
371  ui->spinBoxAutoclearSeconds->setEnabled(false);
372  ui->labelSeconds->setEnabled(false);
373  }
374 }
375 
380 void ConfigDialog::on_checkBoxAutoclearPanel_clicked() {
381  bool state = ui->checkBoxAutoclearPanel->isChecked();
382  ui->spinBoxAutoclearPanelSeconds->setEnabled(state);
383  ui->labelPanelSeconds->setEnabled(state);
384 }
385 
391 void ConfigDialog::useSelection(bool useSelection) {
392  ui->checkBoxSelection->setChecked(useSelection);
393  on_checkBoxSelection_clicked();
394 }
395 
401 void ConfigDialog::useAutoclear(bool useAutoclear) {
402  ui->checkBoxAutoclear->setChecked(useAutoclear);
403  on_checkBoxAutoclear_clicked();
404 }
405 
411 void ConfigDialog::useAutoclearPanel(bool useAutoclearPanel) {
412  ui->checkBoxAutoclearPanel->setChecked(useAutoclearPanel);
413  on_checkBoxAutoclearPanel_clicked();
414 }
415 
420 void ConfigDialog::on_checkBoxSelection_clicked() {
421  on_comboBoxClipboard_activated(ui->comboBoxClipboard->currentIndex());
422 }
423 
428 void ConfigDialog::on_checkBoxAutoclear_clicked() {
429  on_comboBoxClipboard_activated(ui->comboBoxClipboard->currentIndex());
430 }
431 
439 void ConfigDialog::genKey(QString batch, QDialog *dialog) {
440  mainWindow->generateKeyPair(batch, dialog);
441 }
442 
449 void ConfigDialog::setProfiles(QHash<QString, QString> profiles,
450  QString profile) {
451  // dbg()<< profiles;
452  if (profiles.contains("")) {
453  profiles.remove("");
454  // remove weird "" key value pairs
455  }
456 
457  ui->profileTable->setRowCount(profiles.count());
458  QHashIterator<QString, QString> i(profiles);
459  int n = 0;
460  while (i.hasNext()) {
461  i.next();
462  if (!i.value().isEmpty() && !i.key().isEmpty()) {
463  ui->profileTable->setItem(n, 0, new QTableWidgetItem(i.key()));
464  ui->profileTable->setItem(n, 1, new QTableWidgetItem(i.value()));
465  // dbg()<< "naam:" + i.key();
466  if (i.key() == profile)
467  ui->profileTable->selectRow(n);
468  }
469  ++n;
470  }
471 }
472 
477 QHash<QString, QString> ConfigDialog::getProfiles() {
478  QHash<QString, QString> profiles;
479  // Check?
480  for (int i = 0; i < ui->profileTable->rowCount(); ++i) {
481  QTableWidgetItem *pathItem = ui->profileTable->item(i, 1);
482  if (nullptr != pathItem) {
483  QTableWidgetItem *item = ui->profileTable->item(i, 0);
484  if (item == nullptr) {
485  continue;
486  }
487  profiles.insert(item->text(), pathItem->text());
488  }
489  }
490  return profiles;
491 }
492 
496 void ConfigDialog::on_addButton_clicked() {
497  int n = ui->profileTable->rowCount();
498  ui->profileTable->insertRow(n);
499  ui->profileTable->setItem(n, 0, new QTableWidgetItem());
500  ui->profileTable->setItem(n, 1, new QTableWidgetItem(ui->storePath->text()));
501  ui->profileTable->selectRow(n);
502  ui->deleteButton->setEnabled(true);
503 
504  validate();
505 }
506 
510 void ConfigDialog::on_deleteButton_clicked() {
511  QSet<int> selectedRows; // we use a set to prevent doubles
512  QList<QTableWidgetItem *> itemList = ui->profileTable->selectedItems();
513  if (itemList.count() == 0) {
514  QMessageBox::warning(this, tr("No profile selected"),
515  tr("No profile selected to delete"));
516  return;
517  }
518  QTableWidgetItem *item;
519  foreach (item, itemList)
520  selectedRows.insert(item->row());
521  // get a list, and sort it big to small
522  QList<int> rows = selectedRows.toList();
523  qSort(rows.begin(), rows.end());
524  // now actually do the removing:
525  foreach (int row, rows)
526  ui->profileTable->removeRow(row);
527  if (ui->profileTable->rowCount() < 1)
528  ui->deleteButton->setEnabled(false);
529 
530  validate();
531 }
532 
539 void ConfigDialog::criticalMessage(const QString &title, const QString &text) {
540  QMessageBox::critical(this, title, text, QMessageBox::Ok, QMessageBox::Ok);
541 }
542 
543 bool ConfigDialog::isPassOtpAvailable() {
544 #ifdef Q_OS_WIN
545  return false;
546 #elif defined(__APPLE__)
547  return false;
548 #else
549  QFileInfo file("/usr/lib/password-store/extensions/otp.bash");
550 
551  return file.exists();
552 #endif
553 }
554 
560  // mainWindow->checkConfig();
561  bool clean = false;
562 
563  QString gpg = ui->gpgPath->text();
564  // QString gpg = mainWindow->getGpgExecutable();
565  if (!gpg.startsWith("wsl ") && !QFile(gpg).exists()) {
566  criticalMessage(
567  tr("GnuPG not found"),
568  tr("Please install GnuPG on your system.<br>Install "
569  "<strong>gpg</strong> using your favorite package manager<br>or "
570  "<a "
571  "href=\"https://www.gnupg.org/download/#sec-1-2\">download</a> it "
572  "from GnuPG.org"));
573  clean = true;
574  }
575 
576  QStringList names = getSecretKeys();
577 
578 #ifdef QT_DEBUG
579  dbg() << names;
580 #endif
581 
582  if ((gpg.startsWith("wsl ") || QFile(gpg).exists()) && names.empty()) {
583  KeygenDialog d(this);
584  if (!d.exec())
585  return;
586  }
587 
588  QString passStore = ui->storePath->text();
589 
590  if (!QFile(passStore).exists()) {
591  // TODO(annejan) pass version?
592  if (QMessageBox::question(
593  this, tr("Create password-store?"),
594  tr("Would you like to create a password-store at %1?")
595  .arg(passStore),
596  QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
597  QDir().mkdir(passStore);
598 #ifdef Q_OS_WIN
599  SetFileAttributes(passStore.toStdWString().c_str(),
600  FILE_ATTRIBUTE_HIDDEN);
601 #endif
602  if (ui->checkBoxUseGit->isChecked())
603  emit mainWindow->passGitInitNeeded();
604  mainWindow->userDialog(passStore);
605  }
606  }
607 
608  if (!QFile(QDir(passStore).filePath(".gpg-id")).exists()) {
609 #ifdef QT_DEBUG
610  dbg() << ".gpg-id file does not exist";
611 #endif
612  if (!clean) {
613  criticalMessage(tr("Password store not initialised"),
614  tr("The folder %1 doesn't seem to be a password store or "
615  "is not yet initialised.")
616  .arg(passStore));
617  }
618  while (!QFile(passStore).exists()) {
619  on_toolButtonStore_clicked();
620  // allow user to cancel
621  if (passStore == ui->storePath->text())
622  return;
623  passStore = ui->storePath->text();
624  }
625  if (!QFile(passStore + ".gpg-id").exists()) {
626 #ifdef QT_DEBUG
627  dbg() << ".gpg-id file still does not exist :/";
628 #endif
629  // appears not to be store
630  // init yes / no ?
631  mainWindow->userDialog(passStore);
632  }
633  }
634 }
635 
641 void ConfigDialog::useTrayIcon(bool useSystray) {
642  if (QSystemTrayIcon::isSystemTrayAvailable() == true) {
643  ui->checkBoxUseTrayIcon->setChecked(useSystray);
644  ui->checkBoxHideOnClose->setEnabled(useSystray);
645  ui->checkBoxStartMinimized->setEnabled(useSystray);
646 
647  if (!useSystray) {
648  ui->checkBoxHideOnClose->setChecked(false);
649  ui->checkBoxStartMinimized->setChecked(false);
650  }
651  }
652 }
653 
658 void ConfigDialog::on_checkBoxUseTrayIcon_clicked() {
659  bool state = ui->checkBoxUseTrayIcon->isChecked();
660  ui->checkBoxHideOnClose->setEnabled(state);
661  ui->checkBoxStartMinimized->setEnabled(state);
662 }
663 
668 void ConfigDialog::closeEvent(QCloseEvent *event) {
669  // TODO(annejan) save window size or something?
670  event->accept();
671 }
672 
677 void ConfigDialog::useGit(bool useGit) {
678  ui->checkBoxUseGit->setChecked(useGit);
679  on_checkBoxUseGit_clicked();
680 }
681 
686 void ConfigDialog::useOtp(bool useOtp) {
687  ui->checkBoxUseOtp->setChecked(useOtp);
688 }
689 
694 void ConfigDialog::on_checkBoxUseGit_clicked() {
695  ui->checkBoxAddGPGId->setEnabled(ui->checkBoxUseGit->isChecked());
696  ui->checkBoxAutoPull->setEnabled(ui->checkBoxUseGit->isChecked());
697  ui->checkBoxAutoPush->setEnabled(ui->checkBoxUseGit->isChecked());
698 }
699 
704 void ConfigDialog::on_toolButtonPwgen_clicked() {
705  QString pwgen = selectExecutable();
706  if (!pwgen.isEmpty()) {
707  ui->pwgenPath->setText(pwgen);
708  ui->checkBoxUsePwgen->setEnabled(true);
709  } else {
710  ui->checkBoxUsePwgen->setEnabled(false);
711  ui->checkBoxUsePwgen->setChecked(false);
712  }
713 }
714 
720 void ConfigDialog::setPwgenPath(QString pwgen) {
721  ui->pwgenPath->setText(pwgen);
722  if (pwgen.isEmpty()) {
723  ui->checkBoxUsePwgen->setChecked(false);
724  ui->checkBoxUsePwgen->setEnabled(false);
725  }
726  on_checkBoxUsePwgen_clicked();
727 }
728 
733 void ConfigDialog::on_checkBoxUsePwgen_clicked() {
734  bool usePwgen = ui->checkBoxUsePwgen->isChecked();
735  ui->checkBoxAvoidCapitals->setEnabled(usePwgen);
736  ui->checkBoxAvoidNumbers->setEnabled(usePwgen);
737  ui->checkBoxLessRandom->setEnabled(usePwgen);
738  ui->checkBoxUseSymbols->setEnabled(usePwgen);
739  ui->lineEditPasswordChars->setEnabled(!usePwgen);
740  ui->labelPasswordChars->setEnabled(!usePwgen);
741  ui->passwordCharTemplateSelector->setEnabled(!usePwgen);
742 }
743 
751 void ConfigDialog::usePwgen(bool usePwgen) {
752  if (ui->pwgenPath->text().isEmpty())
753  usePwgen = false;
754  ui->checkBoxUsePwgen->setChecked(usePwgen);
755  on_checkBoxUsePwgen_clicked();
756 }
757 
759  const PasswordConfiguration &config) {
760  ui->spinBoxPasswordLength->setValue(config.length);
761  ui->passwordCharTemplateSelector->setCurrentIndex(config.selected);
763  ui->lineEditPasswordChars->setEnabled(false);
764  ui->lineEditPasswordChars->setText(config.Characters[config.selected]);
765 }
766 
768  PasswordConfiguration config;
769  config.length = ui->spinBoxPasswordLength->value();
770  config.selected = static_cast<PasswordConfiguration::characterSet>(
771  ui->passwordCharTemplateSelector->currentIndex());
773  ui->lineEditPasswordChars->text();
774  return config;
775 }
776 
783 void ConfigDialog::on_passwordCharTemplateSelector_activated(int index) {
784  ui->lineEditPasswordChars->setText(
785  QtPassSettings::getPasswordConfiguration().Characters[index]);
786  if (index == 3) {
787  ui->lineEditPasswordChars->setEnabled(true);
788  } else {
789  ui->lineEditPasswordChars->setEnabled(false);
790  }
791 }
792 
797 void ConfigDialog::on_checkBoxUseTemplate_clicked() {
798  ui->plainTextEditTemplate->setEnabled(ui->checkBoxUseTemplate->isChecked());
799  ui->checkBoxTemplateAllFields->setEnabled(
800  ui->checkBoxUseTemplate->isChecked());
801 }
802 
803 void ConfigDialog::onProfileTableItemChanged(QTableWidgetItem *item) {
804  validate(item);
805 }
806 
811 void ConfigDialog::useTemplate(bool useTemplate) {
812  ui->checkBoxUseTemplate->setChecked(useTemplate);
813  on_checkBoxUseTemplate_clicked();
814 }
static void setPwgenExecutable(const QString &pwgenExecutable)
void passGitInitNeeded()
static void setAutoclearSeconds(const int &autoClearSeconds)
QHash< QString, QString > getProfiles()
ConfigDialog::getProfiles return profile list.
static int getAutoclearSeconds(const int &defaultValue=QVariant().toInt())
static void setUsePwgen(const bool &usePwgen)
static bool isStartMinimized(const bool &defaultValue=QVariant().toBool())
void setPasswordConfiguration(const PasswordConfiguration &config)
~ConfigDialog()
ConfigDialog::~ConfigDialog config destructor, makes sure the mainWindow knows about git...
static void setUsePass(const bool &usePass)
static bool isLessRandom(const bool &defaultValue=QVariant().toBool())
static void setPassExecutable(const QString &passExecutable)
int length
Length of the password.
QList< UserInfo > listKeys(QStringList keystring, bool secret=false)
Pass::listKeys list users.
Definition: pass.cpp:128
void useOtp(bool useOtp)
ConfigDialog::useOtp set preference for using otp plugin.
#define dbg()
Definition: debughelper.h:7
static bool isAlwaysOnTop(const bool &defaultValue=QVariant().toBool())
Holds the Password configuration settings.
Definition: configdialog.h:9
static QString findBinaryInPath(QString binary)
Util::findBinaryInPath search for executables.
Definition: util.cpp:79
static void setAutoPush(const bool &autoPush)
static void setGitExecutable(const QString &gitExecutable)
static void setAlwaysOnTop(const bool &alwaysOnTop)
static bool isUseSelection(const bool &defaultValue=QVariant().toBool())
Handles GPG keypair generation.
Definition: keygendialog.h:16
static void setPassTemplate(const QString &passTemplate)
ConfigDialog(MainWindow *parent)
ConfigDialog::ConfigDialog this sets up the configuration screen.
static void setUseGit(const bool &useGit)
static bool isAvoidNumbers(const bool &defaultValue=QVariant().toBool())
void useGit(bool useGit)
ConfigDialog::useGit set preference for using git.
static void setPasswordConfiguration(const PasswordConfiguration &config)
static void setHideContent(const bool &hideContent)
static bool isUseAutoclearPanel(const bool &defaultValue=QVariant().toBool())
static void setLessRandom(const bool &lessRandom)
static void setAutoPull(const bool &autoPull)
static bool isAddGPGId(const bool &defaultValue=QVariant().toBool())
static bool isUseAutoclear(const bool &defaultValue=QVariant().toBool())
static bool isHideOnClose(const bool &defaultValue=QVariant().toBool())
static void setProfiles(const QHash< QString, QString > &profiles)
static bool isUseGit(const bool &defaultValue=QVariant().toBool())
void useAutoclearPanel(bool useAutoclearPanel)
ConfigDialog::useAutoclearPanel set the panel autoclear use from MainWindow.
static QString getPassStore(const QString &defaultValue=QVariant().toString())
void userDialog(QString="")
MainWindow::userDialog see MainWindow::onUsers()
Definition: mainwindow.cpp:684
void useAutoclear(bool useAutoclear)
ConfigDialog::useAutoclear set the clipboard autoclear use from MainWindow.
static QString getGitExecutable(const QString &defaultValue=QVariant().toString())
enum PasswordConfiguration::characterSet selected
static void setAutoclearPanelSeconds(const int &autoClearPanelSeconds)
void genKey(QString, QDialog *)
ConfigDialog::genKey tunnel function to make MainWindow generate a gpg key pair.
static void setUseAutoclearPanel(const bool &useAutoclearPanel)
void wizard()
ConfigDialog::wizard first-time use wizard.
static bool isUseTrayIcon(const bool &defaultValue=QVariant().toBool())
static bool isUseOtp(const bool &defaultValue=QVariant().toBool())
static void setAvoidNumbers(const bool &avoidNumbers)
static QString getPassExecutable(const QString &defaultValue=QVariant().toString())
static void setHideOnClose(const bool &hideOnClose)
static bool isAvoidCapitals(const bool &defaultValue=QVariant().toBool())
void closeEvent(QCloseEvent *event)
ConfigDialog::closeEvent close this window.
void usePwgen(bool usePwgen)
ConfigDialog::usePwgen set preference for using pwgen (can be overruled buy empty pwgenPath)...
static Pass * getPass()
static void setGpgExecutable(const QString &gpgExecutable)
void useSelection(bool useSelection)
ConfigDialog::useSelection set the clipboard type use from MainWindow.
static void setStartMinimized(const bool &startMinimized)
static bool isUsePwgen(const bool &defaultValue=QVariant().toBool())
static void setUseAutoclear(const bool &useAutoclear)
static QString getPassTemplate(const QString &defaultValue=QVariant().toString())
static QString getPwgenExecutable(const QString &defaultValue=QVariant().toString())
static void setUseOtp(const bool &useOtp)
static bool isUseSymbols(const bool &defaultValue=QVariant().toBool())
void useTemplate(bool useTemplate)
ConfigDialog::useTemplate set preference for using templates.
The ConfigDialog handles the configuration interface.
Definition: configdialog.h:24
QString name
UserInfo::name full name.
Definition: userinfo.h:32
Stores key info lines including validity, creation date and more.
Definition: userinfo.h:11
static void setUseTemplate(const bool &useTemplate)
static int getAutoclearPanelSeconds(const int &defaultValue=QVariant().toInt())
static void setAddGPGId(const bool &addGPGId)
static QString getGpgExecutable(const QString &defaultValue=QVariant().toString())
static bool isUseTemplate(const bool &defaultValue=QVariant().toBool())
static bool isTemplateAllFields(const bool &defaultValue=QVariant().toBool())
static void setUseSymbols(const bool &useSymbols)
QString Characters[CHARSETS_COUNT]
The different character sets.
static void setTemplateAllFields(const bool &templateAllFields)
static QHash< QString, QString > getProfiles()
static void setUseTrayIcon(const bool &useTrayIcon)
static PasswordConfiguration getPasswordConfiguration()
PasswordConfiguration getPasswordConfiguration()
static void setClipBoardType(const int &clipBoardType)
void generateKeyPair(QString, QDialog *)
MainWindow::generateKeyPair internal gpg keypair generator . .
Definition: mainwindow.cpp:726
The MainWindow class does way too much, not only is it a switchboard, configuration handler and more...
Definition: mainwindow.h:39
static bool isHidePassword(const bool &defaultValue=QVariant().toBool())
static bool isHideContent(const bool &defaultValue=QVariant().toBool())
static bool checkConfig()
Util::checkConfig do we have prequisite settings?
Definition: util.cpp:131
static QString getProfile(const QString &defaultValue=QVariant().toString())
void setPwgenPath(QString)
ConfigDialog::setPwgenPath set pwgen executable path. Enable or disable related options in the interf...
static void setVersion(const QString &version)
static void setHidePassword(const bool &hidePassword)
static void setPassStore(const QString &passStore)
static void setUseSelection(const bool &useSelection)
void useTrayIcon(bool useTrayIdon)
ConfigDialog::useTrayIcon set preference for using trayicon. Enable or disable related checkboxes acc...
static bool isUsePass(const bool &defaultValue=QVariant().toBool())
static bool isAutoPull(const bool &defaultValue=QVariant().toBool())
static QString normalizeFolderPath(QString path)
Util::normalizeFolderPath let&#39;s always end folders with a QDir::separator()
Definition: util.cpp:68
characterSet
The selected character set.
static bool isAutoPush(const bool &defaultValue=QVariant().toBool())
static int getClipBoardTypeRaw(const Enums::clipBoardType &defaultvalue=Enums::CLIPBOARD_NEVER)
static void setAvoidCapitals(const bool &avoidCapitals)