28 m_foreground(QColor(
"black")),
29 m_background(QColor(
"white")),
44 d->m_text = text.isEmpty() ? QByteArray(
"https://github.com/Greedysky/TTKMusicPlayer") :
text;
78 d->m_percent = percent < 0.5 ? percent : 0.3;
115 d->m_foreground = color;
121 return d->m_foreground;
127 d->m_background = color;
133 return d->m_background;
163 QWidget::paintEvent (event);
164 QPainter painter(
this);
169 unsigned char *point = qrcode->
data;
170 painter.setPen(Qt::NoPen);
171 painter.fillRect(0, 0, width(), height(), d->m_background);
173 const double scale = (width () - 2.0 * d->m_margin) / qrcode->
width;
174 painter.setBrush(d->m_foreground);
176 for(
int x = 0; x < qrcode->
width; ++x)
178 for(
int y = 0; y < qrcode->
width; ++y)
182 QRectF r(d->m_margin + y * scale, d->m_margin + x * scale, scale, scale);
183 painter.drawRects(&r, 1);
192 painter.setBrush(d->m_background);
193 const double icon_width = (width () - 2.0 * d->m_margin) * d->m_percent;
194 const double icon_height = icon_width;
195 const double wrap_x = (width () - icon_width) / 2.0;
196 const double wrap_y = (width () - icon_height) / 2.0;
197 const QRectF wrap(wrap_x - 5, wrap_y - 5, icon_width + 10, icon_height + 10);
198 painter.drawRoundedRect(wrap, 10, 10);
200 QPixmap image(d->m_iconPath);
201 const QRectF target(wrap_x, wrap_y, icon_width, icon_height);
202 const QRectF source(0, 0, image.width (), image.height ());
203 painter.drawPixmap(target, image, source);
void QRcode_free(QRcode *qrcode)
Free the instance of QRcode class.
QRecLevel
Level of error correction.
QRencodeMode
Encoding mode.
QRcode * QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
Create a symbol from the string.
unsigned char * data
symbol data
int width
width of the symbol
#define TTK_INIT_PRIVATE(Class)
The class of the ttk private base.