diff options
author | Anne Jan Brouwer <brouwer@annejan.com> | 2014-07-31 15:56:59 +0200 |
---|---|---|
committer | Anne Jan Brouwer <ajbrouwer@totalactivemedia.nl> | 2014-07-31 15:56:59 +0200 |
commit | 86a6b3ba28919e13ecaa4ff67a602542035a9058 (patch) | |
tree | 5d202c64821ae789025ce15b9ec984cf3b8f85f7 | |
parent | 2aba44d04c76984f8c96a7c4cff36722f0e5ff76 (diff) |
pass less pass
-rw-r--r-- | main.cpp | 33 | ||||
-rw-r--r-- | mainwindow.cpp | 57 | ||||
-rw-r--r-- | mainwindow.h | 5 | ||||
-rw-r--r-- | qtpass.pro | 1 |
4 files changed, 78 insertions, 18 deletions
@@ -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 @@ -11,7 +11,6 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = qtpass TEMPLATE = app - SOURCES += main.cpp\ mainwindow.cpp |