blob: 578e6550f73933f7658a8cb870860c8e30cd337f [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#include "StatusBar.h"
2#include <ui/HBoxLayout.h>
3#include <ui/Spacer.h>
4
5namespace MGUI
6{
7
8StatusBar::StatusBar(ilixi::Widget* parent)
9 : ContainerBase(parent),
10 _batteryIcon(NULL)
11{
12 ilixi::HBoxLayout* layout = new ilixi::HBoxLayout();
13 layout->setSpacing(0);
14 layout->setVerticalAlignment(ilixi::Alignment::Middle);
15 setLayout(layout);
16
17 _clock = new ilixi::Label("00:00");
18 addWidget(_clock);
19
20 addWidget(new ilixi::Spacer());
21
22 _simIcon = new SimIcon();
23 addWidget(_simIcon);
24
25 _sdcardIcon = new SDCardIcon();
26 addWidget(_sdcardIcon);
27
28 _wifiIcon = new WiFiIcon();
29 addWidget(_wifiIcon);
30
31 _cellularTechIcon = new CellularTechIcon();
32 addWidget(_cellularTechIcon);
33
34 _cellularIcon = new CellularIcon();
35 addWidget(_cellularIcon);
36
37 _gpsIcon = new GPSIcon();
38 addWidget(_gpsIcon);
39
40 _bluetoothIcon = new BTIcon();
41 addWidget(_bluetoothIcon);
42
43 _batteryIcon = new BatteryIcon();
44 addWidget(_batteryIcon);
45
46 _timer = new ilixi::Timer();
47 _timer->sigExec.connect(sigc::mem_fun(this, &StatusBar::updateTime));
48 _timer->start(10000);
49 updateTime();
50}
51
52StatusBar::~StatusBar()
53{
54 delete _timer;
55}
56
57void
58StatusBar::compose(const ilixi::PaintEvent& event)
59{
60}
61
62void
63StatusBar::setBatteryState(BatteryState state)
64{
65 _batteryIcon->setBatteryState(state);
66}
67
68void
69StatusBar::setBluetoothState(BluetoothState state)
70{
71 _bluetoothIcon->setBluetoothState(state);
72}
73
74void
75StatusBar::setCellularState(CellularState state)
76{
77 _cellularIcon->setCellularState(state);
78}
79
80void
81StatusBar::setCellularTechState(CellularTechState state)
82{
83 _cellularTechIcon->setCellularTechState(state);
84}
85
86void
87StatusBar::setGPSState(GpsState state)
88{
89 _gpsIcon->setGpsState(state);
90}
91
92void
93StatusBar::setSDCardState(SDCardState state)
94{
95 _sdcardIcon->setSdcardState(state);
96}
97
98void
99StatusBar::setSimState(SimState state)
100{
101 _simIcon->setSimState(state);
102}
103
104void
105StatusBar::setWifiState(WifiState state)
106{
107 _wifiIcon->setWifiState(state);
108}
109
110void
111StatusBar::updateTime()
112{
113 struct timeval tv;
114 struct tm* tm;
115 gettimeofday(&tv, NULL);
116 tm = localtime(&tv.tv_sec);
117
118 _clock->setText(ilixi::PrintF("%02d:%02d", tm->tm_hour, tm->tm_min));
119}
120
121} /* namespace MGUI */