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

46
src/mainwindow.ui

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

16
src/qrcodelabel.cpp

@ -12,7 +12,7 @@ QRCodeLabel::QRCodeLabel(QWidget *parent) :
QSize QRCodeLabel::sizeHint() const
{
int w = this->width();
return QSize(w, w); // 1:1
return QSize(w, w); // 1:1
}
void QRCodeLabel::resizeEvent(QResizeEvent*)
@ -25,8 +25,8 @@ QPixmap QRCodeLabel::scaledPixmap() const {
QPixmap pm(size());
pm.fill(Qt::white);
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 double w = pm.width();
const double h = pm.height();
@ -35,8 +35,8 @@ QPixmap QRCodeLabel::scaledPixmap() const {
const double scale = size/(s+2);
const double woff = (w - size) > 0 ? (w - 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.setBrush(QColor(Qt::black));
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;
}

Loading…
Cancel
Save