1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef STATUSWIDGET_H
6#define STATUSWIDGET_H
7
8#include <QWidget>
9#include <QTimer>
10#include <QPainter>
11#include <QDebug>
12#include <QtMath>
13class StatusWidgetPrivate;
14class StatusWidget : public QWidget
15{
16 Q_OBJECT
17 StatusWidgetPrivate *const d;
18public:
19 //time Control speed from mes
20 enum RotaSpeed
21 {
22 Rapidly = 50,
23 Fast = 65,
24 Usual = 80,
25 Slow = 100,
26 Turtle = 120,
27 };
28
29 enum PatternFlag
30 {
31 Simple = 0x01,
32 Radar = 0x02,
33 Ring = 0x04,
34 Twinkle = 0x08,
35 Ripple = 0x0F
36 };
37
38 Q_DECLARE_FLAGS(PatternFlags, PatternFlag)
39
40 // Radar = Simple|Radar
41 // Ring = Simple|Ring
42
43 enum State
44 {
45 Running,
46 Error,
47 Stoped,
48 };
49
50 explicit StatusWidget(QWidget *parent = nullptr);
51 StatusWidget(PatternFlags flags, QWidget *parent = nullptr);
52 virtual ~StatusWidget();
53 void setElemCount(int count);
54 int elemCount();
55 void setPatternFlags(StatusWidget::PatternFlags flags);
56 StatusWidget::PatternFlags patternFlags();
57 void setRotaSpeed(StatusWidget::RotaSpeed speed);
58 RotaSpeed rotaSpeed() const;
59 //timer start
60 void start(StatusWidget::RotaSpeed speed);
61 void start();
62 void stop();
63 //get timer and flag state
64 bool isRunning();
65 bool isStoped();
66 //paint error
67 void setError();
68 bool isError();
69 //paint warning
70 void setWarning();
71 bool isWarning();
72 //extend method and to setting run state color
73 void setRunningColor(QColor color);
74
75protected:
76 virtual void paintEvent(QPaintEvent *event);
77 virtual void paintError(QPainter &painter);
78 virtual void paintSimple(QPainter &painter);
79 virtual void paintRadar(QPainter &painter);
80 virtual void paintRing(QPainter &painter);
81 virtual void paintTwinkle(QPainter &painter);
82 virtual void paintRipple(QPainter &painter);
83};
84
85Q_DECLARE_OPERATORS_FOR_FLAGS(StatusWidget::PatternFlags)
86
87#endif // STATUSWIDGET_H
88