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

IJHack / QtPass / 24243340405

10 Apr 2026 12:39PM UTC coverage: 20.907% (-0.1%) from 21.036%
24243340405

push

github

web-flow
fix: address AI findings in qtpasssettings (#960)

- Keep Pass* as non-owning pointer to avoid double-free
- Replace foreach with std::as_const range-based for loops
- Add null check before calling pass->init()
- Clear pass pointer in setUsePass() so next getPass() reinitializes

5 of 7 new or added lines in 1 file covered. (71.43%)

6 existing lines in 3 files now uncovered.

1106 of 5290 relevant lines covered (20.91%)

7.76 hits per line

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

93.53
/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 <QCursor>
21
#include <QDebug>
22
#include <QGuiApplication>
23
#include <QScreen>
24
#include <utility>
25

26
bool QtPassSettings::initialized = false;
27

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

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

57
    initialized = true;
5✔
58
  }
59

60
  return m_instance;
1,382✔
61
}
62

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

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

91
  return config;
7✔
92
}
×
93

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

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

120
  // migration from version <= v1.3.2: profiles datastructure
121
  QStringList childKeys = getInstance()->childKeys();
3✔
122
  if (!childKeys.empty()) {
3✔
NEW
123
    for (const auto &key : std::as_const(childKeys)) {
×
124
      QHash<QString, QString> profile;
×
125
      profile.insert("path", getInstance()->value(key).toString());
×
126
      profile.insert("signingKey", "");
×
127
      profiles.insert(key, profile);
128
    }
×
129
  }
130
  // /migration from version <= v1.3.2
131

132
  QStringList childGroups = getInstance()->childGroups();
3✔
133
  for (const auto &group : std::as_const(childGroups)) {
6✔
134
    QHash<QString, QString> profile;
3✔
135
    profile.insert("path", getInstance()->value(group + "/path").toString());
6✔
136
    profile.insert("signingKey",
6✔
137
                   getInstance()->value(group + "/signingKey").toString());
9✔
138
    // profiles.insert(group, getInstance()->value(group).toString());
139
    profiles.insert(group, profile);
140
  }
3✔
141

142
  getInstance()->endGroup();
3✔
143

144
  return profiles;
3✔
145
}
×
146

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

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

168
  getInstance()->endGroup();
3✔
169
}
3✔
170

171
auto QtPassSettings::getPass() -> Pass * {
11✔
172
  if (!pass) {
11✔
173
    if (isUsePass()) {
1✔
NEW
174
      pass = getRealPass();
×
175
    } else {
176
      pass = getImitatePass();
1✔
177
    }
178
    if (pass) {
1✔
179
      pass->init();
1✔
180
    }
181
  }
182
  return pass;
11✔
183
}
184

185
auto QtPassSettings::getVersion(const QString &defaultValue) -> QString {
1✔
186
  return getInstance()
1✔
187
      ->value(SettingsConstants::version, defaultValue)
2✔
188
      .toString();
2✔
189
}
190
void QtPassSettings::setVersion(const QString &version) {
1✔
191
  getInstance()->setValue(SettingsConstants::version, version);
1✔
192
}
1✔
193

194
auto QtPassSettings::getGeometry(const QByteArray &defaultValue) -> QByteArray {
1✔
195
  return getInstance()
1✔
196
      ->value(SettingsConstants::geometry, defaultValue)
2✔
197
      .toByteArray();
2✔
198
}
199
void QtPassSettings::setGeometry(const QByteArray &geometry) {
1✔
200
  getInstance()->setValue(SettingsConstants::geometry, geometry);
1✔
201
}
1✔
202

203
auto QtPassSettings::getSavestate(const QByteArray &defaultValue)
1✔
204
    -> QByteArray {
205
  return getInstance()
1✔
206
      ->value(SettingsConstants::savestate, defaultValue)
2✔
207
      .toByteArray();
2✔
208
}
209
void QtPassSettings::setSavestate(const QByteArray &saveState) {
1✔
210
  getInstance()->setValue(SettingsConstants::savestate, saveState);
1✔
211
}
1✔
212

