• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IJHack / QtPass / 24124365613

08 Apr 2026 07:54AM UTC coverage: 21.044%. Remained the same
24124365613

push

github

web-flow
Merge pull request #929 from IJHack/fix/clang-format-docstrings

docs: add Doxygen docstrings to source files (clang-formatted)

1109 of 5270 relevant lines covered (21.04%)

7.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.57
/src/qtpasssettings.cpp
1
// SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
3

4
/**
5
 * @class QtPassSettings
6
 * @brief Singleton settings manager implementation.
7
 *
8
 * Implementation of QtPassSettings singleton. Handles persistence using
9
 * QSettings with support for portable mode (qtpass.ini next to executable).
10
 *
11
 * @see qtpasssettings.h
12
 */
13

14
#include "qtpasssettings.h"
15
#include "pass.h"
16

17
#include "util.h"
18

19
#include <QCoreApplication>
20
#include <QDebug>
21

22
bool QtPassSettings::initialized = false;
23

24
Pass *QtPassSettings::pass;
25
// Go via pointer to avoid dynamic initialization,
26
// due to "random" initialization order relative to other
27
// globals, especially around QObject metadata dynamic initialization
28
// can lead to crashes depending on compiler, linker etc.
29
QScopedPointer<RealPass> QtPassSettings::realPass;
30
QScopedPointer<ImitatePass> QtPassSettings::imitatePass;
31

32
QtPassSettings *QtPassSettings::m_instance = nullptr;
33
/**
34
 * @brief Returns the singleton instance of QtPassSettings, creating it on first
35
 * access.
36
 * @example
37
 * QtPassSettings *settings = QtPassSettings::getInstance();
38
 * std::cout << settings << std::endl; // Expected output sample: a valid
39
 * QtPassSettings pointer
40
 *
41
 * @return QtPassSettings* - Pointer to the shared QtPassSettings instance.
42
 */
43
auto QtPassSettings::getInstance() -> QtPassSettings * {
1,382✔
44
  if (!QtPassSettings::initialized) {
1,382✔
45
    QString portable_ini = QCoreApplication::applicationDirPath() +
5✔
46
                           QDir::separator() + "qtpass.ini";
5✔
47
    if (QFile(portable_ini).exists()) {
5✔
48
      m_instance = new QtPassSettings(portable_ini, QSettings::IniFormat);
×
49
    } else {
50
      m_instance = new QtPassSettings("IJHack", "QtPass");
10✔
51
    }
52

53
    initialized = true;
5✔
54
  }
55

56
  return m_instance;
1,382✔
57
}
58

59
/**
60
 * @brief Retrieves the current password configuration from application
61
 * settings.
62
 * @example
63
 * PasswordConfiguration result = QtPassSettings::getPasswordConfiguration();
64
 * std::cout << result.length << std::endl; // Expected output sample
65
 *
66
 * @return PasswordConfiguration - The password configuration populated from
67
 * stored settings, including length, selected character set, and custom
68
 * characters.
69
 */
70
auto QtPassSettings::getPasswordConfiguration() -> PasswordConfiguration {
7✔
71
  PasswordConfiguration config;
7✔
72

73
  config.length =
7✔
74
      getInstance()->value(SettingsConstants::passwordLength, 16).toInt();
7✔
75
  if (config.length <= 0) {
7✔
76
    config.length = 16;
×
77
  }
78
  config.selected = static_cast<PasswordConfiguration::characterSet>(
7✔
79
      getInstance()
7✔
80
          ->value(SettingsConstants::passwordCharsselection, 0)
14✔
81
          .toInt());
7✔
82
  config.Characters[PasswordConfiguration::CUSTOM] =
83
      getInstance()
7✔
84
          ->value(SettingsConstants::passwordChars, QString())
14✔
85
          .toString();
7✔
86

87
  return config;
7✔
88
}
×
89

90
void QtPassSettings::setPasswordConfiguration(
1✔
91
    const PasswordConfiguration &config) {
92
  getInstance()->setValue(SettingsConstants::passwordLength, config.length);
1✔
93
  getInstance()->setValue(SettingsConstants::passwordCharsselection,
2✔
94
                          config.selected);
1✔
95
  getInstance()->setValue(SettingsConstants::passwordChars,
2✔
96
                          config.Characters[PasswordConfiguration::CUSTOM]);
1✔
97
}
1✔
98

99
/**
100
 * @brief Retrieves the stored profiles configuration as a nested hash map.
101
 * @details Reads profile data from the settings group, including legacy profile
102
 *          formats from versions <= v1.3.2, and returns each profile name
103
 * mapped to its properties such as path and signing key.
104
 * @example
105
 * QHash<QString, QHash<QString, QString>> profiles =
106
 * QtPassSettings::getProfiles(); std::cout << profiles.size() << std::endl; //
107
 * Expected output: number of profiles
108
 *
109
 * @return QHash<QString, QHash<QString, QString>> - A hash map of profile names
110
 *         mapped to their key/value properties.
111
 */
