phoneplugins/infowidgetplugin/infowidget/src/infowidget.cpp
changeset 50 377c906a8701
parent 46 bc5a64e5bc3c
child 52 a49bfe5190e4
equal deleted inserted replaced
46:bc5a64e5bc3c 50:377c906a8701
    45   \brief Operator info widget main class. 
    45   \brief Operator info widget main class. 
    46 
    46 
    47    Implements HomeScreen specific slots and 
    47    Implements HomeScreen specific slots and 
    48    graphical representation of the 
    48    graphical representation of the 
    49    Operator Info widget. 
    49    Operator Info widget. 
    50 
       
    51    Derived from HbWidget.
       
    52     
    50     
    53 */
    51 */
    54 
    52 
    55 // Local constants 
    53 // Local constants 
    56 const int INFOWIDGET_DEFAULT_HEIGHT = 100;
    54 const int INFOWIDGET_DEFAULT_HEIGHT = 100;
    79     INSTALL_TRACE_MSG_HANDLER; 
    77     INSTALL_TRACE_MSG_HANDLER; 
    80     DPRINT;
    78     DPRINT;
    81     
    79     
    82     // Localization file loading
    80     // Localization file loading
    83     installTranslator(TS_FILE_OPERATOR_WIDGET);
    81     installTranslator(TS_FILE_OPERATOR_WIDGET);
    84     installTranslator(TS_FILE_COMMON);
       
    85 
    82 
    86     // Create layout & child-widget manager 
    83     // Create layout & child-widget manager 
    87     m_layoutManager.reset(new InfoWidgetLayoutManager);
    84     m_layoutManager.reset(new InfoWidgetLayoutManager);
    88     
    85     
    89     // Create widget engine 
    86     // Create widget engine 
   212     Handles timer events.  
   209     Handles timer events.  
   213 */
   210 */
   214 void InfoWidget::timerEvent(QTimerEvent *event)
   211 void InfoWidget::timerEvent(QTimerEvent *event)
   215 {
   212 {
   216     Q_UNUSED(event); 
   213     Q_UNUSED(event); 
   217     
       
   218     if (m_animationState == AnimationStarting) {
   214     if (m_animationState == AnimationStarting) {
   219         // Execute delayed start of marquee animation 
   215         // Execute delayed start of marquee animation 
   220         if (m_animatingItem) {
   216         if (m_animatingItem) {
   221             m_animationState = AnimationOngoing;
   217             m_animationState = AnimationOngoing;
   222             m_animatingItem->startAnimation(); 
   218             m_animatingItem->startAnimation(); 
   297         // if widget size is changing
   293         // if widget size is changing
   298         if (size() != requiredSize) {
   294         if (size() != requiredSize) {
   299             m_backgroundFrameItem->resize(requiredSize);
   295             m_backgroundFrameItem->resize(requiredSize);
   300         }
   296         }
   301     }
   297     }
   302     
       
   303     DPRINT << ": returning size: " << requiredSize;
       
   304     return requiredSize; 
   298     return requiredSize; 
   305 }
   299 }
   306 
   300 
   307 /*!
   301 /*!
   308     Returns size polizy for the widget.   
   302     Returns size polizy for the widget.   
   319     Update item visibility based on display preferences.   
   313     Update item visibility based on display preferences.   
   320 */
   314 */
   321 void InfoWidget::updateItemsVisibility()
   315 void InfoWidget::updateItemsVisibility()
   322 {
   316 {
   323     DPRINT; 
   317     DPRINT; 
   324     int layoutRows = 0; 
       
   325     
       
   326     // Update layout according to item visibility settings
       
   327     if (m_preferences->preference(InfoWidgetPreferences::DisplaySpn).compare(
   318     if (m_preferences->preference(InfoWidgetPreferences::DisplaySpn).compare(
   328             DISPLAY_SETTING_ON) == 0) {
   319             DISPLAY_SETTING_OFF) == 0) {
   329         layoutRows++;
       
   330     } else {
       
   331         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSpnMarqueeItem); 
   320         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSpnMarqueeItem); 
   332         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSpnIcon); 
   321         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSpnIcon); 
   333     }
   322     }
   334 
   323     
   335     if (m_preferences->preference(InfoWidgetPreferences::DisplayMcn).compare(
   324     if (m_preferences->preference(InfoWidgetPreferences::DisplayMcn).compare(
   336             DISPLAY_SETTING_ON) == 0) {
   325             DISPLAY_SETTING_OFF) == 0) {
   337         layoutRows++;
       
   338     } else {
       
   339         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleMcnMarqueeItem); 
   326         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleMcnMarqueeItem); 
   340         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleMcnIcon); 
   327         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleMcnIcon); 
   341     }
   328     }
   342     
   329     
   343     if (m_preferences->preference(InfoWidgetPreferences::DisplaySatText).compare(
   330     if (m_preferences->preference(InfoWidgetPreferences::DisplaySatText).compare(
   344             DISPLAY_SETTING_ON) == 0) {
   331             DISPLAY_SETTING_OFF) == 0) {
   345         layoutRows++;
       
   346     } else {
       
   347         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatMarqueeItem); 
   332         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatMarqueeItem); 
   348         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatTextIcon); 
   333         m_layoutManager->removeWidget(InfoWidgetLayoutManager::RoleSatTextIcon); 
   349     }
   334     }
   350     
       
   351     if (m_animatingItems.count() == 0) {
       
   352         m_animatingItem = NULL; 
       
   353     }
       
   354     
       
   355     m_layoutManager->setLayoutRows(layoutRows);
       
   356 }
   335 }
   357 
   336 
   358 /*!
   337 /*!
   359     Layout info display.    
   338     Layout info display.    
   360 */
   339 */
   361 void InfoWidget::layoutInfoDisplay()
   340 void InfoWidget::layoutInfoDisplay()
   362 {  
   341 {  
   363     DPRINT;
   342     DPRINT;
   364     QGraphicsLayout *infoDisplayLayout = 
   343     QGraphicsWidget *infoDisplay = 
   365         m_layoutManager->layoutInfoDisplay(); 
   344         m_layoutManager->layoutInfoDisplay(); 
   366     
   345     if ((!m_layout->count()) && infoDisplay) {
   367     if (!m_layout->count()) {
   346             m_layout->addItem(infoDisplay);
   368         QGraphicsWidget *contentWidget = 
   347         }
   369                 m_layoutManager->contentWidget();
   348 
   370         if (contentWidget) {
       
   371             // Add content widget to main layout 
       
   372             m_layout->addItem(contentWidget);
       
   373         }
       
   374     }
       
   375     updateItemsVisibility(); 
   349     updateItemsVisibility(); 
   376     endChanges();
   350     endChanges();
   377 }
   351 }
   378 
   352 
   379 /*!
   353 /*!
   381 */
   355 */
   382 void InfoWidget::layoutSettingsDialog()
   356 void InfoWidget::layoutSettingsDialog()
   383 {  
   357 {  
   384     DPRINT;
   358     DPRINT;
   385     startChanges();
   359     startChanges();
   386     
   360     HbDialog *settingsDialog =
   387     m_layoutManager->reloadWidgets(InfoWidgetLayoutManager::SettingsDialog); 
   361             qobject_cast<HbDialog *>(
   388     QGraphicsLayout *settingDialogLayout =
   362                     m_layoutManager->layoutSettingsDialog()); 
   389             m_layoutManager->layoutSettingsDialog(); 
   363 
   390     
   364     if (settingsDialog) {
   391     if (settingDialogLayout) {
   365         initializeSettingsDialogItems();
   392         HbDialog *settingsDialog = qobject_cast<HbDialog *>(
   366         settingsDialog->setDismissPolicy(HbDialog::NoDismiss); 
   393                 m_layoutManager->getWidget(InfoWidgetLayoutManager::
   367         settingsDialog->setTimeout(HbDialog::NoTimeout);
   394                 RoleSettingsDialog)); 
   368         settingsDialog->open(this, 
   395 
   369                 SLOT(settingsDialogClosed(HbAction *))); 
   396         if (settingsDialog) {
   370         }
   397             initializeSettingsDialogItems();
       
   398             settingsDialog->setDismissPolicy(HbDialog::NoDismiss); 
       
   399             settingsDialog->setTimeout(HbDialog::NoTimeout);
       
   400             settingsDialog->open(this, 
       
   401                     SLOT(settingsDialogClosed(HbAction *))); 
       
   402             }
       
   403     }    
       
   404 }
   371 }
   405 
   372 
   406 /*!
   373 /*!
   407     Set up initial check box states 
   374     Set up initial check box states 
   408     and connect signals to local slots.  
   375     and connect signals to local slots.  
   457         QString text)
   424         QString text)
   458 {
   425 {
   459     DPRINT; 
   426     DPRINT; 
   460     HbMarqueeItem *marqueeItem = qobject_cast<HbMarqueeItem *>(
   427     HbMarqueeItem *marqueeItem = qobject_cast<HbMarqueeItem *>(
   461             m_layoutManager->getWidget(itemRole));
   428             m_layoutManager->getWidget(itemRole));
   462     
       
   463     if (marqueeItem) {
   429     if (marqueeItem) {
   464         marqueeItem->setText(text);
   430         marqueeItem->setText(text);
   465         marqueeItem->setTextColor( HbColorScheme::color(
   431         marqueeItem->setTextColor( HbColorScheme::color(
   466                 "qtc_hs_list_item_title_normal"));
   432                 "qtc_hs_list_item_title_normal"));
   467         
   433         
   795     when the settings dialog is closed with Ok action.   
   761     when the settings dialog is closed with Ok action.   
   796 */
   762 */
   797 void InfoWidget::settingsEditingFinished()
   763 void InfoWidget::settingsEditingFinished()
   798 {
   764 {
   799     DPRINT;
   765     DPRINT;
   800      
       
   801     if (m_preferences->validate()) {
   766     if (m_preferences->validate()) {
   802 
   767 
   803         // Signal HS framework to store Meta-object 
   768         // Signal HS framework to store Meta-object 
   804         // preferences if preferences have changed. 
   769         // preferences if preferences have changed. 
   805         if (m_preferences->storePreferences()) {
   770         if (m_preferences->storePreferences()) {
   807                     m_preferences->preferenceNames());
   772                     m_preferences->preferenceNames());
   808             }
   773             }
   809         
   774         
   810         // Visible item configuration changed, reload 
   775         // Visible item configuration changed, reload 
   811         // widgets. Restores deleted items.  
   776         // widgets. Restores deleted items.  
   812         m_layoutManager->reloadWidgets(
   777         m_layoutManager->loadWidgets(
   813                 InfoWidgetLayoutManager::InfoDisplay);
   778                 InfoWidgetLayoutManager::InfoDisplay);
   814         m_layoutManager->removeWidget(
   779         m_layoutManager->removeWidget(
   815                 InfoWidgetLayoutManager::RoleSettingsDialog,
   780                 InfoWidgetLayoutManager::RoleSettingsDialog,
   816                 true);
   781                 true);
   817         
   782         
   832 void InfoWidget::settingsEditingCancelled()
   797 void InfoWidget::settingsEditingCancelled()
   833 {
   798 {
   834     DPRINT;
   799     DPRINT;
   835     m_preferences->restorePreferences(); 
   800     m_preferences->restorePreferences(); 
   836     
   801     
   837     m_layoutManager->reloadWidgets(
   802     m_layoutManager->loadWidgets(
   838             InfoWidgetLayoutManager::InfoDisplay);
   803             InfoWidgetLayoutManager::InfoDisplay);
   839     m_layoutManager->removeWidget(
   804     m_layoutManager->removeWidget(
   840             InfoWidgetLayoutManager::RoleSettingsDialog,
   805             InfoWidgetLayoutManager::RoleSettingsDialog,
   841             true); 
   806             true); 
   842 }
   807 }