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);
165 painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
170 unsigned char *point = qrcode->
data;
171 painter.setPen(Qt::NoPen);
172 painter.fillRect(0, 0, width(), height(), d->m_background);
174 const double scale = (width() - 2.0 * d->m_margin) / qrcode->
width;
175 painter.setBrush(d->m_foreground);
177 for(
int x = 0; x < qrcode->
width; ++x)
179 for(
int y = 0; y < qrcode->
width; ++y)
183 QRectF r(d->m_margin + y * scale, d->m_margin + x * scale, scale, scale);
184 painter.drawRects(&r, 1);
193 painter.setBrush(d->m_background);
194 const double icon_width = (width() - 2.0 * d->m_margin) * d->m_percent;
195 const double icon_height = icon_width;
196 const double wrap_x = (width() - icon_width) / 2.0;
197 const double wrap_y = (width() - icon_height) / 2.0;
198 const QRectF wrap(wrap_x - 5, wrap_y - 5, icon_width + 10, icon_height + 10);
199 painter.drawRoundedRect(wrap, 10, 10);
201 QPixmap image(d->m_iconPath);
202 const QRectF target(wrap_x, wrap_y, icon_width, icon_height);
203 const QRectF source(0, 0, image.width(), image.height());
204 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.