112
auto QtPassSettings::getProfiles() -> QHash<QString, QHash<QString, QString>> {
3✔
113
  getInstance()->beginGroup(SettingsConstants::profile);
3✔
114
  QHash<QString, QHash<QString, QString>> profiles;
3✔
115

116
  // migration from version <= v1.3.2: profiles datastructure
117
  QStringList childKeys = getInstance()->childKeys();
3✔
118
  if (!childKeys.empty()) {
3✔
119
    foreach (QString key, childKeys) {
×
120
      QHash<QString, QString> profile;
×
121
      profile.insert("path", getInstance()->value(key).toString());
×
122
      profile.insert("signingKey", "");
×
123
      profiles.insert(key, profile);
124
    }
×
125
  }
126
  // /migration from version <= v1.3.2
127

128
  QStringList childGroups = getInstance()->childGroups();
3✔
129
  foreach (QString group, childGroups) {
6✔
130
    QHash<QString, QString> profile;
3✔
131
    profile.insert("path", getInstance()->value(group + "/path").toString());
9✔
132
    profile.insert("signingKey",
6✔
133
                   getInstance()->value(group + "/signingKey").toString());
9✔
134
    // profiles.insert(group, getInstance()->value(group).toString());
135
    profiles.insert(group, profile);
136
  }
3✔
137

138
  getInstance()->endGroup();
3✔
139

140
  return profiles;
3✔
141
}
×
142

143
/**
144
 * @brief Stores the profile settings in the application's configuration.
145
 * @example
146
 * QtPassSettings::setProfiles(profiles);
147
 *
148
 * @param profiles - A hash of profile names mapped to their key-value settings,
149
 * such as "path" and "signingKey".
150
 * @return void - This method does not return a value.
151
 */
152
void QtPassSettings::setProfiles(
3✔
153
    const QHash<QString, QHash<QString, QString>> &profiles) {
154
  getInstance()->remove(SettingsConstants::profile);
3✔
155
  getInstance()->beginGroup(SettingsConstants::profile);
3✔
156

157
  QHash<QString, QHash<QString, QString>>::const_iterator i = profiles.begin();
3✔
158
  for (; i != profiles.end(); ++i) {
3✔
159
    getInstance()->setValue(i.key() + "/path", i.value().value("path"));
6✔
160
    getInstance()->setValue(i.key() + "/signingKey",
9✔
161
                            i.value().value("signingKey"));
6✔
162
  }
163

164
  getInstance()->endGroup();
3✔
165
}
3✔
166

167
auto QtPassSettings::getPass() -> Pass * {
11✔
168
  if (!pass) {
11✔
169
    if (isUsePass()) {
1✔
170
      QtPassSettings::pass = getRealPass();
×
171
    } else {
172
      QtPassSettings::pass = getImitatePass();
1✔
173
    }
174
    pass->init();
1✔
175
  }
176
  return pass;
11✔
177
}
178

179
auto QtPassSettings::getVersion(const QString &defaultValue) -> QString {
1✔
180
  return getInstance()
1✔
181
      ->value(SettingsConstants::version, defaultValue)
2✔
182
      .toString();
2✔
183
}
184
void QtPassSettings::setVersion(const QString &version) {
1✔
185
  getInstance()->setValue(SettingsConstants::version, version);
1✔
186
}
1✔
187

188
auto QtPassSettings::getGeometry(const QByteArray &defaultValue) -> QByteArray {
1✔
189
  return getInstance()
1✔
190
      ->value(SettingsConstants::geometry, defaultValue)
2✔
191
      .toByteArray();
2✔
192
}
193
void QtPassSettings::setGeometry(const QByteArray &geometry) {
1✔
194
  getInstance()->setValue(SettingsConstants::geometry, geometry);
1✔
195
}
1✔
196

197
auto QtPassSettings::getSavestate(const QByteArray &defaultValue)
1✔
198
    -> QByteArray {
199
  return getInstance()
1✔
200
      ->value(SettingsConstants::savestate, defaultValue)
2✔
201
      .toByteArray();
2✔
202
}
203
void QtPassSettings::setSavestate(const QByteArray &saveState) {
1✔
204
  getInstance()->setValue(SettingsConstants::savestate, saveState);
1✔
205
}
1✔
206

207
auto QtPassSettings::getPos(const QPoint &defaultValue) -> QPoint {
1✔
208
  return getInstance()->value(SettingsConstants::pos, defaultValue).toPoint();
1✔
209
}
210
void QtPassSettings::setPos(const QPoint &pos) {
1✔
211
  getInstance()->setValue(SettingsConstants::pos, pos);
1✔
212
}
1✔
213

