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