Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/thermowidget.h
Show All 13 Lines | 1 | /* Atelier KDE Printer Host for 3D Printing | |||
---|---|---|---|---|---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | #pragma once | 20 | #pragma once | ||
21 | 21 | | |||
22 | #include <qwt_dial.h> | 22 | #include <qwt/qwt_dial.h> | ||
23 | #include <qwt_dial_needle.h> | 23 | #include <qwt/qwt_dial_needle.h> | ||
24 | 24 | | |||
25 | class QKeyEvent; | 25 | class QKeyEvent; | ||
26 | class QPaintEvent; | 26 | class QPaintEvent; | ||
27 | class QFocusEvent; | 27 | class QFocusEvent; | ||
28 | class QWheelEvent; | 28 | class QWheelEvent; | ||
29 | 29 | | |||
30 | class ThermoWidget : public QwtDial | 30 | class ThermoWidget : public QwtDial | ||
31 | { | 31 | { | ||
32 | Q_OBJECT | 32 | Q_OBJECT | ||
33 | 33 | | |||
34 | public: | 34 | public: | ||
35 | ThermoWidget(QWidget *parent, const QString &name); | 35 | ThermoWidget(QWidget *parent, const QString &name); | ||
36 | ~ThermoWidget() = default; | 36 | ~ThermoWidget() = default; | ||
37 | 37 | | |||
38 | void drawNeedle(QPainter *painter, const QPointF ¢er, | 38 | void drawNeedle(QPainter *painter, const QPointF ¢er, | ||
39 | double radius, double dir, QPalette::ColorGroup colorGroup) const; | 39 | double radius, double dir, QPalette::ColorGroup colorGroup) const override; | ||
40 | 40 | | |||
41 | void setCurrentTemperature(double temperature); | 41 | void setCurrentTemperature(double temperature); | ||
42 | void setTargetTemperature(int temperature); | 42 | void setTargetTemperature(int temperature); | ||
43 | 43 | | |||
44 | signals: | 44 | signals: | ||
45 | void targetTemperatureChanged(double targetTemperature); | 45 | void targetTemperatureChanged(double targetTemperature); | ||
46 | 46 | | |||
47 | protected: | 47 | protected: | ||
48 | void focusInEvent(QFocusEvent *event); | 48 | void focusInEvent(QFocusEvent *event) override; | ||
49 | void focusOutEvent(QFocusEvent *event); | 49 | void focusOutEvent(QFocusEvent *event) override; | ||
50 | void keyPressEvent(QKeyEvent *event); | 50 | void keyPressEvent(QKeyEvent *event) override; | ||
51 | void paintEvent(QPaintEvent *event); | 51 | void paintEvent(QPaintEvent *event) override; | ||
52 | void wheelEvent(QWheelEvent *event); | 52 | void wheelEvent(QWheelEvent *event) override; | ||
53 | 53 | | |||
54 | private: | 54 | private: | ||
55 | bool isEqual(double a = 0, double b = 0); | 55 | bool isEqual(double a = 0, double b = 0); | ||
56 | QwtDialSimpleNeedle *m_currentTemperatureNeedle; | 56 | QwtDialSimpleNeedle *m_currentTemperatureNeedle; | ||
57 | QwtDialSimpleNeedle *m_targetTemperatureNeedle; | 57 | QwtDialSimpleNeedle *m_targetTemperatureNeedle; | ||
58 | QString m_currentTemperatureTextFromEditor = QString("-"); | 58 | QString m_currentTemperatureTextFromEditor = QString("-"); | ||
59 | QString m_name; | 59 | QString m_name; | ||
60 | QTimer *m_cursorTimer = nullptr; | 60 | QTimer *m_cursorTimer = nullptr; | ||
61 | QTimer *m_tempChangedTimer = nullptr; | 61 | QTimer *m_tempChangedTimer = nullptr; | ||
62 | bool m_paintCursor = false; | 62 | bool m_paintCursor = false; | ||
63 | int m_cursorPos = 0; | 63 | int m_cursorPos = 0; | ||
64 | double m_currentTemperature; | 64 | double m_currentTemperature; | ||
65 | int m_targetTemperature; | 65 | int m_targetTemperature; | ||
66 | void resetTimer(); | 66 | void resetTimer(); | ||
67 | }; | 67 | }; |