diff options
author | Anne Jan Brouwer <annejan@noprotocol.com> | 2015-05-05 23:05:13 +0200 |
---|---|---|
committer | Anne Jan Brouwer <annejan@noprotocol.com> | 2015-05-05 23:05:13 +0200 |
commit | 93a0d6745de473a9ccd5cf65f0e2e5cd7763b36c (patch) | |
tree | 2e977acc8256d6b54574ddab1d435295805a0a4b | |
parent | c8b5ce5cdcb8c01d6177792dd577f5b26d210977 (diff) |
cleanup of mac PATH stuff & enabling/disabling of pushButton
-rw-r--r-- | mainwindow.cpp | 30 | ||||
-rw-r--r-- | mainwindow.h | 1 | ||||
-rw-r--r-- | util.cpp | 10 |
3 files changed, 29 insertions, 12 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp index 7b1d9733..6364fc0e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -195,6 +195,24 @@ void MainWindow::checkConfig() { ui->textBrowser->setOpenExternalLinks(true); + env = QProcess::systemEnvironment(); + if (!gpgHome.isEmpty()) { + QDir absHome(gpgHome); + absHome.makeAbsolute(); + env << "GNUPGHOME=" + absHome.path(); + } +#ifdef __APPLE__ + // If it exists, add the gpgtools to PATH + if (QFile("/usr/local/MacGPG2/bin").exists()) { + env.replaceInStrings("PATH=", "PATH=/usr/local/MacGPG2/bin:"); + } + // Add missing /usr/local/bin + if (env.filter("/usr/local/bin").isEmpty()) { + env.replaceInStrings("PATH=", "PATH=/usr/local/bin:"); + } +#endif + //QMessageBox::information(this, "env", env.join("\n")); + ui->lineEdit->setFocus(); } @@ -348,17 +366,6 @@ void MainWindow::executeWrapper(QString app, QString args, QString input) { } wrapperRunning = true; process->setWorkingDirectory(passStore); - QStringList env = QProcess::systemEnvironment(); - if (!gpgHome.isEmpty()) { - QDir absHome(gpgHome); - absHome.makeAbsolute(); - env << "GNUPGHOME=" + absHome.path(); - } -#ifdef __APPLE__ - // TODO needs check to see if path exists or some other handling!! - env.replaceInStrings("PATH=", "PATH=/usr/local/MacGPG2/bin:/usr/local/bin:"); -#endif - //QMessageBox::information(this, "env", env.join("\n")); process->setEnvironment(env); ui->textBrowser->clear(); ui->textBrowser->setTextColor(Qt::black); @@ -462,6 +469,7 @@ void MainWindow::enableUiElements(bool state) { state &= ui->treeView->currentIndex().isValid(); ui->deleteButton->setEnabled(state); ui->editButton->setEnabled(state); + ui->pushButton->setEnabled(state); } /** diff --git a/mainwindow.h b/mainwindow.h index 8cd092a4..95d3f2b3 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -86,6 +86,7 @@ private: actionType currentAction; QString lastDecrypt; bool wrapperRunning; + QStringList env; QQueue<execQueueItem> *execQueue; void updateText(); void executePass(QString, QString = QString()); @@ -14,7 +14,15 @@ void Util::initialiseEnvironment() _env = QProcessEnvironment::systemEnvironment(); #ifdef __APPLE__ // TODO checks here - _env.insert("PATH", _env.value("PATH") + ":/usr/local/bin:/usr/local/MacGPG2/bin"); + QString path = _env.value("PATH"); + + if (!path.contains("/usr/local/MacGPG2/bin") && QFile("/usr/local/MacGPG2/bin").exists()) { + path += ":/usr/local/MacGPG2/bin"; + } + if (!path.contains("/usr/local/bin")) { + path += ":/usr/local/bin"; + } + _env.insert("PATH", path); #endif _envInitialised = true; } |