diff --git a/silentdragon.pro b/silentdragon.pro index 0ccc417..1df3eaf 100644 --- a/silentdragon.pro +++ b/silentdragon.pro @@ -95,6 +95,7 @@ HEADERS += \ FORMS += \ src/mainwindow.ui \ + src/qrcode.ui \ src/rescandialog.ui \ src/settings.ui \ src/about.ui \ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 810e9b4..74806c4 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -8,6 +8,7 @@ #include "ui_mobileappconnector.h" #include "ui_addressbook.h" #include "ui_privkey.h" +#include "ui_qrcode.h" #include "ui_viewkey.h" #include "ui_about.h" #include "ui_settings.h" @@ -1139,6 +1140,20 @@ void MainWindow::getViewKey(QString addr) { *isDialogAlive = false; } +void MainWindow::getQRCode(QString addr) { + QDialog d(this); + Ui_QRCode qrui; + qrui.setupUi(&d); + + // Display QR Code for address + qrui.qrcodeDisplayAddr->setQrcodeString(addr); + + auto isDialogAlive = std::make_shared(true); + + d.exec(); + *isDialogAlive = false; +} + void MainWindow::exportKeys(QString addr) { bool allKeys = addr.isEmpty() ? true : false; @@ -1343,6 +1358,11 @@ void MainWindow::setupBalancesTab() { menu.addAction(tr("Get viewing key"), [=] () { this->getViewKey(addr); }); + + // QR Code for zaddrs only + menu.addAction(tr("Get QR code"), [=] () { + this->getQRCode(addr); + }); } menu.addAction("Send from " % addr.left(40) % (addr.size() > 40 ? "..." : ""), [=]() { @@ -1643,6 +1663,7 @@ void MainWindow::setupTransactionsTab() { QMessageBox mb; mb.setText(memo); mb.setWindowTitle(tr("Memo")); + mb.setIcon(QMessageBox::Information); QAbstractButton* buttonMemoReply = mb.addButton(tr("Reply"), QMessageBox::YesRole); mb.addButton(tr("OK"), QMessageBox::NoRole); @@ -1756,10 +1777,57 @@ void MainWindow::setupTransactionsTab() { // View Memo if (!memo.isEmpty()) { menu.addAction(tr("View Memo"), [=] () { + /* QMessageBox mb(QMessageBox::Information, tr("Memo"), memo, QMessageBox::Ok, this); + mb.setTextFormat(Qt::PlainText); + mb.setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); + mb.exec();*/ + QMessageBox mb; + mb.setText(memo); + mb.setWindowTitle(tr("Memo")); + mb.setIcon(QMessageBox::Information); + + QAbstractButton* buttonMemoReply = mb.addButton(tr("Reply"), QMessageBox::YesRole); mb.addButton(tr("OK"), QMessageBox::NoRole); + mb.setTextFormat(Qt::PlainText); mb.setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); mb.exec(); + + if (mb.clickedButton()==buttonMemoReply) { + qDebug() << "Reply clicked"; + + int lastPost = memo.trimmed().lastIndexOf(QRegExp("[\r\n]+")); + QString lastWord = memo.right(memo.length() - lastPost - 1); + + if (Settings::getInstance()->isSaplingAddress(lastWord)) { + + // First, cancel any pending stuff in the send tab by pretending to click + // the cancel button + cancelButton(); + + // Then set up the fields in the send tab + ui->Address1->setText(lastWord); + ui->Address1->setCursorPosition(0); + ui->Amount1->setText("0.0001"); + + // And switch to the send tab. + ui->tabWidget->setCurrentIndex(1); + + qApp->processEvents(); + + // Click the memo button + this->memoButtonClicked(1, true); + }else{ + // TODO: This memo has no reply to address. Show alert or don't show button to begin with. + QMessageBox mb; + mb.setText(tr("Sorry! This memo has no reply to address.")); + mb.setWindowTitle(tr("Error")); + + mb.setTextFormat(Qt::PlainText); + mb.setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); + mb.exec(); + } + } }); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 78442e7..7841d85 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -140,6 +140,7 @@ private: void exportAllKeys(); void exportKeys(QString addr = ""); void getViewKey(QString addr = ""); + void getQRCode(QString addr = ""); void backupWalletDat(); void exportTransactions(); diff --git a/src/qrcode.ui b/src/qrcode.ui new file mode 100644 index 0000000..81f7eaf --- /dev/null +++ b/src/qrcode.ui @@ -0,0 +1,71 @@ + + + QRCode + + + + 0 + 0 + 320 + 320 + + + + QR Code + + + + QLayout::SetFixedSize + + + + + + 0 + 0 + + + + + 300 + 300 + + + + + 0 + 0 + + + + + 0 + 0 + + + + false + + + + + + + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + + QRCodeLabel + QLabel +
qrcodelabel.h
+
+
+ + +
diff --git a/src/qrcodelabel.cpp b/src/qrcodelabel.cpp index bc5fa72..e52afc5 100644 --- a/src/qrcodelabel.cpp +++ b/src/qrcodelabel.cpp @@ -51,7 +51,7 @@ QPixmap QRCodeLabel::scaledPixmap() const { } // TODO: Maybe add logo if it doesn't break QR code - requires setting Ecc to HIGH - painter.drawPixmap(65, 65, 100, 100, QPixmap(":/img/res/logobig.gif")); + painter.drawPixmap((w/2)-50, (h/2)-50, 100, 100, QPixmap(":/img/res/logobig.gif")); painter.end(); return pm;