214
auto QtPassSettings::getSize(const QSize &defaultValue) -> QSize {
1✔
215
  return getInstance()->value(SettingsConstants::size, defaultValue).toSize();
1✔
216
}
217
void QtPassSettings::setSize(const QSize &size) {
1✔
218
  getInstance()->setValue(SettingsConstants::size, size);
1✔
219
}
1✔
220

221
auto QtPassSettings::isMaximized(const bool &defaultValue) -> bool {
4✔
222
  return getInstance()
4✔
223
      ->value(SettingsConstants::maximized, defaultValue)
8✔
224
      .toBool();
8✔
225
}
226
void QtPassSettings::setMaximized(const bool &maximized) {
2✔
227
  getInstance()->setValue(SettingsConstants::maximized, maximized);
2✔
228
}
2✔
229

230
auto QtPassSettings::getDialogGeometry(const QString &key,
1✔
231
                                       const QByteArray &defaultValue)
232
    -> QByteArray {
233
  return getInstance()
1✔
234
      ->value(SettingsConstants::dialogGeometry + "/" + key, defaultValue)
3✔
235
      .toByteArray();
2✔
236
}
237
void QtPassSettings::setDialogGeometry(const QString &key,
1✔
238
                                       const QByteArray &geometry) {
239
  getInstance()->setValue(SettingsConstants::dialogGeometry + "/" + key,
2✔
240
                          geometry);
241
}
1✔
242

243
auto QtPassSettings::getDialogPos(const QString &key,
1✔
244
                                  const QPoint &defaultValue) -> QPoint {
245
  return getInstance()
1✔
246
      ->value(SettingsConstants::dialogPos + "/" + key, defaultValue)
3✔
247
      .toPoint();
2✔
248
}
249
void QtPassSettings::setDialogPos(const QString &key, const QPoint &pos) {
1✔
250
  getInstance()->setValue(SettingsConstants::dialogPos + "/" + key, pos);
2✔
251
}
1✔
252

253
auto QtPassSettings::getDialogSize(const QString &key,
1✔
254
                                   const QSize &defaultValue) -> QSize {
255
  return getInstance()
1✔
256
      ->value(SettingsConstants::dialogSize + "/" + key, defaultValue)
3✔
257
      .toSize();
2✔
258
}
259
void QtPassSettings::setDialogSize(const QString &key, const QSize &size) {
1✔
260
  getInstance()->setValue(SettingsConstants::dialogSize + "/" + key, size);
2✔
261
}
1✔
262

263
auto QtPassSettings::isDialogMaximized(const QString &key,
2✔
264
                                       const bool &defaultValue) -> bool {
265
  return getInstance()
2✔
266
      ->value(SettingsConstants::dialogMaximized + "/" + key, defaultValue)
6✔
267
      .toBool();
4✔
268
}
269
void QtPassSettings::setDialogMaximized(const QString &key,
2✔
270
                                        const bool &maximized) {
271
  getInstance()->setValue(SettingsConstants::dialogMaximized + "/" + key,
6✔
272
                          maximized);
2✔
273
}
2✔
274

275
auto QtPassSettings::isUsePass(const bool &defaultValue) -> bool {
5✔
276
  return getInstance()
5✔
277
      ->value(SettingsConstants::usePass, defaultValue)
10✔
278
      .toBool();
10✔
279
}
280
void QtPassSettings::setUsePass(const bool &usePass) {
2✔
281
  if (usePass) {
2✔
282
    QtPassSettings::pass = getRealPass();
1✔
283
  } else {
284
    QtPassSettings::pass = getImitatePass();
1✔
285
  }
286
  getInstance()->setValue(SettingsConstants::usePass, usePass);
2✔
287
}
2✔
288

289
auto QtPassSettings::getClipBoardTypeRaw(
1✔
290
    const Enums::clipBoardType &defaultvalue) -> int {
291
  return getInstance()
1✔
292
      ->value(SettingsConstants::clipBoardType, static_cast<int>(defaultvalue))
2✔
293
      .toInt();
2✔
294
}
295

296
auto QtPassSettings::getClipBoardType(const Enums::clipBoardType &defaultvalue)
1✔
297
    -> Enums::clipBoardType {
298
  return static_cast<Enums::clipBoardType>(getClipBoardTypeRaw(defaultvalue));
1✔
299
}
300
void QtPassSettings::setClipBoardType(const int &clipBoardType) {
1✔
301
  getInstance()->setValue(SettingsConstants::clipBoardType, clipBoardType);
1✔
302
}
1✔
303