213
auto QtPassSettings::getPos(const QPoint &defaultValue) -> QPoint {
1✔
214
  QPoint pos =
215
      getInstance()->value(SettingsConstants::pos, defaultValue).toPoint();
1✔
216
  if (pos == QPoint(0, 0)) {
217
    QScreen *screen = QGuiApplication::screenAt(QCursor::pos());
×
218
    if (!screen)
×
219
      screen = QGuiApplication::primaryScreen();
×
220
    if (screen)
×
221
      pos = screen->geometry().center();
×
222
  }
223
  return pos;
1✔
224
}
225
void QtPassSettings::setPos(const QPoint &pos) {
1✔
226
  if (pos == QPoint(0, 0))
227
    return;
×
228
  getInstance()->setValue(SettingsConstants::pos, pos);
1✔
229
}
230

231
auto QtPassSettings::getSize(const QSize &defaultValue) -> QSize {
1✔
232
  return getInstance()->value(SettingsConstants::size, defaultValue).toSize();
1✔
233
}
234
void QtPassSettings::setSize(const QSize &size) {
1✔
235
  getInstance()->setValue(SettingsConstants::size, size);
1✔
236
}
1✔
237

238
auto QtPassSettings::isMaximized(const bool &defaultValue) -> bool {
4✔
239
  return getInstance()
4✔
240
      ->value(SettingsConstants::maximized, defaultValue)
8✔
241
      .toBool();
8✔
242
}
243
void QtPassSettings::setMaximized(const bool &maximized) {
2✔
244
  getInstance()->setValue(SettingsConstants::maximized, maximized);
2✔
245
}
2✔
246

247
auto QtPassSettings::getDialogGeometry(const QString &key,
1✔
248
                                       const QByteArray &defaultValue)
249
    -> QByteArray {
250
  return getInstance()
1✔
251
      ->value(SettingsConstants::dialogGeometry + "/" + key, defaultValue)
3✔
252
      .toByteArray();
2✔
253
}
254
void QtPassSettings::setDialogGeometry(const QString &key,
1✔
255
                                       const QByteArray &geometry) {
256
  getInstance()->setValue(SettingsConstants::dialogGeometry + "/" + key,
2✔
257
                          geometry);
258
}
1✔
259

260
auto QtPassSettings::getDialogPos(const QString &key,
1✔
261
                                  const QPoint &defaultValue) -> QPoint {
262
  return getInstance()
1✔
263
      ->value(SettingsConstants::dialogPos + "/" + key, defaultValue)
3✔
264
      .toPoint();
2✔
265
}
266
void QtPassSettings::setDialogPos(const QString &key, const QPoint &pos) {
1✔
267
  getInstance()->setValue(SettingsConstants::dialogPos + "/" + key, pos);
2✔
268
}
1✔
269

270
auto QtPassSettings::getDialogSize(const QString &key,
1✔
271
                                   const QSize &defaultValue) -> QSize {
272
  return getInstance()
1✔
273
      ->value(SettingsConstants::dialogSize + "/" + key, defaultValue)
3✔
274
      .toSize();
2✔
275
}
276
void QtPassSettings::setDialogSize(const QString &key, const QSize &size) {
1✔
277
  getInstance()->setValue(SettingsConstants::dialogSize + "/" + key, size);
2✔
278
}
1✔
279

280
auto QtPassSettings::isDialogMaximized(const QString &key,
2✔
281
                                       const bool &defaultValue) -> bool {
282
  return getInstance()
2✔
283
      ->value(SettingsConstants::dialogMaximized + "/" + key, defaultValue)
6✔
284
      .toBool();
4✔
285
}
286
void QtPassSettings::setDialogMaximized(const QString &key,
2✔
287
                                        const bool &maximized) {
288
  getInstance()->setValue(SettingsConstants::dialogMaximized + "/" + key,
6✔
289
                          maximized);
2✔
290
}
2✔
291

292
auto QtPassSettings::isUsePass(const bool &defaultValue) -> bool {
5✔
293
  return getInstance()
5✔
294
      ->value(SettingsConstants::usePass, defaultValue)
10✔
295
      .toBool();
10✔
296
}
297
void QtPassSettings::setUsePass(const bool &usePass) {
2✔
298
  getInstance()->setValue(SettingsConstants::usePass, usePass);
2✔
299
  pass = nullptr;
2✔
300
}
2✔
301

