LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SystemMenu.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2010-2013 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef SYSTEMMENU_H
23 #define SYSTEMMENU_H
24 
25 
26 #include <QGraphicsObject>
27 #include <QPropertyAnimation>
28 #include <QTimer>
30 
31 class QDeclarativeEngine;
32 class QDeclarativeComponent;
33 class MenuHandler;
34 
36 {
37  Q_OBJECT
38 
39 public:
40  SystemMenu(int width, int height, bool restricted = false);
41  ~SystemMenu();
42 
43  void init();
44 
45  void setOpened(bool opened);
46  bool isOpened() { return m_opened; }
47 
48  QRectF boundingRect() const; // This item is Left Aligned (The position of the icon is the position of the LEFT EDGE of the bounding rect)
49  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
50  int getRightEdgeOffset() { return m_rightEdgeOffset; }
51 
52 private Q_SLOTS:
53  void slotCloseSystemMenu();
54 
55  void slotWifiMenuOpened();
56  void slotWifiMenuClosed();
57  void slotWifiOnOffTriggered();
58  void slotWifiPrefsTriggered();
59  void slotWifiNetworkSelected(int index, QString name, int profileId, QString securityType, QString connStatus);
60 
61  void slotBluetoothMenuOpened();
62  void slotBluetoothMenuClosed();
63  void slotBluetoothOnOffTriggered();
64  void slotBluetoothPrefsTriggered();
65  void slotBluetoothDeviceSelected(int index);
66 
67  void slotVpnMenuOpened();
68  void slotVpnMenuClosed();
69  void slotVpnPrefsTriggered();
70  void slotVpnNetworkSelected(QString name, QString status, QString profInfo);
71 
72  void slotAirplaneModeTriggered();
73  void slotRotationLockTriggered(bool isLocked);
74  void slotMuteToggleTriggered(bool isMuted);
75  void slotRotationLockChanged(OrientationEvent::Orientation rotationLock);
76  void slotMuteSoundChanged(bool muteOn);
77  void slotDisplayMaxBrightnessChanged(int brightness);
78 
79  void slotPowerdConnectionStateChanged(bool connected);
80  void slotBatteryLevelUpdated(int percentage);
81 
82  void slotWifiStateChanged(bool wifiOn, bool wifiConnected, std::string wifiSSID, std::string wifiConnState);
83  void slotWifiAvailableNetworksListUpdate(int numNetworks, t_wifiAccessPoint* list);
84 
85  void slotBluetoothTurnedOn();
86  void slotBluetoothPowerStateChanged(t_radioState radioState);
87  void slotBluetoothConnStateChanged(bool btConnected, std::string deviceName);
88  void slotBluetoothTrustedDevicesUpdate(int numTrustedDevices, t_bluetoothDevice* list);
89  void slotBluetoothParedDevicesAvailable(bool available);
90  void slotBluetoothUpdateDeviceStatus(t_bluetoothDevice* deviceStatus);
91  void slotVpnProfileListUpdate(int numProfiles, t_vpnProfile* list);
92  void slotVpnStateChanged(bool enabled);
93  void slotAirplaneModeState(t_airplaneModeState state);
94  void slotMenuBrightnessChanged(qreal value, bool save);
95 
96  void slotSystemTimeChanged();
97  void slotPositiveSpaceChangeFinished(QRect rect);
98  void tick();
99 
100  Q_SIGNALS:
101  void signalCloseMenu();
102 
103 private:
104 
105  bool sceneEvent(QEvent* event);
106 
107  void setAirplaneModeState(t_airplaneModeState state);
108  void launchApp(std::string appId, std::string params);
109 
110  void connectBtAudioDevice(std::string address, unsigned int cod);
111 
112  QRect m_bounds;
113  bool m_restricted;
114  bool m_opened;
115  int m_rightEdgeOffset;
116  QDeclarativeComponent* m_qmlMenu;
117  // Top Level Menu Object
118  QGraphicsObject* m_menuObject;
119 
120  // Children Menu Objects
121  QGraphicsObject* m_wifiMenu;
122  QGraphicsObject* m_vpnMenu;
123  QGraphicsObject* m_bluetoothMenu;
124 
125  bool m_wifiMenuOpened;
126  bool m_wifiOn;
127 
128  bool m_bluetoothMenuOpened;
129  t_radioState m_bluetoothPower;
130  bool m_btPairedDevicesAvailable;
131  bool m_btTurnOnRequested;
132  std::vector<t_bluetoothDevice> m_trustedDevices;
133  std::string m_pendingDevAddress;
134  int m_pendingCod;
135 
136  QTimer *m_dateTimer;
137 
138  bool m_vpnMenuOpened;
139 
140  MenuHandler* m_menuHandler; // provides an interface to interact with the QML menu
141 
142  t_airplaneModeState m_airplaneModeState;
143 
144  struct {
145  int year;
146  int month;
147  int day;
148  } m_lastUpdateDate;
149 };
150 
151 
152 
153  class MenuHandler : public QObject
154  {
155  Q_OBJECT
156  public:
157  MenuHandler(SystemMenu *parent = 0);
158  ~MenuHandler();
159 
160  void updateBatteryLevel(QString level) { Q_EMIT batteryLevelUpdated(level); }
162 
163 Q_SIGNALS:
164 
165  void batteryLevelUpdated(QString batteryLevel);
166  void wifiStateChanged(bool wifiOn, QString wifiString);
167  void wifiListUpdated();
168 
169  private:
170 
171  SystemMenu* m_systemMenu;
172  };
173 
174 
175 
177  {
178  Q_OBJECT
179  Q_PROPERTY(int duration READ duration WRITE setDuration)
180  Q_PROPERTY(bool on READ on WRITE setOn)
181  Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame)
182  public:
183  AnimatedSpinner(QObject *parent = 0);
184  ~AnimatedSpinner();
185 
186  int duration() const { return m_duration; }
187  void setDuration(const int duration );
188 
189  int currentFrame() const { return m_currentFrame; }
190  void setCurrentFrame(const int frame );
191 
192  int on() const { return m_on; }
193  void setOn(const bool on );
194 
195  QRectF boundingRect() const;
196  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
197 
198  private:
199  int m_duration;
200  bool m_on;
201  QPixmap m_img;
202  QRectF m_bounds;
203  int m_nFrames;
204  int m_currentFrame;
205 
206  QPropertyAnimation m_anim;
207  };
208 
209 
210 
211 #endif /* SYSTEMMENU_H */