26 #include <QTime> |
26 #include <QTime> |
27 |
27 |
28 #include <hbtextitem.h> |
28 #include <hbtextitem.h> |
29 #include <hbmainwindow.h> |
29 #include <hbmainwindow.h> |
30 #include <hbview.h> |
30 #include <hbview.h> |
|
31 #include <hbextendedlocale.h> |
31 |
32 |
32 #include "hbstatusbar_p.h" |
33 #include "hbstatusbar_p.h" |
33 #include "hbstatusbar_p_p.h" |
34 #include "hbstatusbar_p_p.h" |
34 #include "hbstyleoptionstatusbar_p.h" |
35 #include "hbstyleoptionstatusbar_p.h" |
35 #include "hbsignalindicator_p.h" |
36 #include "hbsignalindicator_p.h" |
36 #include "hbbatteryindicator_p.h" |
37 #include "hbbatteryindicator_p.h" |
37 #include "hbindicatorgroup_p.h" |
38 #include "hbindicatorgroup_p.h" |
38 |
39 |
39 #if defined(Q_OS_SYMBIAN) |
40 #if defined(Q_OS_SYMBIAN) |
40 #include "hbindicatorsym_p.h" |
41 #include "hbindicatorsym_p.h" |
|
42 #include <bacntf.h> // CEnvironmentChangeNotifier |
|
43 #include <coemain.h> // EActivePriorityLogonA |
41 #else |
44 #else |
42 #include "hbindicatorwin32_p.h" |
45 #include "hbindicatorwin32_p.h" |
43 #endif // defined(Q_OS_SYMBIAN) |
46 #endif // defined(Q_OS_SYMBIAN) |
44 |
47 |
45 const int clockUpdateDelay = 10000; // 10 s |
48 const int clockUpdateDelay = 10000; // 10 s |
60 mSettingsIndicatorGroup(0), |
63 mSettingsIndicatorGroup(0), |
61 mMainWindow(0), |
64 mMainWindow(0), |
62 mPreviousProperties(0), |
65 mPreviousProperties(0), |
63 mIndicatorPrivate(0) |
66 mIndicatorPrivate(0) |
64 { |
67 { |
|
68 #if defined(Q_OS_SYMBIAN) |
|
69 // Register for system environment changes |
|
70 TCallBack envCallback(EnvChangeCallback, this); |
|
71 |
|
72 mEnvChangeNotifier = |
|
73 CEnvironmentChangeNotifier::NewL(EActivePriorityLogonA, envCallback); |
|
74 |
|
75 mEnvChangeNotifier->Start(); |
|
76 #endif |
65 } |
77 } |
66 |
78 |
67 HbStatusBarPrivate::~HbStatusBarPrivate() |
79 HbStatusBarPrivate::~HbStatusBarPrivate() |
68 { |
80 { |
69 mIndicatorPrivate->stopListen(); |
81 mIndicatorPrivate->stopListen(); |
70 delete mIndicatorPrivate; |
82 delete mIndicatorPrivate; |
|
83 |
|
84 #if defined(Q_OS_SYMBIAN) |
|
85 // Stop environment change notifications |
|
86 if (mEnvChangeNotifier) |
|
87 { |
|
88 mEnvChangeNotifier->Cancel(); |
|
89 delete mEnvChangeNotifier; |
|
90 } |
|
91 #endif |
71 } |
92 } |
72 |
93 |
73 void HbStatusBarPrivate::delayedConstruction() |
94 void HbStatusBarPrivate::delayedConstruction() |
74 { |
95 { |
75 Q_Q(HbStatusBar); |
96 Q_Q(HbStatusBar); |
136 } |
157 } |
137 |
158 |
138 void HbStatusBarPrivate::updateTime() |
159 void HbStatusBarPrivate::updateTime() |
139 { |
160 { |
140 Q_Q(HbStatusBar); |
161 Q_Q(HbStatusBar); |
141 // use QLocale to find out whether there is am/pm info |
162 |
142 QString timeFormat(QLocale().timeFormat(QLocale::ShortFormat)); |
163 QString timeFormat; |
143 |
164 // set the time format accordingly |
144 if(timeFormat.contains("ap", Qt::CaseInsensitive)) { |
165 if (HbExtendedLocale().timeStyle() == HbExtendedLocale::Time12) { |
145 timeFormat.clear(); |
166 timeFormat.clear(); |
146 timeFormat.insert(0, "hh:mm ap"); |
167 timeFormat.insert(0, "hh:mm ap"); |
147 } else { |
168 } else { |
148 timeFormat.clear(); |
169 timeFormat.clear(); |
149 timeFormat.insert(0, "hh:mm"); |
170 timeFormat.insert(0, "hh:mm"); |
154 // set time, using a proper formatting |
175 // set time, using a proper formatting |
155 mTimeText = current.toString(timeFormat); |
176 mTimeText = current.toString(timeFormat); |
156 |
177 |
157 q->updatePrimitives(); |
178 q->updatePrimitives(); |
158 } |
179 } |
|
180 |
|
181 #if defined(Q_OS_SYMBIAN) |
|
182 TInt HbStatusBarPrivate::EnvChangeCallback(TAny *aObject) |
|
183 { |
|
184 // Return value for functions used as TCallBack objects should be EFalse |
|
185 // unless the function is intended to be called again from a timer. |
|
186 return static_cast<HbStatusBarPrivate*>(aObject)->DoEnvChange(); |
|
187 } |
|
188 |
|
189 TInt HbStatusBarPrivate::DoEnvChange() |
|
190 { |
|
191 const TInt changes(mEnvChangeNotifier->Change()); |
|
192 if ((changes & EChangesLocale) || (changes & EChangesSystemTime)) |
|
193 { |
|
194 updateTime(); |
|
195 } |
|
196 return EFalse ; |
|
197 } |
|
198 #endif |
159 |
199 |
160 /* |
200 /* |
161 Constructor, the statusbar. |
201 Constructor, the statusbar. |
162 The \a parent is an optional parameter. |
202 The \a parent is an optional parameter. |
163 */ |
203 */ |