302
auto QtPassSettings::getClipBoardTypeRaw(
1✔
303
    const Enums::clipBoardType &defaultvalue) -> int {
304
  return getInstance()
1✔
305
      ->value(SettingsConstants::clipBoardType, static_cast<int>(defaultvalue))
2✔
306
      .toInt();
2✔
307
}
308

309
auto QtPassSettings::getClipBoardType(const Enums::clipBoardType &defaultvalue)
1✔
310
    -> Enums::clipBoardType {
311
  return static_cast<Enums::clipBoardType>(getClipBoardTypeRaw(defaultvalue));
1✔
312
}
313
void QtPassSettings::setClipBoardType(const int &clipBoardType) {
1✔
314
  getInstance()->setValue(SettingsConstants::clipBoardType, clipBoardType);
1✔
315
}
1✔
316

317
auto QtPassSettings::isUseSelection(const bool &defaultValue) -> bool {
4✔
318
  return getInstance()
4✔
319
      ->value(SettingsConstants::useSelection, defaultValue)
8✔
320
      .toBool();
8✔
321
}
322
void QtPassSettings::setUseSelection(const bool &useSelection) {
2✔
323
  getInstance()->setValue(SettingsConstants::useSelection, useSelection);
2✔
324
}
2✔
325

326
auto QtPassSettings::isUseAutoclear(const bool &defaultValue) -> bool {
4✔
327
  return getInstance()
4✔
328
      ->value(SettingsConstants::useAutoclear, defaultValue)
8✔
329
      .toBool();
8✔
330
}
331
void QtPassSettings::setUseAutoclear(const bool &useAutoclear) {
2✔
332
  getInstance()->setValue(SettingsConstants::useAutoclear, useAutoclear);
2✔
333
}
2✔
334

335
auto QtPassSettings::getAutoclearSeconds(const int &defaultValue) -> int {
2✔
336
  return getInstance()
2✔
337
      ->value(SettingsConstants::autoclearSeconds, defaultValue)
4✔
338
      .toInt();
4✔
339
}
340
void QtPassSettings::setAutoclearSeconds(const int &autoClearSeconds) {
2✔
341
  getInstance()->setValue(SettingsConstants::autoclearSeconds,
2✔
342
                          autoClearSeconds);
343
}
2✔
344

345
auto QtPassSettings::isUseAutoclearPanel(const bool &defaultValue) -> bool {
4✔
346
  return getInstance()
4✔
347
      ->value(SettingsConstants::useAutoclearPanel, defaultValue)
8✔
348
      .toBool();
8✔
349
}
350
void QtPassSettings::setUseAutoclearPanel(const bool &useAutoclearPanel) {
2✔
351
  getInstance()->setValue(SettingsConstants::useAutoclearPanel,
4✔
352
                          useAutoclearPanel);
2✔
353
}
2✔
354

355
auto QtPassSettings::getAutoclearPanelSeconds(const int &defaultValue) -> int {
2✔
356
  return getInstance()
2✔
357
      ->value(SettingsConstants::autoclearPanelSeconds, defaultValue)
4✔
358
      .toInt();
4✔
359
}
360
void QtPassSettings::setAutoclearPanelSeconds(
2✔
361
    const int &autoClearPanelSeconds) {
362
  getInstance()->setValue(SettingsConstants::autoclearPanelSeconds,
2✔
363
                          autoClearPanelSeconds);
364
}
2✔
365

366
auto QtPassSettings::isHidePassword(const bool &defaultValue) -> bool {
4✔
367
  return getInstance()
4✔
368
      ->value(SettingsConstants::hidePassword, defaultValue)
8✔
369
      .toBool();
8✔
370
}
371
void QtPassSettings::setHidePassword(const bool &hidePassword) {
2✔
372
  getInstance()->setValue(SettingsConstants::hidePassword, hidePassword);
2✔
373
}
2✔
374

