Cppcheck
codeeditstylecontrols.h
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2023 Cppcheck team.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 // widget subclass methodology derived from here:
20 // https://stackoverflow.com/questions/18257281/qt-color-picker-widget/43871405#43871405
21 
22 #ifndef CODEEDITORSTYLECONTROLS_H
23 #define CODEEDITORSTYLECONTROLS_H
24 
25 #include <QColor>
26 #include <QComboBox>
27 #include <QFont>
28 #include <QObject>
29 #include <QPushButton>
30 #include <QString>
31 
32 class QWidget;
33 
34 class SelectColorButton : public QPushButton {
35  Q_OBJECT
36 public:
37  explicit SelectColorButton(QWidget* parent);
38 
39  void setColor(const QColor& color);
40  const QColor& getColor();
41 
42 signals:
43  // NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code
44  void colorChanged(const QColor& newColor);
45 
46 public slots:
47  void updateColor();
48  void changeColor();
49 
50 private:
51  QColor mColor;
52 };
53 
54 
55 class SelectFontWeightCombo : public QComboBox {
56  Q_OBJECT
57 public:
58  explicit SelectFontWeightCombo(QWidget* parent);
59 
60  void setWeight(QFont::Weight weight);
61  const QFont::Weight& getWeight();
62 
63 signals:
64  // NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code
65  void weightChanged(QFont::Weight newWeight);
66 
67 public slots:
68  void updateWeight();
69  void changeWeight(int index);
70 
71 private:
72  QFont::Weight mWeight = QFont::Normal;
73 };
74 
75 #endif //CODEEDITORSTYLECONTROLS_H
76 
const QColor & getColor()
SelectColorButton(QWidget *parent)
void setColor(const QColor &color)
void colorChanged(const QColor &newColor)
void setWeight(QFont::Weight weight)
void weightChanged(QFont::Weight newWeight)
SelectFontWeightCombo(QWidget *parent)
const QFont::Weight & getWeight()