LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
centeredcheckbox.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_CENTEREDCHECKBOX_H
21 #define LIBREPCB_CENTEREDCHECKBOX_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include <QtCore>
27 #include <QtWidgets>
28 
29 /*******************************************************************************
30  * Namespace / Forward Declarations
31  ******************************************************************************/
32 namespace librepcb {
33 
34 /*******************************************************************************
35  * Class CenteredCheckBox
36  ******************************************************************************/
37 
44 class CenteredCheckBox final : public QWidget {
45  Q_OBJECT
46 
47 public:
48  // Constructors / Destructor
49  explicit CenteredCheckBox(QWidget* parent = nullptr) noexcept;
50  explicit CenteredCheckBox(const QString& text,
51  QWidget* parent = nullptr) noexcept;
52  CenteredCheckBox(const CenteredCheckBox& other) = delete;
53  ~CenteredCheckBox() noexcept;
54 
55  // Wrapper Methods
56  void setText(const QString& text) noexcept { mCheckBox->setText(text); }
57  bool isChecked() const noexcept { return mCheckBox->isChecked(); }
58  void setChecked(bool checked) noexcept { mCheckBox->setChecked(checked); }
59 
60  // Operator Overloadings
61  CenteredCheckBox& operator=(const CenteredCheckBox& rhs) = delete;
62 
63 signals:
64  void toggled(bool checked);
65  void clicked(bool checked);
66  void stateChanged(int state);
67 
68 private: // Data
69  QCheckBox* mCheckBox; // ownership by Qt's parent-child-mechanism
70 };
71 
72 /*******************************************************************************
73  * End of File
74  ******************************************************************************/
75 
76 } // namespace librepcb
77 
78 #endif // LIBREPCB_CENTEREDCHECKBOX_H
void clicked(bool checked)
void setChecked(bool checked) noexcept
Definition: centeredcheckbox.h:58
void stateChanged(int state)
bool isChecked() const noexcept
Definition: centeredcheckbox.h:57
QCheckBox * mCheckBox
Definition: centeredcheckbox.h:69
~CenteredCheckBox() noexcept
Definition: centeredcheckbox.cpp:55
void setText(const QString &text) noexcept
Definition: centeredcheckbox.h:56
The CenteredCheckBox class is a centered variant of the QCheckBox.
Definition: centeredcheckbox.h:44
CenteredCheckBox & operator=(const CenteredCheckBox &rhs)=delete
void toggled(bool checked)
CenteredCheckBox(QWidget *parent=nullptr) noexcept
Definition: centeredcheckbox.cpp:37