375
auto QtPassSettings::isHideContent(const bool &defaultValue) -> bool {
4✔
376
  return getInstance()
4✔
377
      ->value(SettingsConstants::hideContent, defaultValue)
8✔
378
      .toBool();
8✔
379
}
380
void QtPassSettings::setHideContent(const bool &hideContent) {
2✔
381
  getInstance()->setValue(SettingsConstants::hideContent, hideContent);
2✔
382
}
2✔
383

384
auto QtPassSettings::isUseMonospace(const bool &defaultValue) -> bool {
4✔
385
  return getInstance()
4✔
386
      ->value(SettingsConstants::useMonospace, defaultValue)
8✔
387
      .toBool();
8✔
388
}
389
void QtPassSettings::setUseMonospace(const bool &useMonospace) {
2✔
390
  getInstance()->setValue(SettingsConstants::useMonospace, useMonospace);
2✔
391
}
2✔
392

393
auto QtPassSettings::isDisplayAsIs(const bool &defaultValue) -> bool {
4✔
394
  return getInstance()
4✔
395
      ->value(SettingsConstants::displayAsIs, defaultValue)
8✔
396
      .toBool();
8✔
397
}
398
void QtPassSettings::setDisplayAsIs(const bool &displayAsIs) {
2✔
399
  getInstance()->setValue(SettingsConstants::displayAsIs, displayAsIs);
2✔
400
}
2✔
401

402
auto QtPassSettings::isNoLineWrapping(const bool &defaultValue) -> bool {
4✔
403
  return getInstance()
4✔
404
      ->value(SettingsConstants::noLineWrapping, defaultValue)
8✔
405
      .toBool();
8✔
406
}
407
void QtPassSettings::setNoLineWrapping(const bool &noLineWrapping) {
2✔
408
  getInstance()->setValue(SettingsConstants::noLineWrapping, noLineWrapping);
2✔
409
}
2✔
410

411
auto QtPassSettings::isAddGPGId(const bool &defaultValue) -> bool {
4✔
412
  return getInstance()
4✔
413
      ->value(SettingsConstants::addGPGId, defaultValue)
8✔
414
      .toBool();
8✔
415
}
416
void QtPassSettings::setAddGPGId(const bool &addGPGId) {
2✔
417
  getInstance()->setValue(SettingsConstants::addGPGId, addGPGId);
2✔
418
}
2✔
419

420
/**
421
 * @brief Retrieves the password store path, normalizes it, and ensures the
422
 * directory exists.
423
 * @example
424
 * QString passStore =
425
 * QtPassSettings::getPassStore("/home/user/.password-store"); qDebug() <<
426
 * passStore; // Expected output: "/home/user/.password-store/"
427
 *
428
 * @param defaultValue - Fallback path used when no password store is
429
 * configured.
430
 * @return QString - The normalized absolute password store path, guaranteed to
431
 * end with a path separator.
432
 */
433
auto QtPassSettings::getPassStore(const QString &defaultValue) -> QString {
28✔
434
  QString returnValue = getInstance()
28✔
435
                            ->value(SettingsConstants::passStore, defaultValue)
56✔
436
                            .toString();
28✔
437

438
  // Normalize the path string
439
  returnValue = QDir(returnValue).absolutePath();
56✔
440

441
  // ensure directory exists if never used pass or misconfigured.
442
  // otherwise process->setWorkingDirectory(passStore); will fail on execution.
443
  if (!QDir(returnValue).exists()) {
28✔
444
    if (!QDir().mkdir(returnValue)) {
6✔
445
      qWarning() << "Failed to create password store directory:" << returnValue;
×
446
    }
447
  }
448

449
  // ensure path ends in /
450
  if (!returnValue.endsWith("/") && !returnValue.endsWith(QDir::separator())) {
56✔
451
    returnValue += QDir::separator();
28✔
452
  }
453

454
  return returnValue;
28✔
455
}
456
void QtPassSettings::setPassStore(const QString &passStore) {
17✔
457
  getInstance()->setValue(SettingsConstants::passStore, passStore);
17✔
458
}
17✔
459