304
auto QtPassSettings::isUseSelection(const bool &defaultValue) -> bool {
4✔
305
  return getInstance()
4✔
306
      ->value(SettingsConstants::useSelection, defaultValue)
8✔
307
      .toBool();
8✔
308
}
309
void QtPassSettings::setUseSelection(const bool &useSelection) {
2✔
310
  getInstance()->setValue(SettingsConstants::useSelection, useSelection);
2✔
311
}
2✔
312

313
auto QtPassSettings::isUseAutoclear(const bool &defaultValue) -> bool {
4✔
314
  return getInstance()
4✔
315
      ->value(SettingsConstants::useAutoclear, defaultValue)
8✔
316
      .toBool();
8✔
317
}
318
void QtPassSettings::setUseAutoclear(const bool &useAutoclear) {
2✔
319
  getInstance()->setValue(SettingsConstants::useAutoclear, useAutoclear);
2✔
320
}
2✔
321

322
auto QtPassSettings::getAutoclearSeconds(const int &defaultValue) -> int {
2✔
323
  return getInstance()
2✔
324
      ->value(SettingsConstants::autoclearSeconds, defaultValue)
4✔
325
      .toInt();
4✔
326
}
327
void QtPassSettings::setAutoclearSeconds(const int &autoClearSeconds) {
2✔
328
  getInstance()->setValue(SettingsConstants::autoclearSeconds,
2✔
329
                          autoClearSeconds);
330
}
2✔
331

332
auto QtPassSettings::isUseAutoclearPanel(const bool &defaultValue) -> bool {
4✔
333
  return getInstance()
4✔
334
      ->value(SettingsConstants::useAutoclearPanel, defaultValue)
8✔
335
      .toBool();
8✔
336
}
337
void QtPassSettings::setUseAutoclearPanel(const bool &useAutoclearPanel) {
2✔
338
  getInstance()->setValue(SettingsConstants::useAutoclearPanel,
4✔
339
                          useAutoclearPanel);
2✔
340
}
2✔
341

342
auto QtPassSettings::getAutoclearPanelSeconds(const int &defaultValue) -> int {
2✔
343
  return getInstance()
2✔
344
      ->value(SettingsConstants::autoclearPanelSeconds, defaultValue)
4✔
345
      .toInt();
4✔
346
}
347
void QtPassSettings::setAutoclearPanelSeconds(
2✔
348
    const int &autoClearPanelSeconds) {
349
  getInstance()->setValue(SettingsConstants::autoclearPanelSeconds,
2✔
350
                          autoClearPanelSeconds);
351
}
2✔
352

353
auto QtPassSettings::isHidePassword(const bool &defaultValue) -> bool {
4✔
354
  return getInstance()
4✔
355
      ->value(SettingsConstants::hidePassword, defaultValue)
8✔
356
      .toBool();
8✔
357
}
358
void QtPassSettings::setHidePassword(const bool &hidePassword) {
2✔
359
  getInstance()->setValue(SettingsConstants::hidePassword, hidePassword);
2✔
360
}
2✔
361

362
auto QtPassSettings::isHideContent(const bool &defaultValue) -> bool {
4✔
363
  return getInstance()
4✔
364
      ->value(SettingsConstants::hideContent, defaultValue)
8✔
365
      .toBool();
8✔
366
}
367
void QtPassSettings::setHideContent(const bool &hideContent) {
2✔
368
  getInstance()->setValue(SettingsConstants::hideContent, hideContent);
2✔
369
}
2✔
370

371
auto QtPassSettings::isUseMonospace(const bool &defaultValue) -> bool {
4✔
372
  return getInstance()
4✔
373
      ->value(SettingsConstants::useMonospace, defaultValue)
8✔
374
      .toBool();
8✔
375
}
376
void QtPassSettings::setUseMonospace(const bool &useMonospace) {
2✔
377
  getInstance()->setValue(SettingsConstants::useMonospace, useMonospace);
2✔
378
}
2✔
379

380
auto QtPassSettings::isDisplayAsIs(const bool &defaultValue) -> bool {
4✔
381
  return getInstance()
4✔
382
      ->value(SettingsConstants::displayAsIs, defaultValue)
8✔
383
      .toBool();
8✔
384
}
385
void QtPassSettings::setDisplayAsIs(const bool &displayAsIs) {
2✔
386
  getInstance()->setValue(SettingsConstants::displayAsIs, displayAsIs);
2✔
387
}
2✔
388

389
auto QtPassSettings::isNoLineWrapping(const bool &defaultValue) -> bool {
4✔
390
  return getInstance()
4✔
391
      ->value(SettingsConstants::noLineWrapping, defaultValue)
8✔
392
      .toBool();
8✔
393
}
394
void QtPassSettings::setNoLineWrapping(const bool &noLineWrapping) {
2✔
395
  getInstance()->setValue(SettingsConstants::noLineWrapping, noLineWrapping);
2✔
396
}
2✔
397

