mirror of
https://github.com/wf-group/wfview
synced 2026-08-13 17:32:59 -04:00
35 lines
625 B
C++
35 lines
625 B
C++
#include "clickablelabel.h"
|
|
|
|
ClickableLabel::ClickableLabel(QWidget *parent)
|
|
: QLabel(parent)
|
|
{
|
|
setCursor(Qt::PointingHandCursor);
|
|
}
|
|
|
|
void ClickableLabel::setActive(bool active)
|
|
{
|
|
m_active = active;
|
|
updateStyle();
|
|
}
|
|
|
|
bool ClickableLabel::isActive() const
|
|
{
|
|
return m_active;
|
|
}
|
|
|
|
void ClickableLabel::mousePressEvent(QMouseEvent *event)
|
|
{
|
|
if (event->button() == Qt::LeftButton) {
|
|
m_active = !m_active;
|
|
updateStyle();
|
|
emit clicked();
|
|
}
|
|
QLabel::mousePressEvent(event);
|
|
}
|
|
|
|
void ClickableLabel::updateStyle()
|
|
{
|
|
QFont f = font();
|
|
f.setBold(m_active);
|
|
setFont(f);
|
|
}
|