mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Add address label to request payment QR Code (QT)
In the Receive 'Tab' of the QT wallet, when 'Show'ing a previously requested payment, add a label underneath the QR Code showing the bitcoin address where the funds will go to. This way the user can be sure that the QR code scanner app the user using is reading the correct bitcoin address, preventing funds to be stolen. Includes fix for HiDPI screens by @jonasschnelli.
This commit is contained in:
parent
44c1b1c9bb
commit
1c2a1bac0a
@ -22,7 +22,7 @@
|
|||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>300</width>
|
||||||
<height>300</height>
|
<height>320</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
@ -43,7 +43,7 @@ static const int TOOLTIP_WRAP_THRESHOLD = 80;
|
|||||||
static const int MAX_URI_LENGTH = 255;
|
static const int MAX_URI_LENGTH = 255;
|
||||||
|
|
||||||
/* QRCodeDialog -- size of exported QR Code image */
|
/* QRCodeDialog -- size of exported QR Code image */
|
||||||
#define EXPORT_IMAGE_SIZE 256
|
#define QR_IMAGE_SIZE 300
|
||||||
|
|
||||||
/* Number of frames in spinner animation */
|
/* Number of frames in spinner animation */
|
||||||
#define SPINNER_FRAMES 36
|
#define SPINNER_FRAMES 36
|
||||||
|
@ -45,7 +45,7 @@ QImage QRImageWidget::exportImage()
|
|||||||
{
|
{
|
||||||
if(!pixmap())
|
if(!pixmap())
|
||||||
return QImage();
|
return QImage();
|
||||||
return pixmap()->toImage().scaled(EXPORT_IMAGE_SIZE, EXPORT_IMAGE_SIZE);
|
return pixmap()->toImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QRImageWidget::mousePressEvent(QMouseEvent *event)
|
void QRImageWidget::mousePressEvent(QMouseEvent *event)
|
||||||
@ -166,20 +166,32 @@ void ReceiveRequestDialog::update()
|
|||||||
ui->lblQRCode->setText(tr("Error encoding URI into QR Code."));
|
ui->lblQRCode->setText(tr("Error encoding URI into QR Code."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QImage myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
|
QImage qrImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
|
||||||
myImage.fill(0xffffff);
|
qrImage.fill(0xffffff);
|
||||||
unsigned char *p = code->data;
|
unsigned char *p = code->data;
|
||||||
for (int y = 0; y < code->width; y++)
|
for (int y = 0; y < code->width; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < code->width; x++)
|
for (int x = 0; x < code->width; x++)
|
||||||
{
|
{
|
||||||
myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
|
qrImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QRcode_free(code);
|
QRcode_free(code);
|
||||||
|
|
||||||
ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300));
|
QImage qrAddrImage = QImage(QR_IMAGE_SIZE, QR_IMAGE_SIZE+20, QImage::Format_RGB32);
|
||||||
|
qrAddrImage.fill(0xffffff);
|
||||||
|
QPainter painter(&qrAddrImage);
|
||||||
|
painter.drawImage(0, 0, qrImage.scaled(QR_IMAGE_SIZE, QR_IMAGE_SIZE));
|
||||||
|
QFont font = GUIUtil::fixedPitchFont();
|
||||||
|
font.setPixelSize(12);
|
||||||
|
painter.setFont(font);
|
||||||
|
QRect paddedRect = qrAddrImage.rect();
|
||||||
|
paddedRect.setHeight(QR_IMAGE_SIZE+12);
|
||||||
|
painter.drawText(paddedRect, Qt::AlignBottom|Qt::AlignCenter, info.address);
|
||||||
|
painter.end();
|
||||||
|
|
||||||
|
ui->lblQRCode->setPixmap(QPixmap::fromImage(qrAddrImage));
|
||||||
ui->btnSaveAs->setEnabled(true);
|
ui->btnSaveAs->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
class OptionsModel;
|
class OptionsModel;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user