398
auto QtPassSettings::isAddGPGId(const bool &defaultValue) -> bool {
4✔
399
  return getInstance()
4✔
400
      ->value(SettingsConstants::addGPGId, defaultValue)
8✔
401
      .toBool();
8✔
402
}
403
void QtPassSettings::setAddGPGId(const bool &addGPGId) {
2✔
404
  getInstance()->setValue(SettingsConstants::addGPGId, addGPGId);
2✔
405
}
2✔
406

407
/**
408
 * @brief Retrieves the password store path, normalizes it, and ensures the
409
 * directory exists.
410
 * @example
411
 * QString passStore =
412
 * QtPassSettings::getPassStore("/home/user/.password-store"); qDebug() <<
413
 * passStore; // Expected output: "/home/user/.password-store/"
414
 *
415
 * @param defaultValue - Fallback path used when no password store is
416
 * configured.
417
 * @return QString - The normalized absolute password store path, guaranteed to
418
 * end with a path separator.
419
 */
420
auto QtPassSettings::getPassStore(const QString &defaultValue) -> QString {
28✔
421
  QString returnValue = getInstance()
28✔
422
                            ->value(SettingsConstants::passStore, defaultValue)
56✔
423
                            .toString();
28✔
424

425
  // Normalize the path string
426
  returnValue = QDir(returnValue).absolutePath();
56✔
427

428
  // ensure directory exists if never used pass or misconfigured.
429
  // otherwise process->setWorkingDirectory(passStore); will fail on execution.
430
  if (!QDir(returnValue).exists()) {
28✔
431
    if (!QDir().mkdir(returnValue)) {
6✔
432
      qWarning() << "Failed to create password store directory:" << returnValue;
×
433
    }
434
  }
435

436
  // ensure path ends in /
437
  if (!returnValue.endsWith("/") && !returnValue.endsWith(QDir::separator())) {
56✔
438
    returnValue += QDir::separator();
28✔
439
  }
440

441
  return returnValue;
28✔
442
}
443
void QtPassSettings::setPassStore(const QString &passStore) {
17✔
444
  getInstance()->setValue(SettingsConstants::passStore, passStore);
17✔
445
}
17✔
446

447
auto QtPassSettings::getPassSigningKey(const QString &defaultValue) -> QString {
2✔
448
  return getInstance()
2✔
449
      ->value(SettingsConstants::passSigningKey, defaultValue)
4✔
450
      .toString();
4✔
451
}
452
void QtPassSettings::setPassSigningKey(const QString &passSigningKey) {
2✔
453
  getInstance()->setValue(SettingsConstants::passSigningKey, passSigningKey);
2✔
454
}
2✔
455

456
/**
457
 * @brief Initializes executable paths for Pass, Git, GPG, and Pwgen by locating
458
 * them in the system PATH.
459
 * @example
460
 * QtPassSettings::initExecutables();
461
 *
462
 * @return void - This method does not return a value.
463
 */
464
void QtPassSettings::initExecutables() {
×
465
  QString passExecutable =
466
      QtPassSettings::getPassExecutable(Util::findBinaryInPath("pass"));
×
467
  QtPassSettings::setPassExecutable(passExecutable);
×
468

469
  QString gitExecutable =
470
      QtPassSettings::getGitExecutable(Util::findBinaryInPath("git"));
×
471
  QtPassSettings::setGitExecutable(gitExecutable);
×
472

473
  QString gpgExecutable =
474
      QtPassSettings::getGpgExecutable(Util::findBinaryInPath("gpg2"));
×
475
  QtPassSettings::setGpgExecutable(gpgExecutable);
×
476

477
  QString pwgenExecutable =
478
      QtPassSettings::getPwgenExecutable(Util::findBinaryInPath("pwgen"));
×
479
  QtPassSettings::setPwgenExecutable(pwgenExecutable);
×
480
}
×
481
auto QtPassSettings::getPassExecutable(const QString &defaultValue) -> QString {
2✔
482
  return getInstance()
2✔
483
      ->value(SettingsConstants::passExecutable, defaultValue)
4✔
484
      .toString();
4✔
485
}
486
void QtPassSettings::setPassExecutable(const QString &passExecutable) {
2✔
487
  getInstance()->setValue(SettingsConstants::passExecutable, passExecutable);
2✔
488
}
2✔
489

490
auto QtPassSettings::getGitExecutable(const QString &defaultValue) -> QString {
2✔
491
  return getInstance()
2✔
492
      ->value(SettingsConstants::gitExecutable, defaultValue)
4✔
493
      .toString();
4✔
494
}
495
void QtPassSettings::setGitExecutable(const QString &gitExecutable) {
2✔
496
  getInstance()->setValue(SettingsConstants::gitExecutable, gitExecutable);
2✔
497
}
2✔
498

