1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Videolist content widget implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 15 % |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <hbpushbutton.h> |
|
22 #include <hblabel.h> |
|
23 #include <qgraphicsitem.h> |
|
24 #include <hbinstance.h> |
|
25 |
|
26 #include "videohintwidget.h" |
|
27 #include "videocollectionuiloader.h" |
|
28 #include "videocollectionviewutils.h" |
|
29 #include "videocollectioncenrepdefs.h" |
|
30 #include "videocollectiontrace.h" |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // Constructor |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 VideoHintWidget::VideoHintWidget( VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent ) |
|
37 : HbWidget( parent ) |
|
38 , mUiLoader( uiLoader ) |
|
39 , mCurrentLevel( AllVideos ) |
|
40 , mButtonShown( false ) |
|
41 , mActivated( false ) |
|
42 { |
|
43 FUNC_LOG; |
|
44 // NOP |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // Destructor |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 VideoHintWidget::~VideoHintWidget() |
|
52 { |
|
53 FUNC_LOG; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // initialize |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 void VideoHintWidget::initialize() |
|
61 { |
|
62 FUNC_LOG; |
|
63 VideoCollectionViewUtils& utils = VideoCollectionViewUtils::instance(); |
|
64 |
|
65 QString textId = utils.getCenRepStringValue(KVideoCollectionViewCenrepServiceItem1Text); |
|
66 if(!textId.isEmpty()) |
|
67 { |
|
68 mHintText = hbTrId(textId.toLatin1().constData()); |
|
69 } |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // setLevel |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 void VideoHintWidget::setLevel(HintLevel level) |
|
77 { |
|
78 FUNC_LOG; |
|
79 INFO_1("VideoHintWidget::setLevel() level: %d", level); |
|
80 mCurrentLevel = level; |
|
81 if(mActivated) { |
|
82 updateUiComponents(); |
|
83 } |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // setButtonShown |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void VideoHintWidget::setButtonShown(bool shown) |
|
91 { |
|
92 FUNC_LOG; |
|
93 INFO_1("VideoHintWidget::setButtonShown() shown: %d", shown); |
|
94 mButtonShown = shown; |
|
95 if(mActivated) { |
|
96 updateUiComponents(); |
|
97 } |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // orientationChanged |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 void VideoHintWidget::orientationChangedSlot(Qt::Orientation targetOrientation) |
|
105 { |
|
106 FUNC_LOG; |
|
107 Q_UNUSED(targetOrientation); |
|
108 updateUiComponents(); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // activate |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void VideoHintWidget::activate() |
|
116 { |
|
117 FUNC_LOG; |
|
118 if (!mActivated) |
|
119 { |
|
120 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
|
121 connect( |
|
122 mainWnd, SIGNAL(orientationChanged(Qt::Orientation)), |
|
123 this, SLOT(orientationChangedSlot(Qt::Orientation))); |
|
124 |
|
125 updateUiComponents(); |
|
126 |
|
127 setVisible(true); |
|
128 |
|
129 mActivated = true; |
|
130 } |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // deactivate |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void VideoHintWidget::deactivate() |
|
138 { |
|
139 FUNC_LOG; |
|
140 if (mActivated) |
|
141 { |
|
142 mActivated = false; |
|
143 |
|
144 setVisible(false); |
|
145 |
|
146 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
|
147 disconnect( |
|
148 mainWnd, SIGNAL(orientationChanged(Qt::Orientation)), |
|
149 this, SLOT(orientationChangedSlot(Qt::Orientation))); |
|
150 } |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // updateUiComponents |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void VideoHintWidget::updateUiComponents() |
|
158 { |
|
159 FUNC_LOG; |
|
160 HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0); |
|
161 if (mainWnd) |
|
162 { |
|
163 HbPushButton *hintButton = |
|
164 mUiLoader->findWidget<HbPushButton>( |
|
165 DOCML_NAME_HINT_BUTTON); |
|
166 HbLabel *noVideosLabel = |
|
167 mUiLoader->findWidget<HbLabel>( |
|
168 DOCML_NAME_NO_VIDEOS_LABEL); |
|
169 if (hintButton && noVideosLabel) |
|
170 { |
|
171 noVideosLabel->setVisible(true); |
|
172 |
|
173 if (mCurrentLevel == AllVideos && !mHintText.isEmpty()) |
|
174 { |
|
175 hintButton->setText(mHintText); |
|
176 hintButton->setVisible(mButtonShown); |
|
177 } |
|
178 else |
|
179 { |
|
180 hintButton->setVisible(false); |
|
181 } |
|
182 } |
|
183 } |
|
184 } |
|
185 |
|
186 // end of file |
|