QtPass
2.0.0
Developer documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
profile.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
8
#ifndef SRC_PROFILE_H_
9
#define SRC_PROFILE_H_
10
11
#include <QMap>
12
#include <QString>
13
#include <optional>
14
26
struct
Profile
{
27
QString
path
;
28
QString
signingKey
;
29
std::optional<bool>
useGit
;
30
std::optional<bool>
autoPush
;
31
std::optional<bool>
autoPull
;
32
38
static
auto
flagFromString
(
const
QString &value) -> std::optional<bool> {
39
if
(value == QLatin1String(
"true"
)) {
40
return
true
;
41
}
42
if
(value == QLatin1String(
"false"
)) {
43
return
false
;
44
}
45
return
std::nullopt;
46
}
47
53
static
auto
flagToString
(std::optional<bool> flag) -> QString {
54
if
(!flag.has_value()) {
55
return
{};
56
}
57
return
*flag ? QStringLiteral(
"true"
) : QStringLiteral(
"false"
);
58
}
59
65
auto
operator==
(
const
Profile
&other)
const
->
bool
{
66
return
path
== other.path &&
signingKey
== other.signingKey &&
67
useGit
== other.useGit &&
autoPush
== other.autoPush &&
68
autoPull
== other.autoPull;
69
}
70
75
auto
operator!=
(
const
Profile
&other)
const
->
bool
{
76
return
!(*
this
== other);
77
}
78
};
79
81
using
Profiles
= QMap<QString, Profile>;
82
83
#endif
// SRC_PROFILE_H_
Profiles
QMap< QString, Profile > Profiles
All profiles by name. QMap so iteration order is the name order.
Definition
profile.h:81
Profile
One named password store: where it is, how its .gpg-id is signed and, optionally, its own Git switche...
Definition
profile.h:26
Profile::autoPush
std::optional< bool > autoPush
Push after commits; unset = global.
Definition
profile.h:30
Profile::path
QString path
Password store directory.
Definition
profile.h:27
Profile::operator==
auto operator==(const Profile &other) const -> bool
Field-wise equality, including the unset state of each flag.
Definition
profile.h:65
Profile::autoPull
std::optional< bool > autoPull
Pull on start; unset = global.
Definition
profile.h:31
Profile::useGit
std::optional< bool > useGit
Git on/off; unset follows the global.
Definition
profile.h:29
Profile::flagToString
static auto flagToString(std::optional< bool > flag) -> QString
Format a flag the way it is stored.
Definition
profile.h:53
Profile::operator!=
auto operator!=(const Profile &other) const -> bool
Negation of operator==.
Definition
profile.h:75
Profile::flagFromString
static auto flagFromString(const QString &value) -> std::optional< bool >
Parse the on-disk tri-state.
Definition
profile.h:38
Profile::signingKey
QString signingKey
Key(s) that sign this store's .gpg-id.
Definition
profile.h:28
src
profile.h
Generated by
1.18.0