499
auto QtPassSettings::getGpgExecutable(const QString &defaultValue) -> QString {
5✔
500
  return getInstance()
5✔
501
      ->value(SettingsConstants::gpgExecutable, defaultValue)
10✔
502
      .toString();
10✔
503
}
504
void QtPassSettings::setGpgExecutable(const QString &gpgExecutable) {
2✔
505
  getInstance()->setValue(SettingsConstants::gpgExecutable, gpgExecutable);
2✔
506
}
2✔
507

508
auto QtPassSettings::getPwgenExecutable(const QString &defaultValue)
2✔
509
    -> QString {
510
  return getInstance()
2✔
511
      ->value(SettingsConstants::pwgenExecutable, defaultValue)
4✔
512
      .toString();
4✔
513
}
514
void QtPassSettings::setPwgenExecutable(const QString &pwgenExecutable) {
2✔
515
  getInstance()->setValue(SettingsConstants::pwgenExecutable, pwgenExecutable);
2✔
516
}
2✔
517

518
auto QtPassSettings::getGpgHome(const QString &defaultValue) -> QString {
1✔
519
  return getInstance()
1✔
520
      ->value(SettingsConstants::gpgHome, defaultValue)
2✔
521
      .toString();
2✔
522
}
523

524
auto QtPassSettings::isUseWebDav(const bool &defaultValue) -> bool {
4✔
525
  return getInstance()
4✔
526
      ->value(SettingsConstants::useWebDav, defaultValue)
8✔
527
      .toBool();
8✔
528
}
529
void QtPassSettings::setUseWebDav(const bool &useWebDav) {
2✔
530
  getInstance()->setValue(SettingsConstants::useWebDav, useWebDav);
2✔
531
}
2✔
532

533
auto QtPassSettings::getWebDavUrl(const QString &defaultValue) -> QString {
2✔
534
  return getInstance()
2✔
535
      ->value(SettingsConstants::webDavUrl, defaultValue)
4✔
536
      .toString();
4✔
537
}
538
void QtPassSettings::setWebDavUrl(const QString &webDavUrl) {
2✔
539
  getInstance()->setValue(SettingsConstants::webDavUrl, webDavUrl);
2✔
540
}
2✔
541

542
auto QtPassSettings::getWebDavUser(const QString &defaultValue) -> QString {
2✔
543
  return getInstance()
2✔
544
      ->value(SettingsConstants::webDavUser, defaultValue)
4✔
545
      .toString();
4✔
546
}
547
void QtPassSettings::setWebDavUser(const QString &webDavUser) {
2✔
548
  getInstance()->setValue(SettingsConstants::webDavUser, webDavUser);
2✔
549
}
2✔
550

551
auto QtPassSettings::getWebDavPassword(const QString &defaultValue) -> QString {
2✔
552
  return getInstance()
2✔
553
      ->value(SettingsConstants::webDavPassword, defaultValue)
4✔
554
      .toString();
4✔
555
}
556
void QtPassSettings::setWebDavPassword(const QString &webDavPassword) {
2✔
557
  getInstance()->setValue(SettingsConstants::webDavPassword, webDavPassword);
2✔
558
}
2✔
559

560
auto QtPassSettings::getProfile(const QString &defaultValue) -> QString {
3✔
561
  return getInstance()
3✔
562
      ->value(SettingsConstants::profile, defaultValue)
6✔
563
      .toString();
6✔
564
}
565
void QtPassSettings::setProfile(const QString &profile) {
3✔
566
  getInstance()->setValue(SettingsConstants::profile, profile);
3✔
567
}
3✔
568

569
/**
570
 * @brief Determines whether Git should be used for the current QtPass settings.
571
 * @example
572
 * bool result = QtPassSettings::isUseGit(true);
573
 * std::cout << result << std::endl; // Expected output: true or false
574
 *
575
 * @param const bool &defaultValue - The fallback value used when no explicit
576
 * setting is stored.
577
 * @return bool - True if Git usage is enabled, otherwise false.
578
 */
579
auto QtPassSettings::isUseGit(const bool &defaultValue) -> bool {
8✔
580
  bool storedValue =
581
      getInstance()->value(SettingsConstants::useGit, defaultValue).toBool();
8✔
582
  if (storedValue == defaultValue && defaultValue) {
8✔
583
    QString passStore = getPassStore();
4✔
584
    if (QFileInfo(passStore).isDir() &&
4✔
585
        QFileInfo(passStore + QDir::separator() + ".git").isDir()) {
6✔
586
      return true;
587
    }
588
  }
589
  return storedValue;
590
}
591
void QtPassSettings::setUseGit(const bool &useGit) {
2✔
592
  getInstance()->setValue(SettingsConstants::useGit, useGit);
2✔
593
}
2✔
594

