18 |
18 |
19 // System includes |
19 // System includes |
20 #include <QApplication> |
20 #include <QApplication> |
21 #include <QGesture> |
21 #include <QGesture> |
22 #include <QGestureEvent> |
22 #include <QGestureEvent> |
23 #include <QDebug> |
|
24 #include <QGraphicsSceneMouseEvent> |
23 #include <QGraphicsSceneMouseEvent> |
25 #include <QTranslator> |
24 |
26 #include <hbdocumentloader.h> |
25 #include <hbdocumentloader.h> |
27 #include <hbpushbutton.h> |
26 #include <hbpushbutton.h> |
28 #include <hblabel.h> |
27 #include <hblabel.h> |
29 #include <hbinstance.h> |
28 #include <hbinstance.h> |
30 #include <hbextendedlocale.h> |
29 #include <hbextendedlocale.h> |
31 #include <hbi18ndef.h> |
30 #include <hbi18ndef.h> |
32 #include <hbapplication.h> |
|
33 #include <hbaction.h> |
31 #include <hbaction.h> |
|
32 #include <hbtranslator.h> |
34 |
33 |
35 // User includes |
34 // User includes |
36 #include "alarmalertwidget_p.h" |
35 #include "alarmalertwidget_p.h" |
37 #include "alarmalert.h" |
36 #include "alarmalert.h" |
38 #include "alarmalertdocloader.h" |
37 #include "alarmalertdocloader.h" |
41 // AlarmAlertDialogPrivate::AlarmAlertDialogPrivate |
40 // AlarmAlertDialogPrivate::AlarmAlertDialogPrivate |
42 // rest of the details are commented in the header |
41 // rest of the details are commented in the header |
43 // --------------------------------------------------------- |
42 // --------------------------------------------------------- |
44 // |
43 // |
45 AlarmAlertDialogPrivate::AlarmAlertDialogPrivate(const QVariantMap ¶meters): |
44 AlarmAlertDialogPrivate::AlarmAlertDialogPrivate(const QVariantMap ¶meters): |
|
45 mTranslator(new HbTranslator("alarmui")), |
46 mClosedByClient(false), |
46 mClosedByClient(false), |
47 mIsSilenceKey(false) |
47 mIsSilenceKey(false) |
48 { |
48 { |
49 // Extract all the parameters sent by the client |
49 // Extract all the parameters sent by the client |
50 parseAndFetchParams(parameters); |
50 parseAndFetchParams(parameters); |
51 |
51 |
52 // Set the dismiss policy and timeout property |
52 // Set the dismiss policy and timeout property |
53 setDismissPolicy(HbPopup::NoDismiss); |
53 setDismissPolicy(HbPopup::NoDismiss); |
54 setTimeout(HbPopup::NoTimeout); |
54 setTimeout(HbPopup::NoTimeout); |
|
55 |
|
56 // Listen the signal when alarmui is about to display so that we can start playing the alarm tone. |
|
57 connect(this, SIGNAL(aboutToShow()), this, SLOT(aboutToDisplay()) ); |
55 |
58 |
56 // Initialize the user response |
59 // Initialize the user response |
57 mUserResponse = Other; |
60 mUserResponse = Other; |
58 |
|
59 // Load the translation file and install the editor specific translator |
|
60 mTranslator = new QTranslator; |
|
61 QString lang = QLocale::system().name(); |
|
62 QString path = "Z:/resource/qt/translations/"; |
|
63 bool loaded = mTranslator->load("alarmui_en_GB",":/translations"); |
|
64 // TODO: Load the appropriate .qm file based on locale |
|
65 //bool loaded = mTranslator->load("alarmui_" + lang, path); |
|
66 HbApplication::instance()->installTranslator(mTranslator); |
|
67 |
61 |
68 // TODO: Gestures not working. Integrate once support is available from Qt |
62 // TODO: Gestures not working. Integrate once support is available from Qt |
69 grabGesture(Qt::SwipeGesture); |
63 grabGesture(Qt::SwipeGesture); |
70 } |
64 } |
71 |
65 |
149 void AlarmAlertDialogPrivate::showEvent(QShowEvent *event) |
142 void AlarmAlertDialogPrivate::showEvent(QShowEvent *event) |
150 { |
143 { |
151 HbDialog::showEvent(event); |
144 HbDialog::showEvent(event); |
152 QVariantMap param; |
145 QVariantMap param; |
153 param.insert(alarmCommand, mUserResponse); |
146 param.insert(alarmCommand, mUserResponse); |
154 //emit deviceDialogData(param); |
147 emit deviceDialogData(param); |
155 } |
148 } |
156 |
149 |
157 // --------------------------------------------------------- |
150 // --------------------------------------------------------- |
158 // AlarmAlertDialogPrivate::closeEvent |
151 // AlarmAlertDialogPrivate::closeEvent |
159 // rest of the details are commented in the header |
152 // rest of the details are commented in the header |
160 // --------------------------------------------------------- |
153 // --------------------------------------------------------- |
161 // |
154 // |
162 void AlarmAlertDialogPrivate::closeEvent(QCloseEvent *event) |
155 void AlarmAlertDialogPrivate::closeEvent(QCloseEvent *event) |
163 { |
156 { |
164 // Forward the call to the base class |
157 |
165 HbDialog::closeEvent(event); |
|
166 |
|
167 // Do not notify the client back if the close was initiated by client itself |
158 // Do not notify the client back if the close was initiated by client itself |
168 if(!mClosedByClient) { |
159 if(!mClosedByClient) { |
169 // Package the user response and send it |
160 // Package the user response and send it |
170 QVariantMap param; |
161 QVariantMap param; |
171 param.insert(alarmCommand, mUserResponse); |
162 param.insert(alarmCommand, mUserResponse); |
172 emit deviceDialogData(param); |
163 emit deviceDialogData(param); |
173 } |
164 } |
174 // This signal has to be emitted so that the dialog can be cleaned up later |
165 // This signal has to be emitted so that the dialog can be cleaned up later |
175 emit deviceDialogClosed(); |
166 emit deviceDialogClosed(); |
|
167 |
|
168 // Forward the call to the base class |
|
169 HbDialog::closeEvent(event); |
176 } |
170 } |
177 |
171 |
178 // --------------------------------------------------------- |
172 // --------------------------------------------------------- |
179 // AlarmAlertDialogPrivate::handleOrientationChange |
173 // AlarmAlertDialogPrivate::handleOrientationChange |
180 // rest of the details are commented in the header |
174 // rest of the details are commented in the header |
213 }else { |
207 }else { |
214 mUserResponse = Snooze; |
208 mUserResponse = Snooze; |
215 close(); |
209 close(); |
216 } |
210 } |
217 } |
211 } |
218 |
212 |
|
213 // --------------------------------------------------------- |
|
214 // AlarmAlertDialogPrivate::aboutToDisplay |
|
215 // rest of the details are commented in the header |
|
216 // --------------------------------------------------------- |
|
217 // |
|
218 void AlarmAlertDialogPrivate::aboutToDisplay() |
|
219 { |
|
220 mUserResponse = Shown; |
|
221 QVariantMap param; |
|
222 param.insert(alarmCommand, mUserResponse); |
|
223 emit deviceDialogData(param); |
|
224 } |
|
225 |
219 // --------------------------------------------------------- |
226 // --------------------------------------------------------- |
220 // AlarmAlertDialogPrivate::dismissed |
227 // AlarmAlertDialogPrivate::dismissed |
221 // rest of the details are commented in the header |
228 // rest of the details are commented in the header |
222 // --------------------------------------------------------- |
229 // --------------------------------------------------------- |
223 // |
230 // |
241 QString key(iter.key()); |
248 QString key(iter.key()); |
242 if (alarmSubject == key) { |
249 if (alarmSubject == key) { |
243 mSubject = iter.value().toString(); |
250 mSubject = iter.value().toString(); |
244 } else if (alarmLocation == key) { |
251 } else if (alarmLocation == key) { |
245 mLocation = iter.value().toString(); |
252 mLocation = iter.value().toString(); |
246 } else if (alarmDateTime == key) { |
253 } else if (alarmTime == key) { |
247 mAlarmTime = iter.value().toDateTime(); |
254 mAlarmTime = iter.value().toString(); |
|
255 } else if (alarmDate == key) { |
|
256 mAlarmDate = iter.value().toString(); |
248 } else if (alarmType == key) { |
257 } else if (alarmType == key) { |
249 mAlarmAlertType = static_cast <AlarmType> (iter.value().toInt()); |
258 mAlarmAlertType = static_cast <AlarmType> (iter.value().toInt()); |
250 } else if (alarmCanSnooze == key) { |
259 } else if (alarmCanSnooze == key) { |
251 mCanSnooze = iter.value().toBool(); |
260 mCanSnooze = iter.value().toBool(); |
252 } else if (alarmRingingType == key) { |
261 } else if (alarmRingingType == key) { |
300 if (!mAlarmDateTime) { |
309 if (!mAlarmDateTime) { |
301 qFatal("Unable to load the alarmTime label"); |
310 qFatal("Unable to load the alarmTime label"); |
302 } |
311 } |
303 HbExtendedLocale locale = HbExtendedLocale::system(); |
312 HbExtendedLocale locale = HbExtendedLocale::system(); |
304 mAlarmDateTime->setPlainText( |
313 mAlarmDateTime->setPlainText( |
305 hbTrId("txt_calendar_info_alarm_start_time").arg( |
314 hbTrId("txt_calendar_info_alarm_start_time").arg(mAlarmTime)); |
306 locale.format(mAlarmTime.time(), r_qtn_time_usual))); |
|
307 |
315 |
308 mAlarmDescription = qobject_cast<HbLabel*> ( |
316 mAlarmDescription = qobject_cast<HbLabel*> ( |
309 mAlertDocLoader->findWidget("alarmDescription")); |
317 mAlertDocLoader->findWidget("alarmDescription")); |
310 if (!mAlarmDescription) { |
318 if (!mAlarmDescription) { |
311 qFatal("Unable to load the alarmDescription label"); |
319 qFatal("Unable to load the alarmDescription label"); |
365 mAlertDocLoader->findWidget("alarmTime")); |
373 mAlertDocLoader->findWidget("alarmTime")); |
366 if (!mAlarmDateTime) { |
374 if (!mAlarmDateTime) { |
367 qFatal("Unable to find the alarmTime label"); |
375 qFatal("Unable to find the alarmTime label"); |
368 } |
376 } |
369 mAlarmDateTime->setPlainText( |
377 mAlarmDateTime->setPlainText( |
370 hbTrId("txt_calendar_info_alarm_start_time").arg( |
378 hbTrId("txt_calendar_info_alarm_start_time").arg(mAlarmTime)); |
371 locale.format(mAlarmTime.time(), r_qtn_time_usual))); |
|
372 HbLabel *alarmDate = qobject_cast<HbLabel*> ( |
379 HbLabel *alarmDate = qobject_cast<HbLabel*> ( |
373 mAlertDocLoader->findWidget("alarmDate")); |
380 mAlertDocLoader->findWidget("alarmDate")); |
374 if (!alarmDate) { |
381 if (!alarmDate) { |
375 qFatal("Unable to find the alarmDate label"); |
382 qFatal("Unable to find the alarmDate label"); |
376 } |
383 } |
377 alarmDate->setPlainText( |
384 alarmDate->setPlainText( |
378 hbTrId("txt_calendar_info_alarm_start_date").arg( |
385 hbTrId("txt_calendar_info_alarm_start_date").arg(mAlarmDate)); |
379 locale.format(mAlarmTime.date(), r_qtn_date_usual_with_zero))); |
|
380 HbLabel *alarmDateNonTimed = qobject_cast<HbLabel*> ( |
386 HbLabel *alarmDateNonTimed = qobject_cast<HbLabel*> ( |
381 mAlertDocLoader->findWidget("nonTimedAlarmDate")); |
387 mAlertDocLoader->findWidget("nonTimedAlarmDate")); |
382 if (!alarmDateNonTimed) { |
388 if (!alarmDateNonTimed) { |
383 qFatal("Unable to find the nonTimedAlarmDate label"); |
389 qFatal("Unable to find the nonTimedAlarmDate label"); |
384 } |
390 } |
405 mAlertDocLoader->findWidget("nonTimedAlarmDate")); |
411 mAlertDocLoader->findWidget("nonTimedAlarmDate")); |
406 if (!alarmDateNonTimed) { |
412 if (!alarmDateNonTimed) { |
407 qFatal("Unable to find the alarmDateNonTimed label"); |
413 qFatal("Unable to find the alarmDateNonTimed label"); |
408 } |
414 } |
409 alarmDateNonTimed->setPlainText( |
415 alarmDateNonTimed->setPlainText( |
410 hbTrId("txt_calendar_info_alarm_start_date").arg( |
416 hbTrId("txt_calendar_info_alarm_start_date").arg(mAlarmDate)); |
411 locale.format(mAlarmTime.date(), r_qtn_date_usual_with_zero))); |
|
412 } |
417 } |
413 |
418 |
414 QGraphicsWidget *headingWidget = mAlertDocLoader->findWidget("heading"); |
419 QGraphicsWidget *headingWidget = mAlertDocLoader->findWidget("heading"); |
415 if (!headingWidget) { |
420 if (!headingWidget) { |
416 qFatal("Unable to find the heading widget"); |
421 qFatal("Unable to find the heading widget"); |
480 mAlertDocLoader->findWidget("alarmDate")); |
485 mAlertDocLoader->findWidget("alarmDate")); |
481 if (!alarmDate) { |
486 if (!alarmDate) { |
482 qFatal("Unable to load the alarmDate label"); |
487 qFatal("Unable to load the alarmDate label"); |
483 } |
488 } |
484 alarmDate->setPlainText( |
489 alarmDate->setPlainText( |
485 hbTrId("txt_calendar_info_alarm_start_date").arg( |
490 hbTrId("txt_calendar_info_alarm_start_date").arg(mAlarmDate)); |
486 locale.format(mAlarmTime.date(), r_qtn_date_usual_with_zero))); |
|
487 |
491 |
488 mAlarmDescription = qobject_cast<HbLabel*> ( |
492 mAlarmDescription = qobject_cast<HbLabel*> ( |
489 mAlertDocLoader->findWidget("alarmDescription")); |
493 mAlertDocLoader->findWidget("alarmDescription")); |
490 if (!mAlarmDescription) { |
494 if (!mAlarmDescription) { |
491 qFatal("Unable to load the alarmDescription label"); |
495 qFatal("Unable to load the alarmDescription label"); |