summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2015-04-04 16:43:27 +0200
committerAnne Jan Brouwer <brouwer@annejan.com>2015-04-04 16:43:27 +0200
commitd7233142cef390f75f17a77c5d554c20b4f42eb5 (patch)
tree570d128925098f4018adea1614df9acf433091f2
parent2dd722a6bd5006b80cc1a0fab0aadae64c06bcfd (diff)
parentcfce9cf8bfcbba4ef558fec01b2767a421710ddd (diff)
merged manually
-rw-r--r--mainwindow.cpp68
1 files changed, 38 insertions, 30 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp
index fbd3947a..44003833 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -271,39 +271,38 @@ void MainWindow::executeWrapper(QString app, QString args, QString input) {
* @brief MainWindow::readyRead
*/
void MainWindow::readyRead(bool finished = false) {
- QString output = ui->textBrowser->document()->toPlainText();
- QString error = process->readAllStandardError();
- if (error.size() > 0) {
- ui->textBrowser->setTextColor(Qt::red);
- output += error;
- } else {
- output += process->readAllStandardOutput();
- if (finished && currentAction == GPG) {
- lastDecrypt = output;
- if (useClipboard) {
- QClipboard *clip = QApplication::clipboard();
- QStringList tokens = output.split("\n");
- clip->setText(tokens[0]);
- ui->statusBar->showMessage(tr("Password copied to clipboard"), 3000);
- if (useAutoclear) {
- clippedPass = tokens[0];
- QTimer::singleShot(1000*autoclearSeconds, this, SLOT(clearClipboard()));
- }
- if (hidePassword) {
- tokens.pop_front();
- output = tokens.join("\n");
- }
- if (hideContent) {
- output = tr("Content hidden");
- }
+ QString output = process->readAllStandardOutput();
+ if (finished && currentAction == GPG) {
+ lastDecrypt = output;
+ if (useClipboard) {
+ QClipboard *clip = QApplication::clipboard();
+ QStringList tokens = output.split("\n");
+ clip->setText(tokens[0]);
+ ui->statusBar->showMessage(tr("Password copied to clipboard"), 3000);
+ if (useAutoclear) {
+ clippedPass = tokens[0];
+ QTimer::singleShot(1000*autoclearSeconds, this, SLOT(clearClipboard()));
+ }
+ if (hidePassword) {
+ tokens.pop_front();
+ output = tokens.join("\n");
+ }
+ if (hideContent) {
+ output = tr("Content hidden");
}
}
}
output.replace(QRegExp("<"), "&lt;");
output.replace(QRegExp(">"), "&gt;");
+
+ QString error = process->readAllStandardError();
+ if (error.size() > 0) {
+ output = "<font color=\"red\">" + error + "</font><br />" + output;
+ }
+
output.replace(QRegExp("((http|https|ftp)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\\'/\\\\+&amp;%\\$#\\=~])*)"), "<a href=\"\\1\">\\1</a>");
output.replace(QRegExp("\n"), "<br />");
- ui->textBrowser->setHtml(output);
+ ui->textBrowser->setHtml(ui->textBrowser->toHtml() + output);
}
/**
@@ -519,14 +518,21 @@ void MainWindow::setPassword(QString file, bool overwrite)
tr("Password store lacks .gpg-id specifying encryption key"));
return;
}
- QString recipient(gpgId.readAll());
- if (recipient.isEmpty()) {
+ QString recipients;
+ while (!gpgId.atEnd()) {
+ QString recipient(gpgId.readLine());
+ recipient = recipient.trimmed();
+ if (!recipient.isEmpty()) {
+ recipients += " -r \"" + recipient + '"';
+ }
+ }
+ if (recipients.isEmpty()) {
QMessageBox::critical(this, tr("Can not edit"),
tr("Could not read encryption key to use"));
return;
}
QString force(overwrite ? " --yes " : " ");
- executeWrapper(gpgExecutable , force + "--batch -eq --output \"" + file + "\" -r " + recipient + " -", newValue);
+ executeWrapper(gpgExecutable , force + "--batch -eq --output \"" + file + "\" " + recipients + " -", newValue);
}
}
@@ -540,7 +546,9 @@ void MainWindow::on_addButton_clicked()
return;
}
file = getDir(ui->treeView->currentIndex(), usePass) + file;
- file += ".gpg";
+ if (!usePass) {
+ file += ".gpg";
+ }
lastDecrypt = "";
setPassword(file, false);
executeWrapper(gitExecutable, "add " + file);