595
auto QtPassSettings::isUseOtp(const bool &defaultValue) -> bool {
4✔
596
  return getInstance()->value(SettingsConstants::useOtp, defaultValue).toBool();
4✔
597
}
598

599
void QtPassSettings::setUseOtp(const bool &useOtp) {
2✔
600
  getInstance()->setValue(SettingsConstants::useOtp, useOtp);
2✔
601
}
2✔
602

603
auto QtPassSettings::isUseQrencode(const bool &defaultValue) -> bool {
4✔
604
  return getInstance()
4✔
605
      ->value(SettingsConstants::useQrencode, defaultValue)
8✔
606
      .toBool();
8✔
607
}
608

609
void QtPassSettings::setUseQrencode(const bool &useQrencode) {
2✔
610
  getInstance()->setValue(SettingsConstants::useQrencode, useQrencode);
2✔
611
}
2✔
612

613
auto QtPassSettings::getQrencodeExecutable(const QString &defaultValue)
2✔
614
    -> QString {
615
  return getInstance()
2✔
616
      ->value(SettingsConstants::qrencodeExecutable, defaultValue)
4✔
617
      .toString();
4✔
618
}
619
void QtPassSettings::setQrencodeExecutable(const QString &qrencodeExecutable) {
2✔
620
  getInstance()->setValue(SettingsConstants::qrencodeExecutable,
2✔
621
                          qrencodeExecutable);
622
}
2✔
623

624
auto QtPassSettings::isUsePwgen(const bool &defaultValue) -> bool {
1,008✔
625
  return getInstance()
1,008✔
626
      ->value(SettingsConstants::usePwgen, defaultValue)
2,016✔
627
      .toBool();
2,016✔
628
}
629
void QtPassSettings::setUsePwgen(const bool &usePwgen) {
2✔
630
  getInstance()->setValue(SettingsConstants::usePwgen, usePwgen);
2✔
631
}
2✔
632

633
auto QtPassSettings::isAvoidCapitals(const bool &defaultValue) -> bool {
4✔
634
  return getInstance()
4✔
635
      ->value(SettingsConstants::avoidCapitals, defaultValue)
8✔
636
      .toBool();
8✔
637
}
638
void QtPassSettings::setAvoidCapitals(const bool &avoidCapitals) {
2✔
639
  getInstance()->setValue(SettingsConstants::avoidCapitals, avoidCapitals);
2✔
640
}
2✔
641

642
auto QtPassSettings::isAvoidNumbers(const bool &defaultValue) -> bool {
4✔
643
  return getInstance()
4✔
644
      ->value(SettingsConstants::avoidNumbers, defaultValue)
8✔
645
      .toBool();
8✔
646
}
647
void QtPassSettings::setAvoidNumbers(const bool &avoidNumbers) {
2✔
648
  getInstance()->setValue(SettingsConstants::avoidNumbers, avoidNumbers);
2✔
649
}
2✔
650

651
auto QtPassSettings::isLessRandom(const bool &defaultValue) -> bool {
4✔
652
  return getInstance()
4✔
653
      ->value(SettingsConstants::lessRandom, defaultValue)
8✔
654
      .toBool();
8✔
655
}
656
void QtPassSettings::setLessRandom(const bool &lessRandom) {
2✔
657
  getInstance()->setValue(SettingsConstants::lessRandom, lessRandom);
2✔
658
}
2✔
659

660
auto QtPassSettings::isUseSymbols(const bool &defaultValue) -> bool {
4✔
661
  return getInstance()
4✔
662
      ->value(SettingsConstants::useSymbols, defaultValue)
8✔
663
      .toBool();
8✔
664
}
665
void QtPassSettings::setUseSymbols(const bool &useSymbols) {
2✔
666
  getInstance()->setValue(SettingsConstants::useSymbols, useSymbols);
2✔
667
}
2✔
668

669
void QtPassSettings::setPasswordLength(const int &passwordLength) {
2✔
670
  getInstance()->setValue(SettingsConstants::passwordLength, passwordLength);
2✔
671
}
2✔
672
void QtPassSettings::setPasswordCharsselection(
6✔
673
    const int &passwordCharsselection) {
674
  getInstance()->setValue(SettingsConstants::passwordCharsselection,
6✔
675
                          passwordCharsselection);
676
}
6✔
677
void QtPassSettings::setPasswordChars(const QString &passwordChars) {
5✔
678
  getInstance()->setValue(SettingsConstants::passwordChars, passwordChars);
5✔
679
}
5✔
680

