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

IJHack / QtPass / 24848506644

23 Apr 2026 05:11PM UTC coverage: 27.334% (+0.3%) from 27.079%
24848506644

push

github

web-flow
feat: Store git options per profile (#112) (#1140)

* feat: Store git options per profile (#112)

- Add useGit, autoPush, autoPull to profile storage in getProfiles/setProfiles
- Add getProfileUseGit, setProfileUseGit, getProfileAutoPush, setProfileAutoPush,
  getProfileAutoPull, setProfileAutoPull methods to QtPassSettings
- Load git settings when selecting profile in ConfigDialog
- Save git settings to profile when saving

Allows each profile to have its own git settings, fixing the issue
where global git settings caused errors for mixed local/remote stores.

* feat: Store git options per profile (#112)

- Fix data corruption: only save git settings for selected profile
- Fix getters to fall back to default for empty values (migration)
- Add unit tests for profile git options
- Add test cleanup for profileGitOptions

* fix: preserve git settings for non-selected profiles

- Load existing profiles in getProfiles() to preserve git settings for non-selected profiles
- Use useGit setter in loadGitSettingsForProfile so dependent controls refresh
- Add selection change handler to reload profile git settings when switching rows
- Fix test cleanup to use QtPassSettings singleton instead of raw QSettings

* fix: apply CodeRabbit auto-fixes

Fixed 4 file(s) based on 3 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

* style: format qtpasssettings.cpp

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: CodeRabbit <noreply@coderabbit.ai>

39 of 93 new or added lines in 2 files covered. (41.94%)

18 existing lines in 2 files now uncovered.

1631 of 5967 relevant lines covered (27.33%)

29.7 hits per line

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

92.23
/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 * {
5,704✔
48
  if (!QtPassSettings::initialized) {
5,704✔
49
    QString portable_ini = QCoreApplication::applicationDirPath() +
6✔
50
                           QDir::separator() + "qtpass.ini";
6✔
51
    if (QFile(portable_ini).exists()) {
6✔
52
      m_instance = new QtPassSettings(portable_ini, QSettings::IniFormat);
×
53
    } else {
54
      m_instance = new QtPassSettings("IJHack", "QtPass");
12✔
55
    }
56

57
    initialized = true;
6✔
58
  }
59

60
  return m_instance;
5,704✔
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 {
1,233✔
75
  PasswordConfiguration config;
1,233✔
76

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

91
  return config;
1,233✔
92
}
×
93

94
void QtPassSettings::setPasswordConfiguration(
3✔
95
    const PasswordConfiguration &config) {
96
  getInstance()->setValue(SettingsConstants::passwordLength, config.length);
3✔
97
  getInstance()->setValue(SettingsConstants::passwordCharsSelection,
6✔
98
                          config.selected);
3✔
99
  getInstance()->setValue(SettingsConstants::passwordChars,
6✔
100
                          config.Characters[PasswordConfiguration::CUSTOM]);
3✔
101
}
3✔
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✔
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", "");
×
NEW
127
      profile.insert("useGit", "");
×
NEW
128
      profile.insert("autoPush", "");
×
NEW
129
      profile.insert("autoPull", "");
×
130
      profiles.insert(key, profile);
131
    }
×
132
  }
133
  // /migration from version <= v1.3.2
134

135
  QStringList childGroups = getInstance()->childGroups();
3✔
136
  for (const auto &group : std::as_const(childGroups)) {
6✔
137
    QHash<QString, QString> profile;
3✔
138
    profile.insert("path", getInstance()->value(group + "/path").toString());
6✔
139
    profile.insert("signingKey",
6✔
140
                   getInstance()->value(group + "/signingKey").toString());
6✔
141
    profile.insert("useGit",
6✔
142
                   getInstance()->value(group + "/useGit").toString());
6✔
143
    profile.insert("autoPush",
6✔
144
                   getInstance()->value(group + "/autoPush").toString());
6✔
145
    profile.insert("autoPull",
6✔
146
                   getInstance()->value(group + "/autoPull").toString());
9✔
147
    profiles.insert(group, profile);
148
  }
3✔
149

150
  getInstance()->endGroup();
3✔
151

152
  return profiles;
3✔
153
}
×
154

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

169
  QHash<QString, QHash<QString, QString>>::const_iterator i = profiles.begin();
3✔
170
  for (; i != profiles.end(); ++i) {
3✔
171
    getInstance()->setValue(i.key() + "/path", i.value().value("path"));
6✔
172
    getInstance()->setValue(i.key() + "/signingKey",
9✔
173
                            i.value().value("signingKey"));
3✔
174
    getInstance()->setValue(i.key() + "/useGit", i.value().value("useGit"));
6✔
175
    getInstance()->setValue(i.key() + "/autoPush", i.value().value("autoPush"));
6✔
176
    getInstance()->setValue(i.key() + "/autoPull", i.value().value("autoPull"));
9✔
177
  }
178

179
  getInstance()->endGroup();
3✔
180
}
3✔
181

