QtPass Developer documentation
QtPass test coverage
Current view: top level - src/appsettings.h (source / functions) Coverage Total Hit
Test: QtPass Lines: 100.0 % 8 8
Test Date: 2026-11-14 13:19:18 Functions: 100.0 % 1 1

            Line data    Source code
       1              : // SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
       2              : // SPDX-License-Identifier: GPL-3.0-or-later
       3              : /**
       4              :  * @file
       5              :  * @brief AppSettings, the value object holding every flat QtPass setting.
       6              :  */
       7              : #ifndef SRC_APPSETTINGS_H_
       8              : #define SRC_APPSETTINGS_H_
       9              : 
      10              : #include "enums.h"
      11              : #include "passwordconfiguration.h"
      12              : 
      13              : #include <QByteArray>
      14              : #include <QPoint>
      15              : #include <QSize>
      16              : #include <QString>
      17              : #include <QStringList>
      18              : 
      19              : /**
      20              :  * @struct AppSettings
      21              :  * @ingroup settings
      22              :  * @brief Plain value-object holding all flat QtPass configuration.
      23              :  *
      24              :  * One field per persisted setting, with the same defaults the legacy
      25              :  * QtPassSettings getters apply. This is a pure data carrier: it has no
      26              :  * QSettings dependency and performs none of the side effects that the old
      27              :  * getters did (directory creation for the pass store, screen-centring of the
      28              :  * window position, `.git` auto-detection). Those remain application logic in
      29              :  * the consumers; SettingsSerializer maps this struct straight to and from
      30              :  * QSettings.
      31              :  *
      32              :  * Nested/keyed settings — profiles (a dedicated Profile type is tracked
      33              :  * separately), per-dialog geometry, and splitter positions — are intentionally
      34              :  * out of scope here and still go through QtPassSettings directly.
      35              :  */
      36              : struct AppSettings {
      37              :   /**
      38              :    * @brief The secret field names a new or emptied setting starts with:
      39              :    * what an entry commonly holds besides its password.
      40              :    * @return The names, lower case.
      41              :    */
      42         1904 :   static auto defaultSecretFieldNames() -> QStringList {
      43         1904 :     return {QStringLiteral("pin"),        QStringLiteral("pincode"),
      44         1904 :             QStringLiteral("puk"),        QStringLiteral("cvv"),
      45         1904 :             QStringLiteral("cvc"),        QStringLiteral("secret"),
      46         1904 :             QStringLiteral("token"),      QStringLiteral("key"),
      47         1904 :             QStringLiteral("passphrase"), QStringLiteral("password"),
      48         1904 :             QStringLiteral("recovery"),   QStringLiteral("answer"),
      49        28560 :             QStringLiteral("seed"),       QStringLiteral("mnemonic")};
      50              :   }
      51              : 
      52              :   // --- Window / session ---
      53              :   QString version;       ///< Last-run application version.
      54              :   QByteArray geometry;   ///< Main-window saved geometry.
      55              :   QByteArray savestate;  ///< Main-window saved dock/toolbar state.
      56              :   QString activeProfile; ///< Name of the active profile.
      57              : 
      58              :   // --- Backend selection / store ---
      59              :   bool usePass{false};    ///< Use the `pass` CLI (true) or native git/gpg.
      60              :   QString passStore;      ///< Password-store root path.
      61              :   QString passSigningKey; ///< GPG key used to sign `.gpg-id` files.
      62              : 
      63              :   // --- Executables ---
      64              :   QString passExecutable;      ///< Path to the `pass` executable.
      65              :   QString gitExecutable;       ///< Path to the `git` executable.
      66              :   QString gpgExecutable;       ///< Path to the `gpg`/`gpg2` executable.
      67              :   QString pwgenExecutable;     ///< Path to the `pwgen` executable.
      68              :   QString qrencodeExecutable;  ///< Path to the `qrencode` executable.
      69              :   QString gpgHome;             ///< GPG home directory (read-only externally).
      70              :   QString sshAuthSockOverride; ///< Manual SSH_AUTH_SOCK override path.
      71              : 
      72              :   // --- Clipboard / autoclear ---
      73              :   Enums::ClipBoardType clipBoardType{
      74              :       Enums::CLIPBOARD_NEVER}; ///< Clipboard copy behaviour.
      75              :   bool useSelection{false};    ///< Use the X11 primary selection.
      76              :   bool useAutoclear{false};    ///< Clear the clipboard after a delay.
      77              :   /// When autoclear runs: put back what was on the clipboard before, as
      78              :   /// `pass -c` does, unless something else was copied meanwhile.
      79              :   bool restoreClipboard{true};
      80              :   int autoclearSeconds{0};       ///< Clipboard autoclear delay (seconds).
      81              :   bool useAutoclearPanel{false}; ///< Clear the content panel after a delay.
      82              :   int autoclearPanelSeconds{0};  ///< Panel autoclear delay (seconds).
      83              : 
      84              :   // --- Content display ---
      85              :   bool hidePassword{false}; ///< Hide the password line in the panel.
      86              :   /// With hidePassword: hide the fields named in secretFieldNames too. Off,
      87              :   /// only the password is hidden, as in 1.8.
      88              :   bool hideSecretFields{true};
      89              :   /// The field names hideSecretFields hides, as whole words in any case
      90              :   /// ("key" hides "API key", not "keyboard"). May be empty.
      91              :   QStringList secretFieldNames{defaultSecretFieldNames()};
      92              :   /// With hidePassword: hide every field, not only the secrets (shared
      93              :   /// screens, presenting). The notes and the OTP code stay visible.
      94              :   bool hideAllFields{false};
      95              :   bool hideContent{false};    ///< Hide the entire content panel.
      96              :   bool useMonospace{false};   ///< Render content in a monospace font.
      97              :   bool displayAsIs{false};    ///< Show file content unmodified.
      98              :   bool noLineWrapping{false}; ///< Disable line wrapping in the panel.
      99              : 
     100              :   // --- Features ---
     101              :   bool addGPGId{true};       ///< Auto-add `.gpg-id` files to git.
     102              :   bool useGit{false};        ///< Enable git integration.
     103              :   bool useGrepSearch{false}; ///< Enable content (grep) search.
     104              :   bool useOtp{true};         ///< Enable native TOTP (OTP) support.
     105              :   bool useQrencode{false};   ///< Enable qrencode support.
     106              :   bool usePwgen{false};      ///< Use pwgen for password generation.
     107              :   bool autoPull{false};      ///< Automatically `git pull` on open.
     108              :   bool autoPush{false};      ///< Automatically `git push` after changes.
     109              :   /// Let git use a repository in a folder above the store when the store
     110              :   /// has none of its own; off, git stops at the store's parent, as in pass.
     111              :   bool gitUseParentRepository{false};
     112              :   bool showProcessOutput{false}; ///< Show external process output.
     113              :   bool showMenuBar{false};       ///< Show the menu bar (Ctrl+M toggles it).
     114              : 
     115              :   // --- Templates ---
     116              :   QString passTemplate;          ///< Newline-separated template field names.
     117              :   bool useTemplate{false};       ///< Use the password template.
     118              :   bool templateAllFields{false}; ///< Treat every `key:` line as a field.
     119              : 
     120              :   // --- Password generation ---
     121              :   PasswordConfiguration passwordConfiguration; ///< Length/charset/custom chars.
     122              :   bool avoidCapitals{false};                   ///< Exclude uppercase letters.
     123              :   bool avoidNumbers{false};                    ///< Exclude digits.
     124              :   bool lessRandom{false}; ///< Generate memorable (less random) passwords.
     125              :   bool useSymbols{false}; ///< Include special symbols.
     126              : 
     127              :   // --- System / tray ---
     128              :   bool useTrayIcon{false};    ///< Show a system tray icon.
     129              :   bool hideOnClose{false};    ///< Hide to tray instead of quitting on close.
     130              :   bool startMinimized{false}; ///< Start the window minimised.
     131              :   bool alwaysOnTop{false};    ///< Keep the main window always on top.
     132              : };
     133              : 
     134              : #endif // SRC_APPSETTINGS_H_
        

Generated by: LCOV version 2.0-1