Browse Source

QR code and memo tweaks

pull/112/head
fekt 2 years ago
parent
commit
c3c7f5161a
  1. 1
      silentdragon.pro
  2. 68
      src/mainwindow.cpp
  3. 1
      src/mainwindow.h
  4. 71
      src/qrcode.ui
  5. 2
      src/qrcodelabel.cpp

1
silentdragon.pro

@ -95,6 +95,7 @@ HEADERS += \
FORMS += \
src/mainwindow.ui \
src/qrcode.ui \
src/rescandialog.ui \
src/settings.ui \
src/about.ui \

68
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<bool>(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();
}
}
});
}

1
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();

71
src/qrcode.ui

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QRCode</class>
<widget class="QDialog" name="QRCode">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>320</height>
</rect>
</property>
<property name="windowTitle">
<string>QR Code</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="0" column="0">
<widget class="QRCodeLabel" name="qrcodeDisplayAddr">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QRCodeLabel</class>
<extends>QLabel</extends>
<header>qrcodelabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

2
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;

Loading…
Cancel
Save