QtPass 1.6.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
qtpasssettings.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
3
13
14#include "qtpasssettings.h"
15#include "pass.h"
16
17#include "util.h"
18
19#include <QCoreApplication>
20#include <QCursor>
21#include <QDebug>
22#include <QGuiApplication>
23#include <QScreen>
24#include <utility>
25
26bool QtPassSettings::initialized = false;
27
28Pass *QtPassSettings::pass;
29// Go via pointer to avoid dynamic initialization,
30// due to "random" initialization order relative to other
31// globals, especially around QObject metadata dynamic initialization
32// can lead to crashes depending on compiler, linker etc.
33QScopedPointer<RealPass> QtPassSettings::realPass;
34QScopedPointer<ImitatePass> QtPassSettings::imitatePass;
35
36QtPassSettings *QtPassSettings::m_instance = nullptr;
47auto QtPassSettings::getInstance() -> QtPassSettings * {
48 if (!QtPassSettings::initialized) {
49 QString portable_ini = QCoreApplication::applicationDirPath() +
50 QDir::separator() + "qtpass.ini";
51 if (QFile(portable_ini).exists()) {
52 m_instance = new QtPassSettings(portable_ini, QSettings::IniFormat);
53 } else {
54 m_instance = new QtPassSettings("IJHack", "QtPass");
55 }
56
57 initialized = true;
58 }
59
60 return m_instance;
61}
62
76
77 config.length =
79 if (config.length <= 0) {
80 config.length = 16;
81 }
85 .toInt());
88 ->value(SettingsConstants::passwordChars, QString())
89 .toString();
90
91 return config;
92}
93
102
116auto QtPassSettings::getProfiles() -> QHash<QString, QHash<QString, QString>> {
118 QHash<QString, QHash<QString, QString>> profiles;
119
120 // migration from version <= v1.3.2: profiles datastructure
121 QStringList childKeys = getInstance()->childKeys();
122 if (!childKeys.empty()) {
123 for (const auto &key : std::as_const(childKeys)) {
124 QHash<QString, QString> profile;
125 profile.insert("path", getInstance()->value(key).toString());
126 profile.insert("signingKey", "");
127 profiles.insert(key, profile);
128 }
129 }
130 // /migration from version <= v1.3.2
131
132 QStringList childGroups = getInstance()->childGroups();
133 for (const auto &group : std::as_const(childGroups)) {
134 QHash<QString, QString> profile;
135 profile.insert("path", getInstance()->value(group + "/path").toString());
136 profile.insert("signingKey",
137 getInstance()->value(group + "/signingKey").toString());
138 // profiles.insert(group, getInstance()->value(group).toString());
139 profiles.insert(group, profile);
140 }
141
142 getInstance()->endGroup();
143
144 return profiles;
145}
146
157 const QHash<QString, QHash<QString, QString>> &profiles) {
160
161 QHash<QString, QHash<QString, QString>>::const_iterator i = profiles.begin();
162 for (; i != profiles.end(); ++i) {
163 getInstance()->setValue(i.key() + "/path", i.value().value("path"));
164 getInstance()->setValue(i.key() + "/signingKey",
165 i.value().value("signingKey"));
166 }
167
168 getInstance()->endGroup();
169}
170
172 if (!pass) {
173 if (isUsePass()) {
174 pass = getRealPass();
175 } else {
176 pass = getImitatePass();
177 }
178 if (pass) {
179 pass->init();
180 }
181 }
182 return pass;
183}
184
185auto QtPassSettings::getVersion(const QString &defaultValue) -> QString {
186 return getInstance()
187 ->value(SettingsConstants::version, defaultValue)
188 .toString();
189}
190void QtPassSettings::setVersion(const QString &version) {
191 getInstance()->setValue(SettingsConstants::version, version);
192}
193
194auto QtPassSettings::getGeometry(const QByteArray &defaultValue) -> QByteArray {
195 return getInstance()
196 ->value(SettingsConstants::geometry, defaultValue)
197 .toByteArray();
198}
199void QtPassSettings::setGeometry(const QByteArray &geometry) {
200 getInstance()->setValue(SettingsConstants::geometry, geometry);
201}
202
203auto QtPassSettings::getSavestate(const QByteArray &defaultValue)
204 -> QByteArray {
205 return getInstance()
206 ->value(SettingsConstants::savestate, defaultValue)
207 .toByteArray();
208}
209void QtPassSettings::setSavestate(const QByteArray &saveState) {
210 getInstance()->setValue(SettingsConstants::savestate, saveState);
211}
212
213auto QtPassSettings::getPos(const QPoint &defaultValue) -> QPoint {
214 QPoint pos =
215 getInstance()->value(SettingsConstants::pos, defaultValue).toPoint();
216 if (pos == QPoint(0, 0)) {
217 QScreen *screen = QGuiApplication::screenAt(QCursor::pos());
218 if (!screen)
219 screen = QGuiApplication::primaryScreen();
220 if (screen)
221 pos = screen->geometry().center();
222 }
223 return pos;
224}
225void QtPassSettings::setPos(const QPoint &pos) {
226 if (pos == QPoint(0, 0))
227 return;
228 getInstance()->setValue(SettingsConstants::pos, pos);
229}
230
231auto QtPassSettings::getSize(const QSize &defaultValue) -> QSize {
232 return getInstance()->value(SettingsConstants::size, defaultValue).toSize();
233}
234void QtPassSettings::setSize(const QSize &size) {
235 getInstance()->setValue(SettingsConstants::size, size);
236}
237
238auto QtPassSettings::isMaximized(const bool &defaultValue) -> bool {
239 return getInstance()
240 ->value(SettingsConstants::maximized, defaultValue)
241 .toBool();
242}
243void QtPassSettings::setMaximized(const bool &maximized) {
244 getInstance()->setValue(SettingsConstants::maximized, maximized);
245}
246
247auto QtPassSettings::getDialogGeometry(const QString &key,
248 const QByteArray &defaultValue)
249 -> QByteArray {
250 return getInstance()
251 ->value(SettingsConstants::dialogGeometry + "/" + key, defaultValue)
252 .toByteArray();
253}
254void QtPassSettings::setDialogGeometry(const QString &key,
255 const QByteArray &geometry) {
256 getInstance()->setValue(SettingsConstants::dialogGeometry + "/" + key,
257 geometry);
258}
259
260auto QtPassSettings::getDialogPos(const QString &key,
261 const QPoint &defaultValue) -> QPoint {
262 return getInstance()
263 ->value(SettingsConstants::dialogPos + "/" + key, defaultValue)
264 .toPoint();
265}
266void QtPassSettings::setDialogPos(const QString &key, const QPoint &pos) {
267 getInstance()->setValue(SettingsConstants::dialogPos + "/" + key, pos);
268}
269
270auto QtPassSettings::getDialogSize(const QString &key,
271 const QSize &defaultValue) -> QSize {
272 return getInstance()
273 ->value(SettingsConstants::dialogSize + "/" + key, defaultValue)
274 .toSize();
275}
276void QtPassSettings::setDialogSize(const QString &key, const QSize &size) {
277 getInstance()->setValue(SettingsConstants::dialogSize + "/" + key, size);
278}
279
280auto QtPassSettings::isDialogMaximized(const QString &key,
281 const bool &defaultValue) -> bool {
282 return getInstance()
283 ->value(SettingsConstants::dialogMaximized + "/" + key, defaultValue)
284 .toBool();
285}
287 const bool &maximized) {
288 getInstance()->setValue(SettingsConstants::dialogMaximized + "/" + key,
289 maximized);
290}
291
292auto QtPassSettings::isUsePass(const bool &defaultValue) -> bool {
293 return getInstance()
294 ->value(SettingsConstants::usePass, defaultValue)
295 .toBool();
296}
297void QtPassSettings::setUsePass(const bool &usePass) {
298 getInstance()->setValue(SettingsConstants::usePass, usePass);
299 pass = nullptr;
300}
301
303 const Enums::clipBoardType &defaultValue) -> int {
304 return getInstance()
305 ->value(SettingsConstants::clipBoardType, static_cast<int>(defaultValue))
306 .toInt();
307}
308
311 return static_cast<Enums::clipBoardType>(getClipBoardTypeRaw(defaultValue));
312}
313void QtPassSettings::setClipBoardType(const int &clipBoardType) {
314 getInstance()->setValue(SettingsConstants::clipBoardType, clipBoardType);
315}
316
317auto QtPassSettings::isUseSelection(const bool &defaultValue) -> bool {
318 return getInstance()
319 ->value(SettingsConstants::useSelection, defaultValue)
320 .toBool();
321}
322void QtPassSettings::setUseSelection(const bool &useSelection) {
323 getInstance()->setValue(SettingsConstants::useSelection, useSelection);
324}
325
326auto QtPassSettings::isUseAutoclear(const bool &defaultValue) -> bool {
327 return getInstance()
328 ->value(SettingsConstants::useAutoclear, defaultValue)
329 .toBool();
330}
331void QtPassSettings::setUseAutoclear(const bool &useAutoclear) {
332 getInstance()->setValue(SettingsConstants::useAutoclear, useAutoclear);
333}
334
335auto QtPassSettings::getAutoclearSeconds(const int &defaultValue) -> int {
336 return getInstance()
337 ->value(SettingsConstants::autoclearSeconds, defaultValue)
338 .toInt();
339}
340void QtPassSettings::setAutoclearSeconds(const int &autoClearSeconds) {
342 autoClearSeconds);
343}
344
345auto QtPassSettings::isUseAutoclearPanel(const bool &defaultValue) -> bool {
346 return getInstance()
347 ->value(SettingsConstants::useAutoclearPanel, defaultValue)
348 .toBool();
349}
350void QtPassSettings::setUseAutoclearPanel(const bool &useAutoclearPanel) {
352 useAutoclearPanel);
353}
354
355auto QtPassSettings::getAutoclearPanelSeconds(const int &defaultValue) -> int {
356 return getInstance()
357 ->value(SettingsConstants::autoclearPanelSeconds, defaultValue)
358 .toInt();
359}
361 const int &autoClearPanelSeconds) {
363 autoClearPanelSeconds);
364}
365
366auto QtPassSettings::isHidePassword(const bool &defaultValue) -> bool {
367 return getInstance()
368 ->value(SettingsConstants::hidePassword, defaultValue)
369 .toBool();
370}
371void QtPassSettings::setHidePassword(const bool &hidePassword) {
372 getInstance()->setValue(SettingsConstants::hidePassword, hidePassword);
373}
374
375auto QtPassSettings::isHideContent(const bool &defaultValue) -> bool {
376 return getInstance()
377 ->value(SettingsConstants::hideContent, defaultValue)
378 .toBool();
379}
380void QtPassSettings::setHideContent(const bool &hideContent) {
381 getInstance()->setValue(SettingsConstants::hideContent, hideContent);
382}
383
384auto QtPassSettings::isUseMonospace(const bool &defaultValue) -> bool {
385 return getInstance()
386 ->value(SettingsConstants::useMonospace, defaultValue)
387 .toBool();
388}
389void QtPassSettings::setUseMonospace(const bool &useMonospace) {
390 getInstance()->setValue(SettingsConstants::useMonospace, useMonospace);
391}
392
393auto QtPassSettings::isDisplayAsIs(const bool &defaultValue) -> bool {
394 return getInstance()
395 ->value(SettingsConstants::displayAsIs, defaultValue)
396 .toBool();
397}
398void QtPassSettings::setDisplayAsIs(const bool &displayAsIs) {
399 getInstance()->setValue(SettingsConstants::displayAsIs, displayAsIs);
400}
401
402auto QtPassSettings::isNoLineWrapping(const bool &defaultValue) -> bool {
403 return getInstance()
404 ->value(SettingsConstants::noLineWrapping, defaultValue)
405 .toBool();
406}
407void QtPassSettings::setNoLineWrapping(const bool &noLineWrapping) {
408 getInstance()->setValue(SettingsConstants::noLineWrapping, noLineWrapping);
409}
410
411auto QtPassSettings::isAddGPGId(const bool &defaultValue) -> bool {
412 return getInstance()
413 ->value(SettingsConstants::addGPGId, defaultValue)
414 .toBool();
415}
416void QtPassSettings::setAddGPGId(const bool &addGPGId) {
417 getInstance()->setValue(SettingsConstants::addGPGId, addGPGId);
418}
419
433auto QtPassSettings::getPassStore(const QString &defaultValue) -> QString {
434 QString returnValue = getInstance()
435 ->value(SettingsConstants::passStore, defaultValue)
436 .toString();
437
438 // Normalize the path string
439 returnValue = QDir(returnValue).absolutePath();
440
441 // ensure directory exists if never used pass or misconfigured.
442 // otherwise process->setWorkingDirectory(passStore); will fail on execution.
443 if (!QDir(returnValue).exists()) {
444 if (!QDir().mkdir(returnValue)) {
445 qWarning() << "Failed to create password store directory:" << returnValue;
446 }
447 }
448
449 // ensure path ends in /
450 if (!returnValue.endsWith("/") && !returnValue.endsWith(QDir::separator())) {
451 returnValue += QDir::separator();
452 }
453
454 return returnValue;
455}
456void QtPassSettings::setPassStore(const QString &passStore) {
457 getInstance()->setValue(SettingsConstants::passStore, passStore);
458}
459
460auto QtPassSettings::getPassSigningKey(const QString &defaultValue) -> QString {
461 return getInstance()
462 ->value(SettingsConstants::passSigningKey, defaultValue)
463 .toString();
464}
465void QtPassSettings::setPassSigningKey(const QString &passSigningKey) {
466 getInstance()->setValue(SettingsConstants::passSigningKey, passSigningKey);
467}
468
478 QString passExecutable =
480 QtPassSettings::setPassExecutable(passExecutable);
481
482 QString gitExecutable =
485
486 QString gpgExecutable =
489
490 QString pwgenExecutable =
492 QtPassSettings::setPwgenExecutable(pwgenExecutable);
493}
494auto QtPassSettings::getPassExecutable(const QString &defaultValue) -> QString {
495 return getInstance()
496 ->value(SettingsConstants::passExecutable, defaultValue)
497 .toString();
498}
499void QtPassSettings::setPassExecutable(const QString &passExecutable) {
500 getInstance()->setValue(SettingsConstants::passExecutable, passExecutable);
501}
502
503auto QtPassSettings::getGitExecutable(const QString &defaultValue) -> QString {
504 return getInstance()
505 ->value(SettingsConstants::gitExecutable, defaultValue)
506 .toString();
507}
508void QtPassSettings::setGitExecutable(const QString &gitExecutable) {
509 getInstance()->setValue(SettingsConstants::gitExecutable, gitExecutable);
510}
511
512auto QtPassSettings::getGpgExecutable(const QString &defaultValue) -> QString {
513 return getInstance()
514 ->value(SettingsConstants::gpgExecutable, defaultValue)
515 .toString();
516}
517void QtPassSettings::setGpgExecutable(const QString &gpgExecutable) {
518 getInstance()->setValue(SettingsConstants::gpgExecutable, gpgExecutable);
519}
520
521auto QtPassSettings::getPwgenExecutable(const QString &defaultValue)
522 -> QString {
523 return getInstance()
524 ->value(SettingsConstants::pwgenExecutable, defaultValue)
525 .toString();
526}
527void QtPassSettings::setPwgenExecutable(const QString &pwgenExecutable) {
528 getInstance()->setValue(SettingsConstants::pwgenExecutable, pwgenExecutable);
529}
530
531auto QtPassSettings::getGpgHome(const QString &defaultValue) -> QString {
532 return getInstance()
533 ->value(SettingsConstants::gpgHome, defaultValue)
534 .toString();
535}
536
537auto QtPassSettings::isUseWebDav(const bool &defaultValue) -> bool {
538 return getInstance()
539 ->value(SettingsConstants::useWebDav, defaultValue)
540 .toBool();
541}
542void QtPassSettings::setUseWebDav(const bool &useWebDav) {
543 getInstance()->setValue(SettingsConstants::useWebDav, useWebDav);
544}
545
546auto QtPassSettings::getWebDavUrl(const QString &defaultValue) -> QString {
547 return getInstance()
548 ->value(SettingsConstants::webDavUrl, defaultValue)
549 .toString();
550}
551void QtPassSettings::setWebDavUrl(const QString &webDavUrl) {
552 getInstance()->setValue(SettingsConstants::webDavUrl, webDavUrl);
553}
554
555auto QtPassSettings::getWebDavUser(const QString &defaultValue) -> QString {
556 return getInstance()
557 ->value(SettingsConstants::webDavUser, defaultValue)
558 .toString();
559}
560void QtPassSettings::setWebDavUser(const QString &webDavUser) {
561 getInstance()->setValue(SettingsConstants::webDavUser, webDavUser);
562}
563
564auto QtPassSettings::getWebDavPassword(const QString &defaultValue) -> QString {
565 return getInstance()
566 ->value(SettingsConstants::webDavPassword, defaultValue)
567 .toString();
568}
569void QtPassSettings::setWebDavPassword(const QString &webDavPassword) {
570 getInstance()->setValue(SettingsConstants::webDavPassword, webDavPassword);
571}
572
573auto QtPassSettings::getProfile(const QString &defaultValue) -> QString {
574 return getInstance()
575 ->value(SettingsConstants::profile, defaultValue)
576 .toString();
577}
578void QtPassSettings::setProfile(const QString &profile) {
579 getInstance()->setValue(SettingsConstants::profile, profile);
580}
581
592auto QtPassSettings::isUseGit(const bool &defaultValue) -> bool {
593 bool storedValue =
594 getInstance()->value(SettingsConstants::useGit, defaultValue).toBool();
595 if (storedValue == defaultValue && defaultValue) {
596 QString passStore = getPassStore();
597 if (QFileInfo(passStore).isDir() &&
598 QFileInfo(passStore + QDir::separator() + ".git").isDir()) {
599 return true;
600 }
601 }
602 return storedValue;
603}
604void QtPassSettings::setUseGit(const bool &useGit) {
605 getInstance()->setValue(SettingsConstants::useGit, useGit);
606}
607
608auto QtPassSettings::isUseOtp(const bool &defaultValue) -> bool {
609 return getInstance()->value(SettingsConstants::useOtp, defaultValue).toBool();
610}
611
612void QtPassSettings::setUseOtp(const bool &useOtp) {
613 getInstance()->setValue(SettingsConstants::useOtp, useOtp);
614}
615
616auto QtPassSettings::isUseQrencode(const bool &defaultValue) -> bool {
617 return getInstance()
618 ->value(SettingsConstants::useQrencode, defaultValue)
619 .toBool();
620}
621
622void QtPassSettings::setUseQrencode(const bool &useQrencode) {
623 getInstance()->setValue(SettingsConstants::useQrencode, useQrencode);
624}
625
626auto QtPassSettings::getQrencodeExecutable(const QString &defaultValue)
627 -> QString {
628 return getInstance()
629 ->value(SettingsConstants::qrencodeExecutable, defaultValue)
630 .toString();
631}
632void QtPassSettings::setQrencodeExecutable(const QString &qrencodeExecutable) {
634 qrencodeExecutable);
635}
636
637auto QtPassSettings::isUsePwgen(const bool &defaultValue) -> bool {
638 return getInstance()
639 ->value(SettingsConstants::usePwgen, defaultValue)
640 .toBool();
641}
642void QtPassSettings::setUsePwgen(const bool &usePwgen) {
643 getInstance()->setValue(SettingsConstants::usePwgen, usePwgen);
644}
645
646auto QtPassSettings::isAvoidCapitals(const bool &defaultValue) -> bool {
647 return getInstance()
648 ->value(SettingsConstants::avoidCapitals, defaultValue)
649 .toBool();
650}
651void QtPassSettings::setAvoidCapitals(const bool &avoidCapitals) {
652 getInstance()->setValue(SettingsConstants::avoidCapitals, avoidCapitals);
653}
654
655auto QtPassSettings::isAvoidNumbers(const bool &defaultValue) -> bool {
656 return getInstance()
657 ->value(SettingsConstants::avoidNumbers, defaultValue)
658 .toBool();
659}
660void QtPassSettings::setAvoidNumbers(const bool &avoidNumbers) {
661 getInstance()->setValue(SettingsConstants::avoidNumbers, avoidNumbers);
662}
663
664auto QtPassSettings::isLessRandom(const bool &defaultValue) -> bool {
665 return getInstance()
666 ->value(SettingsConstants::lessRandom, defaultValue)
667 .toBool();
668}
669void QtPassSettings::setLessRandom(const bool &lessRandom) {
670 getInstance()->setValue(SettingsConstants::lessRandom, lessRandom);
671}
672
673auto QtPassSettings::isUseSymbols(const bool &defaultValue) -> bool {
674 return getInstance()
675 ->value(SettingsConstants::useSymbols, defaultValue)
676 .toBool();
677}
678void QtPassSettings::setUseSymbols(const bool &useSymbols) {
679 getInstance()->setValue(SettingsConstants::useSymbols, useSymbols);
680}
681
682void QtPassSettings::setPasswordLength(const int &passwordLength) {
683 getInstance()->setValue(SettingsConstants::passwordLength, passwordLength);
684}
686 const int &passwordCharsSelection) {
688 passwordCharsSelection);
689}
690void QtPassSettings::setPasswordChars(const QString &passwordChars) {
691 getInstance()->setValue(SettingsConstants::passwordChars, passwordChars);
692}
693
694auto QtPassSettings::isUseTrayIcon(const bool &defaultValue) -> bool {
695 return getInstance()
696 ->value(SettingsConstants::useTrayIcon, defaultValue)
697 .toBool();
698}
699void QtPassSettings::setUseTrayIcon(const bool &useTrayIcon) {
700 getInstance()->setValue(SettingsConstants::useTrayIcon, useTrayIcon);
701}
702
703auto QtPassSettings::isHideOnClose(const bool &defaultValue) -> bool {
704 return getInstance()
705 ->value(SettingsConstants::hideOnClose, defaultValue)
706 .toBool();
707}
708void QtPassSettings::setHideOnClose(const bool &hideOnClose) {
709 getInstance()->setValue(SettingsConstants::hideOnClose, hideOnClose);
710}
711
712auto QtPassSettings::isStartMinimized(const bool &defaultValue) -> bool {
713 return getInstance()
714 ->value(SettingsConstants::startMinimized, defaultValue)
715 .toBool();
716}
717void QtPassSettings::setStartMinimized(const bool &startMinimized) {
718 getInstance()->setValue(SettingsConstants::startMinimized, startMinimized);
719}
720
721auto QtPassSettings::isAlwaysOnTop(const bool &defaultValue) -> bool {
722 return getInstance()
723 ->value(SettingsConstants::alwaysOnTop, defaultValue)
724 .toBool();
725}
726void QtPassSettings::setAlwaysOnTop(const bool &alwaysOnTop) {
727 getInstance()->setValue(SettingsConstants::alwaysOnTop, alwaysOnTop);
728}
729
730auto QtPassSettings::isAutoPull(const bool &defaultValue) -> bool {
731 return getInstance()
732 ->value(SettingsConstants::autoPull, defaultValue)
733 .toBool();
734}
735void QtPassSettings::setAutoPull(const bool &autoPull) {
736 getInstance()->setValue(SettingsConstants::autoPull, autoPull);
737}
738
739auto QtPassSettings::isAutoPush(const bool &defaultValue) -> bool {
740 return getInstance()
741 ->value(SettingsConstants::autoPush, defaultValue)
742 .toBool();
743}
744void QtPassSettings::setAutoPush(const bool &autoPush) {
745 getInstance()->setValue(SettingsConstants::autoPush, autoPush);
746}
747
748auto QtPassSettings::getPassTemplate(const QString &defaultValue) -> QString {
749 return getInstance()
750 ->value(SettingsConstants::passTemplate, defaultValue)
751 .toString();
752}
753void QtPassSettings::setPassTemplate(const QString &passTemplate) {
754 getInstance()->setValue(SettingsConstants::passTemplate, passTemplate);
755}
756
757auto QtPassSettings::isUseTemplate(const bool &defaultValue) -> bool {
758 return getInstance()
759 ->value(SettingsConstants::useTemplate, defaultValue)
760 .toBool();
761}
762void QtPassSettings::setUseTemplate(const bool &useTemplate) {
763 getInstance()->setValue(SettingsConstants::useTemplate, useTemplate);
764}
765
766auto QtPassSettings::isTemplateAllFields(const bool &defaultValue) -> bool {
767 return getInstance()
768 ->value(SettingsConstants::templateAllFields, defaultValue)
769 .toBool();
770}
771void QtPassSettings::setTemplateAllFields(const bool &templateAllFields) {
773 templateAllFields);
774}
775
777 if (realPass.isNull()) {
778 realPass.reset(new RealPass());
779 }
780 return realPass.data();
781}
783 if (imitatePass.isNull()) {
784 imitatePass.reset(new ImitatePass());
785 }
786 return imitatePass.data();
787}
Implementation that imitates 'pass' when the real tool is unavailable.
Definition imitatepass.h:23
Abstract base class for password store operations.
Definition pass.h:35
Singleton settings manager implementation.
static auto isUseSelection(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to use selection (X11) for clipboard.
static void setMaximized(const bool &maximized)
Save maximized state.
static void setStartMinimized(const bool &startMinimized)
Save start-minimized flag.
static void setUseWebDav(const bool &useWebDav)
Save WebDAV integration flag.
static auto isUseAutoclear(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to use autoclear for clipboard.
static void setAutoclearPanelSeconds(const int &autoClearPanelSeconds)
Save panel autoclear seconds.
static void setPassExecutable(const QString &passExecutable)
Save pass executable path.
static auto getWebDavPassword(const QString &defaultValue=QVariant().toString()) -> QString
Get WebDAV password.
static auto isStartMinimized(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether application should start minimized.
static void setHidePassword(const bool &hidePassword)
Save hide password setting.
static auto isUseOtp(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether OTP support is enabled.
static void setPwgenExecutable(const QString &pwgenExecutable)
Save pwgen executable path.
static auto getPwgenExecutable(const QString &defaultValue=QVariant().toString()) -> QString
Get pwgen executable path.
static void setProfile(const QString &profile)
Save active profile name.
static void setUseTrayIcon(const bool &useTrayIcon)
Save tray icon support flag.
static void setWebDavPassword(const QString &webDavPassword)
Save WebDAV password.
static auto getInstance() -> QtPassSettings *
Get the singleton instance.
static auto isNoLineWrapping(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to disable line wrapping.
static auto getWebDavUser(const QString &defaultValue=QVariant().toString()) -> QString
Get WebDAV username.
static void setPassStore(const QString &passStore)
Save password store path.
static auto getDialogPos(const QString &key, const QPoint &defaultValue=QVariant().toPoint()) -> QPoint
Get saved dialog position.
static auto isHideContent(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to hide content (password + username).
static void setPasswordConfiguration(const PasswordConfiguration &config)
Save complete password generation configuration.
static auto getSize(const QSize &defaultValue=QVariant().toSize()) -> QSize
Get saved window size.
static void setHideOnClose(const bool &hideOnClose)
Save hide-on-close flag.
static auto getPass() -> Pass *
Get currently active pass backend instance.
static auto getPasswordConfiguration() -> PasswordConfiguration
Get complete password generation configuration.
static auto getGpgHome(const QString &defaultValue=QVariant().toString()) -> QString
Get GPG home directory.
static auto isUseQrencode(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether qrencode support is enabled.
static void setPasswordLength(const int &passwordLength)
Save password length setting.
static auto isUseAutoclearPanel(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to use panel autoclear.
static auto isAutoPull(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether automatic pull is enabled.
static void setGitExecutable(const QString &gitExecutable)
Save git executable path.
static void setPasswordChars(const QString &passwordChars)
Save custom password characters.
static auto isUseGit(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether Git integration is enabled.
static void setUseOtp(const bool &useOtp)
Save OTP support flag.
static void setProfiles(const QHash< QString, QHash< QString, QString > > &profiles)
Save all configured profiles.
static auto getClipBoardType(const Enums::clipBoardType &defaultValue=Enums::CLIPBOARD_NEVER) -> Enums::clipBoardType
Get clipboard type as enum.
static void setUsePwgen(const bool &usePwgen)
Save pwgen support flag.
static auto isTemplateAllFields(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether template applies to all fields.
static void setPassSigningKey(const QString &passSigningKey)
Save GPG signing key.
static auto isUsePass(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to use pass (true) or GPG (false).
static auto getPassStore(const QString &defaultValue=QVariant().toString()) -> QString
Get password store directory path.
static auto getVersion(const QString &defaultValue=QVariant().toString()) -> QString
Get saved application version.
static auto isUseTemplate(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether template usage is enabled.
static auto isUseTrayIcon(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether tray icon support is enabled.
static void initExecutables()
Initialize executable paths by auto-detecting them.
static void setUseTemplate(const bool &useTemplate)
Save template usage flag.
static void setDialogPos(const QString &key, const QPoint &pos)
Save dialog position.
static auto isAvoidCapitals(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether uppercase characters should be avoided.
static auto isAddGPGId(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to auto-add GPG ID when receiving files.
static void setPasswordCharsselection(const int &passwordCharsSelection)
Save password character selection mode.
static auto getGpgExecutable(const QString &defaultValue=QVariant().toString()) -> QString
Get GPG executable path.
static void setAutoPull(const bool &autoPull)
Save automatic pull flag.
static auto getPassSigningKey(const QString &defaultValue=QVariant().toString()) -> QString
Get GPG signing key for pass.
static void setPassTemplate(const QString &passTemplate)
Save pass entry template.
static auto isUseSymbols(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether symbol characters are enabled.
static auto getQrencodeExecutable(const QString &defaultValue=QVariant().toString()) -> QString
Get qrencode executable path.
static auto getDialogSize(const QString &key, const QSize &defaultValue=QVariant().toSize()) -> QSize
Get saved dialog size.
static void setGpgExecutable(const QString &gpgExecutable)
Save GPG executable path.
static void setPos(const QPoint &pos)
Save window position.
static void setVersion(const QString &version)
Save application version.
static void setUseAutoclear(const bool &useAutoclear)
Save use autoclear setting.
static auto getRealPass() -> RealPass *
Get real pass backend instance.
static auto isLessRandom(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether less random password generation is enabled.
static void setAlwaysOnTop(const bool &alwaysOnTop)
Save always-on-top flag.
static auto getPassTemplate(const QString &defaultValue=QVariant().toString()) -> QString
Get pass entry template.
static void setWebDavUser(const QString &webDavUser)
Save WebDAV username.
static void setDisplayAsIs(const bool &displayAsIs)
Save display as-is setting.
static auto isMaximized(const bool &defaultValue=QVariant().toBool()) -> bool
Get maximized state.
static void setUseMonospace(const bool &useMonospace)
Save use monospace setting.
static void setDialogSize(const QString &key, const QSize &size)
Save dialog size.
static void setAvoidCapitals(const bool &avoidCapitals)
Save uppercase avoidance flag.
static void setDialogMaximized(const QString &key, const bool &maximized)
Save dialog maximized state.
static void setQrencodeExecutable(const QString &qrencodeExecutable)
Save qrencode executable path.
static void setWebDavUrl(const QString &webDavUrl)
Save WebDAV URL.
static auto getProfile(const QString &defaultValue=QVariant().toString()) -> QString
Get active profile name.
static auto getWebDavUrl(const QString &defaultValue=QVariant().toString()) -> QString
Get WebDAV URL.
static auto isUseMonospace(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to use monospace font.
static void setAddGPGId(const bool &addGPGId)
Save add GPG ID setting.
static void setUsePass(const bool &usePass)
Save use pass setting.
static auto isUseWebDav(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether WebDAV integration is enabled.
static auto isDialogMaximized(const QString &key, const bool &defaultValue=QVariant().toBool()) -> bool
Get dialog maximized state.
static auto getAutoclearPanelSeconds(const int &defaultValue=QVariant().toInt()) -> int
Get panel autoclear delay in seconds.
static auto isUsePwgen(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether pwgen support is enabled.
static void setSavestate(const QByteArray &saveState)
Save window state.
static auto isAlwaysOnTop(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether main window should stay always on top.
static auto isAvoidNumbers(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether numeric characters should be avoided.
static auto isHidePassword(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to hide password in UI.
static void setDialogGeometry(const QString &key, const QByteArray &geometry)
Save dialog geometry.
static auto getPassExecutable(const QString &defaultValue=QVariant().toString()) -> QString
Get pass executable path.
static void setUseAutoclearPanel(const bool &useAutoclearPanel)
Save use autoclear panel setting.
static void setAutoclearSeconds(const int &autoClearSeconds)
Save autoclear seconds.
static void setNoLineWrapping(const bool &noLineWrapping)
Save no line wrapping setting.
static void setUseQrencode(const bool &useQrencode)
Save qrencode support flag.
static auto getPos(const QPoint &defaultValue=QVariant().toPoint()) -> QPoint
Get saved window position.
static void setAvoidNumbers(const bool &avoidNumbers)
Save numeric avoidance flag.
static auto getDialogGeometry(const QString &key, const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
Get saved dialog geometry.
static auto getImitatePass() -> ImitatePass *
Get imitate pass backend instance.
static auto isHideOnClose(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether closing the window hides the application.
static void setAutoPush(const bool &autoPush)
Save automatic push flag.
static void setClipBoardType(const int &clipBoardType)
Save clipboard type.
static auto getProfiles() -> QHash< QString, QHash< QString, QString > >
Get all configured profiles.
static void setSize(const QSize &size)
Save window size.
static void setLessRandom(const bool &lessRandom)
Save less-random generation flag.
static auto getAutoclearSeconds(const int &defaultValue=QVariant().toInt()) -> int
Get autoclear delay in seconds.
static void setHideContent(const bool &hideContent)
Save hide content setting.
static auto isAutoPush(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether automatic push is enabled.
static void setGeometry(const QByteArray &geometry)
Save window geometry.
static void setUseSelection(const bool &useSelection)
Save use selection setting.
static auto getClipBoardTypeRaw(const Enums::clipBoardType &defaultValue=Enums::CLIPBOARD_NEVER) -> int
Get clipboard type preference.
static auto getGitExecutable(const QString &defaultValue=QVariant().toString()) -> QString
Get git executable path.
static void setTemplateAllFields(const bool &templateAllFields)
Save template-all-fields flag.
static auto getGeometry(const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
Get saved window geometry.
static void setUseSymbols(const bool &useSymbols)
Save symbol usage flag.
static auto isDisplayAsIs(const bool &defaultValue=QVariant().toBool()) -> bool
Get whether to display password as-is (no modification).
static void setUseGit(const bool &useGit)
Save Git integration flag.
static auto getSavestate(const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
Get saved window state.
Implementation of Pass that wraps the 'pass' command-line tool.
Definition realpass.h:21
static const QString maximized
static const QString savestate
static const QString useSelection
static const QString passExecutable
static const QString noLineWrapping
static const QString autoPull
static const QString dialogGeometry
static const QString lessRandom
static const QString pwgenExecutable
static const QString geometry
static const QString gpgHome
static const QString version
static const QString passTemplate
static const QString useAutoclear
static const QString webDavUrl
static const QString clipBoardType
static const QString autoclearPanelSeconds
static const QString avoidNumbers
static const QString useAutoclearPanel
static const QString useWebDav
static const QString usePass
static const QString hideOnClose
static const QString alwaysOnTop
static const QString pos
static const QString useGit
static const QString gitExecutable
static const QString gpgExecutable
static const QString profile
static const QString useTrayIcon
static const QString size
static const QString dialogSize
static const QString useOtp
static const QString startMinimized
static const QString dialogMaximized
static const QString hideContent
static const QString avoidCapitals
static const QString webDavUser
static const QString autoclearSeconds
static const QString usePwgen
static const QString useMonospace
static const QString passwordLength
static const QString qrencodeExecutable
static const QString dialogPos
static const QString passStore
static const QString passwordChars
static const QString webDavPassword
static const QString displayAsIs
static const QString useSymbols
static const QString passSigningKey
static const QString templateAllFields
static const QString passwordCharsselection
static const QString addGPGId
static const QString useQrencode
static const QString useTemplate
static const QString autoPush
static const QString hidePassword
static auto findBinaryInPath(QString binary) -> QString
Locate an executable by searching the process PATH and (on Windows) falling back to WSL.
Definition util.cpp:120
clipBoardType
Defines when to copy passwords to clipboard.
Definition enums.h:16
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.