460
auto QtPassSettings::getPassSigningKey(const QString &defaultValue) -> QString {
2✔
461
  return getInstance()
2✔
462
      ->value(SettingsConstants::passSigningKey, defaultValue)
4✔
463
      .toString();
4✔
464
}
465
void QtPassSettings::setPassSigningKey(const QString &passSigningKey) {
2✔
466
  getInstance()->setValue(SettingsConstants::passSigningKey, passSigningKey);
2✔
467
}
2✔
468

469
/**
470
 * @brief Initializes executable paths for Pass, Git, GPG, and Pwgen by locating
471
 * them in the system PATH.
472
 * @example
473
 * QtPassSettings::initExecutables();
474
 *
475
 * @return void - This method does not return a value.
476
 */
477
void QtPassSettings::initExecutables() {
×
478
  QString passExecutable =
479
      QtPassSettings::getPassExecutable(Util::findBinaryInPath("pass"));
×
480
  QtPassSettings::setPassExecutable(passExecutable);
×
481

482
  QString gitExecutable =
483
      QtPassSettings::getGitExecutable(Util::findBinaryInPath("git"));
×
484
  QtPassSettings::setGitExecutable(gitExecutable);
×
485

486
  QString gpgExecutable =
487
      QtPassSettings::getGpgExecutable(Util::findBinaryInPath("gpg2"));
×
488
  QtPassSettings::setGpgExecutable(gpgExecutable);
×
489

490
  QString pwgenExecutable =
491
      QtPassSettings::getPwgenExecutable(Util::findBinaryInPath("pwgen"));
×
492
  QtPassSettings::setPwgenExecutable(pwgenExecutable);
×
493
}
×
494
auto QtPassSettings::getPassExecutable(const QString &defaultValue) -> QString {
2✔
495
  return getInstance()
2✔
496
      ->value(SettingsConstants::passExecutable, defaultValue)
4✔
497
      .toString();
4✔
498
}
499
void QtPassSettings::setPassExecutable(const QString &passExecutable) {
2✔
500
  getInstance()->setValue(SettingsConstants::passExecutable, passExecutable);
2✔
501
}
2✔
502

503
auto QtPassSettings::getGitExecutable(const QString &defaultValue) -> QString {
2✔
504
  return getInstance()
2✔
505
      ->value(SettingsConstants::gitExecutable, defaultValue)
4✔
506
      .toString();
4✔
507
}
508
void QtPassSettings::setGitExecutable(const QString &gitExecutable) {
2✔
509
  getInstance()->setValue(SettingsConstants::gitExecutable, gitExecutable);
2✔
510
}
2✔
511

512
auto QtPassSettings::getGpgExecutable(const QString &defaultValue) -> QString {
5✔
513
  return getInstance()
5✔
514
      ->value(SettingsConstants::gpgExecutable, defaultValue)
10✔
515
      .toString();
10✔
516
}
517
void QtPassSettings::setGpgExecutable(const QString &gpgExecutable) {
2✔
518
  getInstance()->setValue(SettingsConstants::gpgExecutable, gpgExecutable);
2✔
519
}
2✔
520

521
auto QtPassSettings::getPwgenExecutable(const QString &defaultValue)
2✔
522
    -> QString {
523
  return getInstance()
2✔
524
      ->value(SettingsConstants::pwgenExecutable, defaultValue)
4✔
525
      .toString();
4✔
526
}
527
void QtPassSettings::setPwgenExecutable(const QString &pwgenExecutable) {
2✔
528
  getInstance()->setValue(SettingsConstants::pwgenExecutable, pwgenExecutable);
2✔
529
}
2✔
530

531
auto QtPassSettings::getGpgHome(const QString &defaultValue) -> QString {
1✔
532
  return getInstance()
1✔
533
      ->value(SettingsConstants::gpgHome, defaultValue)
2✔
534
      .toString();
2✔
535
}
536

537
auto QtPassSettings::isUseWebDav(const bool &defaultValue) -> bool {
4✔
538
  return getInstance()
4✔
539
      ->value(SettingsConstants::useWebDav, defaultValue)
8✔
540
      .toBool();
8✔
541
}
542
void QtPassSettings::setUseWebDav(const bool &useWebDav) {
2✔
543
  getInstance()->setValue(SettingsConstants::useWebDav, useWebDav);
2✔
544
}
2✔
545

