Commit 0da128bb885570dcad239f02163f6b764b8cc45c
1 parent
c41b8944df
Exists in
fhd
상태 영역에 제어 보드 통신 상태 표시
Showing
4 changed files
with
81 additions
and
0 deletions
Show diff stats
app/gui/oven_control/commicon.cpp
... | ... | @@ -0,0 +1,38 @@ |
1 | +#include "commicon.h" | |
2 | + | |
3 | +#include <QPainter> | |
4 | +#include <QPaintEvent> | |
5 | + | |
6 | +#include "udphandler.h" | |
7 | + | |
8 | +CommIcon::CommIcon(QWidget *parent) : QWidget(parent) | |
9 | +{ | |
10 | + isFault = false; | |
11 | + | |
12 | + UdpHandler *udp = UdpHandler::getInstance(); | |
13 | + connect(udp, SIGNAL(timeout()), SLOT(setFault())); | |
14 | + connect(udp, SIGNAL(recovered()), SLOT(setOK())); | |
15 | +} | |
16 | + | |
17 | +void CommIcon::setFault() | |
18 | +{ | |
19 | + isFault = true; | |
20 | + update(); | |
21 | +} | |
22 | + | |
23 | +void CommIcon::setOK() | |
24 | +{ | |
25 | + isFault = false; | |
26 | + update(); | |
27 | +} | |
28 | + | |
29 | +void CommIcon::paintEvent(QPaintEvent *event) | |
30 | +{ | |
31 | + if (isFault) | |
32 | + return; | |
33 | + | |
34 | + QPainter painter(this); | |
35 | + painter.setRenderHint(QPainter::Antialiasing); | |
36 | + painter.setBrush(Qt::blue); | |
37 | + painter.drawEllipse(rect()); | |
38 | +} | ... | ... |
app/gui/oven_control/commicon.h
... | ... | @@ -0,0 +1,25 @@ |
1 | +#ifndef COMMICON_H | |
2 | +#define COMMICON_H | |
3 | + | |
4 | +#include <QWidget> | |
5 | + | |
6 | +class CommIcon : public QWidget | |
7 | +{ | |
8 | + Q_OBJECT | |
9 | +public: | |
10 | + explicit CommIcon(QWidget *parent = nullptr); | |
11 | + | |
12 | +signals: | |
13 | + | |
14 | +public slots: | |
15 | + void setFault(); | |
16 | + void setOK(); | |
17 | + | |
18 | +protected: | |
19 | + void paintEvent(QPaintEvent *event); | |
20 | + | |
21 | +private: | |
22 | + bool isFault; | |
23 | +}; | |
24 | + | |
25 | +#endif // COMMICON_H | ... | ... |
app/gui/oven_control/oven_control.pro
... | ... | @@ -13,6 +13,7 @@ TEMPLATE = app |
13 | 13 | |
14 | 14 | |
15 | 15 | SOURCES += main.cpp\ |
16 | + commicon.cpp \ | |
16 | 17 | mainwindow.cpp \ |
17 | 18 | cook.cpp \ |
18 | 19 | oven.cpp \ |
... | ... | @@ -153,6 +154,7 @@ SOURCES += main.cpp\ |
153 | 154 | |
154 | 155 | |
155 | 156 | HEADERS += mainwindow.h \ |
157 | + commicon.h \ | |
156 | 158 | cook.h \ |
157 | 159 | oven.h \ |
158 | 160 | abstractoveninterface.h \ | ... | ... |
app/gui/oven_control/statusarea.ui
... | ... | @@ -95,6 +95,16 @@ |
95 | 95 | <string/> |
96 | 96 | </property> |
97 | 97 | </widget> |
98 | + <widget class="CommIcon" name="commIcon" native="true"> | |
99 | + <property name="geometry"> | |
100 | + <rect> | |
101 | + <x>20</x> | |
102 | + <y>20</y> | |
103 | + <width>20</width> | |
104 | + <height>20</height> | |
105 | + </rect> | |
106 | + </property> | |
107 | + </widget> | |
98 | 108 | </widget> |
99 | 109 | <customwidgets> |
100 | 110 | <customwidget> |
... | ... | @@ -133,6 +143,12 @@ |
133 | 143 | <extends>QLabel</extends> |
134 | 144 | <header>waterlevelicon.h</header> |
135 | 145 | </customwidget> |
146 | + <customwidget> | |
147 | + <class>CommIcon</class> | |
148 | + <extends>QWidget</extends> | |
149 | + <header>commicon.h</header> | |
150 | + <container>1</container> | |
151 | + </customwidget> | |
136 | 152 | </customwidgets> |
137 | 153 | <resources/> |
138 | 154 | <connections/> | ... | ... |