182
auto QtPassSettings::getPass() -> Pass * {
8✔
183
  if (!pass) {
8✔
184
    if (isUsePass()) {
1✔
185
      pass = getRealPass();
×
186
    } else {
187
      pass = getImitatePass();
1✔
188
    }
189
    if (pass) {
1✔
190
      pass->init();
1✔
191
    }
192
  }
193
  return pass;
8✔
194
}
195

196
auto QtPassSettings::getVersion(const QString &defaultValue) -> QString {
1✔
197
  return getInstance()
1✔
198
      ->value(SettingsConstants::version, defaultValue)
2✔
199
      .toString();
2✔
200
}
201
void QtPassSettings::setVersion(const QString &version) {
1✔
202
  getInstance()->setValue(SettingsConstants::version, version);
1✔
203
}
1✔
204

205
auto QtPassSettings::getGeometry(const QByteArray &defaultValue) -> QByteArray {
1✔
206
  return getInstance()
1✔
207
      ->value(SettingsConstants::geometry, defaultValue)
2✔
208
      .toByteArray();
2✔
209
}
210
void QtPassSettings::setGeometry(const QByteArray &geometry) {
1✔
211
  getInstance()->setValue(SettingsConstants::geometry, geometry);
1✔
212
}
1✔
213

214
auto QtPassSettings::getSavestate(const QByteArray &defaultValue)
1✔
215
    -> QByteArray {
216
  return getInstance()
1✔
217
      ->value(SettingsConstants::savestate, defaultValue)
2✔
218
      .toByteArray();
2✔
219
}
220
void QtPassSettings::setSavestate(const QByteArray &saveState) {
1✔
221
  getInstance()->setValue(SettingsConstants::savestate, saveState);
1✔
222
}
1✔
223

224
auto QtPassSettings::getPos(const QPoint &defaultValue) -> QPoint {
1✔
225
  QPoint pos =
226
      getInstance()->value(SettingsConstants::pos, defaultValue).toPoint();
1✔
227
  if (pos == QPoint(0, 0)) {
228
    QScreen *screen = QGuiApplication::screenAt(QCursor::pos());
×
229
    if (!screen)
×
230
      screen = QGuiApplication::primaryScreen();
×
231
    if (screen)
×
232
      pos = screen->geometry().center();
×
233
  }
234
  return pos;
1✔
235
}
236
void QtPassSettings::setPos(const QPoint &pos) {
1✔
237
  if (pos == QPoint(0, 0))
238
    return;
×
239
  getInstance()->setValue(SettingsConstants::pos, pos);
1✔
240
}
241

242
auto QtPassSettings::getSize(const QSize &defaultValue) -> QSize {
1✔
243
  return getInstance()->value(SettingsConstants::size, defaultValue).toSize();
1✔
244
}
245
void QtPassSettings::setSize(const QSize &size) {
1✔
246
  getInstance()->setValue(SettingsConstants::size, size);
1✔
247
}
1✔
248

249
auto QtPassSettings::isMaximized(const bool &defaultValue) -> bool {
4✔
250
  return getInstance()
4✔
251
      ->value(SettingsConstants::maximized, defaultValue)
8✔
252
      .toBool();
8✔
253
}
254
void QtPassSettings::setMaximized(const bool &maximized) {
2✔
255
  getInstance()->setValue(SettingsConstants::maximized, maximized);
2✔
256
}
2✔
257

258
auto QtPassSettings::getDialogGeometry(const QString &key,
1✔
259
                                       const QByteArray &defaultValue)
260
    -> QByteArray {
261
  return getInstance()
1✔
262
      ->value(SettingsConstants::dialogGeometry + "/" + key, defaultValue)
3✔
263
      .toByteArray();
2✔
264
}
265
void QtPassSettings::setDialogGeometry(const QString &key,
1✔
266
                                       const QByteArray &geometry) {
267
  getInstance()->setValue(SettingsConstants::dialogGeometry + "/" + key,
2✔
268
                          geometry);
269
}
1✔
270

271
auto QtPassSettings::getDialogPos(const QString &key,
1✔
272
                                  const QPoint &defaultValue) -> QPoint {
273
  return getInstance()
1✔
274
      ->value(SettingsConstants::dialogPos + "/" + key, defaultValue)
3✔
275
      .toPoint();
2✔
276
}
277
void QtPassSettings::setDialogPos(const QString &key, const QPoint &pos) {
1✔
278
  getInstance()->setValue(SettingsConstants::dialogPos + "/" + key, pos);
2✔
279
}
1✔
280

281
auto QtPassSettings::getDialogSize(const QString &key,
1✔
282
                                   const QSize &defaultValue) -> QSize {
283
  return getInstance()
1✔
284
      ->value(SettingsConstants::dialogSize + "/" + key, defaultValue)
3✔
285
      .toSize();
2✔
286
}
287
void QtPassSettings::setDialogSize(const QString &key, const QSize &size) {
1✔
288
  getInstance()->setValue(SettingsConstants::dialogSize + "/" + key, size);
2✔
289
}
1✔
290

291
auto QtPassSettings::isDialogMaximized(const QString &key,
2✔
292
                                       const bool &defaultValue) -> bool {
293
  return getInstance()
2✔
294
      ->value(SettingsConstants::dialogMaximized + "/" + key, defaultValue)
6✔
295
      .toBool();
4✔
296
}
297
void QtPassSettings::setDialogMaximized(const QString &key,
2✔
298
                                        const bool &maximized) {
299
  getInstance()->setValue(SettingsConstants::dialogMaximized + "/" + key,
6✔
300
                          maximized);
2✔
301
}
2✔
302

303
auto QtPassSettings::isUsePass(const bool &defaultValue) -> bool {
8✔
304
  return getInstance()
8✔
305
      ->value(SettingsConstants::usePass, defaultValue)
16✔
306
      .toBool();
16✔
307
}
308
void QtPassSettings::setUsePass(const bool &usePass) {
4✔
309
  getInstance()->setValue(SettingsConstants::usePass, usePass);
4✔
310
  pass = nullptr;
4✔
311
}
4✔
312

313
auto QtPassSettings::getClipBoardTypeRaw(
1✔
314
    const Enums::clipBoardType &defaultValue) -> int {
315
  return getInstance()
1✔
316
      ->value(SettingsConstants::clipBoardType, static_cast<int>(defaultValue))
2✔
317
      .toInt();
2✔
318
}
319

320
auto QtPassSettings::getClipBoardType(const Enums::clipBoardType &defaultValue)
1✔
321
    -> Enums::clipBoardType {
322
  return static_cast<Enums::clipBoardType>(getClipBoardTypeRaw(defaultValue));
1✔
323
}
324
void QtPassSettings::setClipBoardType(const int &clipBoardType) {
1✔
325
  getInstance()->setValue(SettingsConstants::clipBoardType, clipBoardType);
1✔
326
}
1✔
327

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

337
auto QtPassSettings::isUseAutoclear(const bool &defaultValue) -> bool {
4✔
338
  return getInstance()
4✔
339
      ->value(SettingsConstants::useAutoclear, defaultValue)
8✔
340
      .toBool();
8✔
341
}
342
void QtPassSettings::setUseAutoclear(const bool &useAutoclear) {
2✔
343
  getInstance()->setValue(SettingsConstants::useAutoclear, useAutoclear);
2✔
344
}
2✔
345

346
auto QtPassSettings::getAutoclearSeconds(const int &defaultValue) -> int {
2✔
347
  return getInstance()
2✔
348
      ->value(SettingsConstants::autoclearSeconds, defaultValue)
4✔
349
      .toInt();
4✔
350
}
351
void QtPassSettings::setAutoclearSeconds(const int &autoClearSeconds) {
2✔
352
  getInstance()->setValue(SettingsConstants::autoclearSeconds,
2✔
353
                          autoClearSeconds);
354
}
2✔
355

356
auto QtPassSettings::isUseAutoclearPanel(const bool &defaultValue) -> bool {
4✔
357
  return getInstance()
4✔
358
      ->value(SettingsConstants::useAutoclearPanel, defaultValue)
8✔
359
      .toBool();
8✔
360
}
361
void QtPassSettings::setUseAutoclearPanel(const bool &useAutoclearPanel) {
2✔
362
  getInstance()->setValue(SettingsConstants::useAutoclearPanel,
4✔
363
                          useAutoclearPanel);
2✔
364
}
2✔
365

366
auto QtPassSettings::getAutoclearPanelSeconds(const int &defaultValue) -> int {
2✔
367
  return getInstance()
2✔
368
      ->value(SettingsConstants::autoclearPanelSeconds, defaultValue)
4✔
369
      .toInt();
4✔
370
}
371
void QtPassSettings::setAutoclearPanelSeconds(
2✔
372
    const int &autoClearPanelSeconds) {
373
  getInstance()->setValue(SettingsConstants::autoclearPanelSeconds,
2✔
374
                          autoClearPanelSeconds);
375
}
2✔
376

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

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

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

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

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

422
auto QtPassSettings::isAddGPGId(const bool &defaultValue) -> bool {
4✔
423
  return getInstance()
4✔
424
      ->value(SettingsConstants::addGPGId, defaultValue)
8✔
425
      .toBool();
8✔
426
}
427
void QtPassSettings::setAddGPGId(const bool &addGPGId) {
2✔
428
  getInstance()->setValue(SettingsConstants::addGPGId, addGPGId);
2✔
429
}
2✔
430

431
/**
432
 * @brief Retrieves the password store path, normalizes it, and ensures the
433
 * directory exists.
434
 * @example
435
 * QString passStore =
436
 * QtPassSettings::getPassStore("/home/user/.password-store"); qDebug() <<
437
 * passStore; // Expected output: "/home/user/.password-store/"
438
 *
439
 * @param defaultValue - Fallback path used when no password store is
440
 * configured.
441
 * @return QString - The normalized absolute password store path, guaranteed to
442
 * end with a path separator.
443
 */
444
auto QtPassSettings::getPassStore(const QString &defaultValue) -> QString {
181✔
445
  QString returnValue = getInstance()
181✔
446
                            ->value(SettingsConstants::passStore, defaultValue)
362✔
447
                            .toString();
181✔
448

449
  // Normalize the path string
450
  returnValue = QDir(returnValue).absolutePath();
362✔
451

452
  // ensure directory exists if never used pass or misconfigured.
453
  // otherwise process->setWorkingDirectory(passStore); will fail on execution.
454
  if (!QDir(returnValue).exists()) {
181✔
455
    if (!QDir().mkdir(returnValue)) {
4✔
456
      qWarning() << "Failed to create password store directory:" << returnValue;
×
457
    }
458
  }
459

460
  // ensure path ends in /
461
  if (!returnValue.endsWith("/") && !returnValue.endsWith(QDir::separator())) {
362✔
462
    returnValue += QDir::separator();
181✔
463
  }
464

465
  return returnValue;
181✔
466
}
467
void QtPassSettings::setPassStore(const QString &passStore) {
44✔
468
  getInstance()->setValue(SettingsConstants::passStore, passStore);
44✔
469
}
44✔
470

471
auto QtPassSettings::getPassSigningKey(const QString &defaultValue) -> QString {
43✔
472
  return getInstance()
43✔
473
      ->value(SettingsConstants::passSigningKey, defaultValue)
86✔
474
      .toString();
86✔
475
}
476
void QtPassSettings::setPassSigningKey(const QString &passSigningKey) {
4✔
477
  getInstance()->setValue(SettingsConstants::passSigningKey, passSigningKey);
4✔
478
}
4✔
479

480
/**
481
 * @brief Initializes executable paths for Pass, Git, GPG, and Pwgen by locating
482
 * them in the system PATH.
483
 * @example
484
 * QtPassSettings::initExecutables();
485
 *
486
 * @return void - This method does not return a value.
487
 */
488
void QtPassSettings::initExecutables() {
×
489
  QString passExecutable =
490
      QtPassSettings::getPassExecutable(Util::findBinaryInPath("pass"));
×
491
  QtPassSettings::setPassExecutable(passExecutable);
×
492

493
  QString gitExecutable =
494
      QtPassSettings::getGitExecutable(Util::findBinaryInPath("git"));
×
495
  QtPassSettings::setGitExecutable(gitExecutable);
×
496

497
  QString gpgExecutable =
498
      QtPassSettings::getGpgExecutable(Util::findBinaryInPath("gpg2"));
×
499
  QtPassSettings::setGpgExecutable(gpgExecutable);
×
500

501
  QString pwgenExecutable =
502
      QtPassSettings::getPwgenExecutable(Util::findBinaryInPath("pwgen"));
×
503
  QtPassSettings::setPwgenExecutable(pwgenExecutable);
×
504
}
×
505
auto QtPassSettings::getPassExecutable(const QString &defaultValue) -> QString {
2✔
506
  return getInstance()
2✔
507
      ->value(SettingsConstants::passExecutable, defaultValue)
4✔
508
      .toString();
4✔
509
}
510
void QtPassSettings::setPassExecutable(const QString &passExecutable) {
2✔
511
  getInstance()->setValue(SettingsConstants::passExecutable, passExecutable);
2✔
512
}
2✔
513

514
auto QtPassSettings::getGitExecutable(const QString &defaultValue) -> QString {
6✔
515
  return getInstance()
6✔
516
      ->value(SettingsConstants::gitExecutable, defaultValue)
12✔
517
      .toString();
12✔
518
}
519
void QtPassSettings::setGitExecutable(const QString &gitExecutable) {
3✔
520
  getInstance()->setValue(SettingsConstants::gitExecutable, gitExecutable);
3✔
521
}
3✔
522

523
auto QtPassSettings::getGpgExecutable(const QString &defaultValue) -> QString {
85✔
524
  return getInstance()
85✔
525
      ->value(SettingsConstants::gpgExecutable, defaultValue)
170✔
526
      .toString();
170✔
527
}
528
void QtPassSettings::setGpgExecutable(const QString &gpgExecutable) {
6✔
529
  getInstance()->setValue(SettingsConstants::gpgExecutable, gpgExecutable);
6✔
530
}
6✔
531

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

542
auto QtPassSettings::getGpgHome(const QString &defaultValue) -> QString {
29✔
543
  return getInstance()
29✔
544
      ->value(SettingsConstants::gpgHome, defaultValue)
58✔
545
      .toString();
58✔
546
}
547

548
auto QtPassSettings::isUseWebDav(const bool &defaultValue) -> bool {
23✔
549
  return getInstance()
23✔
550
      ->value(SettingsConstants::useWebDav, defaultValue)
46✔
551
      .toBool();
46✔
552
}
553
void QtPassSettings::setUseWebDav(const bool &useWebDav) {
2✔
554
  getInstance()->setValue(SettingsConstants::useWebDav, useWebDav);
2✔
555
}
2✔
556

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

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

575
auto QtPassSettings::getWebDavPassword(const QString &defaultValue) -> QString {
2✔
576
  return getInstance()
2✔
577
      ->value(SettingsConstants::webDavPassword, defaultValue)
4✔
578
      .toString();
4✔
579
}
580
void QtPassSettings::setWebDavPassword(const QString &webDavPassword) {
2✔
581
  getInstance()->setValue(SettingsConstants::webDavPassword, webDavPassword);
2✔
582
}
2✔
583

584
auto QtPassSettings::getProfile(const QString &defaultValue) -> QString {
3✔
585
  return getInstance()
3✔
586
      ->value(SettingsConstants::profile, defaultValue)
6✔
587
      .toString();
6✔
588
}
589
void QtPassSettings::setProfile(const QString &profile) {
3✔
590
  getInstance()->setValue(SettingsConstants::profile, profile);
3✔
591
}
3✔
592

593
/**
594
 * @brief Gets the useGit setting for a specific profile.
595
 * @param profileName The profile name.
596
 * @param defaultValue The default value if not set.
597
 * @return The useGit setting for the profile.
598
 */
599
auto QtPassSettings::getProfileUseGit(const QString &profileName,
3✔
600
                                      const bool &defaultValue) -> bool {
601
  QString stored =
602
      getInstance()
3✔
603
          ->value(SettingsConstants::profile + "/" + profileName + "/useGit")
9✔
604
          .toString();
3✔
605
  // If empty or not set, return default (migration-friendly fallback)
606
  if (stored.isEmpty()) {
3✔
607
    return defaultValue;
1✔
608
  }
609
  return stored == "true";
610
}
611