546
auto QtPassSettings::getWebDavUrl(const QString &defaultValue) -> QString {
2✔
547
  return getInstance()
2✔
548
      ->value(SettingsConstants::webDavUrl, defaultValue)
4✔
549
      .toString();
4✔
550
}
551
void QtPassSettings::setWebDavUrl(const QString &webDavUrl) {
2✔
552
  getInstance()->setValue(SettingsConstants::webDavUrl, webDavUrl);
2✔
553
}
2✔
554

555
auto QtPassSettings::getWebDavUser(const QString &defaultValue) -> QString {
2✔
556
  return getInstance()
2✔
557
      ->value(SettingsConstants::webDavUser, defaultValue)
4✔
558
      .toString();
4✔
559
}
560
void QtPassSettings::setWebDavUser(const QString &webDavUser) {
2✔
561
  getInstance()->setValue(SettingsConstants::webDavUser, webDavUser);
2✔
562
}
2✔
563

564
auto QtPassSettings::getWebDavPassword(const QString &defaultValue) -> QString {
2✔
565
  return getInstance()
2✔
566
      ->value(SettingsConstants::webDavPassword, defaultValue)
4✔
567
      .toString();
4✔
568
}
569
void QtPassSettings::setWebDavPassword(const QString &webDavPassword) {
2✔
570
  getInstance()->setValue(SettingsConstants::webDavPassword, webDavPassword);
2✔
571
}
2✔
572

573
auto QtPassSettings::getProfile(const QString &defaultValue) -> QString {
3✔
574
  return getInstance()
3✔
575
      ->value(SettingsConstants::profile, defaultValue)
6✔
576
      .toString();
6✔
577
}
578
void QtPassSettings::setProfile(const QString &profile) {
3✔
579
  getInstance()->setValue(SettingsConstants::profile, profile);
3✔
580
}
3✔
581

582
/**
583
 * @brief Determines whether Git should be used for the current QtPass settings.
584
 * @example
585
 * bool result = QtPassSettings::isUseGit(true);
586
 * std::cout << result << std::endl; // Expected output: true or false
587
 *
588
 * @param const bool &defaultValue - The fallback value used when no explicit
589
 * setting is stored.
590
 * @return bool - True if Git usage is enabled, otherwise false.
591
 */
592
auto QtPassSettings::isUseGit(const bool &defaultValue) -> bool {
8✔
593
  bool storedValue =
594
      getInstance()->value(SettingsConstants::useGit, defaultValue).toBool();
8✔
595
  if (storedValue == defaultValue && defaultValue) {
8✔
596
    QString passStore = getPassStore();
4✔
597
    if (QFileInfo(passStore).isDir() &&
4✔
598
        QFileInfo(passStore + QDir::separator() + ".git").isDir()) {
6✔
599
      return true;
600
    }
601
  }
602
  return storedValue;
603
}
604
void QtPassSettings::setUseGit(const bool &useGit) {
2✔
605
  getInstance()->setValue(SettingsConstants::useGit, useGit);
2✔
606
}
2✔
607

608
auto QtPassSettings::isUseOtp(const bool &defaultValue) -> bool {
4✔
609
  return getInstance()->value(SettingsConstants::useOtp, defaultValue).toBool();
4✔
610
}
611

612
void QtPassSettings::setUseOtp(const bool &useOtp) {
2✔
613
  getInstance()->setValue(SettingsConstants::useOtp, useOtp);
2✔
614
}
2✔
615

616
auto QtPassSettings::isUseQrencode(const bool &defaultValue) -> bool {
4✔
617
  return getInstance()
4✔
618
      ->value(SettingsConstants::useQrencode, defaultValue)
8✔
619
      .toBool();
8✔
620
}
621

622
void QtPassSettings::setUseQrencode(const bool &useQrencode) {
2✔
623
  getInstance()->setValue(SettingsConstants::useQrencode, useQrencode);
2✔
624
}
2✔
625

