5
5
#include < qt/qrimagewidget.h>
6
6
7
7
#include < qt/guiutil.h>
8
+ #include < qt/optionsmodel.h>
8
9
9
10
#include < QApplication>
10
11
#include < QClipboard>
@@ -31,7 +32,7 @@ QRImageWidget::QRImageWidget(QWidget* parent)
31
32
contextMenu->addAction (tr (" &Copy Image" ), this , &QRImageWidget::copyImage);
32
33
}
33
34
34
- bool QRImageWidget::setQR (const QString& data, const QString& text)
35
+ bool QRImageWidget::setQR (const QString& data, const QString& text, const OptionsModel::FontChoice& fontchoice )
35
36
{
36
37
#ifdef USE_QRCODE
37
38
setText (" " );
@@ -72,11 +73,19 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)
72
73
QRect paddedRect = qrAddrImage.rect ();
73
74
paddedRect.setHeight (QR_IMAGE_SIZE + QR_IMAGE_TEXT_MARGIN);
74
75
75
- QFont font = GUIUtil::fixedPitchFont ();
76
- font.setStretch (QFont::SemiCondensed);
77
- font.setLetterSpacing (QFont::AbsoluteSpacing, 1 );
78
- const qreal font_size = GUIUtil::calculateIdealFontSize (paddedRect.width () - 2 * QR_IMAGE_TEXT_MARGIN, text, font);
79
- font.setPointSizeF (font_size);
76
+ // Determine font to use
77
+ QFont font;
78
+ if (std::holds_alternative<OptionsModel::FontChoiceAbstract>(fontchoice)) {
79
+ font = GUIUtil::fixedPitchFont (fontchoice != OptionsModel::UseBestSystemFont);
80
+ font.setWeight (QFont::Bold);
81
+ font.setStretch (QFont::SemiCondensed);
82
+ font.setLetterSpacing (QFont::AbsoluteSpacing, 1 );
83
+
84
+ const qreal font_size = GUIUtil::calculateIdealFontSize (paddedRect.width () - 2 * QR_IMAGE_TEXT_MARGIN, text, font);
85
+ font.setPointSizeF (font_size);
86
+ } else {
87
+ font = std::get<QFont>(fontchoice);
88
+ }
80
89
81
90
painter.setFont (font);
82
91
painter.drawText (paddedRect, Qt::AlignBottom | Qt::AlignCenter, text);
@@ -92,6 +101,11 @@ bool QRImageWidget::setQR(const QString& data, const QString& text)
92
101
#endif
93
102
}
94
103
104
+ bool QRImageWidget::setQR (const QString& data)
105
+ {
106
+ return setQR (data, " " , OptionsModel::FontChoiceAbstract::EmbeddedFont);
107
+ }
108
+
95
109
QImage QRImageWidget::exportImage ()
96
110
{
97
111
return GUIUtil::GetImage (this );
0 commit comments