612
/**
613
 * @brief Sets the useGit setting for a specific profile.
614
 * @param profileName The profile name.
615
 * @param useGit The useGit value to set.
616
 */
617
void QtPassSettings::setProfileUseGit(const QString &profileName,
2✔
618
                                      const bool &useGit) {
619
  getInstance()->setValue(SettingsConstants::profile + "/" + profileName +
6✔
620
                              "/useGit",
621
                          useGit ? "true" : "false");
2✔
622
}
2✔
623

624
/**
625
 * @brief Gets the autoPush setting for a specific profile.
626
 * @param profileName The profile name.
627
 * @param defaultValue The default value if not set.
628
 * @return The autoPush setting for the profile.
629
 */
630
auto QtPassSettings::getProfileAutoPush(const QString &profileName,
3✔
631
                                        const bool &defaultValue) -> bool {
632
  QString stored =
633
      getInstance()
3✔
634
          ->value(SettingsConstants::profile + "/" + profileName + "/autoPush")
9✔
635
          .toString();
3✔
636
  if (stored.isEmpty()) {
3✔
637
    return defaultValue;
1✔
638
  }
639
  return stored == "true";
640
}
641

642
/**
643
 * @brief Sets the autoPush setting for a specific profile.
644
 * @param profileName The profile name.
645
 * @param autoPush The autoPush value to set.
646
 */
647
void QtPassSettings::setProfileAutoPush(const QString &profileName,
2✔
648
                                        const bool &autoPush) {
649
  getInstance()->setValue(SettingsConstants::profile + "/" + profileName +
6✔
650
                              "/autoPush",
651
                          autoPush ? "true" : "false");
2✔
652
}
2✔
653

654
/**
655
 * @brief Gets the autoPull setting for a specific profile.
656
 * @param profileName The profile name.
657
 * @param defaultValue The default value if not set.
658
 * @return The autoPull setting for the profile.
659
 */
660
auto QtPassSettings::getProfileAutoPull(const QString &profileName,
3✔
661
                                        const bool &defaultValue) -> bool {
662
  QString stored =
663
      getInstance()
3✔
664
          ->value(SettingsConstants::profile + "/" + profileName + "/autoPull")
9✔
665
          .toString();
3✔
666
  if (stored.isEmpty()) {
3✔
667
    return defaultValue;
1✔
668
  }
669
  return stored == "true";
670
}
671

672
/**
673
 * @brief Sets the autoPull setting for a specific profile.
674
 * @param profileName The profile name.
675
 * @param autoPull The autoPull value to set.
676
 */
677
void QtPassSettings::setProfileAutoPull(const QString &profileName,
2✔
678
                                        const bool &autoPull) {
679
  getInstance()->setValue(SettingsConstants::profile + "/" + profileName +
6✔
680
                              "/autoPull",
681
                          autoPull ? "true" : "false");
2✔
682
}
2✔
683

684
/**
685
 * @brief Determines whether Git should be used for the current QtPass settings.
686
 * @example
687
 * bool result = QtPassSettings::isUseGit(true);
688
 * std::cout << result << std::endl; // Expected output: true or false
689
 *
690
 * @param const bool &defaultValue - The fallback value used when no explicit
691
 * setting is stored.
692
 * @return bool - True if Git usage is enabled, otherwise false.
693
 */
694
auto QtPassSettings::isUseGit(const bool &defaultValue) -> bool {
33✔
695
  bool storedValue =
696
      getInstance()->value(SettingsConstants::useGit, defaultValue).toBool();
33✔
697
  if (storedValue == defaultValue && defaultValue) {
33✔
698
    QString passStore = getPassStore();
4✔
699
    if (QFileInfo(passStore).isDir() &&
4✔
700
        QFileInfo(passStore + QDir::separator() + ".git").isDir()) {
6✔
701
      return true;
702
    }
703
  }
704
  return storedValue;
705
}
706
void QtPassSettings::setUseGit(const bool &useGit) {
6✔
707
  getInstance()->setValue(SettingsConstants::useGit, useGit);
6✔
708
}
6✔
709

710
auto QtPassSettings::isUseGrepSearch(const bool &defaultValue) -> bool {
×
711
  return getInstance()
×
712
      ->value(SettingsConstants::useGrepSearch, defaultValue)
×
713
      .toBool();
×
714
}
715

