6 #include "ui_receiverequestdialog.h"
18 #include <QMouseEvent>
23 #if defined(HAVE_CONFIG_H)
35 QAction* saveImageAction =
new QAction(tr(
"&Save Image..."),
this);
36 connect(saveImageAction, SIGNAL(triggered()),
this, SLOT(
saveImage()));
38 QAction* copyImageAction =
new QAction(tr(
"&Copy Image"),
this);
39 connect(copyImageAction, SIGNAL(triggered()),
this, SLOT(
copyImage()));
52 if (event->button() == Qt::LeftButton && pixmap()) {
54 QMimeData* mimeData =
new QMimeData;
57 QDrag* drag =
new QDrag(
this);
58 drag->setMimeData(mimeData);
61 QLabel::mousePressEvent(event);
96 ui->btnSaveAs->setVisible(
false);
97 ui->lblQRCode->setVisible(
false);
100 connect(
ui->btnSaveAs, SIGNAL(clicked()),
ui->lblQRCode, SLOT(saveImage()));
113 connect(
model, SIGNAL(displayUnitChanged(
int)),
this, SLOT(
update()));
130 if (target.isEmpty())
132 setWindowTitle(tr(
"Request payment to %1").arg(target));
135 ui->btnSaveAs->setEnabled(
false);
137 html +=
"<html><font face='verdana, arial, helvetica, sans-serif'>";
138 html +=
"<b>" + tr(
"Payment information") +
"</b><br>";
139 html +=
"<b>" + tr(
"URI") +
"</b>: ";
140 html +=
"<a style=\"color:#5B4C7C;\" href=\"" + uri +
"\">" +
GUIUtil::HtmlEscape(uri) +
"</a><br>";
148 ui->outUri->setText(html);
151 ui->lblQRCode->setText(
"");
152 if (!uri.isEmpty()) {
154 if (uri.length() > MAX_URI_LENGTH) {
155 ui->lblQRCode->setText(tr(
"Resulting URI too long, try to reduce the text for label / message."));
157 QRcode* code = QRcode_encodeString(
info.
address.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1);
159 ui->lblQRCode->setText(tr(
"Error encoding URI into QR Code."));
162 QImage myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
163 myImage.fill(0xffffff);
164 unsigned char* p = code->data;
165 for (
int y = 0; y < code->width; y++) {
166 for (
int x = 0; x < code->width; x++) {
167 myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
173 ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300));
174 ui->btnSaveAs->setEnabled(
true);