videocollection/videocollectionview/src/videohintwidget.cpp
changeset 41 229f037ce963
parent 36 8aed59de29f9
child 44 518105d52e45
equal deleted inserted replaced
40:13331705e488 41:229f037ce963
    13 *
    13 *
    14 * Description:   Videolist content widget implementation
    14 * Description:   Videolist content widget implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 13 %
    18 // Version : %version: 14 %
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <hbpushbutton.h>
    21 #include <hbpushbutton.h>
    22 #include <hblabel.h>
    22 #include <hblabel.h>
    23 #include <qgraphicsitem.h>
    23 #include <qgraphicsitem.h>
    34 //
    34 //
    35 VideoHintWidget::VideoHintWidget( VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent ) 
    35 VideoHintWidget::VideoHintWidget( VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent ) 
    36     : HbWidget( parent )
    36     : HbWidget( parent )
    37     , mUiLoader( uiLoader )
    37     , mUiLoader( uiLoader )
    38     , mServiceIcon( 0 )
    38     , mServiceIcon( 0 )
    39     , mAddVideosIcon( 0 )
       
    40     , mCurrentLevel( AllVideos )
    39     , mCurrentLevel( AllVideos )
    41     , mButtonShown( false )
    40     , mButtonShown( false )
    42     , mActivated( false )
    41     , mActivated( false )
    43 {
    42 {
    44 	FUNC_LOG;
    43     FUNC_LOG;
    45     // NOP
    44     // NOP
    46 }
    45 }
    47 
    46 
    48 // ---------------------------------------------------------------------------
    47 // ---------------------------------------------------------------------------
    49 // Destructor
    48 // Destructor
    50 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    51 //
    50 //
    52 VideoHintWidget::~VideoHintWidget()
    51 VideoHintWidget::~VideoHintWidget()
    53 {
    52 {
    54 	FUNC_LOG;
    53     FUNC_LOG;
    55     delete mServiceIcon;
    54     delete mServiceIcon;
    56     delete mAddVideosIcon;
       
    57 }
    55 }
    58 
    56 
    59 // ---------------------------------------------------------------------------
    57 // ---------------------------------------------------------------------------
    60 // initialize
    58 // initialize
    61 // ---------------------------------------------------------------------------
    59 // ---------------------------------------------------------------------------
    62 //
    60 //
    63 int VideoHintWidget::initialize()
    61 int VideoHintWidget::initialize()
    64 {
    62 {
    65 	FUNC_LOG;
    63     FUNC_LOG;
    66     VideoCollectionViewUtils& utils = VideoCollectionViewUtils::instance();
    64     VideoCollectionViewUtils& utils = VideoCollectionViewUtils::instance();
    67     return utils.getServiceIconStrings(mServiceIconString, mServiceIconPressedString);
    65     return utils.getServiceIconStrings(mServiceIconString, mServiceIconPressedString);
    68 }
    66 }
    69 
    67 
    70 // ---------------------------------------------------------------------------
    68 // ---------------------------------------------------------------------------
    71 // setLevel
    69 // setLevel
    72 // ---------------------------------------------------------------------------
    70 // ---------------------------------------------------------------------------
    73 //
    71 //
    74 void VideoHintWidget::setLevel(HintLevel level)
    72 void VideoHintWidget::setLevel(HintLevel level)
    75 {
    73 {
    76 	FUNC_LOG;
    74     FUNC_LOG;
    77 	INFO_1("VideoHintWidget::setLevel() level: %d", level);
    75     INFO_1("VideoHintWidget::setLevel() level: %d", level);
    78     mCurrentLevel = level;
    76     mCurrentLevel = level;
    79     if(mActivated) {
    77     if(mActivated) {
    80         updateUiComponents();
    78         updateUiComponents();
    81     }
    79     }
    82 }
    80 }
    85 // setButtonShown
    83 // setButtonShown
    86 // ---------------------------------------------------------------------------
    84 // ---------------------------------------------------------------------------
    87 //
    85 //
    88 void VideoHintWidget::setButtonShown(bool shown)
    86 void VideoHintWidget::setButtonShown(bool shown)
    89 {
    87 {
    90 	FUNC_LOG;
    88     FUNC_LOG;
    91 	INFO_1("VideoHintWidget::setButtonShown() shown: %d", shown);
    89     INFO_1("VideoHintWidget::setButtonShown() shown: %d", shown);
    92     mButtonShown = shown;
    90 	mButtonShown = shown;
    93     if(mActivated) {
    91     if(mActivated) {
    94         updateUiComponents();
    92         updateUiComponents();
    95     }
    93     }
    96 }
    94 }
    97 
    95 
    99 // orientationChanged
    97 // orientationChanged
   100 // ---------------------------------------------------------------------------
    98 // ---------------------------------------------------------------------------
   101 //
    99 //
   102 void VideoHintWidget::orientationChangedSlot(Qt::Orientation targetOrientation)
   100 void VideoHintWidget::orientationChangedSlot(Qt::Orientation targetOrientation)
   103 {
   101 {
   104 	FUNC_LOG;
   102     FUNC_LOG;
   105     Q_UNUSED(targetOrientation);
   103     Q_UNUSED(targetOrientation);
   106     updateUiComponents();
   104     updateUiComponents();
   107 }
   105 }
   108 
   106 
   109 // ---------------------------------------------------------------------------
   107 // ---------------------------------------------------------------------------
   110 // activate
   108 // activate
   111 // ---------------------------------------------------------------------------
   109 // ---------------------------------------------------------------------------
   112 //
   110 //
   113 void VideoHintWidget::activate()
   111 void VideoHintWidget::activate()
   114 {
   112 {
   115 	FUNC_LOG;
   113     FUNC_LOG;
   116     if (!mActivated)
   114     if (!mActivated)
   117     {
   115     {
   118         if(mServiceIconString.isEmpty() || 
       
   119            mServiceIconPressedString.isEmpty())
       
   120         {
       
   121             return;
       
   122         }
       
   123         
       
   124         HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
   116         HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
   125         connect(
   117         connect(
   126             mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
   118             mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
   127             this, SLOT(orientationChangedSlot(Qt::Orientation)));
   119             this, SLOT(orientationChangedSlot(Qt::Orientation)));
   128         
   120         
   129         mServiceIcon = new HbIcon(mServiceIconString);
   121         if(!mServiceIconString.isEmpty())
   130         mServiceIcon->setIconName(mServiceIconPressedString, QIcon::Normal, QIcon::On);
   122         {
   131         
   123             mServiceIcon = new HbIcon(mServiceIconString);
   132         mAddVideosIcon = new HbIcon("qtg_mono_add_to_video_collection");
   124         }
       
   125         if(mServiceIcon && !mServiceIconPressedString.isEmpty())
       
   126         {
       
   127             mServiceIcon->setIconName(mServiceIconPressedString, QIcon::Normal, QIcon::On);
       
   128         }
   133         
   129         
   134         updateUiComponents();
   130         updateUiComponents();
   135         
   131         
   136         setVisible(true);
   132         setVisible(true);
   137         
   133         
   143 // deactivate
   139 // deactivate
   144 // ---------------------------------------------------------------------------
   140 // ---------------------------------------------------------------------------
   145 //
   141 //
   146 void VideoHintWidget::deactivate()
   142 void VideoHintWidget::deactivate()
   147 {
   143 {
   148 	FUNC_LOG;
   144     FUNC_LOG;
   149     if (mActivated)
   145     if (mActivated)
   150     {
   146     {
   151         mActivated = false;
   147         mActivated = false;
   152         
   148         
   153         setVisible(false);
   149         setVisible(false);
   162                 DOCML_NAME_HINT_BUTTON);
   158                 DOCML_NAME_HINT_BUTTON);
   163         if (serviceButton)
   159         if (serviceButton)
   164         {
   160         {
   165             serviceButton->setIcon(HbIcon());
   161             serviceButton->setIcon(HbIcon());
   166         }
   162         }
   167         if(mServiceIcon) {
   163 
   168             delete mServiceIcon;
   164         delete mServiceIcon;
   169             mServiceIcon = 0;
   165         mServiceIcon = 0;
   170         }
       
   171         
       
   172         if(mAddVideosIcon) {
       
   173             delete mAddVideosIcon;
       
   174             mAddVideosIcon = 0;
       
   175         }
       
   176     }
   166     }
   177 }
   167 }
   178 
   168 
   179 // ---------------------------------------------------------------------------
   169 // ---------------------------------------------------------------------------
   180 // updateUiComponents
   170 // updateUiComponents
   181 // ---------------------------------------------------------------------------
   171 // ---------------------------------------------------------------------------
   182 //
   172 //
   183 void VideoHintWidget::updateUiComponents()
   173 void VideoHintWidget::updateUiComponents()
   184 {
   174 {
   185 	FUNC_LOG;
   175     FUNC_LOG;
   186     HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
   176     HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
   187     if (mainWnd)
   177     if (mainWnd)
   188     {
   178     {
   189         HbPushButton *serviceButton =
   179         HbPushButton *serviceButton =
   190             mUiLoader->findWidget<HbPushButton>(
   180             mUiLoader->findWidget<HbPushButton>(
   195         HbLabel *noVideosLabel =
   185         HbLabel *noVideosLabel =
   196             mUiLoader->findWidget<HbLabel>(
   186             mUiLoader->findWidget<HbLabel>(
   197                 DOCML_NAME_NO_VIDEOS_LABEL);
   187                 DOCML_NAME_NO_VIDEOS_LABEL);
   198         if (serviceButton && hintLabel && noVideosLabel)
   188         if (serviceButton && hintLabel && noVideosLabel)
   199         {
   189         {
   200             serviceButton->setVisible(mainWnd->orientation() == Qt::Horizontal && mButtonShown);
       
   201             noVideosLabel->setVisible(true);
   190             noVideosLabel->setVisible(true);
   202             if (mCurrentLevel == Collection)
   191             if (mServiceIcon && mCurrentLevel == AllVideos)
       
   192             {
       
   193                 hintLabel->setVisible(true);
       
   194                 serviceButton->setIcon(*mServiceIcon);
       
   195                 serviceButton->setVisible(mButtonShown);
       
   196             }
       
   197             else
   203             {
   198             {
   204                 hintLabel->setVisible(false);
   199                 hintLabel->setVisible(false);
   205                 serviceButton->setIcon(*mAddVideosIcon);
   200                 serviceButton->setVisible(false);
   206             }
   201             }
   207             else
       
   208             {               
       
   209                 hintLabel->setVisible(true);
       
   210                 serviceButton->setIcon(*mServiceIcon);
       
   211             }
       
   212         }
   202         }
   213     }
   203     }
   214 }
   204 }
   215 
   205 
   216 // end of file
   206 // end of file