File indexing completed on 2024-12-01 04:36:37

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "delegatepaintutil.h"
0008 #include <QPainter>
0009 #include <QPainterPath>
0010 
0011 void DelegatePaintUtil::drawLighterText(QPainter *painter, const QString &text, QPoint pos)
0012 {
0013     const QPen oldPen = painter->pen();
0014     QColor col = painter->pen().color();
0015     col.setAlpha(128);
0016     painter->setPen(col);
0017     painter->drawText(pos, text);
0018     painter->setPen(oldPen);
0019 }
0020 
0021 int DelegatePaintUtil::margin()
0022 {
0023     return 8;
0024 }
0025 
0026 void DelegatePaintUtil::createClipRoundedRectangle(QPainter *painter, const QRectF &rect, QPointF pos, const QPixmap &pix)
0027 {
0028     QPainterPath path;
0029     painter->save();
0030     painter->setRenderHint(QPainter::Antialiasing);
0031     path.addRoundedRect(rect, 5, 5);
0032     painter->setClipPath(path);
0033     painter->drawPixmap(pos, pix);
0034     painter->restore();
0035 }