summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.cpp33
-rw-r--r--mainwindow.cpp57
-rw-r--r--mainwindow.h5
-rw-r--r--qtpass.pro1
4 files changed, 78 insertions, 18 deletions
diff --git a/main.cpp b/main.cpp
index 1996b368..96e85e11 100644
--- a/main.cpp
+++ b/main.cpp
@@ -14,11 +14,34 @@ int main(int argc, char *argv[])
testProcess->waitForFinished();
if (testProcess->exitCode() == 0) {
w.setPassExecutable(testProcess->readAllStandardOutput());
- w.show();
- return app.exec();
} else {
- QMessageBox msgBox;
- msgBox.setText("Please install pass from http://www.passwordstore.org/");
- msgBox.exec();
+ w.setPassExecutable("");
+ //QMessageBox msgBox;
+ //msgBox.setText("Please install pass from http://www.passwordstore.org/");
+ //msgBox.exec();
+ testProcess->start("which git");
+ testProcess->waitForFinished();
+ if (testProcess->exitCode() != 0) {
+ QMessageBox msgBox;
+ msgBox.setText("Please install git");
+ msgBox.exec();
+ return 1;
+ }
+ w.setGitExecutable(testProcess->readAllStandardOutput());
+ testProcess->start("which gpg2");
+ testProcess->waitForFinished();
+ if (testProcess->exitCode() != 0) {
+ testProcess->start("which gpg");
+ testProcess->waitForFinished();
+ if (testProcess->exitCode() != 0) {
+ QMessageBox msgBox;
+ msgBox.setText("Please install gpg");
+ msgBox.exec();
+ // return 1;
+ }
+ }
+ w.setGpgExecutable(testProcess->readAllStandardOutput());
}
+ w.show();
+ return app.exec();
}
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 75f96505..3b71b5f7 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -1,4 +1,4 @@
- #include "mainwindow.h"
+#include "mainwindow.h"
#include "ui_mainwindow.h"
/**
@@ -33,7 +33,11 @@ MainWindow::~MainWindow()
*/
void MainWindow::on_pushButton_clicked()
{
- executePass("git pull");
+ if (passExecutable == "") {
+ executeWrapper("git pull");
+ } else {
+ executePass("git pull");
+ }
}
/**
@@ -44,26 +48,31 @@ void MainWindow::on_treeView_clicked(const QModelIndex &index)
{
if (model.fileInfo(index).isFile()){
QString passFile = model.filePath(index);
- passFile.replace(".gpg", "");
- passFile.replace(passStore, "");
- executePass(passFile);
+ if (passExecutable == "") {
+ executeWrapper("gpg --no-tty -dq " + passFile);
+ } else {
+ passFile.replace(".gpg", "");
+ passFile.replace(passStore, "");
+ executePass(passFile);
+ }
}
}
/**
- * @brief MainWindow::setPassExecutable
- * @param path
+ * @brief MainWindow::executePass
+ * @param args
*/
-void MainWindow::setPassExecutable(QString path) {
- passExecutable = path;
+void MainWindow::executePass(QString args) {
+ executeWrapper("pass "+args);
}
/**
- * @brief MainWindow::executePass
+ * @brief MainWindow::executeWrapper
* @param args
*/
-void MainWindow::executePass(QString args) {
- process->start("bash", QStringList() << "-c" << "pass " + args);
+void MainWindow::executeWrapper(QString args) {
+ process->setWorkingDirectory(passStore);
+ process->start("bash", QStringList() << "-c" << args);
process->waitForFinished();
QString output = process->readAllStandardError();
if (output.size() > 0) {
@@ -74,3 +83,27 @@ void MainWindow::executePass(QString args) {
}
ui->textBrowser->setText(output);
}
+
+/**
+ * @brief MainWindow::setPassExecutable
+ * @param path
+ */
+void MainWindow::setPassExecutable(QString path) {
+ passExecutable = path;
+}
+
+/**
+ * @brief MainWindow::setGitExecutable
+ * @param path
+ */
+void MainWindow::setGitExecutable(QString path) {
+ gitExecutable = path;
+}
+
+/**
+ * @brief MainWindow::setGpgExecutable
+ * @param path
+ */
+void MainWindow::setGpgExecutable(QString path) {
+ gpgExecutable = path;
+}
diff --git a/mainwindow.h b/mainwindow.h
index bfae8edd..c0877be2 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -18,6 +18,8 @@ public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void setPassExecutable(QString);
+ void setGitExecutable(QString);
+ void setGpgExecutable(QString);
private slots:
void on_pushButton_clicked();
@@ -28,9 +30,12 @@ private:
QFileSystemModel model;
QString passStore;
QString passExecutable;
+ QString gitExecutable;
+ QString gpgExecutable;
QProcess *process;
void updateText();
void executePass(QString);
+ void executeWrapper(QString);
};
#endif // MAINWINDOW_H
diff --git a/qtpass.pro b/qtpass.pro
index 2e7c1b87..3a9834d3 100644
--- a/qtpass.pro
+++ b/qtpass.pro
@@ -11,7 +11,6 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qtpass
TEMPLATE = app
-
SOURCES += main.cpp\
mainwindow.cpp