diff options
author | Frank Gabriel <frank.gabriel@kryptolyse.org> | 2018-09-28 13:17:28 +0200 |
---|---|---|
committer | Frank Gabriel <frank.gabriel@kryptolyse.org> | 2018-09-28 13:17:28 +0200 |
commit | c6ae420c17725f0ecd3a91c48e59e8cb30561cc1 (patch) | |
tree | 8889d7aad1f6248e2cd65b8e36c870d96f5743dd /src/qtpass.cpp | |
parent | 2ed533a994110c1926f3498b789a692023a1ef44 (diff) |
Prototype for QR encoding fields
Diffstat (limited to 'src/qtpass.cpp')
-rw-r--r-- | src/qtpass.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/qtpass.cpp b/src/qtpass.cpp index 2239e86d..299b7469 100644 --- a/src/qtpass.cpp +++ b/src/qtpass.cpp @@ -3,6 +3,8 @@ #include "qtpasssettings.h" #include <QApplication> #include <QClipboard> +#include <QPixmap> +#include <QLabel> #ifndef Q_OS_WIN #include <QInputDialog> @@ -402,3 +404,29 @@ void QtPass::copyTextToClipboard(const QString &text) { clearClipboardTimer.start(); } } + +/** + * @brief displays the text as qrcode + * @param text + */ +void QtPass::showTextAsQRCode(const QString &text) { + QProcess qrencode; + qrencode.start("/usr/bin/qrencode", QStringList() << "-o-" << "-tPNG"); + qrencode.write(text.toUtf8()); + qrencode.closeWriteChannel(); + qrencode.waitForFinished(); + QByteArray output(qrencode.readAllStandardOutput()); + + if (qrencode.exitStatus() || qrencode.exitCode()) { + QString error(qrencode.readAllStandardError()); + m_mainWindow->showStatusMessage(error); + } else { + QPixmap image; + image.loadFromData(output, "PNG"); + + QLabel *label = new QLabel(); + label->setPixmap(image); + label->setScaledContents(true); + label->show(); + } +} |