Browse Source

QR code changes

onryo
fekt 1 year ago
parent
commit
370cb7623b
  1. 38
      application.qrc
  2. 46
      src/mainwindow.ui
  3. 16
      src/qrcodelabel.cpp

38
application.qrc

@ -45,7 +45,6 @@
<file>res/money-mouth.png</file> <file>res/money-mouth.png</file>
<file>res/money-outgoing.png</file> <file>res/money-outgoing.png</file>
<file>res/hush-money-white.png</file> <file>res/hush-money-white.png</file>
</qresource> </qresource>
<qresource prefix="/img"> <qresource prefix="/img">
<file>res/hushdlogo.png</file> <file>res/hushdlogo.png</file>
@ -56,26 +55,27 @@
<file>res/silentdragonlite-animated-startup-dark.gif</file> <file>res/silentdragonlite-animated-startup-dark.gif</file>
<file>res/loaderblack.gif</file> <file>res/loaderblack.gif</file>
<file>res/loaderwhite.gif</file> <file>res/loaderwhite.gif</file>
<file>res/logobig.gif</file>
</qresource> </qresource>
<qresource prefix="/emoji"> <qresource prefix="/emoji">
<file>res/emoji/emoji1.png</file> <file>res/emoji/emoji1.png</file>
<file>res/emoji/laughing.png</file> <file>res/emoji/laughing.png</file>
<file>res/emoji/money-mouth.png</file> <file>res/emoji/money-mouth.png</file>
<file>res/emoji/joy.png</file> <file>res/emoji/joy.png</file>
<file>res/emoji/innocent.png</file> <file>res/emoji/innocent.png</file>
<file>res/emoji/partying_face.png</file> <file>res/emoji/partying_face.png</file>
<file>res/emoji/face_with_3hearts.png</file> <file>res/emoji/face_with_3hearts.png</file>
<file>res/emoji/face-with-rolling-eyes.png</file> <file>res/emoji/face-with-rolling-eyes.png</file>
<file>res/emoji/face-with-tongue.png</file> <file>res/emoji/face-with-tongue.png</file>
<file>res/emoji/heart_shaped_eyes.png</file> <file>res/emoji/heart_shaped_eyes.png</file>
<file>res/emoji/nauseated-face.png</file> <file>res/emoji/nauseated-face.png</file>
<file>res/emoji/pile-of-poo.png</file> <file>res/emoji/pile-of-poo.png</file>
<file>res/emoji/serious-face-with-symbols-covering-mouth.png</file> <file>res/emoji/serious-face-with-symbols-covering-mouth.png</file>
<file>res/emoji/smiling-face-with-sunglasses.png</file> <file>res/emoji/smiling-face-with-sunglasses.png</file>
<file>res/emoji/stuck-out.png</file> <file>res/emoji/stuck-out.png</file>
<file>res/emoji/sweet_smile.png</file> <file>res/emoji/sweet_smile.png</file>
<file>res/emoji/hush-money-white.png</file> <file>res/emoji/hush-money-white.png</file>
<file>res/emoji/SD.png</file> <file>res/emoji/SD.png</file>
</qresource> </qresource>
<qresource prefix="/translations"> <qresource prefix="/translations">
<file>res/silentdragonlite_ar.qm</file> <file>res/silentdragonlite_ar.qm</file>

46
src/mainwindow.ui

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1308</width> <width>1379</width>
<height>779</height> <height>781</height>
</rect> </rect>
</property> </property>
<property name="palette"> <property name="palette">
@ -93,7 +93,6 @@
<widget class="QLabel" name="contactNameMemo"> <widget class="QLabel" name="contactNameMemo">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -711,7 +710,6 @@
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -724,7 +722,6 @@
<widget class="QLabel" name="balTotal"> <widget class="QLabel" name="balTotal">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -883,7 +880,6 @@
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="font"> <property name="font">
<font> <font>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -956,8 +952,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1268</width> <width>1301</width>
<height>519</height> <height>493</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="sendToLayout"> <layout class="QVBoxLayout" name="sendToLayout">
@ -1311,6 +1307,9 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_11"> <layout class="QHBoxLayout" name="horizontalLayout_11">
<property name="topMargin">
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_10"> <layout class="QVBoxLayout" name="verticalLayout_10">
<item> <item>
@ -1427,16 +1426,37 @@
</item> </item>
</layout> </layout>
</item> </item>
<item> <item alignment="Qt::AlignTop">
<widget class="QRCodeLabel" name="qrcodeDisplay"> <widget class="QRCodeLabel" name="qrcodeDisplay">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>228</width>
<height>228</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: #fff</string> <string notr="true"/>
</property> </property>
<property name="text"> <property name="text">
<string/> <string/>
@ -1909,8 +1929,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1308</width> <width>1379</width>
<height>30</height> <height>24</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

16
src/qrcodelabel.cpp

@ -12,7 +12,7 @@ QRCodeLabel::QRCodeLabel(QWidget *parent) :
QSize QRCodeLabel::sizeHint() const QSize QRCodeLabel::sizeHint() const
{ {
int w = this->width(); int w = this->width();
return QSize(w, w); // 1:1 return QSize(w, w); // 1:1
} }
void QRCodeLabel::resizeEvent(QResizeEvent*) void QRCodeLabel::resizeEvent(QResizeEvent*)
@ -25,8 +25,8 @@ QPixmap QRCodeLabel::scaledPixmap() const {
QPixmap pm(size()); QPixmap pm(size());
pm.fill(Qt::white); pm.fill(Qt::white);
QPainter painter(&pm); QPainter painter(&pm);
qrcodegen::QrCode qr = qrcodegen::QrCode::encodeText(str.toUtf8().constData(), qrcodegen::QrCode::Ecc::LOW); qrcodegen::QrCode qr = qrcodegen::QrCode::encodeText(str.toUtf8().constData(), qrcodegen::QrCode::Ecc::HIGH);
const int s = qr.getSize()>0?qr.getSize():1; const int s = qr.getSize()>0?qr.getSize():1;
const double w = pm.width(); const double w = pm.width();
const double h = pm.height(); const double h = pm.height();
@ -35,8 +35,8 @@ QPixmap QRCodeLabel::scaledPixmap() const {
const double scale = size/(s+2); const double scale = size/(s+2);
const double woff = (w - size) > 0 ? (w - size) / 2 : 0; const double woff = (w - size) > 0 ? (w - size) / 2 : 0;
const double hoff = (h - size) > 0 ? (h - size) / 2 : 0; const double hoff = (h - size) > 0 ? (h - size) / 2 : 0;
// NOTE: For performance reasons my implementation only draws the foreground parts // NOTE: For performance reasons my implementation only draws the foreground parts
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.setBrush(QColor(Qt::black)); painter.setBrush(QColor(Qt::black));
for(int y=0; y<s; y++) { for(int y=0; y<s; y++) {
@ -49,7 +49,11 @@ QPixmap QRCodeLabel::scaledPixmap() const {
} }
} }
} }
// TODO: Maybe add logo if it doesn't break QR code - requires setting Ecc to HIGH
painter.drawPixmap((w/2)-50, (h/2)-50, 100, 100, QPixmap(":/img/logobig.gif"));
painter.end();
return pm; return pm;
} }

Loading…
Cancel
Save