7 #include "ui_receiverequestdialog.h" 19 #include <QMouseEvent> 21 #if QT_VERSION < 0x050000 25 #if defined(HAVE_CONFIG_H) 34 QLabel(parent), contextMenu(0)
37 QAction *saveImageAction =
new QAction(tr(
"&Save Image..."),
this);
38 connect(saveImageAction, SIGNAL(triggered()),
this, SLOT(
saveImage()));
40 QAction *copyImageAction =
new QAction(tr(
"&Copy Image"),
this);
41 connect(copyImageAction, SIGNAL(triggered()),
this, SLOT(
copyImage()));
49 return pixmap()->toImage();
54 if(event->button() == Qt::LeftButton && pixmap())
57 QMimeData *mimeData =
new QMimeData;
60 QDrag *drag =
new QDrag(
this);
61 drag->setMimeData(mimeData);
64 QLabel::mousePressEvent(event);
101 ui->btnSaveAs->setVisible(
false);
102 ui->lblQRCode->setVisible(
false);
105 connect(
ui->btnSaveAs, SIGNAL(clicked()),
ui->lblQRCode, SLOT(saveImage()));
121 this->
model = _model;
124 connect(_model, SIGNAL(displayUnitChanged(
int)),
this, SLOT(
update()));
143 setWindowTitle(tr(
"Request payment to %1").arg(target));
146 ui->btnSaveAs->setEnabled(
false);
148 html +=
"<html><font face='verdana, arial, helvetica, sans-serif'>";
149 html +=
"<b>"+tr(
"Payment information")+
"</b><br>";
150 html +=
"<b>"+tr(
"URI")+
"</b>: ";
159 ui->outUri->setText(html);
162 ui->lblQRCode->setText(
"");
166 if (uri.length() > MAX_URI_LENGTH)
168 ui->lblQRCode->setText(tr(
"Resulting URI too long, try to reduce the text for label / message."));
170 QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1);
173 ui->lblQRCode->setText(tr(
"Error encoding URI into QR Code."));
176 QImage qrImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
177 qrImage.fill(0xffffff);
178 unsigned char *p = code->data;
179 for (
int y = 0; y < code->width; y++)
181 for (
int x = 0; x < code->width; x++)
183 qrImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
190 qrAddrImage.fill(0xffffff);
191 QPainter painter(&qrAddrImage);
194 font.setPixelSize(12);
195 painter.setFont(font);
196 QRect paddedRect = qrAddrImage.rect();
198 painter.drawText(paddedRect, Qt::AlignBottom|Qt::AlignCenter,
info.
address);
201 ui->lblQRCode->setPixmap(QPixmap::fromImage(qrAddrImage));
202 ui->btnSaveAs->setEnabled(
true);
Ui::ReceiveRequestDialog * ui
QString HtmlEscape(const QString &str, bool fMultiLine)
int getDisplayUnit() const
ReceiveRequestDialog(QWidget *parent=0)
void on_btnCopyAddress_clicked()
void setClipboard(const QString &str)
void setInfo(const SendCoinsRecipient &info)
QString formatRavenURI(const SendCoinsRecipient &info)
Interface from Qt to configuration data structure for Raven client.
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut)
Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix when ...
static QString formatHtmlWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as HTML string (with unit)
void setModel(OptionsModel *model)
void on_btnCopyURI_clicked()