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