File indexing completed on 2024-05-19 04:27:46
0001 /* 0002 * SPDX-FileCopyrightText: 2023 Srirupa Datta <srirupa.sps@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "KisTagLabel.h" 0008 0009 #include <QPainter> 0010 #include <QPainterPath> 0011 #include <QApplication> 0012 #include <QHBoxLayout> 0013 #include <QLabel> 0014 0015 KisTagLabel::KisTagLabel(QString string, QWidget *parent) : 0016 QWidget(parent) 0017 { 0018 m_string = string; 0019 0020 QHBoxLayout *layout = new QHBoxLayout(this); 0021 layout->setContentsMargins(8, 0, 8, 0); 0022 layout->setSpacing(2); 0023 0024 QLabel *label = new QLabel(parent); 0025 label->setText(m_string); 0026 label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 0027 layout->addWidget(label); 0028 0029 setLayout(layout); 0030 } 0031 0032 KisTagLabel::~KisTagLabel() 0033 { 0034 } 0035 0036 void KisTagLabel::paintEvent(QPaintEvent *event) 0037 { 0038 QPainter painter(this); 0039 0040 QColor backGroundColor = qApp->palette().light().color(); 0041 QColor foregroundColor = qApp->palette().windowText().color(); 0042 0043 QWidget::paintEvent(event); 0044 painter.setRenderHint(QPainter::Antialiasing); 0045 QPainterPath path; 0046 path.addRoundedRect(this->rect(), 6, 6); 0047 0048 // good color: 0049 painter.fillPath(path, qApp->palette().light()); 0050 } 0051 0052 QString KisTagLabel::getText() 0053 { 0054 return m_string; 0055 }