summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2015-05-06 06:00:56 +0200
committerAnne Jan Brouwer <brouwer@annejan.com>2015-05-06 06:00:56 +0200
commit0d694a53fa8696322cb82ebe3c2998028c7809d0 (patch)
tree341a9e520910abe3dfafd05104cc910ef3a027b0
parent522a0bd62f447be28c2c28168f242b1fc3095c6e (diff)
parent78c848b22f7031167fa3f5eb8117996b03fcf09d (diff)
Merge pull request #44 from IJHack/develop
SingleApplication per user and leading newline removed from output
-rw-r--r--README.md4
-rw-r--r--main.cpp29
-rw-r--r--mainwindow.cpp62
-rw-r--r--mainwindow.h1
4 files changed, 56 insertions, 40 deletions
diff --git a/README.md b/README.md
index 761fc15d..3888978c 100644
--- a/README.md
+++ b/README.md
@@ -54,8 +54,10 @@ On most systems all you need is:
On MacOsX:
`qmake && make && macdeployqt QtPass.app -dmg`
+* Currently seems to only work with MacGPG2
-Currently seems to only work with MacGPG2
+On some systems there are issues with qt4 and qt5 being installed at the same time.
+An easy fix is regenerating the Makefile with: `make clean && rm Makefile && qmake -qt5` or if qmake is ambiguous: `qmake-qt5`
Further reading
---------------
diff --git a/main.cpp b/main.cpp
index 9a23a72d..d9b7336e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -4,27 +4,27 @@
int main(int argc, char *argv[])
{
+ QString text = "";
+ for (int i = 1; i < argc; ++i) {
+ if (i > 1) {
+ text += " ";
+ }
+ text += argv[i];
+ }
#if SINGLE_APP
- SingleApplication app(argc, argv, "ijhackQtPass");
+ QString name = qgetenv("USER");
+ if (name.isEmpty())
+ name = qgetenv("USERNAME");
+ //qDebug() << name;
+ SingleApplication app(argc, argv, name + "QtPass");
if (app.isRunning()) {
- if (argc == 1 ) {
- app.sendMessage("show");
- } else if (argc >= 2) {
- QString text = "";
- for (int i = 1; i < argc; ++i) {
- text += argv[i];
- if (argc >= (i - 2)) {
- text += " ";
- }
- app.sendMessage(text);
- }
- }
+ app.sendMessage(text);
return 0;
}
#else
QApplication app(argc, argv);
#endif
-
+
QCoreApplication::setOrganizationName("IJHack");
QCoreApplication::setOrganizationDomain("ijhack.org");
QCoreApplication::setApplicationName("QtPass");
@@ -42,6 +42,7 @@ int main(int argc, char *argv[])
app.setWindowIcon(QIcon(":artwork/icon.png"));
w.setApp(&app);
w.checkConfig();
+ w.setText(text);
w.show();
return app.exec();
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 6364fc0e..fef19b6e 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -381,31 +381,31 @@ void MainWindow::executeWrapper(QString app, QString args, QString input) {
* @brief MainWindow::readyRead
*/
void MainWindow::readyRead(bool finished = false) {
- QString output;
+ QString output = "";
if (currentAction != GPG_INTERNAL) {
- 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 = 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 = "<font color=\"blue\">" + tr("Content hidden") + "</font><br />";
+ }
}
}
- }
- output.replace(QRegExp("<"), "&lt;");
- output.replace(QRegExp(">"), "&gt;");
+ output.replace(QRegExp("<"), "&lt;");
+ output.replace(QRegExp(">"), "&gt;");
}
QString error = process->readAllStandardError();
@@ -414,8 +414,11 @@ void MainWindow::readyRead(bool finished = false) {
}
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(ui->textBrowser->toHtml() + output);
+ output.replace(QRegExp("\n )"), "<br />");
+ if (ui->textBrowser->toPlainText() != "") {
+ output = ui->textBrowser->toHtml() + output;
+ }
+ ui->textBrowser->setHtml(output);
}
/**
@@ -853,7 +856,7 @@ void MainWindow::setApp(SingleApplication *app)
*/
void MainWindow::messageAvailable(QString message)
{
- if (message == "show") {
+ if (message == "") {
ui->lineEdit->selectAll();
ui->lineEdit->setFocus();
} else {
@@ -864,3 +867,12 @@ void MainWindow::messageAvailable(QString message)
show();
raise();
}
+
+/**
+ * @brief MainWindow::setText
+ * @param message
+ */
+void MainWindow::setText(QString text)
+{
+ ui->lineEdit->setText(text);
+}
diff --git a/mainwindow.h b/mainwindow.h
index 95d3f2b3..9d247311 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -39,6 +39,7 @@ public:
void setGpgExecutable(QString);
void checkConfig();
void setApp(SingleApplication* app);
+ void setText(QString);
private slots:
void on_updateButton_clicked();