author | Pat Downey <patd@symbian.org> |
Wed, 23 Jun 2010 17:20:24 +0100 | |
changeset 29 | 29ba091146f4 |
parent 28 | 075425b8d9a4 |
permissions | -rw-r--r-- |
24 | 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 FMRADIOHSWIDGET_H |
|
19 |
#define FMRADIOHSWIDGET_H |
|
20 |
||
21 |
// System includes |
|
22 |
#include <HbWidget> |
|
23 |
||
24 |
// User includes |
|
25 |
#include "fmradiohswidgetradioserviceclient.h" |
|
26 |
||
27 |
// Forward declarations |
|
28 |
class HbLabel; |
|
29 |
class HbPushButton; |
|
30 |
class HbMarqueeItem; |
|
31 |
class XQSettingsManager; |
|
32 |
class XQSettingsKey; |
|
33 |
class FmRadioHsWidgetProcessHandler; |
|
34 |
class FmRadioHsWidgetProfileReader; |
|
35 |
class QGraphicsLinearLayout; |
|
36 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
37 |
// Constants |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
38 |
/** Path to docml file */ |
24 | 39 |
const QString KDocml = ":/ui/resource/fmradiohswidget.docml"; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
40 |
/** Path to css file */ |
24 | 41 |
const QString KCss = ":/ui/resource/fmradiohswidgetplugin.css"; |
42 |
/** Key for radio information hash. */ |
|
43 |
const QString KRadioInformationStationName = "stationName"; |
|
44 |
/** Key for radio information hash. */ |
|
45 |
const QString KRadioInformationFrequency = "frequency"; |
|
46 |
/** Key for radio information hash. */ |
|
47 |
const QString KRadioInformationRt = "rt"; |
|
48 |
/** Key for radio information hash. */ |
|
49 |
const QString KRadioInformationDynamicPsName = "dynamicPsName"; |
|
50 |
/** Key for radio information hash. */ |
|
51 |
const QString KRadioInformationPty = "pty"; |
|
52 |
/** DOCML object name for mainLayout */ |
|
53 |
const QString KDocmlObjectNameMainLayout = "mainLayout"; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
54 |
/** DOCML object name for tunerBackgroundPushButton */ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
55 |
const QString KDocmlObjectNameTunerBackgroundPushButton = "tunerBackgroundPushButton"; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
56 |
/** DOCML object name for tunerStackedLayout */ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
57 |
const QString KDocmlObjectNameTunerStackedLayout = "tunerStackedLayout"; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
58 |
/** DOCML object name for tunerInformationStackedLayout */ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
59 |
const QString KDocmlObjectNameTunerInformationStackedLayout = "tunerInformationStackedLayout"; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
60 |
/** DOCML object name for controlButtons */ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
61 |
const QString KDocmlObjectNameContolButtonsLayout = "controlButtons"; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
62 |
/** DOCML object name for powerToggleButton */ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
63 |
const QString KDocmlObjectNameowerToggleButton = "powerToggleButton"; |
24 | 64 |
/** DOCML object name for previousPushButton */ |
65 |
const QString KDocmlObjectNamePreviousPushButton = "previousPushButton"; |
|
66 |
/** DOCML object name for nextPushButton */ |
|
67 |
const QString KDocmlObjectNameNextPushButton = "nextPushButton"; |
|
68 |
/** DOCML object name for twoRowsLayout */ |
|
69 |
const QString KDocmlObjectNameTwoRowsLayout = "twoRowsLayout"; |
|
70 |
/** DOCML object name for firstRowLabel */ |
|
71 |
const QString KDocmlObjectNameFirstRowLabel = "firstRowLabel"; |
|
72 |
/** DOCML object name for secondRowLabel */ |
|
73 |
const QString KDocmlObjectNameSecondRowLabel = "secondRowLabel"; |
|
74 |
/** DOCML object name for lonelyRowLabel */ |
|
75 |
const QString KDocmlObjectNameLonelyRowLabel = "lonelyRowLabel"; |
|
76 |
/** DOCML object name for animationIcon */ |
|
77 |
const QString KDocmlObjectNameAnimationIcon = "animationIcon"; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
78 |
/** Delay which after the widget returns to the state where radio is not running. */ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
79 |
const int KRadioStartingStateCancelDelay = 10000; |
24 | 80 |
|
81 |
class FmRadioHsWidget : public HbWidget |
|
82 |
{ |
|
83 |
Q_OBJECT |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
84 |
Q_PROPERTY(QString rootPath READ rootPath WRITE setRootPath) |
24 | 85 |
public: |
86 |
FmRadioHsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags flags = 0); |
|
87 |
~FmRadioHsWidget(); |
|
88 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
89 |
public: |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
90 |
// Enum for commands controlling FM Radio. |
24 | 91 |
enum FmRadioControlCommand |
92 |
{ |
|
93 |
Mute, |
|
94 |
Unmute, |
|
95 |
PreviousChannel, |
|
96 |
NextChannel |
|
97 |
}; |
|
98 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
99 |
// Enum for FM Radio states. |
24 | 100 |
enum FmRadioState |
101 |
{ |
|
102 |
Undefined, |
|
103 |
NotRunning, |
|
104 |
Starting, |
|
105 |
Running, |
|
106 |
ControllingAudio, |
|
107 |
NotControllingAudio, |
|
108 |
Seeking, |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
109 |
AntennaNotConnected, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
110 |
Closing |
24 | 111 |
}; |
112 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
113 |
// Enum for information area layout states. |
24 | 114 |
enum InformationAreaLayout |
115 |
{ |
|
116 |
OneRow, |
|
117 |
TwoRows, |
|
118 |
Animation |
|
119 |
}; |
|
120 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
121 |
// Enum for control button position. |
24 | 122 |
enum ControlButtonPosition |
123 |
{ |
|
124 |
Left, |
|
125 |
Center, |
|
126 |
Right |
|
127 |
}; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
128 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
129 |
QString rootPath()const; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
130 |
void setRootPath(const QString &rootPath); |
24 | 131 |
|
132 |
public slots: |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
133 |
void onInitialize(); |
24 | 134 |
void onShow(); |
135 |
void onHide(); |
|
136 |
//void onUninitialize(); // Can be used in future to get on unintialize event. |
|
137 |
||
138 |
private slots: |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
139 |
void load(const QString &docml); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
140 |
void closeRadio(); |
24 | 141 |
void previousChannel(); |
142 |
void nextChannel(); |
|
143 |
void radioToForeground(); |
|
144 |
void radioToBackground(); |
|
145 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
146 |
void handleRadioInformationChange(const int notificationId, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
147 |
const QVariant &value); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
148 |
bool updateRadioInformation(const QString &informationType, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
149 |
const QString &information); |
24 | 150 |
void radioInformationChanged(); |
151 |
void clearRadioInformation(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
152 |
void handleRadioStateChange(const QVariant &value); |
24 | 153 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
154 |
void changeInformationAreaLayout(const InformationAreaLayout layout); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
155 |
void changePowerButtonOn(const bool isPowerOn); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
156 |
void changeStationButtonsEnabledState(const bool enabled); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
157 |
void changeControlButtonFrameBackground(const bool enabled, |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
158 |
const ControlButtonPosition position, HbPushButton *button); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
159 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
160 |
void cancelRadioStartingState(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
161 |
void stopRadioStartingCancelTimer(); |
24 | 162 |
|
163 |
private: |
|
164 |
// Data |
|
165 |
Q_DISABLE_COPY(FmRadioHsWidget) |
|
166 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
167 |
QString mRootPath; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
168 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
169 |
// UI components. |
24 | 170 |
HbPushButton *mRadioPushButton; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
171 |
HbPushButton *mTunerBackgroundPushButton; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
172 |
HbPushButton *mPowerToggleButton; |
24 | 173 |
HbPushButton *mPreviousPushButton; |
174 |
HbPushButton *mNextPushButton; |
|
175 |
QGraphicsWidget *mInformationAreaTwoRowsLayout; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
176 |
HbLabel *mInformationFirstRowLabel; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
177 |
HbLabel *mInformationSecondRowLabel; |
24 | 178 |
HbLabel *mInformationLonelyRowLabel; |
179 |
HbLabel *mAnimationIcon; |
|
180 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
181 |
// Stores the state of the FM Radio application. |
24 | 182 |
FmRadioState mFmRadioState; |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
183 |
// Stores the presence of favorite stations. |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
184 |
bool mFavoriteStations; |
24 | 185 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
186 |
// Stores the radio information. |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
187 |
QHash<QString, QString> mRadioInformation; |
24 | 188 |
QString mRadioInformationFirstRow; |
189 |
QString mRadioInformationSecondRow; |
|
190 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
191 |
// For reading P&S keys. |
24 | 192 |
FmRadioHsWidgetProfileReader *mProfileMonitor; |
193 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
194 |
// For communicating with the FM Radio through Qt Highway. |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
195 |
FmRadioHsWidgetRadioServiceClient *mRadioServiceClient; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
196 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
197 |
// For cancelinf the starting state after a delay. |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
198 |
QTimer *mRadioStartingCancelTimer; |
24 | 199 |
|
200 |
}; |
|
201 |
||
202 |
#endif // FMRADIOHSWIDGET_H |