diff options
-rw-r--r-- | src/qt/forms/qrcodedialog.ui | 3 | ||||
-rw-r--r-- | src/qt/qrcodedialog.cpp | 28 |
2 files changed, 22 insertions, 9 deletions
diff --git a/src/qt/forms/qrcodedialog.ui b/src/qt/forms/qrcodedialog.ui index fa21f60b9e..fa960069d9 100644 --- a/src/qt/forms/qrcodedialog.ui +++ b/src/qt/forms/qrcodedialog.ui @@ -34,6 +34,9 @@ <property name="alignment"> <set>Qt::AlignCenter</set> </property> + <property name="wordWrap"> + <bool>true</bool> + </property> </widget> </item> <item> diff --git a/src/qt/qrcodedialog.cpp b/src/qt/qrcodedialog.cpp index 82959831de..9cf50b0e58 100644 --- a/src/qt/qrcodedialog.cpp +++ b/src/qt/qrcodedialog.cpp @@ -39,17 +39,27 @@ void QRCodeDialog::genCode() QString uri = getURI(); //qDebug() << "Encoding:" << uri.toUtf8().constData(); QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1); - myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32); - myImage.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)); - p++; + if (code) + { + ui->lblQRCode->setText(""); + + QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1); + myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32); + myImage.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)); + p++; + } } + QRcode_free(code); + ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300)); } - QRcode_free(code); - ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300)); + else + ui->lblQRCode->setText(tr("Error encoding URI into QR Code; try to reduce the text for label / message.")); } QString QRCodeDialog::getURI() |