Krita Source Code Documentation
Loading...
Searching...
No Matches
KisTagLabel.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Srirupa Datta <srirupa.sps@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#include "KisTagLabel.h"
8
9#include <QPainter>
10#include <QPainterPath>
11#include <QApplication>
12#include <QHBoxLayout>
13#include <QLabel>
14
15KisTagLabel::KisTagLabel(QString string, QWidget *parent) :
16 QWidget(parent)
17{
18 m_string = string;
19
20 QHBoxLayout *layout = new QHBoxLayout(this);
21 layout->setContentsMargins(8, 0, 8, 0);
22 layout->setSpacing(2);
23
24 QLabel *label = new QLabel(parent);
25 label->setText(m_string);
26 label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
27 layout->addWidget(label);
28
29 setLayout(layout);
30}
31
35
36void KisTagLabel::paintEvent(QPaintEvent *event)
37{
38 QPainter painter(this);
39
40 QColor backGroundColor = qApp->palette().light().color();
41 QColor foregroundColor = qApp->palette().windowText().color();
42
43 QWidget::paintEvent(event);
44 painter.setRenderHint(QPainter::Antialiasing);
45 QPainterPath path;
46 path.addRoundedRect(this->rect(), 6, 6);
47
48 // good color:
49 painter.fillPath(path, qApp->palette().light());
50}
51
53{
54 return m_string;
55}
void paintEvent(QPaintEvent *event) override
QString m_string
Definition KisTagLabel.h:29
QString getText()
KisTagLabel(QString string, QWidget *parent=nullptr)