|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: FM Radio home screen widget |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef RADIOHSWIDGET_H |
|
19 #define RADIOHSWIDGET_H |
|
20 |
|
21 // System includes |
|
22 #include <HbWidget> |
|
23 |
|
24 // Forward declarations |
|
25 class HbLabel; |
|
26 class HbPushButton; |
|
27 class XQSettingsManager; |
|
28 class XQSettingsKey; |
|
29 class RadioHsWidgetProfileReader; |
|
30 class RadioHsWidgetRadioServiceClient; |
|
31 class QGraphicsLinearLayout; |
|
32 |
|
33 /*! |
|
34 \namespace FmRadio |
|
35 \brief Wraps enumerators for radio state and service request visibility. |
|
36 */ |
|
37 namespace FmRadio |
|
38 { |
|
39 /*! Enum for radio application states. */ |
|
40 enum State |
|
41 { |
|
42 StateUndefined, |
|
43 StateNotRunning, |
|
44 StateStarting, |
|
45 StateRunning, |
|
46 StateSeeking, |
|
47 StateAntennaNotConnected, |
|
48 StateClosing |
|
49 }; |
|
50 |
|
51 /*! Enum for controlling the visibility of the radio application. */ |
|
52 enum VisibiltyAfterRequest |
|
53 { |
|
54 VisibiltyDoNotChange, |
|
55 VisibiltyToForeground, |
|
56 VisibiltyToBackground |
|
57 }; |
|
58 |
|
59 } |
|
60 |
|
61 class RadioHsWidget : public HbWidget |
|
62 { |
|
63 Q_OBJECT |
|
64 |
|
65 public: |
|
66 RadioHsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0); |
|
67 ~RadioHsWidget(); |
|
68 |
|
69 void handleRadioInformationChange(const int informationType, |
|
70 const QVariant &information); |
|
71 void handleRadioStateChange(const QVariant &value); |
|
72 |
|
73 private: |
|
74 /*! Enum for information area layout states. */ |
|
75 enum InformationAreaLayout |
|
76 { |
|
77 OneRow, |
|
78 TwoRows, |
|
79 Animation |
|
80 }; |
|
81 |
|
82 /*! Enum for control button identifier. */ |
|
83 enum ControlButtonIdentifier{ |
|
84 Power, |
|
85 Previous, |
|
86 Next |
|
87 }; |
|
88 |
|
89 /*! Enum for control button state. */ |
|
90 enum ControlButtonState{ |
|
91 Normal, |
|
92 Pressed, |
|
93 Disabled, |
|
94 Latched |
|
95 }; |
|
96 |
|
97 |
|
98 /*! Enum for information types published by radio. */ |
|
99 enum FmRadioInformationType { |
|
100 Frequency, |
|
101 StationName, |
|
102 RadioText, |
|
103 DynamicPsName, |
|
104 Pty |
|
105 }; |
|
106 |
|
107 signals: |
|
108 |
|
109 /* |
|
110 This signal allows your widget to save its properties persistently. |
|
111 Once properties are saved, the user may close and reopen the widget, |
|
112 and the stored properties will still be available. The names |
|
113 parameter contains names for the properties you want to store. The |
|
114 home screen framework reads the corresponding property values from |
|
115 the widget by calling QObject::property() method. Currently only |
|
116 QString type properties are supported. The home screen framework |
|
117 writes widget's properties just before calling the onInitialize slot. |
|
118 Both compile-time and dynamic properties are supported. Optional. |
|
119 */ |
|
120 //void setPreferences(const QStringList &names); |
|
121 |
|
122 /* |
|
123 Your widget can notify the home screen framework about its completion |
|
124 by emitting this signal. With the current implementation, the |
|
125 framework removes the widget after receiving this signal. Optional. |
|
126 */ |
|
127 //void finished(); |
|
128 |
|
129 /*! |
|
130 Widget can notify the home screen framework about errors in its |
|
131 execution by emitting this signal. With the current implementation, |
|
132 the framework removes the widget after receiving this signal. |
|
133 Optional. |
|
134 */ |
|
135 void error(); |
|
136 |
|
137 public slots: |
|
138 /* These slots (prefixed with "on") are called by the home screen |
|
139 * framework for controlling the widget's state during its lifetime. |
|
140 * They are automatically connected by the framework. |
|
141 */ |
|
142 |
|
143 /* Implement this slot if you want to be notified when your widget is |
|
144 * added to the home screen. Upon receiving this event, your widget can |
|
145 * perform any necessary initialization operations, such as preparing |
|
146 * connections and allocating resources. Optional. |
|
147 */ |
|
148 void onInitialize(); |
|
149 |
|
150 /* This slot is called when your widget is shown in the home screen. You |
|
151 * use this slot to activate your widget and begin processing data again |
|
152 * after being quiescent. Each home screen compatible widget must define |
|
153 * this slot. Mandatory. |
|
154 */ |
|
155 void onShow(); |
|
156 |
|
157 /* This slot is called when your widget is hidden from the home screen. |
|
158 * You use this function to deactivate your widget and put it into a |
|
159 * quiescent state. Each home screen compatible widget must define this |
|
160 * slot. Mandatory. |
|
161 */ |
|
162 void onHide(); |
|
163 |
|
164 /* Implement this slot if you want to be notified when your widget is |
|
165 * removed from the home screen. Upon receiving this event, your widget |
|
166 * should perform any necessary cleanup operations, such as remove cache |
|
167 * files, and release any resources it currently holds. Optional. |
|
168 */ |
|
169 //void onUninitialize(); |
|
170 |
|
171 |
|
172 void changeButtonToPressed(int controlButtonId); |
|
173 void changeButtonToReleased(int controlButtonId); |
|
174 |
|
175 private slots: |
|
176 void closeRadio(); |
|
177 void changeToPreviousStation(); |
|
178 void changeToNextStation(); |
|
179 void changeRadioToForeground(); |
|
180 void changeRadioToBackground(); |
|
181 void toggleRadioPower(); |
|
182 |
|
183 private: |
|
184 void load(const QString &docml); |
|
185 |
|
186 void handleSimilarRadioInformation( |
|
187 const FmRadioInformationType informationType, |
|
188 const QVariant &information); |
|
189 bool updateRadioInformation(const FmRadioInformationType informationType, |
|
190 const QString &information); |
|
191 void changeInRadioInformation(); |
|
192 void clearRadioInformation(); |
|
193 |
|
194 void changeInformationAreaLayout(const InformationAreaLayout layout); |
|
195 void changePowerButtonOn(const bool isPowerOn); |
|
196 void enableStationButtons(); |
|
197 void defineButton(HbPushButton &target, const QString &graphicsId, |
|
198 const QStringList &suffix, const QString &icon, |
|
199 const QString &iconColor); |
|
200 void buttonEvent(ControlButtonIdentifier buttonId, |
|
201 const ControlButtonState state); |
|
202 void changeButtonToDisabled(int controlButtonId); |
|
203 void changeButtonToEnabled(int controlButtonId); |
|
204 |
|
205 bool radioStartPermission(); |
|
206 |
|
207 private: |
|
208 // Data |
|
209 Q_DISABLE_COPY(RadioHsWidget) |
|
210 |
|
211 // UI components. |
|
212 /*! Button for capturing taps on information area. */ |
|
213 HbPushButton *mInformationAreaBackgroundButton; |
|
214 /*! Control button for power. */ |
|
215 HbPushButton *mPowerButton; |
|
216 /*! Control button for previous station. */ |
|
217 HbPushButton *mPreviousButton; |
|
218 /*! Control button for next station. */ |
|
219 HbPushButton *mNextButton; |
|
220 /*! Layout for information area. */ |
|
221 QGraphicsWidget *mInformationAreaTwoRowsLayout; |
|
222 /*! Label that is shown when there is only one row of information. */ |
|
223 HbLabel *mInformationLonelyRowLabel; |
|
224 /*! Label for first row when there is two rows of information. */ |
|
225 HbLabel *mInformationFirstRowLabel; |
|
226 // TODO: This label should be modified to support marquee scrolling when Orbit supports it. |
|
227 /*! Label for first second when there is two rows of information. */ |
|
228 HbLabel *mInformationSecondRowLabel; |
|
229 /*! Label for displaying animation. */ |
|
230 HbLabel *mAnimationIcon; |
|
231 |
|
232 /*! Stores the state of the FM Radio application. */ |
|
233 FmRadio::State mFmRadioState; |
|
234 |
|
235 /*! Stores the count of favorite stations. */ |
|
236 int mFavoriteStationCount; |
|
237 /*! Stores the value whether the current station is favorite or not. */ |
|
238 bool mCurrentStationIsFavorite; |
|
239 |
|
240 /*! Stores the radio information. */ |
|
241 QHash<FmRadioInformationType, QString> mRadioInformation; |
|
242 /*! |
|
243 String is used to format the text shown on first or only row from |
|
244 radio information. |
|
245 */ |
|
246 QString mRadioInformationFirstRow; |
|
247 /*! |
|
248 String is used to format the text shown on second row from |
|
249 radio information. |
|
250 */ |
|
251 QString mRadioInformationSecondRow; |
|
252 |
|
253 /*! Profile monitor is used to read P&S keys and profile information. */ |
|
254 RadioHsWidgetProfileReader *mProfileMonitor; |
|
255 |
|
256 /*! For communicating with the FM Radio through Qt Highway. */ |
|
257 RadioHsWidgetRadioServiceClient *mRadioServiceClient; |
|
258 |
|
259 }; |
|
260 |
|
261 #endif // RADIOHSWIDGET_H |