swift
ticklabel.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
4 #include "gui/ticklabel.h"
5 
6 #include "misc/icons.h"
7 
8 using namespace swift::misc;
9 
10 namespace swift::gui
11 {
12  CTickLabel::CTickLabel(QWidget *parent) : QLabel(parent)
13  {
14  this->setText("");
15  this->setMargin(0);
16  this->setMaximumSize(CIcons::tick16().size());
17  this->setLabel();
18  }
19 
20  void CTickLabel::setTicked(bool ticked)
21  {
22  if (m_isPixmapTicked == ticked) { return; }
23  this->m_isPixmapTicked = ticked;
24  this->setLabel();
25 
26  emit tickChanged(this->m_isPixmapTicked);
27  }
28 
29  void CTickLabel::setToolTips(const QString &ticked, const QString &unticked)
30  {
31  m_toolTipTicked = ticked;
32  m_toolTipUnticked = unticked;
33  this->setLabel();
34  }
35 
36  void CTickLabel::setLabel()
37  {
38  this->setText("");
39  this->setPixmap(this->m_isPixmapTicked ? m_pixmapTicked : m_pixmapUnticked);
40  this->setToolTip(this->m_isPixmapTicked ? m_toolTipTicked : m_toolTipUnticked);
41  }
42 } // namespace swift::gui
void tickChanged(bool ticked)
Changed ticked state.
void setTicked(bool ticked)
Set ticked.
Definition: ticklabel.cpp:20
void setToolTips(const QString &ticked, const QString &unticked)
Set the tool tips.
Definition: ticklabel.cpp:29
GUI related classes.
Free functions in swift::misc.