Krita Source Code Documentation
Loading...
Searching...
No Matches
WdgCloseableLabel Class Reference

#include <KisTagSelectionWidget.h>

+ Inheritance diagram for WdgCloseableLabel:

Signals

void sigRemoveTagFromSelection (KoID tag)
 

Public Member Functions

 WdgCloseableLabel (KoID tag, bool editable, bool semiSelected=false, QWidget *parent=0)
 
 ~WdgCloseableLabel () override
 

Protected Member Functions

void paintEvent (QPaintEvent *event) override
 

Private Attributes

QPushButton * m_closeIconLabel {nullptr}
 
bool m_editable {false}
 
bool m_semiSelected {false}
 
int m_size {18}
 
KoID m_tag
 
QLabel * m_textLabel {nullptr}
 

Friends

class TestKisTagSelectionWidget
 

Detailed Description

Definition at line 23 of file KisTagSelectionWidget.h.

Constructor & Destructor Documentation

◆ WdgCloseableLabel()

WdgCloseableLabel::WdgCloseableLabel ( KoID tag,
bool editable,
bool semiSelected = false,
QWidget * parent = 0 )
explicit

Definition at line 39 of file KisTagSelectionWidget.cpp.

40 : QWidget(parent)
41 , m_editable(editable)
42 , m_semiSelected(semiSelected)
43 , m_tag(tag)
44{
45 QHBoxLayout *layout = new QHBoxLayout(this);
46 layout->setContentsMargins(8, 0, 0, 0);
47 layout->setSpacing(2);
48
49 m_textLabel = new QLabel(parent);
50 m_textLabel->setText(tag.name());
51 m_textLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
52 layout->addWidget(m_textLabel);
53 layout->insertStretch(2, 1);
54 if (m_editable) {
55 m_closeIconLabel = new QPushButton(parent);
56 m_closeIconLabel->setFlat(true);
57 m_closeIconLabel->setIcon(KisIconUtils::loadIcon("docker_close"));
58 m_closeIconLabel->setToolTip(i18n("Remove from tag"));
59 m_closeIconLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
60 m_closeIconLabel->setEnabled(m_editable);
61 m_closeIconLabel->setMaximumSize(QSize(1, 1) * m_size);
62
63 connect(m_closeIconLabel, &QAbstractButton::clicked, this, [&]() {
65 });
66 layout->addWidget(m_closeIconLabel);
67 }
68 setLayout(layout);
69}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QString name() const
Definition KoID.cpp:68
QPushButton * m_closeIconLabel
void sigRemoveTagFromSelection(KoID tag)
QIcon loadIcon(const QString &name)

References connect(), KisIconUtils::loadIcon(), m_closeIconLabel, m_editable, m_size, m_tag, m_textLabel, KoID::name(), and sigRemoveTagFromSelection().

◆ ~WdgCloseableLabel()

WdgCloseableLabel::~WdgCloseableLabel ( )
override

Definition at line 71 of file KisTagSelectionWidget.cpp.

72{
73
74}

Member Function Documentation

◆ paintEvent()

void WdgCloseableLabel::paintEvent ( QPaintEvent * event)
overrideprotected

Definition at line 76 of file KisTagSelectionWidget.cpp.

77{
78 QPainter painter(this);
79
80 QColor backGroundColor = qApp->palette().light().color();
81 QColor foregroundColor = qApp->palette().windowText().color();
82 qreal r1 = 0.65;
83 qreal r2 = 1 - r1;
84 QColor outlineColor = QColor::fromRgb(256*(r1*backGroundColor.redF() + r2*foregroundColor.redF()),
85 256*(r1*backGroundColor.greenF() + r2*foregroundColor.greenF()),
86 256*(r1*backGroundColor.blueF() + r2*foregroundColor.blueF()));
87
88
89 QBrush windowB = qApp->palette().window();
90 QBrush windowTextB = qApp->palette().windowText();
91
92 QWidget::paintEvent(event);
93 painter.setRenderHint(QPainter::Antialiasing);
94 QPainterPath path;
95 path.addRoundedRect(this->rect(), 6, 6);
96
97 // good color:
98 painter.fillPath(path, qApp->palette().light());
99
100 if (m_semiSelected) {
101
102 QPen penwt = QPen(outlineColor, 1);
103 penwt.setStyle(Qt::DashLine);
104
105 QPainterPath outlinePath;
106 outlinePath.addRoundedRect(this->rect().adjusted(1, 1, -1, -1), 4, 4);
107
108 painter.setPen(penwt);
109 painter.drawPath(outlinePath);
110 }
111
112}
QPointF r2
QPointF r1

References m_semiSelected, r1, and r2.

◆ sigRemoveTagFromSelection

void WdgCloseableLabel::sigRemoveTagFromSelection ( KoID tag)
signal

Friends And Related Symbol Documentation

◆ TestKisTagSelectionWidget

friend class TestKisTagSelectionWidget
friend

Definition at line 46 of file KisTagSelectionWidget.h.

Member Data Documentation

◆ m_closeIconLabel

QPushButton* WdgCloseableLabel::m_closeIconLabel {nullptr}
private

Definition at line 39 of file KisTagSelectionWidget.h.

39{nullptr};

◆ m_editable

bool WdgCloseableLabel::m_editable {false}
private

Definition at line 42 of file KisTagSelectionWidget.h.

42{false};

◆ m_semiSelected

bool WdgCloseableLabel::m_semiSelected {false}
private

Definition at line 43 of file KisTagSelectionWidget.h.

43{false};

◆ m_size

int WdgCloseableLabel::m_size {18}
private

Definition at line 41 of file KisTagSelectionWidget.h.

41{18};

◆ m_tag

KoID WdgCloseableLabel::m_tag
private

Definition at line 44 of file KisTagSelectionWidget.h.

◆ m_textLabel

QLabel* WdgCloseableLabel::m_textLabel {nullptr}
private

Definition at line 38 of file KisTagSelectionWidget.h.

38{nullptr};

The documentation for this class was generated from the following files: