53 */ |
53 */ |
54 |
54 |
55 // Local constants |
55 // Local constants |
56 const int INFOWIDGET_DEFAULT_HEIGHT = 100; |
56 const int INFOWIDGET_DEFAULT_HEIGHT = 100; |
57 const int INFOWIDGET_DEFAULT_WIDTH = 200; |
57 const int INFOWIDGET_DEFAULT_WIDTH = 200; |
|
58 const int INFOWIDGET_MARQUEE_START_DELAY = 5000; |
58 const char *TS_FILE_OPERATOR_WIDGET = "operator_widget"; |
59 const char *TS_FILE_OPERATOR_WIDGET = "operator_widget"; |
59 const char *TS_FILE_COMMON = "common"; |
60 const char *TS_FILE_COMMON = "common"; |
60 const char *BACKGROUND_FRAME_NAME = "qtg_fr_hswidget_normal"; |
61 const char *BACKGROUND_FRAME_NAME = "qtg_fr_hswidget_normal"; |
61 |
62 |
62 /*! |
63 /*! |
63 InfoWidget::InfoWidget() |
64 Constructor. |
64 */ |
65 */ |
65 InfoWidget::InfoWidget(QGraphicsItem* parent, Qt::WindowFlags flags) |
66 InfoWidget::InfoWidget(QGraphicsItem* parent, Qt::WindowFlags flags) |
66 : HbWidget(parent, flags), |
67 : HbWidget(parent, flags), |
67 m_animationState(AnimationIdle), |
68 m_animationState(AnimationIdle), |
68 m_engine(NULL), |
69 m_engine(NULL), |
118 // transferred for frame item |
118 // transferred for frame item |
119 m_backgroundFrameItem = new HbFrameItem( |
119 m_backgroundFrameItem = new HbFrameItem( |
120 backgroundFrameDrawer.take(), this); |
120 backgroundFrameDrawer.take(), this); |
121 |
121 |
122 setBackgroundItem(m_backgroundFrameItem); |
122 setBackgroundItem(m_backgroundFrameItem); |
123 |
123 } |
124 DPRINT << ": OUT"; |
124 |
125 } |
125 /*! |
126 |
126 Destructor. |
127 /*! |
|
128 InfoWidget::~InfoWidget() |
|
129 */ |
127 */ |
130 InfoWidget::~InfoWidget() |
128 InfoWidget::~InfoWidget() |
131 { |
129 { |
132 DPRINT << ": IN"; |
130 DPRINT; |
133 |
|
134 // Force layout manager to delete widgets |
131 // Force layout manager to delete widgets |
135 // before InfoWidget is destroyed |
132 // before InfoWidget is destroyed |
136 m_layoutManager->destroyWidgets(); |
133 m_layoutManager->destroyWidgets(); |
137 |
134 |
138 // Remove and delete language translators |
135 // Remove and delete language translators |
139 removeTranslators(); |
136 removeTranslators(); |
140 |
|
141 DPRINT << ": OUT"; |
|
142 UNINSTALL_TRACE_MSG_HANDLER; |
137 UNINSTALL_TRACE_MSG_HANDLER; |
143 } |
138 } |
144 |
139 |
145 /*! |
140 /*! |
146 InfoWidget::onInitialize() |
|
147 |
|
148 Called by HS framework, saved preference data |
141 Called by HS framework, saved preference data |
149 is available when onInitialize() is called and |
142 is available when onInitialize() is called and |
150 meta-object data reading should be done here |
143 meta-object data reading should be done here. |
151 */ |
144 */ |
152 void InfoWidget::onInitialize() |
145 void InfoWidget::onInitialize() |
153 { |
146 { |
154 DPRINT << ": IN"; |
147 DPRINT; |
155 |
|
156 m_initialized = true; |
148 m_initialized = true; |
157 |
|
158 // Initialize preferences from meta-object data |
149 // Initialize preferences from meta-object data |
159 if (!readPersistentPreferences()) { |
150 if (!readPersistentPreferences()) { |
160 |
151 |
161 // Reading failed, initialize default values |
152 // Reading failed, initialize default values |
162 m_preferences->setPreference(InfoWidgetPreferences::DisplaySpn, |
153 m_preferences->setPreference(InfoWidgetPreferences::DisplaySpn, |
175 m_backgroundFrameItem->resize(size()); |
166 m_backgroundFrameItem->resize(size()); |
176 |
167 |
177 // Listen for model changes |
168 // Listen for model changes |
178 QObject::connect(m_engine.data(), SIGNAL(modelChanged()), |
169 QObject::connect(m_engine.data(), SIGNAL(modelChanged()), |
179 this, SLOT(readModel()), Qt::UniqueConnection); |
170 this, SLOT(readModel()), Qt::UniqueConnection); |
180 |
171 } |
181 DPRINT << ": OUT"; |
172 |
182 } |
173 /*! |
183 |
174 This slot is called by HomeScreen framework |
184 /*! |
175 when the widget is uninstalled. |
185 InfoWidget::onUninitialize() |
|
186 */ |
176 */ |
187 void InfoWidget::onUninitialize() |
177 void InfoWidget::onUninitialize() |
188 { |
178 { |
189 DPRINT << ": IN"; |
179 DPRINT; |
190 stopMarquees(); |
180 stopMarquees(); |
191 m_initialized = false; |
181 m_initialized = false; |
192 m_engine->suspend(); |
182 m_engine->suspend(); |
193 DPRINT << ": OUT"; |
183 } |
194 } |
184 |
195 |
185 /*! |
196 /*! |
186 This slot is called by HomeScreen framework |
197 InfoWidget::onShow() |
187 when the widget visibility is gained. |
198 */ |
188 */ |
199 void InfoWidget::onShow() |
189 void InfoWidget::onShow() |
200 { |
190 { |
201 DPRINT; |
191 DPRINT; |
202 if (m_initialized) { |
192 if (m_initialized) { |
256 if (translatorLoaded) { |
246 if (translatorLoaded) { |
257 qApp->installTranslator(widgetTranslator.data()); |
247 qApp->installTranslator(widgetTranslator.data()); |
258 m_translators.append(widgetTranslator.take()); |
248 m_translators.append(widgetTranslator.take()); |
259 DPRINT << ": translator installed: " << translationFile; |
249 DPRINT << ": translator installed: " << translationFile; |
260 } |
250 } |
261 |
|
262 DPRINT << ": OUT"; |
|
263 return translatorLoaded; |
251 return translatorLoaded; |
264 } |
252 } |
265 |
253 |
266 /*! |
254 /*! |
267 InfoWidget::removeTranslators() |
255 Remove translators. No need to call |
268 |
256 QApplication::removeTranslator, |
269 Remove translators from qApp and delete objects |
257 QTranslator object removes itself before deletion. |
270 */ |
258 */ |
271 void InfoWidget::removeTranslators() |
259 void InfoWidget::removeTranslators() |
272 { |
260 { |
273 DPRINT << ": IN"; |
261 DPRINT; |
274 |
|
275 foreach (QTranslator *translator, m_translators) { |
|
276 qApp->removeTranslator(translator); |
|
277 } |
|
278 qDeleteAll(m_translators); |
262 qDeleteAll(m_translators); |
279 m_translators.clear(); |
263 m_translators.clear(); |
280 |
264 } |
281 DPRINT << ": OUT"; |
265 |
282 } |
266 /*! |
283 |
267 Returns bounding rect. |
284 /*! |
|
285 InfoWidget::boundingRect() |
|
286 */ |
268 */ |
287 QRectF InfoWidget::boundingRect() const |
269 QRectF InfoWidget::boundingRect() const |
288 { |
270 { |
289 return rect(); |
271 return rect(); |
290 } |
272 } |
291 |
273 |
292 /*! |
274 /*! |
293 InfoWidget::sizeHint() |
275 Calculate widget size hint based on visible row count. |
294 |
|
295 Calculate size hint based on visible rows count |
|
296 */ |
276 */ |
297 QSizeF InfoWidget::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const |
277 QSizeF InfoWidget::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const |
298 { |
278 { |
299 Q_UNUSED(which); |
279 Q_UNUSED(which); |
300 Q_UNUSED(constraint); |
280 Q_UNUSED(constraint); |
367 } else { |
346 } else { |
368 m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatMarqueeItem); |
347 m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatMarqueeItem); |
369 m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatTextIcon); |
348 m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatTextIcon); |
370 } |
349 } |
371 |
350 |
372 DPRINT << ": visible layout rows count: " << layoutRows; |
351 if (m_animatingItems.count() == 0) { |
|
352 m_animatingItem = NULL; |
|
353 } |
|
354 |
373 m_layoutManager->setLayoutRows(layoutRows); |
355 m_layoutManager->setLayoutRows(layoutRows); |
374 } |
356 } |
375 |
357 |
376 /*! |
358 /*! |
377 InfoWidget::layoutInfoDisplay() |
359 Layout info display. |
378 |
|
379 Layout info display |
|
380 */ |
360 */ |
381 void InfoWidget::layoutInfoDisplay() |
361 void InfoWidget::layoutInfoDisplay() |
382 { |
362 { |
383 DPRINT << ": IN"; |
363 DPRINT; |
384 |
|
385 QGraphicsLayout *infoDisplayLayout = |
364 QGraphicsLayout *infoDisplayLayout = |
386 m_layoutManager->layoutInfoDisplay(); |
365 m_layoutManager->layoutInfoDisplay(); |
387 |
366 |
388 if (!m_layout->count()) { |
367 if (!m_layout->count()) { |
389 QGraphicsWidget *contentWidget = |
368 QGraphicsWidget *contentWidget = |
418 HbDialog *settingsDialog = qobject_cast<HbDialog *>( |
392 HbDialog *settingsDialog = qobject_cast<HbDialog *>( |
419 m_layoutManager->getWidget(InfoWidgetLayoutManager:: |
393 m_layoutManager->getWidget(InfoWidgetLayoutManager:: |
420 RoleSettingsDialog)); |
394 RoleSettingsDialog)); |
421 |
395 |
422 if (settingsDialog) { |
396 if (settingsDialog) { |
423 DPRINT << ": settingsDialog has been returned from layout manager"; |
|
424 initializeSettingsDialogItems(); |
397 initializeSettingsDialogItems(); |
425 |
|
426 settingsDialog->setDismissPolicy(HbDialog::NoDismiss); |
398 settingsDialog->setDismissPolicy(HbDialog::NoDismiss); |
427 settingsDialog->setTimeout(HbDialog::NoTimeout); |
399 settingsDialog->setTimeout(HbDialog::NoTimeout); |
428 settingsDialog->open(this, |
400 settingsDialog->open(this, |
429 SLOT(settingsDialogClosed(HbAction *))); |
401 SLOT(settingsDialogClosed(HbAction *))); |
430 } |
402 } |
431 } |
403 } |
432 DPRINT << ": OUT"; |
404 } |
433 } |
405 |
434 |
406 /*! |
435 /*! |
|
436 InfoWidget::initializeSettingsDialogItems() |
|
437 |
|
438 Set up initial check box states |
407 Set up initial check box states |
439 and connect signals to local slots |
408 and connect signals to local slots. |
440 */ |
409 */ |
441 void InfoWidget::initializeSettingsDialogItems() |
410 void InfoWidget::initializeSettingsDialogItems() |
442 { |
411 { |
443 DPRINT << ": IN"; |
412 DPRINT; |
444 |
|
445 // Connect display setting check boxes |
413 // Connect display setting check boxes |
446 HbCheckBox *spnCheckBox = |
414 HbCheckBox *spnCheckBox = |
447 qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
415 qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
448 InfoWidgetLayoutManager::RoleSpnCheckBox)); |
416 InfoWidgetLayoutManager::RoleSpnCheckBox)); |
449 if (spnCheckBox) { |
417 if (spnCheckBox) { |
512 } |
476 } |
513 } |
477 } |
514 } |
478 } |
515 |
479 |
516 /*! |
480 /*! |
517 InfoWidget::updateInfoDisplay() |
|
518 |
|
519 Model or visibility data has changed, |
481 Model or visibility data has changed, |
520 update info display widgets accordingly. |
482 update info display widgets accordingly. |
521 */ |
483 */ |
522 void InfoWidget::updateInfoDisplay() |
484 void InfoWidget::updateInfoDisplay() |
523 { |
485 { |
524 DPRINT << ": IN"; |
486 DPRINT; |
525 |
|
526 if (m_initialized) { |
487 if (m_initialized) { |
527 stopMarquees(); |
488 stopMarquees(); |
528 |
489 |
529 if (m_layoutManager->currentDisplayRole() == |
490 if (m_layoutManager->currentDisplayRole() == |
530 InfoWidgetLayoutManager::InfoDisplay ) |
491 InfoWidgetLayoutManager::InfoDisplay) { |
531 { |
492 |
532 QString text; |
|
533 InfoWidgetEngine::ModelData modelData = m_engine->modelData(); |
493 InfoWidgetEngine::ModelData modelData = m_engine->modelData(); |
534 |
494 |
535 // Update service provider name item |
495 // Update service provider name item |
536 text = modelData.serviceProviderName(); |
496 QString text = modelData.serviceProviderName(); |
537 updateInfoDisplayItem(InfoWidgetLayoutManager::RoleSpnMarqueeItem, text); |
497 updateInfoDisplayItem( |
|
498 InfoWidgetLayoutManager::RoleSpnMarqueeItem, text); |
538 |
499 |
539 // Update MCN name item |
500 // Update MCN name item |
540 text = modelData.mcnName(); |
501 text = modelData.mcnName(); |
541 updateInfoDisplayItem(InfoWidgetLayoutManager::RoleMcnMarqueeItem, text); |
502 updateInfoDisplayItem( |
|
503 InfoWidgetLayoutManager::RoleMcnMarqueeItem, text); |
542 |
504 |
543 // Update SAT display text item |
505 // Update SAT display text item |
544 text = modelData.satDisplayText(); |
506 text = modelData.satDisplayText(); |
545 updateInfoDisplayItem(InfoWidgetLayoutManager::RoleSatMarqueeItem, text); |
507 updateInfoDisplayItem( |
|
508 InfoWidgetLayoutManager::RoleSatMarqueeItem, text); |
546 } |
509 } |
547 |
510 |
548 if (m_animatingItems.count() > 0) { |
511 if (m_animatingItems.count() > 0) { |
549 startMarquees(StartDelayed); |
512 startMarquees(); |
550 } |
513 } |
551 } |
514 } |
552 } |
515 } |
553 |
516 |
554 /*! |
517 /*! |
555 InfoWidget::readModel() |
518 Read model data. |
556 |
519 Model's modelChanged - signal is connected to this slot. |
557 Read model data. Model's modelChanged - signal is connected to this slot. |
|
558 */ |
520 */ |
559 void InfoWidget::readModel() |
521 void InfoWidget::readModel() |
560 { |
522 { |
561 DPRINT << ": IN"; |
523 DPRINT; |
562 |
|
563 if (m_layoutManager->currentDisplayRole() == |
524 if (m_layoutManager->currentDisplayRole() == |
564 InfoWidgetLayoutManager::InfoDisplay) { |
525 InfoWidgetLayoutManager::InfoDisplay) { |
565 updateInfoDisplay(); |
526 updateInfoDisplay(); |
566 } |
527 } |
567 DPRINT << ": OUT"; |
528 } |
568 } |
529 |
569 |
530 /*! |
570 /*! |
531 Model error signal is connected to this slot. |
571 InfoWidget::handleModelError() |
|
572 |
|
573 Model error signal is connected to this slot |
|
574 */ |
532 */ |
575 void InfoWidget::handleModelError(int operation,int errorCode) |
533 void InfoWidget::handleModelError(int operation,int errorCode) |
576 { |
534 { |
577 DWARNING << ": operation: " << operation << " error: " << errorCode; |
535 DWARNING << ": operation: " << operation << |
578 } |
536 " error: " << errorCode; |
579 |
537 } |
580 /*! |
538 |
581 InfoWidget::mousePressEvent() |
539 /*! |
|
540 Mouse press handler. |
582 */ |
541 */ |
583 void InfoWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) |
542 void InfoWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) |
584 { |
543 { |
585 Q_UNUSED(event); |
544 Q_UNUSED(event); |
586 |
|
587 // Clear flag |
545 // Clear flag |
588 m_dragEvent = false; |
546 m_dragEvent = false; |
589 } |
547 } |
590 |
548 |
591 /*! |
549 /*! |
592 InfoWidget::mouseReleaseEvent() |
550 Mouse release handler. |
593 */ |
551 */ |
594 void InfoWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
552 void InfoWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
595 { |
553 { |
596 Q_UNUSED(event); |
554 Q_UNUSED(event); |
597 |
555 // If widget wasn't dragged |
598 // If in info display and widget wasn't dragged |
|
599 // layout and open settings dialog |
556 // layout and open settings dialog |
600 if ((!m_dragEvent) && |
557 if ((!m_dragEvent) && |
601 m_layoutManager->currentDisplayRole() == |
558 m_layoutManager->currentDisplayRole() == |
602 InfoWidgetLayoutManager::InfoDisplay) { |
559 InfoWidgetLayoutManager::InfoDisplay) { |
603 DPRINT << ": layout and display settings dialog"; |
560 DPRINT << ": layout and display settings dialog"; |
604 layoutSettingsDialog(); |
561 layoutSettingsDialog(); |
605 } |
562 } |
606 |
563 |
607 // Clear flag |
564 // Clear flag |
608 m_dragEvent = false; |
565 m_dragEvent = false; |
609 |
566 } |
610 } |
567 |
611 |
568 /*! |
612 /*! |
569 Mouse move handler. |
613 InfoWidget::mouseMoveEvent() |
|
614 */ |
570 */ |
615 void InfoWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
571 void InfoWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
616 { |
572 { |
617 Q_UNUSED(event); |
573 Q_UNUSED(event); |
618 |
|
619 // Mouse is moving |
574 // Mouse is moving |
620 // after mouse press event |
575 // after mouse press event |
621 m_dragEvent = true; |
576 m_dragEvent = true; |
622 } |
577 } |
623 |
578 |
624 /*! |
579 /*! |
625 InfoWidget::spnDisplaySettingChanged() |
580 Slot for handling Spn display setting change. |
626 */ |
581 */ |
627 void InfoWidget::spnDisplaySettingChanged(int state) |
582 void InfoWidget::spnDisplaySettingChanged(int state) |
628 { |
583 { |
629 DPRINT << ": state: " << state; |
584 DPRINT << ": state: " << state; |
630 if (state == Qt::Checked){ |
585 if (state == Qt::Checked){ |
665 InfoWidgetPreferences::DisplaySatText, DISPLAY_SETTING_OFF); |
620 InfoWidgetPreferences::DisplaySatText, DISPLAY_SETTING_OFF); |
666 } |
621 } |
667 } |
622 } |
668 |
623 |
669 /*! |
624 /*! |
670 InfoWidget::mcnDisplay() |
|
671 |
|
672 Getter function for Meta-object property "mcnDisplay" |
625 Getter function for Meta-object property "mcnDisplay" |
673 */ |
626 */ |
674 QString InfoWidget::mcnDisplay() |
627 QString InfoWidget::mcnDisplay() |
675 { |
628 { |
676 DPRINT; |
629 DPRINT; |
677 return m_preferences->preference( |
630 return m_preferences->preference( |
678 InfoWidgetPreferences::DisplayMcn); |
631 InfoWidgetPreferences::DisplayMcn); |
679 } |
632 } |
680 |
633 |
681 /*! |
634 /*! |
682 InfoWidget::setMcnDisplay() |
|
683 |
|
684 Setter function for Meta-object property "mcnDisplay" |
635 Setter function for Meta-object property "mcnDisplay" |
685 */ |
636 */ |
686 void InfoWidget::setMcnDisplay(QString value) |
637 void InfoWidget::setMcnDisplay(QString value) |
687 { |
638 { |
688 DPRINT; |
639 DPRINT; |
689 m_preferences->setPreference( |
640 m_preferences->setPreference( |
690 InfoWidgetPreferences::DisplayMcn, value); |
641 InfoWidgetPreferences::DisplayMcn, value); |
691 } |
642 } |
692 |
643 |
693 /*! |
644 /*! |
694 InfoWidget::homeZoneDisplay() |
|
695 |
|
696 Getter function for Meta-object property "homeZoneDisplay" |
645 Getter function for Meta-object property "homeZoneDisplay" |
697 */ |
646 */ |
698 QString InfoWidget::homeZoneDisplay() |
647 QString InfoWidget::homeZoneDisplay() |
699 { |
648 { |
700 DPRINT; |
649 DPRINT; |
701 return m_preferences->preference( |
650 return m_preferences->preference( |
702 InfoWidgetPreferences::DisplayHomeZone); |
651 InfoWidgetPreferences::DisplayHomeZone); |
703 } |
652 } |
704 |
653 |
705 /*! |
654 /*! |
706 InfoWidget::setHomeZoneDisplay() |
|
707 |
|
708 Setter function for Meta-object property "homeZoneDisplay" |
655 Setter function for Meta-object property "homeZoneDisplay" |
709 */ |
656 */ |
710 void InfoWidget::setHomeZoneDisplay(QString value) |
657 void InfoWidget::setHomeZoneDisplay(QString value) |
711 { |
658 { |
712 DPRINT; |
659 DPRINT; |
713 m_preferences->setPreference( |
660 m_preferences->setPreference( |
714 InfoWidgetPreferences::DisplayHomeZone, value); |
661 InfoWidgetPreferences::DisplayHomeZone, value); |
715 } |
662 } |
716 |
663 |
717 /*! |
664 /*! |
718 InfoWidget::activeLineDisplay() |
|
719 |
|
720 Getter function for Meta-object property "activeLineDisplay" |
665 Getter function for Meta-object property "activeLineDisplay" |
721 */ |
666 */ |
722 QString InfoWidget::activeLineDisplay() |
667 QString InfoWidget::activeLineDisplay() |
723 { |
668 { |
724 DPRINT; |
669 DPRINT; |
725 return m_preferences->preference( |
670 return m_preferences->preference( |
726 InfoWidgetPreferences::DisplayActiveLine); |
671 InfoWidgetPreferences::DisplayActiveLine); |
727 } |
672 } |
728 |
673 |
729 /*! |
674 /*! |
730 InfoWidget::setActiveLineDisplay() |
|
731 |
|
732 Setter function for Meta-object property "activeLineDisplay" |
675 Setter function for Meta-object property "activeLineDisplay" |
733 */ |
676 */ |
734 void InfoWidget::setActiveLineDisplay(QString value) |
677 void InfoWidget::setActiveLineDisplay(QString value) |
735 { |
678 { |
736 DPRINT; |
679 DPRINT; |
749 return m_preferences->preference( |
692 return m_preferences->preference( |
750 InfoWidgetPreferences::DisplaySatText); |
693 InfoWidgetPreferences::DisplaySatText); |
751 } |
694 } |
752 |
695 |
753 /*! |
696 /*! |
754 InfoWidget::setSatDisplay() |
|
755 |
|
756 Setter function for Meta-object property "satDisplay" |
697 Setter function for Meta-object property "satDisplay" |
757 */ |
698 */ |
758 void InfoWidget::setSatDisplay(QString value) |
699 void InfoWidget::setSatDisplay(QString value) |
759 { |
700 { |
760 DPRINT; |
701 DPRINT; |
761 m_preferences->setPreference( |
702 m_preferences->setPreference( |
762 InfoWidgetPreferences::DisplaySatText, value); |
703 InfoWidgetPreferences::DisplaySatText, value); |
763 } |
704 } |
764 |
705 |
765 /*! |
706 /*! |
766 InfoWidget::spnDisplay() |
|
767 |
|
768 Getter function for Meta-object property "spnDisplay" |
707 Getter function for Meta-object property "spnDisplay" |
769 */ |
708 */ |
770 QString InfoWidget::spnDisplay() |
709 QString InfoWidget::spnDisplay() |
771 { |
710 { |
772 DPRINT; |
711 DPRINT; |
773 return m_preferences->preference( |
712 return m_preferences->preference( |
774 InfoWidgetPreferences::DisplaySpn); |
713 InfoWidgetPreferences::DisplaySpn); |
775 } |
714 } |
776 |
715 |
777 /*! |
716 /*! |
778 InfoWidget::setSpnDisplay() |
|
779 |
|
780 Setter function for Meta-object property "spnDisplay" |
717 Setter function for Meta-object property "spnDisplay" |
781 */ |
718 */ |
782 void InfoWidget::setSpnDisplay(QString value) |
719 void InfoWidget::setSpnDisplay(QString value) |
783 { |
720 { |
784 DPRINT; |
721 DPRINT; |
785 m_preferences->setPreference( |
722 m_preferences->setPreference( |
786 InfoWidgetPreferences::DisplaySpn, value); |
723 InfoWidgetPreferences::DisplaySpn, value); |
787 } |
724 } |
788 |
725 |
789 /*! |
726 /*! |
790 InfoWidget::readPersistentPreferences() |
|
791 |
|
792 Read Meta-object properties and store to preference handler. |
727 Read Meta-object properties and store to preference handler. |
793 Restores preferences from previous session. |
728 Restores preferences from previous session. |
794 */ |
729 */ |
795 bool InfoWidget::readPersistentPreferences() |
730 bool InfoWidget::readPersistentPreferences() |
796 { |
731 { |
825 |
760 |
826 return changed; |
761 return changed; |
827 } |
762 } |
828 |
763 |
829 /*! |
764 /*! |
830 InfoWidget::initializeCheckBoxStates() |
|
831 |
|
832 Read display settings from preference store |
765 Read display settings from preference store |
833 and set check box initial states accordingly. |
766 and set check box initial states accordingly. |
834 */ |
767 */ |
835 void InfoWidget::initializeCheckBoxStates() |
768 void InfoWidget::initializeCheckBoxStates() |
836 { |
769 { |
837 DPRINT; |
770 DPRINT; |
838 HbCheckBox *spnCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
771 HbCheckBox *spnCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
839 InfoWidgetLayoutManager::RoleSpnCheckBox)); |
772 InfoWidgetLayoutManager::RoleSpnCheckBox)); |
840 if (spnCheckBox) { |
773 if (spnCheckBox) { |
841 spnCheckBox->setChecked(m_preferences->isPreferenceSet( |
774 spnCheckBox->setChecked(m_preferences->isPreferenceSet( |
842 InfoWidgetPreferences::DisplaySpn)); |
775 InfoWidgetPreferences::DisplaySpn)); |
843 } |
776 } |
844 |
777 |
845 HbCheckBox *mcnCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
778 HbCheckBox *mcnCheckBox = qobject_cast<HbCheckBox *>(m_layoutManager->getWidget( |
846 InfoWidgetLayoutManager::RoleMcnCheckBox)); |
779 InfoWidgetLayoutManager::RoleMcnCheckBox)); |
856 InfoWidgetPreferences::DisplaySatText)); |
789 InfoWidgetPreferences::DisplaySatText)); |
857 } |
790 } |
858 } |
791 } |
859 |
792 |
860 /*! |
793 /*! |
861 InfoWidget::settingsEditingFinished() |
794 Handles settings validating and storing |
|
795 when the settings dialog is closed with Ok action. |
862 */ |
796 */ |
863 void InfoWidget::settingsEditingFinished() |
797 void InfoWidget::settingsEditingFinished() |
864 { |
798 { |
865 DPRINT << ": IN"; |
799 DPRINT; |
866 |
800 |
867 // Save settings data if validation succeeds |
|
868 if (m_preferences->validate()) { |
801 if (m_preferences->validate()) { |
869 DPRINT << ": switching to info display"; |
802 |
870 |
|
871 // Signal HS framework to store Meta-object |
803 // Signal HS framework to store Meta-object |
872 // preferences if changed |
804 // preferences if preferences have changed. |
873 if (m_preferences->storePreferences()) { |
805 if (m_preferences->storePreferences()) { |
874 emit setPreferences( |
806 emit setPreferences( |
875 m_preferences->preferenceNames()); |
807 m_preferences->preferenceNames()); |
876 } |
808 } |
877 |
809 |
882 m_layoutManager->removeWidget( |
814 m_layoutManager->removeWidget( |
883 InfoWidgetLayoutManager::RoleSettingsDialog, |
815 InfoWidgetLayoutManager::RoleSettingsDialog, |
884 true); |
816 true); |
885 |
817 |
886 } else { |
818 } else { |
887 DPRINT << ": settings validation failed"; |
|
888 // Cancel edit mode |
819 // Cancel edit mode |
889 settingsEditingCancelled(); |
820 settingsEditingCancelled(); |
890 |
821 |
891 // Display warning note |
822 // Display warning note |
892 settingsValidationFailed(); |
823 settingsValidationFailed(); |
893 } |
824 } |
894 |
825 } |
895 DPRINT << ": OUT"; |
826 |
896 } |
827 /*! |
897 |
|
898 /*! |
|
899 InfoWidget::settingsEditingCancelled() |
|
900 |
|
901 Slot to be called when settings editing |
828 Slot to be called when settings editing |
902 shouldn't cause change set of visible items. |
829 shouldn't cause change set of visible items. |
903 Restores previous state. |
830 Restores previous state. |
904 */ |
831 */ |
905 void InfoWidget::settingsEditingCancelled() |
832 void InfoWidget::settingsEditingCancelled() |
913 InfoWidgetLayoutManager::RoleSettingsDialog, |
840 InfoWidgetLayoutManager::RoleSettingsDialog, |
914 true); |
841 true); |
915 } |
842 } |
916 |
843 |
917 /*! |
844 /*! |
918 InfoWidget::settingsDialogClosed() |
845 Slot to be called when settings dialog is about to close. |
919 |
|
920 Slot to be called when settings dialog is about to close |
|
921 */ |
846 */ |
922 void InfoWidget::settingsDialogClosed(HbAction* action) |
847 void InfoWidget::settingsDialogClosed(HbAction* action) |
923 { |
848 { |
924 DPRINT << ": IN"; |
849 DPRINT; |
925 if (action) { |
850 if (action) { |
926 if (action->text() == hbTrId("txt_common_button_ok")) { |
851 if (action->text() == hbTrId("txt_common_button_ok")) { |
927 settingsEditingFinished(); |
852 settingsEditingFinished(); |
928 } else if (action->text() == hbTrId("txt_common_button_cancel") ) { |
853 } else if (action->text() == hbTrId("txt_common_button_cancel")) { |
929 settingsEditingCancelled(); |
854 settingsEditingCancelled(); |
930 } |
855 } |
931 } else { |
856 } else { |
932 DPRINT << ": null action"; |
|
933 settingsEditingCancelled(); |
857 settingsEditingCancelled(); |
934 } |
858 } |
935 |
859 |
936 // Switch to info display |
860 // Switch to info display |
937 layoutInfoDisplay(); |
861 layoutInfoDisplay(); |
938 DPRINT << ": OUT"; |
862 } |
939 } |
863 |
940 |
864 /*! |
941 /*! |
865 Handle start of changes, called when settings dialog |
942 InfoWidget::startChanges() |
866 is shown and layout changes are expected. |
943 */ |
867 */ |
944 void InfoWidget::startChanges() |
868 void InfoWidget::startChanges() |
945 { |
869 { |
946 DPRINT; |
870 DPRINT; |
947 m_layoutChanging = true; |
871 m_layoutChanging = true; |
948 if (m_animationState != AnimationIdle) { |
872 if (m_animationState != AnimationIdle) { |
949 stopMarquees(); |
873 stopMarquees(); |
950 } |
874 } |
951 } |
875 } |
952 |
876 |
953 /*! |
877 /*! |
954 InfoWidget::endChanges() |
878 Handle end of changes, called when settings dialog |
|
879 is closed and layout changes are to be finished. |
955 */ |
880 */ |
956 void InfoWidget::endChanges() |
881 void InfoWidget::endChanges() |
957 { |
882 { |
958 DPRINT; |
883 DPRINT; |
959 updateGeometry(); |
884 updateGeometry(); |
960 updateInfoDisplay(); |
885 updateInfoDisplay(); |
961 |
|
962 m_layoutChanging = false; |
886 m_layoutChanging = false; |
963 } |
887 } |
964 |
888 |
965 /*! |
889 /*! |
966 \reimp |
890 \reimp |
1007 return false; |
926 return false; |
1008 } |
927 } |
1009 |
928 |
1010 int animatingItemsCount = m_animatingItems.count(); |
929 int animatingItemsCount = m_animatingItems.count(); |
1011 if (animatingItemsCount > 0) { |
930 if (animatingItemsCount > 0) { |
1012 HbMarqueeItem *marqueeItem(NULL); |
931 foreach (HbMarqueeItem *marqueeItem, m_animatingItems) { |
1013 foreach (marqueeItem, m_animatingItems) { |
932 if (marqueeItem) { |
1014 if (animatingItemsCount > 1) { |
933 if (animatingItemsCount > 1) { |
1015 // Multiple items, connect to marqueeNext() |
934 // Multiple items, connect to marqueeNext() |
1016 // sequence logic |
935 // sequence logic |
1017 QObject::connect( |
936 QObject::connect( |
1018 marqueeItem,SIGNAL(animationStopped()), |
937 marqueeItem, SIGNAL(animationStopped()), |
1019 this, SLOT(marqueeNext()), |
938 this, SLOT(marqueeNext()), |
1020 Qt::UniqueConnection); |
939 Qt::QueuedConnection); |
1021 marqueeItem->setLoopCount(1); |
940 marqueeItem->setLoopCount(1); |
1022 } else if (animatingItemsCount ==1 ){ |
941 } else if (animatingItemsCount == 1){ |
1023 // Single item, set continuous marquee mode |
942 // Single item, set continuous marquee mode |
1024 marqueeItem->setLoopCount(-1); |
943 marqueeItem->setLoopCount(-1); |
|
944 } |
1025 } |
945 } |
1026 } |
946 } |
1027 |
947 |
1028 // Store marquee sequence start item |
948 // Store marquee sequence start item |
1029 m_animatingItem = m_animatingItems.first(); |
949 m_animatingItem = m_animatingItems.first(); |
1030 |
950 m_animationState = AnimationStarting; |
1031 if (delay == StartNoDelay) { |
951 m_timerId = startTimer(INFOWIDGET_MARQUEE_START_DELAY); |
1032 m_animationState = AnimationOngoing; |
|
1033 m_animatingItem->startAnimation(); |
|
1034 } else if (delay == StartDelayed && !m_timerId) { |
|
1035 m_animationState = AnimationStarting; |
|
1036 m_timerId = startTimer(100); |
|
1037 } |
|
1038 |
|
1039 } else { |
952 } else { |
1040 // No animating items, not started |
953 DPRINT << ": not started, no animating items"; |
1041 DWARNING << ": not done, no animating items"; |
|
1042 m_animatingItem = NULL; |
954 m_animatingItem = NULL; |
1043 started = false; |
955 started = false; |
1044 } |
956 } |
1045 |
|
1046 return started; |
957 return started; |
1047 } |
958 } |
1048 |
959 |
1049 /*! |
960 /*! |
1050 InfoWidget::stopMarquees() |
|
1051 |
|
1052 Stop all marquee animations and reset |
961 Stop all marquee animations and reset |
1053 animation state |
962 animation state. |
1054 */ |
963 */ |
1055 void InfoWidget::stopMarquees() |
964 void InfoWidget::stopMarquees() |
1056 { |
965 { |
1057 DPRINT; |
966 DPRINT; |
1058 if (m_animationState != AnimationIdle && |
967 if (m_animationState != AnimationIdle && |
1059 m_animatingItems.count() > 0) { |
968 m_animatingItems.count() > 0) { |
1060 HbMarqueeItem *marqueeItem(NULL); |
969 foreach (HbMarqueeItem *marqueeItem, m_animatingItems) { |
1061 |
970 if (marqueeItem) { |
1062 foreach (marqueeItem, m_animatingItems) { |
|
1063 |
|
1064 // Disconnect if more than one item, |
|
1065 // single animator doesn't connect to animationStopped() |
|
1066 if (m_animatingItems.count() > 1) { |
|
1067 QObject::disconnect( |
971 QObject::disconnect( |
1068 marqueeItem, SIGNAL(animationStopped()), |
972 marqueeItem, SIGNAL(animationStopped()), |
1069 this, SLOT(marqueeNext())); |
973 this, SLOT(marqueeNext())); |
1070 } |
974 |
1071 |
975 if (marqueeItem->isAnimating()) { |
1072 if (marqueeItem->isAnimating()) { |
976 marqueeItem->stopAnimation(); |
1073 marqueeItem->stopAnimation(); |
977 } |
1074 } |
978 } |
1075 } |
979 } |
1076 } |
980 } |
1077 |
981 |
1078 // Stop timer |
982 // Stop timer |