LCOV - code coverage report
Current view: top level - src - qtpasssettings.cpp (source / functions) Coverage Total Hit
Test: .lcov.total Lines: 94.1 % 443 417
Test Date: 2026-03-23 21:55:57 Functions: 97.3 % 110 107

            Line data    Source code
       1              : // SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
       2              : // SPDX-License-Identifier: GPL-3.0-or-later
       3              : #include "qtpasssettings.h"
       4              : #include "pass.h"
       5              : 
       6              : #include "util.h"
       7              : 
       8              : #include <QCoreApplication>
       9              : #include <QDebug>
      10              : 
      11              : bool QtPassSettings::initialized = false;
      12              : 
      13              : Pass *QtPassSettings::pass;
      14              : // Go via pointer to avoid dynamic initialization,
      15              : // due to "random" initialization order realtive to other
      16              : // globals, especially around QObject emtadata dynamic initialization
      17              : // can lead to crashes depending on compiler, linker etc.
      18              : QScopedPointer<RealPass> QtPassSettings::realPass;
      19              : QScopedPointer<ImitatePass> QtPassSettings::imitatePass;
      20              : 
      21              : QtPassSettings *QtPassSettings::m_instance = nullptr;
      22         2227 : auto QtPassSettings::getInstance() -> QtPassSettings * {
      23         2227 :   if (!QtPassSettings::initialized) {
      24           85 :     QString portable_ini = QCoreApplication::applicationDirPath() +
      25           85 :                            QDir::separator() + "qtpass.ini";
      26           85 :     if (QFile(portable_ini).exists()) {
      27            0 :       m_instance = new QtPassSettings(portable_ini, QSettings::IniFormat);
      28              :     } else {
      29          170 :       m_instance = new QtPassSettings("IJHack", "QtPass");
      30              :     }
      31              : 
      32           85 :     initialized = true;
      33              :   }
      34              : 
      35         2227 :   return m_instance;
      36              : }
      37              : 
      38          111 : auto QtPassSettings::getPasswordConfiguration() -> PasswordConfiguration {
      39          111 :   PasswordConfiguration config;
      40              : 
      41          111 :   config.length =
      42          222 :       getInstance()->value(SettingsConstants::passwordLength, 0).toInt();
      43          111 :   config.selected = static_cast<PasswordConfiguration::characterSet>(
      44          111 :       getInstance()
      45          333 :           ->value(SettingsConstants::passwordCharsselection, 0)
      46          111 :           .toInt());
      47              :   config.Characters[PasswordConfiguration::CUSTOM] =
      48          111 :       getInstance()
      49          333 :           ->value(SettingsConstants::passwordChars, QString())
      50          111 :           .toString();
      51              : 
      52          111 :   return config;
      53            0 : }
      54              : 
      55           29 : void QtPassSettings::setPasswordConfiguration(
      56              :     const PasswordConfiguration &config) {
      57           58 :   getInstance()->setValue(SettingsConstants::passwordLength, config.length);
      58           58 :   getInstance()->setValue(SettingsConstants::passwordCharsselection,
      59           58 :                           config.selected);
      60           58 :   getInstance()->setValue(SettingsConstants::passwordChars,
      61           58 :                           config.Characters[PasswordConfiguration::CUSTOM]);
      62           29 : }
      63              : 
      64           58 : auto QtPassSettings::getProfiles() -> QHash<QString, QHash<QString, QString>> {
      65           58 :   getInstance()->beginGroup(SettingsConstants::profile);
      66           58 :   QHash<QString, QHash<QString, QString>> profiles;
      67              : 
      68              :   // migration from version <= v1.3.2: profiles datastructure
      69           58 :   QStringList childKeys = getInstance()->childKeys();
      70           58 :   if (!childKeys.empty()) {
      71            0 :     foreach (QString key, childKeys) {
      72            0 :       QHash<QString, QString> profile;
      73            0 :       profile.insert("path", getInstance()->value(key).toString());
      74            0 :       profile.insert("signingKey", "");
      75              :       profiles.insert(key, profile);
      76            0 :     }
      77              :   }
      78              :   // /migration from version <= v1.3.2
      79              : 
      80           58 :   QStringList childGroups = getInstance()->childGroups();
      81           87 :   foreach (QString group, childGroups) {
      82           29 :     QHash<QString, QString> profile;
      83           87 :     profile.insert("path", getInstance()->value(group + "/path").toString());
      84           58 :     profile.insert("signingKey",
      85          116 :                    getInstance()->value(group + "/signingKey").toString());
      86              :     // profiles.insert(group, getInstance()->value(group).toString());
      87              :     profiles.insert(group, profile);
      88           29 :   }
      89              : 
      90           58 :   getInstance()->endGroup();
      91              : 
      92           58 :   return profiles;
      93            0 : }
      94              : 
      95           29 : void QtPassSettings::setProfiles(
      96              :     const QHash<QString, QHash<QString, QString>> &profiles) {
      97           29 :   getInstance()->remove(SettingsConstants::profile);
      98           29 :   getInstance()->beginGroup(SettingsConstants::profile);
      99              : 
     100           29 :   QHash<QString, QHash<QString, QString>>::const_iterator i = profiles.begin();
     101           29 :   for (; i != profiles.end(); ++i) {
     102           87 :     getInstance()->setValue(i.key() + "/path", i.value().value("path"));
     103           87 :     getInstance()->setValue(i.key() + "/signingKey",
     104           87 :                             i.value().value("signingKey"));
     105              :   }
     106              : 
     107           29 :   getInstance()->endGroup();
     108           29 : }
     109              : 
     110          288 : auto QtPassSettings::getPass() -> Pass * {
     111          288 :   if (!pass) {
     112           32 :     if (isUsePass()) {
     113           32 :       QtPassSettings::pass = getRealPass();
     114              :     } else {
     115            0 :       QtPassSettings::pass = getImitatePass();
     116              :     }
     117           32 :     pass->init();
     118              :   }
     119          288 :   return pass;
     120              : }
     121              : 
     122           23 : auto QtPassSettings::getVersion(const QString &defaultValue) -> QString {
     123           23 :   return getInstance()
     124           69 :       ->value(SettingsConstants::version, defaultValue)
     125           46 :       .toString();
     126              : }
     127           18 : void QtPassSettings::setVersion(const QString &version) {
     128           36 :   getInstance()->setValue(SettingsConstants::version, version);
     129           18 : }
     130              : 
     131           16 : auto QtPassSettings::getGeometry(const QByteArray &defaultValue) -> QByteArray {
     132           16 :   return getInstance()
     133           48 :       ->value(SettingsConstants::geometry, defaultValue)
     134           32 :       .toByteArray();
     135              : }
     136           23 : void QtPassSettings::setGeometry(const QByteArray &geometry) {
     137           46 :   getInstance()->setValue(SettingsConstants::geometry, geometry);
     138           23 : }
     139              : 
     140            3 : auto QtPassSettings::getSavestate(const QByteArray &defaultValue)
     141              :     -> QByteArray {
     142            3 :   return getInstance()
     143            9 :       ->value(SettingsConstants::savestate, defaultValue)
     144            6 :       .toByteArray();
     145              : }
     146            3 : void QtPassSettings::setSavestate(const QByteArray &saveState) {
     147            6 :   getInstance()->setValue(SettingsConstants::savestate, saveState);
     148            3 : }
     149              : 
     150            3 : auto QtPassSettings::getPos(const QPoint &defaultValue) -> QPoint {
     151            6 :   return getInstance()->value(SettingsConstants::pos, defaultValue).toPoint();
     152              : }
     153            3 : void QtPassSettings::setPos(const QPoint &pos) {
     154            6 :   getInstance()->setValue(SettingsConstants::pos, pos);
     155            3 : }
     156              : 
     157            3 : auto QtPassSettings::getSize(const QSize &defaultValue) -> QSize {
     158            6 :   return getInstance()->value(SettingsConstants::size, defaultValue).toSize();
     159              : }
     160            3 : void QtPassSettings::setSize(const QSize &size) {
     161            6 :   getInstance()->setValue(SettingsConstants::size, size);
     162            3 : }
     163              : 
     164            6 : auto QtPassSettings::isMaximized(const bool &defaultValue) -> bool {
     165            6 :   return getInstance()
     166           18 :       ->value(SettingsConstants::maximized, defaultValue)
     167           12 :       .toBool();
     168              : }
     169            6 : void QtPassSettings::setMaximized(const bool &maximized) {
     170           12 :   getInstance()->setValue(SettingsConstants::maximized, maximized);
     171            6 : }
     172              : 
     173           78 : auto QtPassSettings::isUsePass(const bool &defaultValue) -> bool {
     174           78 :   return getInstance()
     175          234 :       ->value(SettingsConstants::usePass, defaultValue)
     176          156 :       .toBool();
     177              : }
     178           46 : void QtPassSettings::setUsePass(const bool &usePass) {
     179           46 :   if (usePass) {
     180           23 :     QtPassSettings::pass = getRealPass();
     181              :   } else {
     182           23 :     QtPassSettings::pass = getImitatePass();
     183              :   }
     184           92 :   getInstance()->setValue(SettingsConstants::usePass, usePass);
     185           46 : }
     186              : 
     187            0 : auto QtPassSettings::getClipBoardTypeRaw(
     188              :     const Enums::clipBoardType &defaultvalue) -> int {
     189            0 :   return getInstance()
     190            0 :       ->value(SettingsConstants::clipBoardType, static_cast<int>(defaultvalue))
     191            0 :       .toInt();
     192              : }
     193              : 
     194            0 : auto QtPassSettings::getClipBoardType(const Enums::clipBoardType &defaultvalue)
     195              :     -> Enums::clipBoardType {
     196            0 :   return static_cast<Enums::clipBoardType>(getClipBoardTypeRaw(defaultvalue));
     197              : }
     198           23 : void QtPassSettings::setClipBoardType(const int &clipBoardType) {
     199           46 :   getInstance()->setValue(SettingsConstants::clipBoardType, clipBoardType);
     200           23 : }
     201              : 
     202           16 : auto QtPassSettings::isUseSelection(const bool &defaultValue) -> bool {
     203           16 :   return getInstance()
     204           48 :       ->value(SettingsConstants::useSelection, defaultValue)
     205           32 :       .toBool();
     206              : }
     207           16 : void QtPassSettings::setUseSelection(const bool &useSelection) {
     208           32 :   getInstance()->setValue(SettingsConstants::useSelection, useSelection);
     209           16 : }
     210              : 
     211           16 : auto QtPassSettings::isUseAutoclear(const bool &defaultValue) -> bool {
     212           16 :   return getInstance()
     213           48 :       ->value(SettingsConstants::useAutoclear, defaultValue)
     214           32 :       .toBool();
     215              : }
     216           16 : void QtPassSettings::setUseAutoclear(const bool &useAutoclear) {
     217           32 :   getInstance()->setValue(SettingsConstants::useAutoclear, useAutoclear);
     218           16 : }
     219              : 
     220           23 : auto QtPassSettings::getAutoclearSeconds(const int &defaultValue) -> int {
     221           23 :   return getInstance()
     222           69 :       ->value(SettingsConstants::autoclearSeconds, defaultValue)
     223           46 :       .toInt();
     224              : }
     225           46 : void QtPassSettings::setAutoclearSeconds(const int &autoClearSeconds) {
     226           92 :   getInstance()->setValue(SettingsConstants::autoclearSeconds,
     227           92 :                           autoClearSeconds);
     228           46 : }
     229              : 
     230            6 : auto QtPassSettings::isUseAutoclearPanel(const bool &defaultValue) -> bool {
     231            6 :   return getInstance()
     232           18 :       ->value(SettingsConstants::useAutoclearPanel, defaultValue)
     233           12 :       .toBool();
     234              : }
     235            6 : void QtPassSettings::setUseAutoclearPanel(const bool &useAutoclearPanel) {
     236           12 :   getInstance()->setValue(SettingsConstants::useAutoclearPanel,
     237           12 :                           useAutoclearPanel);
     238            6 : }
     239              : 
     240            3 : auto QtPassSettings::getAutoclearPanelSeconds(const int &defaultValue) -> int {
     241            3 :   return getInstance()
     242            9 :       ->value(SettingsConstants::autoclearPanelSeconds, defaultValue)
     243            6 :       .toInt();
     244              : }
     245            6 : void QtPassSettings::setAutoclearPanelSeconds(
     246              :     const int &autoClearPanelSeconds) {
     247           12 :   getInstance()->setValue(SettingsConstants::autoclearPanelSeconds,
     248           12 :                           autoClearPanelSeconds);
     249            6 : }
     250              : 
     251           26 : auto QtPassSettings::isHidePassword(const bool &defaultValue) -> bool {
     252           26 :   return getInstance()
     253           78 :       ->value(SettingsConstants::hidePassword, defaultValue)
     254           52 :       .toBool();
     255              : }
     256           26 : void QtPassSettings::setHidePassword(const bool &hidePassword) {
     257           52 :   getInstance()->setValue(SettingsConstants::hidePassword, hidePassword);
     258           26 : }
     259              : 
     260           16 : auto QtPassSettings::isHideContent(const bool &defaultValue) -> bool {
     261           16 :   return getInstance()
     262           48 :       ->value(SettingsConstants::hideContent, defaultValue)
     263           32 :       .toBool();
     264              : }
     265           16 : void QtPassSettings::setHideContent(const bool &hideContent) {
     266           32 :   getInstance()->setValue(SettingsConstants::hideContent, hideContent);
     267           16 : }
     268              : 
     269           16 : auto QtPassSettings::isUseMonospace(const bool &defaultValue) -> bool {
     270           16 :   return getInstance()
     271           48 :       ->value(SettingsConstants::useMonospace, defaultValue)
     272           32 :       .toBool();
     273              : }
     274           16 : void QtPassSettings::setUseMonospace(const bool &useMonospace) {
     275           32 :   getInstance()->setValue(SettingsConstants::useMonospace, useMonospace);
     276           16 : }
     277              : 
     278           10 : auto QtPassSettings::isDisplayAsIs(const bool &defaultValue) -> bool {
     279           10 :   return getInstance()
     280           30 :       ->value(SettingsConstants::displayAsIs, defaultValue)
     281           20 :       .toBool();
     282              : }
     283           10 : void QtPassSettings::setDisplayAsIs(const bool &displayAsIs) {
     284           20 :   getInstance()->setValue(SettingsConstants::displayAsIs, displayAsIs);
     285           10 : }
     286              : 
     287           16 : auto QtPassSettings::isNoLineWrapping(const bool &defaultValue) -> bool {
     288           16 :   return getInstance()
     289           48 :       ->value(SettingsConstants::noLineWrapping, defaultValue)
     290           32 :       .toBool();
     291              : }
     292           16 : void QtPassSettings::setNoLineWrapping(const bool &noLineWrapping) {
     293           32 :   getInstance()->setValue(SettingsConstants::noLineWrapping, noLineWrapping);
     294           16 : }
     295              : 
     296           16 : auto QtPassSettings::isAddGPGId(const bool &defaultValue) -> bool {
     297           16 :   return getInstance()
     298           48 :       ->value(SettingsConstants::addGPGId, defaultValue)
     299           32 :       .toBool();
     300              : }
     301           16 : void QtPassSettings::setAddGPGId(const bool &addGPGId) {
     302           32 :   getInstance()->setValue(SettingsConstants::addGPGId, addGPGId);
     303           16 : }
     304              : 
     305           46 : auto QtPassSettings::getPassStore(const QString &defaultValue) -> QString {
     306           46 :   QString returnValue = getInstance()
     307          138 :                             ->value(SettingsConstants::passStore, defaultValue)
     308           46 :                             .toString();
     309              : 
     310              :   // Normalize the path string
     311           92 :   returnValue = QDir(returnValue).absolutePath();
     312              : 
     313              :   // ensure directory exists if never used pass or misconfigured.
     314              :   // otherwise process->setWorkingDirectory(passStore); will fail on execution.
     315           46 :   if (!QDir(returnValue).exists()) {
     316            2 :     if (!QDir().mkdir(returnValue)) {
     317            0 :       qWarning() << "Failed to create password store directory:" << returnValue;
     318              :     }
     319              :   }
     320              : 
     321              :   // ensure path ends in /
     322           92 :   if (!returnValue.endsWith("/") && !returnValue.endsWith(QDir::separator())) {
     323           46 :     returnValue += QDir::separator();
     324              :   }
     325              : 
     326           46 :   return returnValue;
     327              : }
     328           23 : void QtPassSettings::setPassStore(const QString &passStore) {
     329           46 :   getInstance()->setValue(SettingsConstants::passStore, passStore);
     330           23 : }
     331              : 
     332            3 : auto QtPassSettings::getPassSigningKey(const QString &defaultValue) -> QString {
     333            3 :   return getInstance()
     334            9 :       ->value(SettingsConstants::passSigningKey, defaultValue)
     335            6 :       .toString();
     336              : }
     337            3 : void QtPassSettings::setPassSigningKey(const QString &passSigningKey) {
     338            6 :   getInstance()->setValue(SettingsConstants::passSigningKey, passSigningKey);
     339            3 : }
     340              : 
     341            0 : void QtPassSettings::initExecutables() {
     342              :   QString passExecutable =
     343            0 :       QtPassSettings::getPassExecutable(Util::findBinaryInPath("pass"));
     344            0 :   QtPassSettings::setPassExecutable(passExecutable);
     345              : 
     346              :   QString gitExecutable =
     347            0 :       QtPassSettings::getGitExecutable(Util::findBinaryInPath("git"));
     348            0 :   QtPassSettings::setGitExecutable(gitExecutable);
     349              : 
     350              :   QString gpgExecutable =
     351            0 :       QtPassSettings::getGpgExecutable(Util::findBinaryInPath("gpg2"));
     352            0 :   QtPassSettings::setGpgExecutable(gpgExecutable);
     353              : 
     354              :   QString pwgenExecutable =
     355            0 :       QtPassSettings::getPwgenExecutable(Util::findBinaryInPath("pwgen"));
     356            0 :   QtPassSettings::setPwgenExecutable(pwgenExecutable);
     357            0 : }
     358            3 : auto QtPassSettings::getPassExecutable(const QString &defaultValue) -> QString {
     359            3 :   return getInstance()
     360            9 :       ->value(SettingsConstants::passExecutable, defaultValue)
     361            6 :       .toString();
     362              : }
     363            3 : void QtPassSettings::setPassExecutable(const QString &passExecutable) {
     364            6 :   getInstance()->setValue(SettingsConstants::passExecutable, passExecutable);
     365            3 : }
     366              : 
     367            3 : auto QtPassSettings::getGitExecutable(const QString &defaultValue) -> QString {
     368            3 :   return getInstance()
     369            9 :       ->value(SettingsConstants::gitExecutable, defaultValue)
     370            6 :       .toString();
     371              : }
     372            3 : void QtPassSettings::setGitExecutable(const QString &gitExecutable) {
     373            6 :   getInstance()->setValue(SettingsConstants::gitExecutable, gitExecutable);
     374            3 : }
     375              : 
     376            3 : auto QtPassSettings::getGpgExecutable(const QString &defaultValue) -> QString {
     377            3 :   return getInstance()
     378            9 :       ->value(SettingsConstants::gpgExecutable, defaultValue)
     379            6 :       .toString();
     380              : }
     381            3 : void QtPassSettings::setGpgExecutable(const QString &gpgExecutable) {
     382            6 :   getInstance()->setValue(SettingsConstants::gpgExecutable, gpgExecutable);
     383            3 : }
     384              : 
     385            3 : auto QtPassSettings::getPwgenExecutable(const QString &defaultValue)
     386              :     -> QString {
     387            3 :   return getInstance()
     388            9 :       ->value(SettingsConstants::pwgenExecutable, defaultValue)
     389            6 :       .toString();
     390              : }
     391            3 : void QtPassSettings::setPwgenExecutable(const QString &pwgenExecutable) {
     392            6 :   getInstance()->setValue(SettingsConstants::pwgenExecutable, pwgenExecutable);
     393            3 : }
     394              : 
     395           32 : auto QtPassSettings::getGpgHome(const QString &defaultValue) -> QString {
     396           32 :   return getInstance()
     397           96 :       ->value(SettingsConstants::gpgHome, defaultValue)
     398           64 :       .toString();
     399              : }
     400              : 
     401            6 : auto QtPassSettings::isUseWebDav(const bool &defaultValue) -> bool {
     402            6 :   return getInstance()
     403           18 :       ->value(SettingsConstants::useWebDav, defaultValue)
     404           12 :       .toBool();
     405              : }
     406            6 : void QtPassSettings::setUseWebDav(const bool &useWebDav) {
     407           12 :   getInstance()->setValue(SettingsConstants::useWebDav, useWebDav);
     408            6 : }
     409              : 
     410            3 : auto QtPassSettings::getWebDavUrl(const QString &defaultValue) -> QString {
     411            3 :   return getInstance()
     412            9 :       ->value(SettingsConstants::webDavUrl, defaultValue)
     413            6 :       .toString();
     414              : }
     415            3 : void QtPassSettings::setWebDavUrl(const QString &webDavUrl) {
     416            6 :   getInstance()->setValue(SettingsConstants::webDavUrl, webDavUrl);
     417            3 : }
     418              : 
     419            3 : auto QtPassSettings::getWebDavUser(const QString &defaultValue) -> QString {
     420            3 :   return getInstance()
     421            9 :       ->value(SettingsConstants::webDavUser, defaultValue)
     422            6 :       .toString();
     423              : }
     424            3 : void QtPassSettings::setWebDavUser(const QString &webDavUser) {
     425            6 :   getInstance()->setValue(SettingsConstants::webDavUser, webDavUser);
     426            3 : }
     427              : 
     428            3 : auto QtPassSettings::getWebDavPassword(const QString &defaultValue) -> QString {
     429            3 :   return getInstance()
     430            9 :       ->value(SettingsConstants::webDavPassword, defaultValue)
     431            6 :       .toString();
     432              : }
     433            3 : void QtPassSettings::setWebDavPassword(const QString &webDavPassword) {
     434            6 :   getInstance()->setValue(SettingsConstants::webDavPassword, webDavPassword);
     435            3 : }
     436              : 
     437            3 : auto QtPassSettings::getProfile(const QString &defaultValue) -> QString {
     438            3 :   return getInstance()
     439            9 :       ->value(SettingsConstants::profile, defaultValue)
     440            6 :       .toString();
     441              : }
     442            3 : void QtPassSettings::setProfile(const QString &profile) {
     443            6 :   getInstance()->setValue(SettingsConstants::profile, profile);
     444            3 : }
     445              : 
     446           26 : auto QtPassSettings::isUseGit(const bool &defaultValue) -> bool {
     447           52 :   return getInstance()->value(SettingsConstants::useGit, defaultValue).toBool();
     448              : }
     449           26 : void QtPassSettings::setUseGit(const bool &useGit) {
     450           52 :   getInstance()->setValue(SettingsConstants::useGit, useGit);
     451           26 : }
     452              : 
     453           26 : auto QtPassSettings::isUseOtp(const bool &defaultValue) -> bool {
     454           52 :   return getInstance()->value(SettingsConstants::useOtp, defaultValue).toBool();
     455              : }
     456              : 
     457           26 : void QtPassSettings::setUseOtp(const bool &useOtp) {
     458           52 :   getInstance()->setValue(SettingsConstants::useOtp, useOtp);
     459           26 : }
     460              : 
     461            6 : auto QtPassSettings::isUseQrencode(const bool &defaultValue) -> bool {
     462            6 :   return getInstance()
     463           18 :       ->value(SettingsConstants::useQrencode, defaultValue)
     464           12 :       .toBool();
     465              : }
     466              : 
     467            6 : void QtPassSettings::setUseQrencode(const bool &useQrencode) {
     468           12 :   getInstance()->setValue(SettingsConstants::useQrencode, useQrencode);
     469            6 : }
     470              : 
     471            3 : auto QtPassSettings::getQrencodeExecutable(const QString &defaultValue)
     472              :     -> QString {
     473            3 :   return getInstance()
     474            9 :       ->value(SettingsConstants::qrencodeExecutable, defaultValue)
     475            6 :       .toString();
     476              : }
     477            3 : void QtPassSettings::setQrencodeExecutable(const QString &qrencodeExecutable) {
     478            6 :   getInstance()->setValue(SettingsConstants::qrencodeExecutable,
     479            6 :                           qrencodeExecutable);
     480            3 : }
     481              : 
     482           26 : auto QtPassSettings::isUsePwgen(const bool &defaultValue) -> bool {
     483           26 :   return getInstance()
     484           78 :       ->value(SettingsConstants::usePwgen, defaultValue)
     485           52 :       .toBool();
     486              : }
     487           26 : void QtPassSettings::setUsePwgen(const bool &usePwgen) {
     488           52 :   getInstance()->setValue(SettingsConstants::usePwgen, usePwgen);
     489           26 : }
     490              : 
     491           16 : auto QtPassSettings::isAvoidCapitals(const bool &defaultValue) -> bool {
     492           16 :   return getInstance()
     493           48 :       ->value(SettingsConstants::avoidCapitals, defaultValue)
     494           32 :       .toBool();
     495              : }
     496           16 : void QtPassSettings::setAvoidCapitals(const bool &avoidCapitals) {
     497           32 :   getInstance()->setValue(SettingsConstants::avoidCapitals, avoidCapitals);
     498           16 : }
     499              : 
     500           16 : auto QtPassSettings::isAvoidNumbers(const bool &defaultValue) -> bool {
     501           16 :   return getInstance()
     502           48 :       ->value(SettingsConstants::avoidNumbers, defaultValue)
     503           32 :       .toBool();
     504              : }
     505           16 : void QtPassSettings::setAvoidNumbers(const bool &avoidNumbers) {
     506           32 :   getInstance()->setValue(SettingsConstants::avoidNumbers, avoidNumbers);
     507           16 : }
     508              : 
     509           16 : auto QtPassSettings::isLessRandom(const bool &defaultValue) -> bool {
     510           16 :   return getInstance()
     511           48 :       ->value(SettingsConstants::lessRandom, defaultValue)
     512           32 :       .toBool();
     513              : }
     514           16 : void QtPassSettings::setLessRandom(const bool &lessRandom) {
     515           32 :   getInstance()->setValue(SettingsConstants::lessRandom, lessRandom);
     516           16 : }
     517              : 
     518           16 : auto QtPassSettings::isUseSymbols(const bool &defaultValue) -> bool {
     519           16 :   return getInstance()
     520           48 :       ->value(SettingsConstants::useSymbols, defaultValue)
     521           32 :       .toBool();
     522              : }
     523           16 : void QtPassSettings::setUseSymbols(const bool &useSymbols) {
     524           32 :   getInstance()->setValue(SettingsConstants::useSymbols, useSymbols);
     525           16 : }
     526              : 
     527           47 : void QtPassSettings::setPasswordLength(const int &passwordLength) {
     528           94 :   getInstance()->setValue(SettingsConstants::passwordLength, passwordLength);
     529           47 : }
     530           51 : void QtPassSettings::setPasswordCharsselection(
     531              :     const int &passwordCharsselection) {
     532          102 :   getInstance()->setValue(SettingsConstants::passwordCharsselection,
     533          102 :                           passwordCharsselection);
     534           51 : }
     535            3 : void QtPassSettings::setPasswordChars(const QString &passwordChars) {
     536            6 :   getInstance()->setValue(SettingsConstants::passwordChars, passwordChars);
     537            3 : }
     538              : 
     539           26 : auto QtPassSettings::isUseTrayIcon(const bool &defaultValue) -> bool {
     540           26 :   return getInstance()
     541           78 :       ->value(SettingsConstants::useTrayIcon, defaultValue)
     542           52 :       .toBool();
     543              : }
     544           26 : void QtPassSettings::setUseTrayIcon(const bool &useTrayIcon) {
     545           52 :   getInstance()->setValue(SettingsConstants::useTrayIcon, useTrayIcon);
     546           26 : }
     547              : 
     548           10 : auto QtPassSettings::isHideOnClose(const bool &defaultValue) -> bool {
     549           10 :   return getInstance()
     550           30 :       ->value(SettingsConstants::hideOnClose, defaultValue)
     551           20 :       .toBool();
     552              : }
     553           10 : void QtPassSettings::setHideOnClose(const bool &hideOnClose) {
     554           20 :   getInstance()->setValue(SettingsConstants::hideOnClose, hideOnClose);
     555           10 : }
     556              : 
     557           10 : auto QtPassSettings::isStartMinimized(const bool &defaultValue) -> bool {
     558           10 :   return getInstance()
     559           30 :       ->value(SettingsConstants::startMinimized, defaultValue)
     560           20 :       .toBool();
     561              : }
     562           10 : void QtPassSettings::setStartMinimized(const bool &startMinimized) {
     563           20 :   getInstance()->setValue(SettingsConstants::startMinimized, startMinimized);
     564           10 : }
     565              : 
     566           10 : auto QtPassSettings::isAlwaysOnTop(const bool &defaultValue) -> bool {
     567           10 :   return getInstance()
     568           30 :       ->value(SettingsConstants::alwaysOnTop, defaultValue)
     569           20 :       .toBool();
     570              : }
     571           10 : void QtPassSettings::setAlwaysOnTop(const bool &alwaysOnTop) {
     572           20 :   getInstance()->setValue(SettingsConstants::alwaysOnTop, alwaysOnTop);
     573           10 : }
     574              : 
     575           10 : auto QtPassSettings::isAutoPull(const bool &defaultValue) -> bool {
     576           10 :   return getInstance()
     577           30 :       ->value(SettingsConstants::autoPull, defaultValue)
     578           20 :       .toBool();
     579              : }
     580           10 : void QtPassSettings::setAutoPull(const bool &autoPull) {
     581           20 :   getInstance()->setValue(SettingsConstants::autoPull, autoPull);
     582           10 : }
     583              : 
     584           10 : auto QtPassSettings::isAutoPush(const bool &defaultValue) -> bool {
     585           10 :   return getInstance()
     586           30 :       ->value(SettingsConstants::autoPush, defaultValue)
     587           20 :       .toBool();
     588              : }
     589           10 : void QtPassSettings::setAutoPush(const bool &autoPush) {
     590           20 :   getInstance()->setValue(SettingsConstants::autoPush, autoPush);
     591           10 : }
     592              : 
     593            3 : auto QtPassSettings::getPassTemplate(const QString &defaultValue) -> QString {
     594            3 :   return getInstance()
     595            9 :       ->value(SettingsConstants::passTemplate, defaultValue)
     596            6 :       .toString();
     597              : }
     598            3 : void QtPassSettings::setPassTemplate(const QString &passTemplate) {
     599            6 :   getInstance()->setValue(SettingsConstants::passTemplate, passTemplate);
     600            3 : }
     601              : 
     602           10 : auto QtPassSettings::isUseTemplate(const bool &defaultValue) -> bool {
     603           10 :   return getInstance()
     604           30 :       ->value(SettingsConstants::useTemplate, defaultValue)
     605           20 :       .toBool();
     606              : }
     607           10 : void QtPassSettings::setUseTemplate(const bool &useTemplate) {
     608           20 :   getInstance()->setValue(SettingsConstants::useTemplate, useTemplate);
     609           10 : }
     610              : 
     611            6 : auto QtPassSettings::isTemplateAllFields(const bool &defaultValue) -> bool {
     612            6 :   return getInstance()
     613           18 :       ->value(SettingsConstants::templateAllFields, defaultValue)
     614           12 :       .toBool();
     615              : }
     616            6 : void QtPassSettings::setTemplateAllFields(const bool &templateAllFields) {
     617           12 :   getInstance()->setValue(SettingsConstants::templateAllFields,
     618           12 :                           templateAllFields);
     619            6 : }
     620              : 
     621           55 : auto QtPassSettings::getRealPass() -> RealPass * {
     622           55 :   if (realPass.isNull()) {
     623           55 :     realPass.reset(new RealPass());
     624              :   }
     625           55 :   return realPass.data();
     626              : }
     627           23 : auto QtPassSettings::getImitatePass() -> ImitatePass * {
     628           23 :   if (imitatePass.isNull()) {
     629           23 :     imitatePass.reset(new ImitatePass());
     630              :   }
     631           23 :   return imitatePass.data();
     632              : }
        

Generated by: LCOV version 2.4-beta