QtPass 2.0.0
Developer documentation
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
8#ifndef SRC_QTPASSSETTINGS_H_
9#define SRC_QTPASSSETTINGS_H_
10
11#include "appsettings.h"
12#include "enums.h"
13#include "imitatepass.h"
15#include "profile.h"
16#include "realpass.h"
17#include "settingsconstants.h"
18
19#include <QByteArray>
20#include <QHash>
21#include <QPoint>
22#include <QSettings>
23#include <QSize>
24#include <QVariant>
25
42class QtPassSettings : public QSettings {
43private:
48 explicit QtPassSettings() = delete;
49
56 QtPassSettings(const QString &organization, const QSettings::Format format)
57 : QSettings(organization, format) {}
58
69 QtPassSettings(const QString &organization, const QString &application)
70 : QSettings(QSettings::defaultFormat(), QSettings::UserScope,
71 organization, application) {}
72
73 ~QtPassSettings() override = default;
74
76 static bool initialized;
80
81public:
86 static auto getInstance() -> QtPassSettings *;
87
96 static auto load() -> AppSettings;
104 static void save(const AppSettings &settings);
105
106 // Window settings
112 static auto getVersion(const QString &defaultValue = QVariant().toString())
113 -> QString;
118 static void setVersion(const QString &version);
119
125 static auto
126 getGeometry(const QByteArray &defaultValue = QVariant().toByteArray())
127 -> QByteArray;
132 static void setGeometry(const QByteArray &geometry);
133
139 static auto
140 getSavestate(const QByteArray &defaultValue = QVariant().toByteArray())
141 -> QByteArray;
146 static void setSavestate(const QByteArray &saveState);
147
148 // Dialog-specific settings
155 static auto
156 getDialogGeometry(const QString &key,
157 const QByteArray &defaultValue = QVariant().toByteArray())
158 -> QByteArray;
164 static void setDialogGeometry(const QString &key, const QByteArray &geometry);
165
166 // Password store settings
171 static void setUsePass(const bool &usePass);
172
173 // UI settings
174
180 static auto getAutoclearSeconds(const int &defaultValue = QVariant().toInt())
181 -> int;
182 // Pass store path
188 static auto getPassStore(const QString &defaultValue = QVariant().toString())
189 -> QString;
194 static void setPassStore(const QString &passStore);
195
196 // Executable paths
200 static void initExecutables();
206 static auto
207 getPassExecutable(const QString &defaultValue = QVariant().toString())
208 -> QString;
214 static auto getProfile(const QString &defaultValue = QVariant().toString())
215 -> QString;
216
222 static auto isUseGit(const bool &defaultValue = QVariant().toBool()) -> bool;
228 static auto isUseGrepSearch(const bool &defaultValue = false) -> bool;
234 static auto isUseOtp(const bool &defaultValue = true) -> bool;
239 static void setQrencodeExecutable(const QString &qrencodeExecutable);
240
251 static auto isHideOnClose(const bool &defaultValue = QVariant().toBool())
252 -> bool;
258 static auto isAlwaysOnTop(const bool &defaultValue = QVariant().toBool())
259 -> bool;
265 static auto isAutoPush(const bool &defaultValue = QVariant().toBool())
266 -> bool;
272 static auto isShowProcessOutput(const bool &defaultValue = false) -> bool;
277 static auto getProfiles() -> Profiles;
282 static void setProfiles(const Profiles &profiles);
283
288 static auto getPass() -> Pass *;
293 static auto getRealPass() -> RealPass *;
298 static auto getImitatePass() -> ImitatePass *;
304 static auto backendsIdle() -> bool;
305};
306
307#endif // SRC_QTPASSSETTINGS_H_
AppSettings, the value object holding every flat QtPass setting.
Implementation that imitates 'pass' when the real tool is unavailable.
Definition imitatepass.h:40
Abstract base class for password store operations.
Definition pass.h:75
Singleton that stores QtPass settings, handles persistence and defaults.
static bool initialized
Whether getInstance() has chosen the store and built m_instance.
static auto getInstance() -> QtPassSettings *
Get the singleton instance.
static void setPassStore(const QString &passStore)
Save password store path.
static auto getPass() -> Pass *
Get currently active pass backend instance.
static auto getPasswordConfiguration() -> PasswordConfiguration
Get complete password generation configuration.
static auto isUseGit(const bool &defaultValue=QVariant().toBool()) -> bool
Check whether Git integration is enabled.
static auto isUseOtp(const bool &defaultValue=true) -> bool
Check whether OTP support is enabled.
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 void initExecutables()
Initialize executable paths by auto-detecting them.
static auto load() -> AppSettings
Load all flat settings into an AppSettings value object.
static auto isUseGrepSearch(const bool &defaultValue=false) -> bool
Check whether content search is enabled.
QtPassSettings()=delete
Private default constructor to enforce singleton usage and prevent direct instantiation.
static void setVersion(const QString &version)
Save application version.
static auto getProfiles() -> Profiles
Get all configured profiles.
static auto getRealPass() -> RealPass *
Get real pass backend instance.
static void setQrencodeExecutable(const QString &qrencodeExecutable)
Save qrencode executable path.
static auto getProfile(const QString &defaultValue=QVariant().toString()) -> QString
Get active profile name.
static auto isShowProcessOutput(const bool &defaultValue=false) -> bool
Get showProcessOutput setting.
static void setProfiles(const Profiles &profiles)
Save all configured profiles.
static void setUsePass(const bool &usePass)
Save use pass setting.
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 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 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.
QtPassSettings(const QString &organization, const QSettings::Format format)
Settings in an explicit file: the portable qtpass.ini next to the executable, which getInstance() pre...
static void save(const AppSettings &settings)
Persist an AppSettings value object to the singleton store.
QtPassSettings(const QString &organization, const QString &application)
Per-user settings in QSettings::defaultFormat().
static QtPassSettings * m_instance
static auto getAutoclearSeconds(const int &defaultValue=QVariant().toInt()) -> int
Get autoclear delay in seconds.
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 auto getGeometry(const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
Get saved window geometry.
static auto getSavestate(const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
Get saved window state.
static auto backendsIdle() -> bool
Whether no backend, the active one or one kept from before a switch, runs or waits for anything (Pass...
Implementation of Pass that wraps the 'pass' command-line tool.
Definition realpass.h:32
The Enums namespace: clipboard behaviour and the identifiers of the subprocess kinds QtPass queues.
ImitatePass, the backend that does what pass does by running gpg and git itself.
Value object for the password generator: chosen character set, its alphabets and the length.
One named password store (Profile) and the name-to-profile map (Profiles) the settings trade in.
QMap< QString, Profile > Profiles
All profiles by name. QMap so iteration order is the name order.
Definition profile.h:81
RealPass, the backend that hands every store operation to the pass command-line tool.
Plain value-object holding all flat QtPass configuration.
Definition appsettings.h:36
Holds the password generator settings: which character set is selected, the alphabet of every set,...