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

IJHack / QtPass / 24239274590

10 Apr 2026 10:47AM UTC coverage: 21.036%. First build
24239274590

Pull #958

github

web-flow
Merge e9afb05cb into 3255b93fa
Pull Request #958: fix: improve command-line parsing and window centering in main.cpp

2 of 8 new or added lines in 1 file covered. (25.0%)

1113 of 5291 relevant lines covered (21.04%)

7.78 hits per line

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

94.38
/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

25
bool QtPassSettings::initialized = false;
26

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

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

56
    initialized = true;
5✔
57
  }
58

59
  return m_instance;
1,382✔
60
}
61

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

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

90
  return config;
7✔
91
}
×
92

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

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

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

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

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

143
  return profiles;
3✔
144
}
×
145

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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