QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
QtPassSettings Class Reference

Singleton that stores QtPass settings, handles persistence and defaults. More...

#include <qtpasssettings.h>

Inheritance diagram for QtPassSettings:
Collaboration diagram for QtPassSettings:

Static Public Member Functions

static auto getInstance () -> QtPassSettings *
 Get the singleton instance.
static auto load () -> AppSettings
 Load all flat settings into an AppSettings value object.
static void save (const AppSettings &settings)
 Persist an AppSettings value object to the singleton store.
static auto getVersion (const QString &defaultValue=QVariant().toString()) -> QString
 Get saved application version.
static void setVersion (const QString &version)
 Save application version.
static auto getGeometry (const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
 Get saved window geometry.
static void setGeometry (const QByteArray &geometry)
 Save window geometry.
static auto getSavestate (const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
 Get saved window state.
static void setSavestate (const QByteArray &saveState)
 Save window state.
static auto getDialogGeometry (const QString &key, const QByteArray &defaultValue=QVariant().toByteArray()) -> QByteArray
 Get saved dialog geometry.
static void setDialogGeometry (const QString &key, const QByteArray &geometry)
 Save dialog geometry.
static void setUsePass (const bool &usePass)
 Save use pass setting.
static auto getAutoclearSeconds (const int &defaultValue=QVariant().toInt()) -> int
 Get autoclear delay in seconds.
static auto getPassStore (const QString &defaultValue=QVariant().toString()) -> QString
 Get password store directory path.
static void setPassStore (const QString &passStore)
 Save password store path.
static void initExecutables ()
 Initialize executable paths by auto-detecting them.
static auto getPassExecutable (const QString &defaultValue=QVariant().toString()) -> QString
 Get pass executable path.
static auto getProfile (const QString &defaultValue=QVariant().toString()) -> QString
 Get active profile name.
static auto isUseGit (const bool &defaultValue=QVariant().toBool()) -> bool
 Check whether Git integration is enabled.
static auto isUseGrepSearch (const bool &defaultValue=false) -> bool
 Check whether content search is enabled.
static auto isUseOtp (const bool &defaultValue=true) -> bool
 Check whether OTP support is enabled.
static void setQrencodeExecutable (const QString &qrencodeExecutable)
 Save qrencode executable path.
static auto getPasswordConfiguration () -> PasswordConfiguration
 Get complete password generation configuration.
static auto isHideOnClose (const bool &defaultValue=QVariant().toBool()) -> bool
 Check whether closing the window hides the application.
static auto isAlwaysOnTop (const bool &defaultValue=QVariant().toBool()) -> bool
 Check whether main window should stay always on top.
static auto isAutoPush (const bool &defaultValue=QVariant().toBool()) -> bool
 Check whether automatic push is enabled.
static auto isShowProcessOutput (const bool &defaultValue=false) -> bool
 Get showProcessOutput setting.
static auto getProfiles () -> Profiles
 Get all configured profiles.
static void setProfiles (const Profiles &profiles)
 Save all configured profiles.
static auto getPass () -> Pass *
 Get currently active pass backend instance.
static auto getRealPass () -> RealPass *
 Get real pass backend instance.
static auto getImitatePass () -> ImitatePass *
 Get imitate pass backend instance.
static auto backendsIdle () -> bool
 Whether no backend, the active one or one kept from before a switch, runs or waits for anything (PassBackendFactory::isIdle()).

Private Member Functions

 QtPassSettings ()=delete
 Private default constructor to enforce singleton usage and prevent direct instantiation.
 QtPassSettings (const QString &organization, const QSettings::Format format)
 Settings in an explicit file: the portable qtpass.ini next to the executable, which getInstance() prefers when it exists.
 QtPassSettings (const QString &organization, const QString &application)
 Per-user settings in QSettings::defaultFormat().

Static Private Attributes

static bool initialized = false
 Whether getInstance() has chosen the store and built m_instance.
static QtPassSettings * m_instance = nullptr

Detailed Description

Singleton that stores QtPass settings, handles persistence and defaults.

QtPassSettings manages all application configuration including:

  • Window geometry (QWidget::saveGeometry blobs, main window and dialogs)
  • Password store configuration (path, GPG settings)
  • Executable paths (pass, git, gpg, pwgen)
  • UI preferences (clipboard, autoclear, display options)
  • gopass configuration

Uses QSettings for persistence with a singleton pattern. All getters accept a default value returned when setting is not yet saved.

Definition at line 42 of file qtpasssettings.h.

Constructor & Destructor Documentation

◆ QtPassSettings() [1/3]

QtPassSettings::QtPassSettings ( )
explicitprivatedelete

Private default constructor to enforce singleton usage and prevent direct instantiation.

Here is the caller graph for this function:

◆ QtPassSettings() [2/3]

QtPassSettings::QtPassSettings ( const QString & organization,
const QSettings::Format format )
inlineprivate

Settings in an explicit file: the portable qtpass.ini next to the executable, which getInstance() prefers when it exists.

Parameters
organizationThe file's path (QSettings' file-name constructor).
formatThe file's format; IniFormat for the portable file.

Definition at line 56 of file qtpasssettings.h.

◆ QtPassSettings() [3/3]

QtPassSettings::QtPassSettings ( const QString & organization,
const QString & application )
inlineprivate

Per-user settings in QSettings::defaultFormat().

QSettings(organization, application) ignores setDefaultFormat() and always uses NativeFormat; going through the explicit-format constructor keeps the production default (NativeFormat) while letting the test suites redirect settings to an ini file in a temporary directory.

Parameters
organizationThe organisation the settings are filed under ("IJHack").
applicationThe application name ("QtPass").

Definition at line 69 of file qtpasssettings.h.

Member Function Documentation

◆ backendsIdle()

auto QtPassSettings::backendsIdle ( ) -> bool
static

Whether no backend, the active one or one kept from before a switch, runs or waits for anything (PassBackendFactory::isIdle()).

Returns
true when all are idle.

Definition at line 289 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAutoclearSeconds()

auto QtPassSettings::getAutoclearSeconds ( const int & defaultValue = QVariant().toInt()) -> int
static

Get autoclear delay in seconds.

Parameters
defaultValueInteger returned if not saved.
Returns
Seconds before clipboard is cleared.

Definition at line 176 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDialogGeometry()

auto QtPassSettings::getDialogGeometry ( const QString & key,
const QByteArray & defaultValue = QVariant().toByteArray() ) -> QByteArray
static

Get saved dialog geometry.

Parameters
keyDialog identifier (e.g., "usersDialog").
defaultValueByte array returned if not saved.
Returns
Dialog geometry as QByteArray.

Definition at line 157 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getGeometry()

auto QtPassSettings::getGeometry ( const QByteArray & defaultValue = QVariant().toByteArray()) -> QByteArray
static

Get saved window geometry.

Parameters
defaultValueByte array returned if no geometry saved.
Returns
Window geometry as QByteArray.

Definition at line 138 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getImitatePass()

auto QtPassSettings::getImitatePass ( ) -> ImitatePass *
static

Get imitate pass backend instance.

Returns
Pointer to imitate pass backend.

Definition at line 285 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInstance()

auto QtPassSettings::getInstance ( ) -> QtPassSettings *
static

Get the singleton instance.

Returns
Pointer to the QtPassSettings instance.

Definition at line 31 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPass()

auto QtPassSettings::getPass ( ) -> Pass *
static

Get currently active pass backend instance.

Returns
Pointer to pass backend.

Definition at line 125 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPassExecutable()

auto QtPassSettings::getPassExecutable ( const QString & defaultValue = QVariant().toString()) -> QString
static

Get pass executable path.

Parameters
defaultValueString returned if not saved.
Returns
Path to pass executable.

Definition at line 221 of file qtpasssettings.cpp.

Here is the call graph for this function:

◆ getPassStore()

auto QtPassSettings::getPassStore ( const QString & defaultValue = QVariant().toString()) -> QString
static

Get password store directory path.

Parameters
defaultValueString returned if not saved.
Returns
Path to password store.

Definition at line 182 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPasswordConfiguration()

auto QtPassSettings::getPasswordConfiguration ( ) -> PasswordConfiguration
static

Get complete password generation configuration.

Returns
Password generation configuration.

Definition at line 63 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getProfile()

auto QtPassSettings::getProfile ( const QString & defaultValue = QVariant().toString()) -> QString
static

Get active profile name.

Parameters
defaultValueString returned if not saved.
Returns
Active profile name.

Definition at line 227 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getProfiles()

auto QtPassSettings::getProfiles ( ) -> Profiles
static

Get all configured profiles.

Returns
Profile map keyed by profile name.

Definition at line 67 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRealPass()

auto QtPassSettings::getRealPass ( ) -> RealPass *
static

Get real pass backend instance.

Returns
Pointer to real pass backend.

Definition at line 282 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSavestate()

auto QtPassSettings::getSavestate ( const QByteArray & defaultValue = QVariant().toByteArray()) -> QByteArray
static

Get saved window state.

Parameters
defaultValueByte array returned if no state saved.
Returns
Window state as QByteArray.

Definition at line 147 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVersion()

auto QtPassSettings::getVersion ( const QString & defaultValue = QVariant().toString()) -> QString
static

Get saved application version.

Parameters
defaultValueString returned if no version saved.
Returns
Application version string.

Definition at line 129 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initExecutables()

void QtPassSettings::initExecutables ( )
static

Initialize executable paths by auto-detecting them.

Definition at line 206 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAlwaysOnTop()

auto QtPassSettings::isAlwaysOnTop ( const bool & defaultValue = QVariant().toBool()) -> bool
static

Check whether main window should stay always on top.

Parameters
defaultValueValue returned if not saved.
Returns
True if always-on-top is enabled.

Definition at line 265 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAutoPush()

auto QtPassSettings::isAutoPush ( const bool & defaultValue = QVariant().toBool()) -> bool
static

Check whether automatic push is enabled.

Parameters
defaultValueValue returned if not saved.
Returns
True if automatic push is enabled.

Definition at line 271 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isHideOnClose()

auto QtPassSettings::isHideOnClose ( const bool & defaultValue = QVariant().toBool()) -> bool
static

Check whether closing the window hides the application.

Parameters
defaultValueValue returned if not saved.
Returns
True if close action hides the application.

Definition at line 260 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isShowProcessOutput()

auto QtPassSettings::isShowProcessOutput ( const bool & defaultValue = false) -> bool
static

Get showProcessOutput setting.

Parameters
defaultValueDefault value if not set.
Returns
Whether process output should be displayed.

Definition at line 277 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isUseGit()

auto QtPassSettings::isUseGit ( const bool & defaultValue = QVariant().toBool()) -> bool
static

Check whether Git integration is enabled.

Parameters
defaultValueValue returned if not saved.
Returns
True if Git integration is enabled.

Definition at line 233 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isUseGrepSearch()

auto QtPassSettings::isUseGrepSearch ( const bool & defaultValue = false) -> bool
static

Check whether content search is enabled.

Parameters
defaultValueValue returned if not saved (defaults to false).
Returns
True if grep search is enabled.

Definition at line 245 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isUseOtp()

auto QtPassSettings::isUseOtp ( const bool & defaultValue = true) -> bool
static

Check whether OTP support is enabled.

Parameters
defaultValueValue returned if not saved (defaults to true).
Returns
True if OTP support is enabled.

Definition at line 251 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load()

auto QtPassSettings::load ( ) -> AppSettings
static

Load all flat settings into an AppSettings value object.

Convenience facade over SettingsSerializer using the singleton store. Note: nested/keyed settings (profiles, per-dialog geometry) are not part of AppSettings and still use their dedicated accessors.

Returns
Current settings.

Definition at line 47 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

void QtPassSettings::save ( const AppSettings & settings)
static

Persist an AppSettings value object to the singleton store.

Writes via SettingsSerializer and invalidates the cached Pass backend so a changed "use pass" mode takes effect on the next getPass().

Parameters
settingsValues to save.

Definition at line 57 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDialogGeometry()

void QtPassSettings::setDialogGeometry ( const QString & key,
const QByteArray & geometry )
static

Save dialog geometry.

Parameters
keyDialog identifier.
geometryDialog geometry to save.

Definition at line 164 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGeometry()

void QtPassSettings::setGeometry ( const QByteArray & geometry)
static

Save window geometry.

Parameters
geometryWindow geometry to save.

Definition at line 143 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPassStore()

void QtPassSettings::setPassStore ( const QString & passStore)
static

Save password store path.

Parameters
passStorePath to password store.

Definition at line 203 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setProfiles()

void QtPassSettings::setProfiles ( const Profiles & profiles)
static

Save all configured profiles.

Parameters
profilesProfile map keyed by profile name.

Definition at line 99 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setQrencodeExecutable()

void QtPassSettings::setQrencodeExecutable ( const QString & qrencodeExecutable)
static

Save qrencode executable path.

Parameters
qrencodeExecutablePath to qrencode executable.

Definition at line 255 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSavestate()

void QtPassSettings::setSavestate ( const QByteArray & saveState)
static

Save window state.

Parameters
saveStateWindow state to save.

Definition at line 153 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUsePass()

void QtPassSettings::setUsePass ( const bool & usePass)
static

Save use pass setting.

Parameters
usePasstrue to use pass, false for GPG.

Definition at line 170 of file qtpasssettings.cpp.

Here is the call graph for this function:

◆ setVersion()

void QtPassSettings::setVersion ( const QString & version)
static

Save application version.

Parameters
versionVersion string to save.

Definition at line 134 of file qtpasssettings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ initialized

bool QtPassSettings::initialized = false
staticprivate

Whether getInstance() has chosen the store and built m_instance.

Definition at line 76 of file qtpasssettings.h.

◆ m_instance

QtPassSettings * QtPassSettings::m_instance = nullptr
staticprivate

The one instance, built on the first getInstance() and kept for the life of the process.

Definition at line 79 of file qtpasssettings.h.


The documentation for this class was generated from the following files: