QtCanpool 3.3.0
载入中...
搜索中...
未找到
ribbonutils.cpp
浏览该文件的文档.
1
5#include "ribbonutils.h"
6#include <QPainter>
7
8namespace QxRibbon
9{
10
11QIcon colorIcon(const QColor &color, const QSize &size)
12{
13 return QIcon(colorPixmap(color, size));
14}
15
16QPixmap colorPixmap(const QColor &color, const QSize &size)
17{
18 QPixmap res(size);
19 res.fill(Qt::transparent);
20 QPainter painter(&res);
21 QRect pr(1, 1, res.height() - 2, res.width() - 2);
22 if (color.isValid()) {
23 painter.fillRect(pr, color);
24 } else {
25 QPen pen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap);
26 painter.setPen(pen);
27 painter.drawRect(pr);
28 pen.setColor(Qt::red);
29 painter.setPen(pen);
30 painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
31 painter.setRenderHint(QPainter::Antialiasing, true);
32 painter.drawLine(QPoint(1, size.height()), QPoint(size.width() - 1, 1));
33 }
34 return res;
35}
36
37} // namespace QxRibbon
Copyleft (C) 2023 maminjie canpool@163.com SPDX-License-Identifier: MIT
QIcon colorIcon(const QColor &color, const QSize &size)
QPixmap colorPixmap(const QColor &color, const QSize &size)