QtPass 1.6.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
qtpasssettings.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
3#ifndef SRC_QTPASSSETTINGS_H_
4#define SRC_QTPASSSETTINGS_H_
5
6#include "enums.h"
7#include "imitatepass.h"
9#include "realpass.h"
10#include "settingsconstants.h"
11
12#include <QByteArray>
13#include <QHash>
14#include <QPoint>
15#include <QScopedPointer>
16#include <QSettings>
17#include <QSize>
18#include <QVariant>
19
35class QtPassSettings : public QSettings {
36private:
41 explicit QtPassSettings();
42
43 QtPassSettings(const QString &organization, const QSettings::Format format)
44 : QSettings(organization, format) {}
45 QtPassSettings(const QString &organization, const QString &application)
46 : QSettings(organization, application) {}
47
48 ~QtPassSettings() override = default;
49
50 static bool initialized;
51 static QtPassSettings *m_instance;
52
53 static Pass *pass;
54 static QScopedPointer<RealPass> realPass;
55 static QScopedPointer<ImitatePass> imitatePass;
56
57public:
62 static auto getInstance() -> QtPassSettings *;
63
64 // Window settings
70 static auto getVersion(const QString &defaultValue = QVariant().toString())
71 -> QString;
76 static void setVersion(const QString &version);
77
83 static auto
84 getGeometry(const QByteArray &defaultValue = QVariant().toByteArray())
85 -> QByteArray;
90 static void setGeometry(const QByteArray &geometry);
91
97 static auto
98 getSavestate(const QByteArray &defaultValue = QVariant().toByteArray())
99 -> QByteArray;
104 static void setSavestate(const QByteArray &saveState);
105
111 static auto getPos(const QPoint &defaultValue = QVariant().toPoint())
112 -> QPoint;
117 static void setPos(const QPoint &pos);
118
124 static auto getSize(const QSize &defaultValue = QVariant().toSize()) -> QSize;
129 static void setSize(const QSize &size);
130
136 static auto isMaximized(const bool &defaultValue = QVariant().toBool())
137 -> bool;
142 static void setMaximized(const bool &maximized);
143
144 // Dialog-specific settings
151 static auto
152 getDialogGeometry(const QString &key,
153 const QByteArray &defaultValue = QVariant().toByteArray())
154 -> QByteArray;
160 static void setDialogGeometry(const QString &key, const QByteArray &geometry);
161
168 static auto getDialogPos(const QString &key,
169 const QPoint &defaultValue = QVariant().toPoint())
170 -> QPoint;
176 static void setDialogPos(const QString &key, const QPoint &pos);
177
184 static auto getDialogSize(const QString &key,
185 const QSize &defaultValue = QVariant().toSize())
186 -> QSize;
192 static void setDialogSize(const QString &key, const QSize &size);
193
200 static auto isDialogMaximized(const QString &key,
201 const bool &defaultValue = QVariant().toBool())
202 -> bool;
208 static void setDialogMaximized(const QString &key, const bool &maximized);
209
210 // Password store settings
216 static auto isUsePass(const bool &defaultValue = QVariant().toBool()) -> bool;
221 static void setUsePass(const bool &usePass);
222
228 static auto getClipBoardTypeRaw(
229 const Enums::clipBoardType &defaultValue = Enums::CLIPBOARD_NEVER) -> int;
235 static auto getClipBoardType(
236 const Enums::clipBoardType &defaultValue = Enums::CLIPBOARD_NEVER)
242 static void setClipBoardType(const int &clipBoardType);
243
244 // UI settings
250 static auto isUseSelection(const bool &defaultValue = QVariant().toBool())
251 -> bool;
256 static void setUseSelection(const bool &useSelection);
257
263 static auto isUseAutoclear(const bool &defaultValue = QVariant().toBool())
264 -> bool;
269 static void setUseAutoclear(const bool &useAutoclear);
270
276 static auto getAutoclearSeconds(const int &defaultValue = QVariant().toInt())
277 -> int;
282 static void setAutoclearSeconds(const int &autoClearSeconds);
283
289 static auto
290 isUseAutoclearPanel(const bool &defaultValue = QVariant().toBool()) -> bool;
295 static void setUseAutoclearPanel(const bool &useAutoclearPanel);
296
302 static auto
303 getAutoclearPanelSeconds(const int &defaultValue = QVariant().toInt()) -> int;
308 static void setAutoclearPanelSeconds(const int &autoClearPanelSeconds);
309
315 static auto isHidePassword(const bool &defaultValue = QVariant().toBool())
316 -> bool;
321 static void setHidePassword(const bool &hidePassword);
322
328 static auto isHideContent(const bool &defaultValue = QVariant().toBool())
329 -> bool;
334 static void setHideContent(const bool &hideContent);
335
341 static auto isUseMonospace(const bool &defaultValue = QVariant().toBool())
342 -> bool;
347 static void setUseMonospace(const bool &useMonospace);
348
354 static auto isDisplayAsIs(const bool &defaultValue = QVariant().toBool())
355 -> bool;
360 static void setDisplayAsIs(const bool &displayAsIs);
361
367 static auto isNoLineWrapping(const bool &defaultValue = QVariant().toBool())
368 -> bool;
373 static void setNoLineWrapping(const bool &noLineWrapping);
374
380 static auto isAddGPGId(const bool &defaultValue = QVariant().toBool())
381 -> bool;
386 static void setAddGPGId(const bool &addGPGId);
387
388 // Pass store path
394 static auto getPassStore(const QString &defaultValue = QVariant().toString())
395 -> QString;
400 static void setPassStore(const QString &passStore);
401
407 static auto
408 getPassSigningKey(const QString &defaultValue = QVariant().toString())
409 -> QString;
414 static void setPassSigningKey(const QString &passSigningKey);
415
416 // Executable paths
420 static void initExecutables();
426 static auto
427 getPassExecutable(const QString &defaultValue = QVariant().toString())
428 -> QString;
433 static void setPassExecutable(const QString &passExecutable);
434
440 static auto
441 getGitExecutable(const QString &defaultValue = QVariant().toString())
442 -> QString;
447 static void setGitExecutable(const QString &gitExecutable);
448
454 static auto
455 getGpgExecutable(const QString &defaultValue = QVariant().toString())
456 -> QString;
461 static void setGpgExecutable(const QString &gpgExecutable);
462
468 static auto
469 getPwgenExecutable(const QString &defaultValue = QVariant().toString())
470 -> QString;
475 static void setPwgenExecutable(const QString &pwgenExecutable);
476
482 static auto getGpgHome(const QString &defaultValue = QVariant().toString())
483 -> QString;
484
490 static auto isUseWebDav(const bool &defaultValue = QVariant().toBool())
491 -> bool;
496 static void setUseWebDav(const bool &useWebDav);
497
503 static auto getWebDavUrl(const QString &defaultValue = QVariant().toString())
504 -> QString;
509 static void setWebDavUrl(const QString &webDavUrl);
510
516 static auto getWebDavUser(const QString &defaultValue = QVariant().toString())
517 -> QString;
522 static void setWebDavUser(const QString &webDavUser);
523
529 static auto
530 getWebDavPassword(const QString &defaultValue = QVariant().toString())
531 -> QString;
536 static void setWebDavPassword(const QString &webDavPassword);
537
543 static auto getProfile(const QString &defaultValue = QVariant().toString())
544 -> QString;
549 static void setProfile(const QString &profile);
550
556 static auto isUseGit(const bool &defaultValue = QVariant().toBool()) -> bool;
561 static void setUseGit(const bool &useGit);
562
568 static auto isUseOtp(const bool &defaultValue = QVariant().toBool()) -> bool;
573 static void setUseOtp(const bool &useOtp);
574
580 static auto isUseQrencode(const bool &defaultValue = QVariant().toBool())
581 -> bool;
586 static void setUseQrencode(const bool &useQrencode);
587
593 static auto
594 getQrencodeExecutable(const QString &defaultValue = QVariant().toString())
595 -> QString;
600 static void setQrencodeExecutable(const QString &qrencodeExecutable);
601
607 static auto isUsePwgen(const bool &defaultValue = QVariant().toBool())
608 -> bool;
613 static void setUsePwgen(const bool &usePwgen);
614
620 static auto isAvoidCapitals(const bool &defaultValue = QVariant().toBool())
621 -> bool;
626 static void setAvoidCapitals(const bool &avoidCapitals);
627
633 static auto isAvoidNumbers(const bool &defaultValue = QVariant().toBool())
634 -> bool;
639 static void setAvoidNumbers(const bool &avoidNumbers);
640
646 static auto isLessRandom(const bool &defaultValue = QVariant().toBool())
647 -> bool;
652 static void setLessRandom(const bool &lessRandom);
653
659 static auto isUseSymbols(const bool &defaultValue = QVariant().toBool())
660 -> bool;
665 static void setUseSymbols(const bool &useSymbols);
666
676 static void setPasswordConfiguration(const PasswordConfiguration &config);
681 static void setPasswordLength(const int &passwordLength);
686 static void setPasswordCharsselection(const int &passwordCharsSelection);
691 static void setPasswordChars(const QString &passwordChars);
692
698 static auto isUseTrayIcon(const bool &defaultValue = QVariant().toBool())
699 -> bool;
704 static void setUseTrayIcon(const bool &useTrayIcon);
705
711 static auto isHideOnClose(const bool &defaultValue = QVariant().toBool())
712 -> bool;
717 static void setHideOnClose(const bool &hideOnClose);
718
724 static auto isStartMinimized(const bool &defaultValue = QVariant().toBool())
725 -> bool;
730 static void setStartMinimized(const bool &startMinimized);
731
737 static auto isAlwaysOnTop(const bool &defaultValue = QVariant().toBool())
738 -> bool;
743 static void setAlwaysOnTop(const bool &alwaysOnTop);
744
750 static auto isAutoPull(const bool &defaultValue = QVariant().toBool())
751 -> bool;
756 static void setAutoPull(const bool &autoPull);
757
763 static auto isAutoPush(const bool &defaultValue = QVariant().toBool())
764 -> bool;
769 static void setAutoPush(const bool &autoPush);
770
776 static auto
777 getPassTemplate(const QString &defaultValue = QVariant().toString())
778 -> QString;
783 static void setPassTemplate(const QString &passTemplate);
784
790 static auto isUseTemplate(const bool &defaultValue = QVariant().toBool())
791 -> bool;
796 static void setUseTemplate(const bool &useTemplate);
797
803 static auto
804 isTemplateAllFields(const bool &defaultValue = QVariant().toBool()) -> bool;
809 static void setTemplateAllFields(const bool &templateAllFields);
810
815 static auto getProfiles() -> QHash<QString, QHash<QString, QString>>;
820 static void
821 setProfiles(const QHash<QString, QHash<QString, QString>> &profiles);
822
827 static auto getPass() -> Pass *;
832 static auto getRealPass() -> RealPass *;
837 static auto getImitatePass() -> ImitatePass *;
838};
839
840#endif // SRC_QTPASSSETTINGS_H_
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
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
clipBoardType
Defines when to copy passwords to clipboard.
Definition enums.h:16
@ CLIPBOARD_NEVER
Definition enums.h:17
Holds the Password configuration settings.