681
auto QtPassSettings::isUseTrayIcon(const bool &defaultValue) -> bool {
4✔
682
  return getInstance()
4✔
683
      ->value(SettingsConstants::useTrayIcon, defaultValue)
8✔
684
      .toBool();
8✔
685
}
686
void QtPassSettings::setUseTrayIcon(const bool &useTrayIcon) {
2✔
687
  getInstance()->setValue(SettingsConstants::useTrayIcon, useTrayIcon);
2✔
688
}
2✔
689

690
auto QtPassSettings::isHideOnClose(const bool &defaultValue) -> bool {
4✔
691
  return getInstance()
4✔
692
      ->value(SettingsConstants::hideOnClose, defaultValue)
8✔
693
      .toBool();
8✔
694
}
695
void QtPassSettings::setHideOnClose(const bool &hideOnClose) {
2✔
696
  getInstance()->setValue(SettingsConstants::hideOnClose, hideOnClose);
2✔
697
}
2✔
698

699
auto QtPassSettings::isStartMinimized(const bool &defaultValue) -> bool {
4✔
700
  return getInstance()
4✔
701
      ->value(SettingsConstants::startMinimized, defaultValue)
8✔
702
      .toBool();
8✔
703
}
704
void QtPassSettings::setStartMinimized(const bool &startMinimized) {
2✔
705
  getInstance()->setValue(SettingsConstants::startMinimized, startMinimized);
2✔
706
}
2✔
707

708
auto QtPassSettings::isAlwaysOnTop(const bool &defaultValue) -> bool {
4✔
709
  return getInstance()
4✔
710
      ->value(SettingsConstants::alwaysOnTop, defaultValue)
8✔
711
      .toBool();
8✔
712
}
713
void QtPassSettings::setAlwaysOnTop(const bool &alwaysOnTop) {
2✔
714
  getInstance()->setValue(SettingsConstants::alwaysOnTop, alwaysOnTop);
2✔
715
}
2✔
716

717
auto QtPassSettings::isAutoPull(const bool &defaultValue) -> bool {
4✔
718
  return getInstance()
4✔
719
      ->value(SettingsConstants::autoPull, defaultValue)
8✔
720
      .toBool();
8✔
721
}
722
void QtPassSettings::setAutoPull(const bool &autoPull) {
2✔
723
  getInstance()->setValue(SettingsConstants::autoPull, autoPull);
2✔
724
}
2✔
725

726
auto QtPassSettings::isAutoPush(const bool &defaultValue) -> bool {
4✔
727
  return getInstance()
4✔
728
      ->value(SettingsConstants::autoPush, defaultValue)
8✔
729
      .toBool();
8✔
730
}
731
void QtPassSettings::setAutoPush(const bool &autoPush) {
2✔
732
  getInstance()->setValue(SettingsConstants::autoPush, autoPush);
2✔
733
}
2✔
734

735
auto QtPassSettings::getPassTemplate(const QString &defaultValue) -> QString {
2✔
736
  return getInstance()
2✔
737
      ->value(SettingsConstants::passTemplate, defaultValue)
4✔
738
      .toString();
4✔
739
}
740
void QtPassSettings::setPassTemplate(const QString &passTemplate) {
2✔
741
  getInstance()->setValue(SettingsConstants::passTemplate, passTemplate);
2✔
742
}
2✔
743

744
auto QtPassSettings::isUseTemplate(const bool &defaultValue) -> bool {
4✔
745
  return getInstance()
4✔
746
      ->value(SettingsConstants::useTemplate, defaultValue)
8✔
747
      .toBool();
8✔
748
}
749
void QtPassSettings::setUseTemplate(const bool &useTemplate) {
2✔
750
  getInstance()->setValue(SettingsConstants::useTemplate, useTemplate);
2✔
751
}
2✔
752

753
auto QtPassSettings::isTemplateAllFields(const bool &defaultValue) -> bool {
4✔
754
  return getInstance()
4✔
755
      ->value(SettingsConstants::templateAllFields, defaultValue)
8✔
756
      .toBool();
8✔
757
}
758
void QtPassSettings::setTemplateAllFields(const bool &templateAllFields) {
2✔
759
  getInstance()->setValue(SettingsConstants::templateAllFields,
4✔
760
                          templateAllFields);
2✔
761
}
2✔
762

763
auto QtPassSettings::getRealPass() -> RealPass * {
1✔
764
  if (realPass.isNull()) {
1✔
765
    realPass.reset(new RealPass());
1✔
766
  }
767
  return realPass.data();
1✔
768
}
769
auto QtPassSettings::getImitatePass() -> ImitatePass * {
2✔
770
  if (imitatePass.isNull()) {
2✔
771
    imitatePass.reset(new ImitatePass());
2✔
772
  }
773
  return imitatePass.data();
2✔
774
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc