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 |
|
|
18 |
#include <hbpushbutton.h>
|
|
19 |
#include <hblabel.h>
|
|
20 |
#include <qgraphicsitem.h>
|
|
21 |
#include <hbinstance.h>
|
|
22 |
|
|
23 |
#include "videohintwidget.h"
|
|
24 |
#include "videocollectionuiloader.h"
|
|
25 |
#include "videocollectionviewutils.h"
|
|
26 |
|
|
27 |
// ---------------------------------------------------------------------------
|
|
28 |
// Constructor
|
|
29 |
// ---------------------------------------------------------------------------
|
|
30 |
//
|
|
31 |
VideoHintWidget::VideoHintWidget(VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent) :
|
|
32 |
HbWidget(parent),
|
|
33 |
mUiLoader(uiLoader),
|
|
34 |
mServiceButton(0),
|
|
35 |
mHintLabel(0),
|
|
36 |
mServiceIcon(0),
|
|
37 |
mCurrentLevel(AllVideos)
|
|
38 |
{
|
|
39 |
// NOP
|
|
40 |
}
|
|
41 |
|
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
// Destructor
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
VideoHintWidget::~VideoHintWidget()
|
|
47 |
{
|
|
48 |
delete mServiceIcon;
|
|
49 |
}
|
|
50 |
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
// initialize
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
int VideoHintWidget::initialize()
|
|
56 |
{
|
|
57 |
mServiceButton = mUiLoader->findWidget<HbPushButton>(DOCML_NAME_HINT_BUTTON);
|
|
58 |
mHintLabel = mUiLoader->findWidget<HbLabel>(DOCML_NAME_HINT_LABEL);
|
|
59 |
if(!mServiceButton || !mHintLabel)
|
|
60 |
{
|
|
61 |
return -1;
|
|
62 |
}
|
|
63 |
|
|
64 |
VideoCollectionViewUtils& utils = VideoCollectionViewUtils::instance();
|
|
65 |
return utils.getServiceIconStrings(mServiceIconString, mServiceIconPressedString);
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// setLevel
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
void VideoHintWidget::setLevel(HintLevel level)
|
|
73 |
{
|
|
74 |
mCurrentLevel = level;
|
|
75 |
if(isVisible()) {
|
|
76 |
updateUiComponents();
|
|
77 |
}
|
|
78 |
}
|
|
79 |
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
// setVisible
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
void VideoHintWidget::setVisible(bool visible)
|
|
85 |
{
|
|
86 |
HbWidget::setVisible(visible);
|
|
87 |
|
|
88 |
if(visible) {
|
|
89 |
activate();
|
|
90 |
} else {
|
|
91 |
deactivate();
|
|
92 |
}
|
|
93 |
}
|
|
94 |
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
// orientationChanged
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
void VideoHintWidget::orientationChangedSlot(Qt::Orientation /*targetOrientation*/)
|
|
100 |
{
|
|
101 |
updateUiComponents();
|
|
102 |
}
|
|
103 |
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
// activate
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
void VideoHintWidget::activate()
|
|
109 |
{
|
|
110 |
if(mServiceIconString.isNull() || mServiceIconString.isEmpty() ||
|
|
111 |
mServiceIconPressedString.isNull() || mServiceIconPressedString.isEmpty())
|
|
112 |
{
|
|
113 |
return;
|
|
114 |
}
|
|
115 |
|
|
116 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
|
117 |
connect(mainWnd, SIGNAL(orientationChanged(Qt::Orientation)),
|
|
118 |
this, SLOT(orientationChangedSlot(Qt::Orientation)));
|
|
119 |
|
|
120 |
mServiceIcon = new HbIcon(mServiceIconString);
|
|
121 |
mServiceIcon->setIconName(mServiceIconPressedString, QIcon::Normal, QIcon::On);
|
|
122 |
|
|
123 |
updateUiComponents();
|
|
124 |
}
|
|
125 |
|
|
126 |
// ---------------------------------------------------------------------------
|
|
127 |
// deactivate
|
|
128 |
// ---------------------------------------------------------------------------
|
|
129 |
//
|
|
130 |
void VideoHintWidget::deactivate()
|
|
131 |
{
|
|
132 |
disconnect(this, SLOT(orientationChangedSlot(Qt::Orientation)));
|
|
133 |
|
|
134 |
mServiceButton->setIcon(HbIcon());
|
|
135 |
if(mServiceIcon) {
|
|
136 |
delete mServiceIcon;
|
|
137 |
mServiceIcon = 0;
|
|
138 |
}
|
|
139 |
}
|
|
140 |
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
// updateUiComponents
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
void VideoHintWidget::updateUiComponents()
|
|
146 |
{
|
|
147 |
HbMainWindow *mainWnd = hbInstance->allMainWindows().value(0);
|
|
148 |
mServiceButton->setVisible(mainWnd->orientation() == Qt::Horizontal);
|
|
149 |
|
|
150 |
if(mCurrentLevel == Collection) {
|
|
151 |
mHintLabel->setVisible(false);
|
|
152 |
mServiceButton->setIcon(HbIcon());
|
|
153 |
mServiceButton->setText(tr("Add videos"));
|
|
154 |
} else {
|
|
155 |
mHintLabel->setVisible(true);
|
|
156 |
mServiceButton->setText(QString());
|
|
157 |
mServiceButton->setIcon(*mServiceIcon);
|
|
158 |
}
|
|
159 |
}
|
|
160 |
|
|
161 |
// end of file
|