QtPass 1.6.0
Multi-platform GUI for pass, the standard unix password manager.
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2014 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
3#ifndef SRC_UTIL_H_
4#define SRC_UTIL_H_
5
6#include "storemodel.h"
7#include <QFileSystemModel>
8#include <QProcessEnvironment>
9#include <QRegularExpression>
10#include <QString>
11
12constexpr int MS_PER_SECOND = 1000;
13
14class StoreModel;
15
20class Util {
21public:
30 static auto findBinaryInPath(QString binary) -> QString;
36 static auto findPasswordStore() -> QString;
43 static auto normalizeFolderPath(const QString &path) -> QString;
50 static auto configIsValid() -> bool;
64 static auto getDir(const QModelIndex &index, bool forPass,
65 const QFileSystemModel &model,
66 const StoreModel &storeModel) -> QString;
71 static auto endsWithGpg() -> const QRegularExpression &;
76 static auto protocolRegex() -> const QRegularExpression &;
81 static auto newLinesRegex() -> const QRegularExpression &;
92 static auto isValidKeyId(const QString &keyId) -> bool;
93
94private:
95 static void initialiseEnvironment();
96 static QProcessEnvironment _env;
97 static bool _envInitialised;
98};
99
100#endif // SRC_UTIL_H_
QSortFilterProxyModel for filtering and displaying password store.
Definition storemodel.h:31
Static utility functions implementation.
Definition util.h:20
static auto protocolRegex() -> const QRegularExpression &
Returns a regex to match URL protocols.
Definition util.cpp:266
static auto endsWithGpg() -> const QRegularExpression &
Returns a regex to match .gpg file extensions.
Definition util.cpp:249
static auto findPasswordStore() -> QString
Locate the password store directory.
Definition util.cpp:77
static auto getDir(const QModelIndex &index, bool forPass, const QFileSystemModel &model, const StoreModel &storeModel) -> QString
Get the selected folder path, either relative to the configured pass store or absolute.
Definition util.cpp:231
static auto isValidKeyId(const QString &keyId) -> bool
Check if a string looks like a valid GPG key ID. Validates a GPG key ID after normalization:
Definition util.cpp:277
static auto newLinesRegex() -> const QRegularExpression &
Returns a regex to match newline characters.
Definition util.cpp:272
static auto normalizeFolderPath(const QString &path) -> QString
Ensure a folder path always ends with the native directory separator.
Definition util.cpp:94
static auto findBinaryInPath(QString binary) -> QString
Locate an executable by searching the process PATH and (on Windows) falling back to WSL.
Definition util.cpp:120
static auto configIsValid() -> bool
Verify that the required configuration is complete.
Definition util.cpp:188
constexpr int MS_PER_SECOND
Definition util.h:12