17QProcessEnvironment Util::_env;
18bool Util::_envInitialised;
24void Util::initialiseEnvironment() {
25 if (!_envInitialised) {
26 _env = QProcessEnvironment::systemEnvironment();
28 QString path = _env.value(
"PATH");
29 if (!path.contains(
"/usr/local/MacGPG2/bin") &&
30 QFile(
"/usr/local/MacGPG2/bin").exists())
31 path +=
":/usr/local/MacGPG2/bin";
32 if (!path.contains(
"/usr/local/bin"))
33 path +=
":/usr/local/bin";
34 _env.insert(
"PATH", path);
37 QString path = _env.value(
"PATH");
38 if (!path.contains(
"C:\\Program Files\\WinGPG\\x86") &&
39 QFile(
"C:\\Program Files\\WinGPG\\x86").exists())
40 path +=
";C:\\Program Files\\WinGPG\\x86";
41 if (!path.contains(
"C:\\Program Files\\GnuPG\\bin") &&
42 QFile(
"C:\\Program Files\\GnuPG\\bin").exists())
43 path +=
";C:\\Program Files\\GnuPG\bin";
44 _env.insert(
"PATH", path);
47 dbg() << _env.value(
"PATH");
49 _envInitialised =
true;
60 initialiseEnvironment();
61 if (_env.contains(
"PASSWORD_STORE_DIR")) {
62 path = _env.value(
"PASSWORD_STORE_DIR");
65 path = QDir::homePath() + QDir::separator() +
"password-store" +
68 path = QDir::homePath() + QDir::separator() +
".password-store" +
82 if (!path.endsWith(
"/") && !path.endsWith(QDir::separator())) {
83 path += QDir::separator();
85 return QDir::toNativeSeparators(path);
94 initialiseEnvironment();
98 binary.prepend(QDir::separator());
100 if (_env.contains(
"PATH")) {
101 QString path = _env.value(
"PATH");
105 entries = path.split(
':');
106 if (entries.length() < 2) {
108 entries = path.split(
';');
113 foreach (QString entry, entries) {
114 QScopedPointer<QFileInfo> qfi(
new QFileInfo(entry.append(binary)));
117 qfi.reset(
new QFileInfo(entry.append(
".exe")));
120 if (!qfi->isExecutable()) {
124 ret = qfi->absoluteFilePath();
131 binary.prepend(
"wsl ");
134 !out.isEmpty() && err.isEmpty())
165 const QFileSystemModel &model,
const StoreModel &storeModel)
169 if (!index.isValid()) {
170 return forPass ?
"" : abspath;
172 QFileInfo info = model.fileInfo(storeModel.mapToSource(index));
174 (info.isFile() ? info.absolutePath() : info.absoluteFilePath());
176 filePath = QDir(abspath).relativeFilePath(filePath);
178 filePath += QDir::separator();
189 if (!srcDir.exists()) {
193 foreach (QString dir, srcDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
194 copyDir(src + QDir::separator() + dir, dest + QDir::separator() + dir);
197 foreach (QString file, srcDir.entryList(QDir::Files)) {
198 QFile::copy(src + QDir::separator() + file,
199 dest + QDir::separator() + file);
204 static const QRegularExpression expr{
"\\.gpg$"};
209 static const QRegularExpression regex{
210 "((?:https?|ftp|ssh|sftp|ftps|webdav|webdavs)://[^\\s<>\"\\)\\]\\[]+)"};
215 static const QRegularExpression regex{
"[\r\n]"};
static auto executeBlocking(QString app, const QStringList &args, const QString &input=QString(), QString *process_out=nullptr, QString *process_err=nullptr) -> int
Executor::executeBlocking blocking version of the executor, takes input and presents it as stdin.
static auto isUsePass(const bool &defaultValue=QVariant().toBool()) -> bool
static auto getPassStore(const QString &defaultValue=QVariant().toString()) -> QString
static auto getGpgExecutable(const QString &defaultValue=QVariant().toString()) -> QString
static auto getPassExecutable(const QString &defaultValue=QVariant().toString()) -> QString
The QSortFilterProxyModel for handling filesystem searches.
static auto normalizeFolderPath(QString path) -> QString
Util::normalizeFolderPath let's always end folders with a QDir::separator()
static auto protocolRegex() -> const QRegularExpression &
static auto endsWithGpg() -> const QRegularExpression &
static auto findPasswordStore() -> QString
Util::findPasswordStore look for common .password-store folder location.
static auto getDir(const QModelIndex &index, bool forPass, const QFileSystemModel &model, const StoreModel &storeModel) -> QString
Util::getDir get selectd folder path.
static auto checkConfig() -> bool
Util::checkConfig do we have prequisite settings?
static auto newLinesRegex() -> const QRegularExpression &
static auto findBinaryInPath(QString binary) -> QString
Util::findBinaryInPath search for executables.
static void copyDir(const QString &src, const QString &dest)
Util::copyDir.