626
auto QtPassSettings::getQrencodeExecutable(const QString &defaultValue)
2✔
627
    -> QString {
628
  return getInstance()
2✔
629
      ->value(SettingsConstants::qrencodeExecutable, defaultValue)
4✔
630
      .toString();
4✔
631
}
632
void QtPassSettings::setQrencodeExecutable(const QString &qrencodeExecutable) {
2✔
633
  getInstance()->setValue(SettingsConstants::qrencodeExecutable,
2✔
634
                          qrencodeExecutable);
635
}
2✔
636

637
auto QtPassSettings::isUsePwgen(const bool &defaultValue) -> bool {
1,008✔
638
  return getInstance()
1,008✔
639
      ->value(SettingsConstants::usePwgen, defaultValue)
2,016✔
640
      .toBool();
2,016✔
641
}
642
void QtPassSettings::setUsePwgen(const bool &usePwgen) {
2✔
643
  getInstance()->setValue(SettingsConstants::usePwgen, usePwgen);
2✔
644
}
2✔
645

646
auto QtPassSettings::isAvoidCapitals(const bool &defaultValue) -> bool {
4✔
647
  return getInstance()
4✔
648
      ->value(SettingsConstants::avoidCapitals, defaultValue)
8✔
649
      .toBool();
8✔
650
}
651
void QtPassSettings::setAvoidCapitals(const bool &avoidCapitals) {
2✔
652
  getInstance()->setValue(SettingsConstants::avoidCapitals, avoidCapitals);
2✔
653
}
2✔
654

655
auto QtPassSettings::isAvoidNumbers(const bool &defaultValue) -> bool {
4✔
656
  return getInstance()
4✔
657
      ->value(SettingsConstants::avoidNumbers, defaultValue)
8✔
658
      .toBool();
8✔
659
}
660
void QtPassSettings::setAvoidNumbers(const bool &avoidNumbers) {
2✔
661
  getInstance()->setValue(SettingsConstants::avoidNumbers, avoidNumbers);
2✔
662
}
2✔
663

664
auto QtPassSettings::isLessRandom(const bool &defaultValue) -> bool {
4✔
665
  return getInstance()
4✔
666
      ->value(SettingsConstants::lessRandom, defaultValue)
8✔
667
      .toBool();
8✔
668
}
669
void QtPassSettings::setLessRandom(const bool &lessRandom) {
2✔
670
  getInstance()->setValue(SettingsConstants::lessRandom, lessRandom);
2✔
671
}
2✔
672

673
auto QtPassSettings::isUseSymbols(const bool &defaultValue) -> bool {
4✔
674
  return getInstance()
4✔
675
      ->value(SettingsConstants::useSymbols, defaultValue)
8✔
676
      .toBool();
8✔
677
}
678
void QtPassSettings::setUseSymbols(const bool &useSymbols) {
2✔
679
  getInstance()->setValue(SettingsConstants::useSymbols, useSymbols);
2✔
680
}
2✔
681

682
void QtPassSettings::setPasswordLength(const int &passwordLength) {
2✔
683
  getInstance()->setValue(SettingsConstants::passwordLength, passwordLength);
2✔
684
}
2✔
685
void QtPassSettings::setPasswordCharsselection(
6✔
686
    const int &passwordCharsselection) {
687
  getInstance()->setValue(SettingsConstants::passwordCharsselection,
6✔
688
                          passwordCharsselection);
689
}
6✔
690
void QtPassSettings::setPasswordChars(const QString &passwordChars) {
5✔
691
  getInstance()->setValue(SettingsConstants::passwordChars, passwordChars);
5✔
692
}
5✔
693

694
auto QtPassSettings::isUseTrayIcon(const bool &defaultValue) -> bool {
4✔
695
  return getInstance()
4✔
696
      ->value(SettingsConstants::useTrayIcon, defaultValue)
8✔
697
      .toBool();
8✔
698
}
699
void QtPassSettings::setUseTrayIcon(const bool &useTrayIcon) {
2✔
700
  getInstance()->setValue(SettingsConstants::useTrayIcon, useTrayIcon);
2✔
701
}
2✔
702