716
void QtPassSettings::setUseGrepSearch(const bool &useGrepSearch) {
×
717
  getInstance()->setValue(SettingsConstants::useGrepSearch, useGrepSearch);
×
718
}
×
719

720
auto QtPassSettings::isUseOtp(const bool &defaultValue) -> bool {
4✔
721
  return getInstance()->value(SettingsConstants::useOtp, defaultValue).toBool();
4✔
722
}
723

724
void QtPassSettings::setUseOtp(const bool &useOtp) {
2✔
725
  getInstance()->setValue(SettingsConstants::useOtp, useOtp);
2✔
726
}
2✔
727

728
auto QtPassSettings::isUseQrencode(const bool &defaultValue) -> bool {
4✔
729
  return getInstance()
4✔
730
      ->value(SettingsConstants::useQrencode, defaultValue)
8✔
731
      .toBool();
8✔
732
}
733

734
void QtPassSettings::setUseQrencode(const bool &useQrencode) {
2✔
735
  getInstance()->setValue(SettingsConstants::useQrencode, useQrencode);
2✔
736
}
2✔
737

738
auto QtPassSettings::getQrencodeExecutable(const QString &defaultValue)
2✔
739
    -> QString {
740
  return getInstance()
2✔
741
      ->value(SettingsConstants::qrencodeExecutable, defaultValue)
4✔
742
      .toString();
4✔
743
}
744
void QtPassSettings::setQrencodeExecutable(const QString &qrencodeExecutable) {
2✔
745
  getInstance()->setValue(SettingsConstants::qrencodeExecutable,
2✔
746
                          qrencodeExecutable);
747
}
2✔
748

749
auto QtPassSettings::isUsePwgen(const bool &defaultValue) -> bool {
1,210✔
750
  return getInstance()
1,210✔
751
      ->value(SettingsConstants::usePwgen, defaultValue)
2,420✔
752
      .toBool();
2,420✔
753
}
754
void QtPassSettings::setUsePwgen(const bool &usePwgen) {
6✔
755
  getInstance()->setValue(SettingsConstants::usePwgen, usePwgen);
6✔
756
}
6✔
757

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

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

776
auto QtPassSettings::isLessRandom(const bool &defaultValue) -> bool {
4✔
777
  return getInstance()
4✔
778
      ->value(SettingsConstants::lessRandom, defaultValue)
8✔
779
      .toBool();
8✔
780
}
781
void QtPassSettings::setLessRandom(const bool &lessRandom) {
2✔
782
  getInstance()->setValue(SettingsConstants::lessRandom, lessRandom);
2✔
783
}
2✔
784

785
auto QtPassSettings::isUseSymbols(const bool &defaultValue) -> bool {
4✔
786
  return getInstance()
4✔
787
      ->value(SettingsConstants::useSymbols, defaultValue)
8✔
788
      .toBool();
8✔
789
}
790
void QtPassSettings::setUseSymbols(const bool &useSymbols) {
2✔
791
  getInstance()->setValue(SettingsConstants::useSymbols, useSymbols);
2✔
792
}
2✔
793

794
void QtPassSettings::setPasswordLength(const int &passwordLength) {
2✔
795
  getInstance()->setValue(SettingsConstants::passwordLength, passwordLength);
2✔
796
}
2✔
797
void QtPassSettings::setPasswordCharsSelection(
6✔
798
    const int &passwordCharsSelection) {
799
  getInstance()->setValue(SettingsConstants::passwordCharsSelection,
6✔
800
                          passwordCharsSelection);
801
}
6✔
802
void QtPassSettings::setPasswordChars(const QString &passwordChars) {
5✔
803
  getInstance()->setValue(SettingsConstants::passwordChars, passwordChars);
5✔
804
}
5✔
805

806
auto QtPassSettings::isUseTrayIcon(const bool &defaultValue) -> bool {
4✔
807
  return getInstance()
4✔
808
      ->value(SettingsConstants::useTrayIcon, defaultValue)
8✔
809
      .toBool();
8✔
810
}
811
void QtPassSettings::setUseTrayIcon(const bool &useTrayIcon) {
2✔
812
  getInstance()->setValue(SettingsConstants::useTrayIcon, useTrayIcon);
2✔
813
}
2✔
814

