|
|
|
@ -45,7 +45,7 @@ QImage QRImageWidget::exportImage()
@@ -45,7 +45,7 @@ QImage QRImageWidget::exportImage()
|
|
|
|
|
{ |
|
|
|
|
if(!pixmap()) |
|
|
|
|
return QImage(); |
|
|
|
|
return pixmap()->toImage().scaled(EXPORT_IMAGE_SIZE, EXPORT_IMAGE_SIZE); |
|
|
|
|
return pixmap()->toImage(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QRImageWidget::mousePressEvent(QMouseEvent *event) |
|
|
|
@ -166,20 +166,32 @@ void ReceiveRequestDialog::update()
@@ -166,20 +166,32 @@ void ReceiveRequestDialog::update()
|
|
|
|
|
ui->lblQRCode->setText(tr("Error encoding URI into QR Code.")); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
QImage myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32); |
|
|
|
|
myImage.fill(0xffffff); |
|
|
|
|
QImage qrImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32); |
|
|
|
|
qrImage.fill(0xffffff); |
|
|
|
|
unsigned char *p = code->data; |
|
|
|
|
for (int y = 0; y < code->width; y++) |
|
|
|
|
{ |
|
|
|
|
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++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|