703
auto QtPassSettings::isHideOnClose(const bool &defaultValue) -> bool {
4✔
704
  return getInstance()
4✔
705
      ->value(SettingsConstants::hideOnClose, defaultValue)
8✔
706
      .toBool();
8✔
707
}
708
void QtPassSettings::setHideOnClose(const bool &hideOnClose) {
2✔
709
  getInstance()->setValue(SettingsConstants::hideOnClose, hideOnClose);
2✔
710
}
2✔
711

712
auto QtPassSettings::isStartMinimized(const bool &defaultValue) -> bool {
4✔
713
  return getInstance()
4✔
714
      ->value(SettingsConstants::startMinimized, defaultValue)
8✔
715
      .toBool();
8✔
716
}
717
void QtPassSettings::setStartMinimized(const bool &startMinimized) {
2✔
718
  getInstance()->setValue(SettingsConstants::startMinimized, startMinimized);
2✔
719
}
2✔
720

721
auto QtPassSettings::isAlwaysOnTop(const bool &defaultValue) -> bool {
4✔
722
  return getInstance()
4✔
723
      ->value(SettingsConstants::alwaysOnTop, defaultValue)
8✔
724
      .toBool();
8✔
725
}
726
void QtPassSettings::setAlwaysOnTop(const bool &alwaysOnTop) {
2✔
727
  getInstance()->setValue(SettingsConstants::alwaysOnTop, alwaysOnTop);
2✔
728
}
2✔
729

730
auto QtPassSettings::isAutoPull(const bool &defaultValue) -> bool {
4✔
731
  return getInstance()
4✔
732
      ->value(SettingsConstants::autoPull, defaultValue)
8✔
733
      .toBool();
8✔
734
}
735
void QtPassSettings::setAutoPull(const bool &autoPull) {
2✔
736
  getInstance()->setValue(SettingsConstants::autoPull, autoPull);
2✔
737
}
2✔
738

739
auto QtPassSettings::isAutoPush(const bool &defaultValue) -> bool {
4✔
740
  return getInstance()
4✔
741
      ->value(SettingsConstants::autoPush, defaultValue)
8✔
742
      .toBool();
8✔
743
}
744
void QtPassSettings::setAutoPush(const bool &autoPush) {
2✔
745
  getInstance()->setValue(SettingsConstants::autoPush, autoPush);
2✔
746
}
2✔
747

748
auto QtPassSettings::getPassTemplate(const QString &defaultValue) -> QString {
2✔
749
  return getInstance()
2✔
750
      ->value(SettingsConstants::passTemplate, defaultValue)
4✔
751
      .toString();
4✔
752
}
753
void QtPassSettings::setPassTemplate(const QString &passTemplate) {
2✔
754
  getInstance()->setValue(SettingsConstants::passTemplate, passTemplate);
2✔
755
}
2✔
756

757
auto QtPassSettings::isUseTemplate(const bool &defaultValue) -> bool {
4✔
758
  return getInstance()
4✔
759
      ->value(SettingsConstants::useTemplate, defaultValue)
8✔
760
      .toBool();
8✔
761
}
762
void QtPassSettings::setUseTemplate(const bool &useTemplate) {
2✔
763
  getInstance()->setValue(SettingsConstants::useTemplate, useTemplate);
2✔
764
}
2✔
765

766
auto QtPassSettings::isTemplateAllFields(const bool &defaultValue) -> bool {
4✔
767
  return getInstance()
4✔
768
      ->value(SettingsConstants::templateAllFields, defaultValue)
8✔
769
      .toBool();
8✔
770
}
771
void QtPassSettings::setTemplateAllFields(const bool &templateAllFields) {
2✔
772
  getInstance()->setValue(SettingsConstants::templateAllFields,
4✔
773
                          templateAllFields);
2✔
774
}
2✔
775

UNCOV
776
auto QtPassSettings::getRealPass() -> RealPass * {
×
UNCOV
777
  if (realPass.isNull()) {
×
UNCOV
778
    realPass.reset(new RealPass());
×
779
  }
UNCOV
780
  return realPass.data();
×
781
}
782
auto QtPassSettings::getImitatePass() -> ImitatePass * {
1✔
783
  if (imitatePass.isNull()) {
1✔
784
    imitatePass.reset(new ImitatePass());
1✔
785
  }
786
  return imitatePass.data();
1✔
787
}
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