15QProcessEnvironment Util::_env;
16bool Util::_envInitialised;
22void Util::initialiseEnvironment() {
23 if (!_envInitialised) {
24 _env = QProcessEnvironment::systemEnvironment();
26 QString path = _env.value(
"PATH");
27 if (!path.contains(
"/usr/local/MacGPG2/bin") &&
28 QFile(
"/usr/local/MacGPG2/bin").exists())
29 path +=
":/usr/local/MacGPG2/bin";
30 if (!path.contains(
"/usr/local/bin"))
31 path +=
":/usr/local/bin";
32 _env.insert(
"PATH", path);
35 QString path = _env.value(
"PATH");
36 if (!path.contains(
"C:\\Program Files\\WinGPG\\x86") &&
37 QFile(
"C:\\Program Files\\WinGPG\\x86").exists())
38 path +=
";C:\\Program Files\\WinGPG\\x86";
39 if (!path.contains(
"C:\\Program Files\\GnuPG\\bin") &&
40 QFile(
"C:\\Program Files\\GnuPG\\bin").exists())
41 path +=
";C:\\Program Files\\GnuPG\bin";
42 _env.insert(
"PATH", path);
45 dbg() << _env.value(
"PATH");
47 _envInitialised =
true;
58 initialiseEnvironment();
59 if (_env.contains(
"PASSWORD_STORE_DIR")) {
60 path = _env.value(
"PASSWORD_STORE_DIR");
63 path = QDir::homePath() + QDir::separator() +
"password-store" +
66 path = QDir::homePath() + QDir::separator() +
".password-store" +
80 if (!path.endsWith(
"/") && !path.endsWith(QDir::separator()))
81 path += QDir::separator();
82 return QDir::toNativeSeparators(path);
91 initialiseEnvironment();
95 binary.prepend(QDir::separator());
97 if (_env.contains(
"PATH")) {
98 QString path = _env.value(
"PATH");
102 entries = path.split(
':');
103 if (entries.length() < 2) {
105 entries = path.split(
';');
110 foreach (QString entry, entries) {
111 QScopedPointer<QFileInfo> qfi(
new QFileInfo(entry.append(binary)));
114 qfi.reset(
new QFileInfo(entry.append(
".exe")));
117 if (!qfi->isExecutable())
120 ret = qfi->absoluteFilePath();
127 binary.prepend(
"wsl ");
130 !out.isEmpty() && err.isEmpty())
161 const QFileSystemModel &model,
165 if (!index.isValid())
166 return forPass ?
"" : abspath;
167 QFileInfo info = model.fileInfo(storeModel.mapToSource(index));
169 (info.isFile() ? info.absolutePath() : info.absoluteFilePath());
171 filePath = QDir(abspath).relativeFilePath(filePath);
173 filePath += QDir::separator();
184 if (!srcDir.exists()) {
188 foreach (QString dir, srcDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
189 copyDir(src + QDir::separator() + dir, dest + QDir::separator() + dir);
192 foreach (QString file, srcDir.entryList(QDir::Files)) {
193 QFile::copy(src + QDir::separator() + file,
194 dest + QDir::separator() + file);
199 static const QRegularExpression expr{
"\\.gpg$"};
204 static const QRegularExpression regex{
205 "((?:https?|ftp|ssh|sftp|ftps|webdav|webdavs)://\\S+)"};
static int executeBlocking(QString app, const QStringList &args, QString input=QString(), QString *process_out=Q_NULLPTR, QString *process_err=Q_NULLPTR)
Executor::executeBlocking blocking version of the executor, takes input and presents it as stdin.
static bool isUsePass(const bool &defaultValue=QVariant().toBool())
static QString getGpgExecutable(const QString &defaultValue=QVariant().toString())
static QString getPassStore(const QString &defaultValue=QVariant().toString())
static QString getPassExecutable(const QString &defaultValue=QVariant().toString())
The QSortFilterProxyModel for handling filesystem searches.
static bool checkConfig()
Util::checkConfig do we have prequisite settings?
static QString findPasswordStore()
Util::findPasswordStore look for common .password-store folder location.
static QString getDir(const QModelIndex &index, bool forPass, const QFileSystemModel &model, const StoreModel &storeModel)
Util::getDir get selectd folder path.
static const QRegularExpression & protocolRegex()
static const QRegularExpression & endsWithGpg()
static QString normalizeFolderPath(QString path)
Util::normalizeFolderPath let's always end folders with a QDir::separator()
static QString findBinaryInPath(QString binary)
Util::findBinaryInPath search for executables.
static void copyDir(const QString &src, const QString &dest)
Util::copyDir.