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

            Line data    Source code
       1              : // SPDX-FileCopyrightText: 2018 Anne Jan Brouwer
       2              : // SPDX-License-Identifier: GPL-3.0-or-later
       3              : /**
       4              :  * @file
       5              :  * @brief Value object for the password generator: chosen character set, its
       6              :  * alphabets and the length.
       7              :  */
       8              : #ifndef SRC_PASSWORDCONFIGURATION_H_
       9              : #define SRC_PASSWORDCONFIGURATION_H_
      10              : 
      11              : #include <QString>
      12              : 
      13              : /**
      14              :  * @struct PasswordConfiguration
      15              :  * @ingroup store
      16              :  * @brief Holds the password generator settings: which character set is
      17              :  * selected, the alphabet of every set, and the password length.
      18              :  *
      19              :  * Loaded from and saved to QSettings by QtPassSettings; PasswordDialog reads
      20              :  * it when the user presses "Generate" and ConfigDialog edits it.
      21              :  */
      22        13010 : struct PasswordConfiguration {
      23              :   /**
      24              :    * @brief Character set options for password generation; also the index
      25              :    * into @ref Characters.
      26              :    */
      27              :   enum CharacterSet {
      28              :     ALLCHARS = 0,  /**< Letters, digits and ASCII punctuation. */
      29              :     ALPHABETICAL,  /**< Upper- and lower-case ASCII letters only. */
      30              :     ALPHANUMERIC,  /**< ASCII letters and digits. */
      31              :     CUSTOM,        /**< User-defined alphabet, edited in the settings dialog. */
      32              :     CHARSETS_COUNT /**< Sentinel, not a character set: the number of sets,
      33              :                       used to size @ref Characters. Must stay last. */
      34              :   };
      35              :   /**
      36              :    * @brief Currently active character set selection.
      37              :    */
      38              :   CharacterSet selected{ALLCHARS};
      39              :   /**
      40              :    * @brief Length of the generated password, in characters.
      41              :    */
      42              :   int length{16};
      43              :   /**
      44              :    * @brief The alphabet of each character set, indexed by CharacterSet. Only
      45              :    * the CUSTOM entry is meant to be changed after construction.
      46              :    */
      47              :   QString Characters[CHARSETS_COUNT];
      48              :   /**
      49              :    * @brief Construct a PasswordConfiguration with sensible defaults.
      50              :    */
      51            0 :   PasswordConfiguration() {
      52              :     Characters[ALLCHARS] =
      53              :         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&"
      54         3941 :         "*()_-+={}[]|:;<>,.?"; /*AllChars*/
      55              :     Characters[ALPHABETICAL] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu"
      56         3941 :                                "vwxyz"; /*Only Alphabetical*/
      57              :     Characters[ALPHANUMERIC] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu"
      58         3941 :                                "vwxyz1234567890"; /*Alphabetical and Numerical*/
      59         3941 :     Characters[CUSTOM] = Characters[ALLCHARS];    // may be redefined by user
      60         3941 :   }
      61              : };
      62              : 
      63              : #endif // SRC_PASSWORDCONFIGURATION_H_
        

Generated by: LCOV version 2.0-1