815
auto QtPassSettings::isHideOnClose(const bool &defaultValue) -> bool {
4✔
816
  return getInstance()
4✔
817
      ->value(SettingsConstants::hideOnClose, defaultValue)
8✔
818
      .toBool();
8✔
819
}
820
void QtPassSettings::setHideOnClose(const bool &hideOnClose) {
2✔
821
  getInstance()->setValue(SettingsConstants::hideOnClose, hideOnClose);
2✔
822
}
2✔
823

824
auto QtPassSettings::isStartMinimized(const bool &defaultValue) -> bool {
4✔
825
  return getInstance()
4✔
826
      ->value(SettingsConstants::startMinimized, defaultValue)
8✔
827
      .toBool();
8✔
828
}
829
void QtPassSettings::setStartMinimized(const bool &startMinimized) {
2✔
830
  getInstance()->setValue(SettingsConstants::startMinimized, startMinimized);
2✔
831
}
2✔
832

833
auto QtPassSettings::isAlwaysOnTop(const bool &defaultValue) -> bool {
4✔
834
  return getInstance()
4✔
835
      ->value(SettingsConstants::alwaysOnTop, defaultValue)
8✔
836
      .toBool();
8✔
837
}
838
void QtPassSettings::setAlwaysOnTop(const bool &alwaysOnTop) {
2✔
839
  getInstance()->setValue(SettingsConstants::alwaysOnTop, alwaysOnTop);
2✔
840
}
2✔
841

842
auto QtPassSettings::isAutoPull(const bool &defaultValue) -> bool {
5✔
843
  return getInstance()
5✔
844
      ->value(SettingsConstants::autoPull, defaultValue)
10✔
845
      .toBool();
10✔
846
}
847
void QtPassSettings::setAutoPull(const bool &autoPull) {
2✔
848
  getInstance()->setValue(SettingsConstants::autoPull, autoPull);
2✔
849
}
2✔
850

851
auto QtPassSettings::isAutoPush(const bool &defaultValue) -> bool {
5✔
852
  return getInstance()
5✔
853
      ->value(SettingsConstants::autoPush, defaultValue)
10✔
854
      .toBool();
10✔
855
}
856
void QtPassSettings::setAutoPush(const bool &autoPush) {
2✔
857
  getInstance()->setValue(SettingsConstants::autoPush, autoPush);
2✔
858
}
2✔
859

860
auto QtPassSettings::getPassTemplate(const QString &defaultValue) -> QString {
2✔
861
  return getInstance()
2✔
862
      ->value(SettingsConstants::passTemplate, defaultValue)
4✔
863
      .toString();
4✔
864
}
865
void QtPassSettings::setPassTemplate(const QString &passTemplate) {
2✔
866
  getInstance()->setValue(SettingsConstants::passTemplate, passTemplate);
2✔
867
}
2✔
868

869
auto QtPassSettings::isUseTemplate(const bool &defaultValue) -> bool {
4✔
870
  return getInstance()
4✔
871
      ->value(SettingsConstants::useTemplate, defaultValue)
8✔
872
      .toBool();
8✔
873
}
874
void QtPassSettings::setUseTemplate(const bool &useTemplate) {
2✔
875
  getInstance()->setValue(SettingsConstants::useTemplate, useTemplate);
2✔
876
}
2✔
877

878
auto QtPassSettings::isTemplateAllFields(const bool &defaultValue) -> bool {
4✔
879
  return getInstance()
4✔
880
      ->value(SettingsConstants::templateAllFields, defaultValue)
8✔
881
      .toBool();
8✔
882
}
883
void QtPassSettings::setTemplateAllFields(const bool &templateAllFields) {
2✔
884
  getInstance()->setValue(SettingsConstants::templateAllFields,
4✔
885
                          templateAllFields);
2✔
886
}
2✔
887

888
auto QtPassSettings::getRealPass() -> RealPass * {
×
889
  if (realPass.isNull()) {
×
890
    realPass.reset(new RealPass());
×
891
  }
892
  return realPass.data();
×
893
}
894
auto QtPassSettings::getImitatePass() -> ImitatePass * {
1✔
895
  if (imitatePass.isNull()) {
1✔
896
    imitatePass.reset(new ImitatePass());
1✔
897
  }
898
  return imitatePass.data();
1✔
899
}
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