summaryrefslogtreecommitdiffstats
path: root/src/util.cpp
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2019-04-17 11:26:56 +0200
committerAnne Jan Brouwer <brouwer@annejan.com>2019-04-17 11:26:56 +0200
commitf2b2f6715215e83b27d5b067a2b1a9e890bd8be7 (patch)
tree85d8768d0c0e3052ab21541e3b73f2c4af899bb7 /src/util.cpp
parent5eae57663c53467b946ea7a7b5935766afebc90b (diff)
parent3698ff096cffec3541253ba1e745c389df0118c2 (diff)
Updated to current master
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/util.cpp b/src/util.cpp
index db8478e4..8633a3d3 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -110,6 +110,16 @@ QString Util::findBinaryInPath(QString binary) {
break;
}
}
+#ifdef Q_OS_WIN
+ if (ret.isEmpty()) {
+ binary.remove(0, 1);
+ binary.prepend("wsl ");
+ QString out, err;
+ if (Executor::executeBlocking(binary, {"--version"}, &out, &err) == 0 &&
+ !out.isEmpty() && err.isEmpty())
+ ret = binary;
+ }
+#endif
return ret;
}
@@ -121,7 +131,10 @@ QString Util::findBinaryInPath(QString binary) {
bool Util::checkConfig() {
return !QFile(QDir(QtPassSettings::getPassStore()).filePath(".gpg-id"))
.exists() ||
- (!QFile(QtPassSettings::getPassExecutable()).exists() &&
+ (QtPassSettings::isUsePass() ?
+ !QtPassSettings::getPassExecutable().startsWith("wsl ") &&
+ !QFile(QtPassSettings::getPassExecutable()).exists() :
+ !QtPassSettings::getGpgExecutable().startsWith("wsl ") &&
!QFile(QtPassSettings::getGpgExecutable()).exists());
}
@@ -136,7 +149,8 @@ bool Util::checkConfig() {
QString Util::getDir(const QModelIndex &index, bool forPass,
const QFileSystemModel &model,
const StoreModel &storeModel) {
- QString abspath = QDir(QtPassSettings::getPassStore()).absolutePath() + '/';
+ QString abspath =
+ QDir(QtPassSettings::getPassStore()).absolutePath() + QDir::separator();
if (!index.isValid())
return forPass ? "" : abspath;
QFileInfo info = model.fileInfo(storeModel.mapToSource(index));
@@ -145,7 +159,7 @@ QString Util::getDir(const QModelIndex &index, bool forPass,
if (forPass) {
filePath = QDir(abspath).relativeFilePath(filePath);
}
- filePath += '/';
+ filePath += QDir::separator();
return filePath;
}