forked from aamirglb/GCSWidgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuelindicator.h
executable file
·39 lines (31 loc) · 1006 Bytes
/
fuelindicator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef FUELINDICATOR_H
#define FUELINDICATOR_H
#include <QWidget>
class FuelIndicator : public QWidget
{
Q_OBJECT
public:
explicit FuelIndicator(QWidget *parent = nullptr);
using Range = std::pair<int32_t, int32_t>;
void setNormalRange(Range range) { m_normal = range; }
void setCautionRange(Range range) { m_caution = range; }
void setWarningRange(Range range) { m_warning = range; }
protected:
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
void paintEvent(QPaintEvent *) override;
public slots:
void setMaxFuel(double maxFuelInKg);
void setFuel(double fuel);
private:
QString getColor(double value);
private:
int32_t m_width {120};
int32_t m_height {80};
double m_fuel {50}; // in kg
double m_maxFuel {100}; // in kg
Range m_caution;
Range m_warning;
Range m_normal;
};
#endif // FUELINDICATOR_H