37
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Bubble heading widget
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <hbstyle.h>
|
|
19 |
#include <hbmainwindow.h>
|
|
20 |
#include <hbevent.h>
|
|
21 |
#include <hbiconitem.h>
|
|
22 |
#include <hbtextitem.h>
|
|
23 |
#include <hbfontspec.h>
|
|
24 |
#include <hbdeviceprofile.h>
|
|
25 |
#include <hbstyleloader.h>
|
|
26 |
#include <hbiconanimationmanager.h>
|
|
27 |
#include <hbiconanimator.h>
|
|
28 |
|
|
29 |
#include "bubbleheadingwidget.h"
|
|
30 |
#include "bubblemanager2.h"
|
|
31 |
#include "bubbleutils.h"
|
|
32 |
#include "bubbleheader.h"
|
|
33 |
|
|
34 |
BubbleHeadingWidget::BubbleHeadingWidget(QGraphicsItem* item)
|
|
35 |
: HbWidget(item), mStatusIcon(0), mNumberTypeIcon(0),
|
|
36 |
mCipheringIcon(0), mText1(0), mText2(0), mText3(0)
|
|
37 |
{
|
|
38 |
createPrimitives();
|
|
39 |
|
|
40 |
HbStyleLoader::registerFilePath(":/bubbleheadingwidget.css");
|
|
41 |
HbStyleLoader::registerFilePath(":/bubbleheadingwidget.widgetml");
|
|
42 |
|
|
43 |
// font is update in code, because cli position is changing
|
|
44 |
mCliFont = new HbFontSpec(HbFontSpec::Primary);
|
|
45 |
mTextFont = new HbFontSpec(HbFontSpec::Secondary);
|
|
46 |
|
|
47 |
HbDeviceProfile profile;
|
|
48 |
mCliFont->setTextHeight(4*HbDeviceProfile::current().unitValue());
|
|
49 |
mTextFont->setTextHeight(4*HbDeviceProfile::current().unitValue());
|
|
50 |
|
|
51 |
HbIconAnimationManager *mgr = HbIconAnimationManager::global();
|
|
52 |
mgr->addDefinitionFile(":/bubble_icon_anim.axml");
|
|
53 |
}
|
|
54 |
|
|
55 |
BubbleHeadingWidget::~BubbleHeadingWidget()
|
|
56 |
{
|
|
57 |
delete mCliFont;
|
|
58 |
delete mTextFont;
|
|
59 |
}
|
|
60 |
|
|
61 |
void BubbleHeadingWidget::reset()
|
|
62 |
{
|
|
63 |
mHeader = 0;
|
|
64 |
mText1->setText(QString());
|
|
65 |
mText2->setText(QString());
|
|
66 |
mText3->setText(QString());
|
|
67 |
mStatusIcon->hide();
|
|
68 |
mStatusIcon->animator().stopAnimation();
|
|
69 |
mNumberTypeIcon->hide();
|
|
70 |
mCipheringIcon->hide();
|
|
71 |
}
|
|
72 |
|
|
73 |
void BubbleHeadingWidget::readBubbleHeader(const BubbleHeader& header)
|
|
74 |
{
|
|
75 |
mHeader = &header;
|
|
76 |
updatePrimitives();
|
|
77 |
}
|
|
78 |
|
|
79 |
void BubbleHeadingWidget::createPrimitives()
|
|
80 |
{
|
|
81 |
mText1 = new HbTextItem(this);
|
|
82 |
style()->setItemName( mText1, "text_line_1" );
|
|
83 |
|
|
84 |
mText2 = new HbTextItem(this);
|
|
85 |
style()->setItemName( mText2, "text_line_2" );
|
|
86 |
|
|
87 |
mText3 = new HbTextItem(this);
|
|
88 |
style()->setItemName( mText3, "text_line_3" );
|
|
89 |
|
|
90 |
//mStatusIcon = new BubbleAnimIconItem(BUBBLE_ICON_ANIM_INTERVAL, this);
|
|
91 |
mStatusIcon = new HbIconItem(this);
|
|
92 |
style()->setItemName( mStatusIcon, "status_icon" );
|
|
93 |
|
|
94 |
mNumberTypeIcon = new HbIconItem(this);
|
|
95 |
style()->setItemName( mNumberTypeIcon, "number_type_icon" );
|
|
96 |
|
|
97 |
mCipheringIcon = new HbIconItem(this);
|
|
98 |
style()->setItemName( mCipheringIcon, "ciphering_icon" );
|
|
99 |
}
|
|
100 |
|
|
101 |
void BubbleHeadingWidget::updatePrimitives()
|
|
102 |
{
|
|
103 |
if (mHeader!=0) {
|
|
104 |
BubbleUtils::setCallStatusIcon(
|
|
105 |
mHeader->callState(), mHeader->callFlags(), *mStatusIcon);
|
|
106 |
|
|
107 |
BubbleUtils::setNumberTypeIcon(
|
|
108 |
mHeader->callState(), mHeader->callFlags(), *mNumberTypeIcon);
|
|
109 |
|
|
110 |
BubbleUtils::setCipheringIcon(
|
|
111 |
mHeader->callState(), mHeader->callFlags(), *mCipheringIcon);
|
|
112 |
|
|
113 |
// update text lines
|
|
114 |
int cliLine = 0;
|
|
115 |
|
|
116 |
if (lines==3) {
|
|
117 |
BubbleUtils::setCallHeaderTexts3Lines(
|
|
118 |
*mHeader, *mText1, *mText2, *mText3, cliLine,
|
|
119 |
mCallTimerTextLine );
|
|
120 |
} else if (lines==2) {
|
|
121 |
BubbleUtils::setCallHeaderTexts2Lines(
|
|
122 |
*mHeader, *mText1, *mText2, cliLine,
|
|
123 |
mCallTimerTextLine );
|
|
124 |
} else {
|
|
125 |
// todo: 1-line
|
|
126 |
BubbleUtils::setCallHeaderTexts2Lines(
|
|
127 |
*mHeader, *mText1, *mText2, cliLine,
|
|
128 |
mCallTimerTextLine );
|
|
129 |
}
|
|
130 |
|
|
131 |
// update font
|
|
132 |
if (cliLine==2) {
|
|
133 |
mText1->setFontSpec(*mTextFont);
|
|
134 |
mText2->setFontSpec(*mCliFont);
|
|
135 |
mText3->setFontSpec(*mTextFont);
|
|
136 |
} else {
|
|
137 |
mText1->setFontSpec(*mCliFont);
|
|
138 |
mText2->setFontSpec(*mTextFont);
|
|
139 |
mText3->setFontSpec(*mTextFont);
|
|
140 |
}
|
|
141 |
}
|
|
142 |
|
|
143 |
repolish();
|
|
144 |
}
|
|
145 |
|
|
146 |
void BubbleHeadingWidget::polishEvent()
|
|
147 |
{
|
|
148 |
if (lines == 3) {
|
|
149 |
setLayout("three_lines");
|
|
150 |
mText1->setVisible(true);
|
|
151 |
mText2->setVisible(true);
|
|
152 |
mText3->setVisible(true);
|
|
153 |
} else if (lines == 2) {
|
|
154 |
setLayout("two_lines");
|
|
155 |
mText1->setVisible(true);
|
|
156 |
mText2->setVisible(true);
|
|
157 |
mText3->setVisible(false);
|
|
158 |
} else if (lines == 1) {
|
|
159 |
setLayout("one_line");
|
|
160 |
mText1->setVisible(true);
|
|
161 |
mText2->setVisible(true);
|
|
162 |
mText3->setVisible(false);
|
|
163 |
}
|
|
164 |
|
|
165 |
HbWidget::polishEvent();
|
|
166 |
}
|
|
167 |
|
|
168 |
int BubbleHeadingWidget::lineCount() const
|
|
169 |
{
|
|
170 |
return lines;
|
|
171 |
}
|
|
172 |
|
|
173 |
void BubbleHeadingWidget::setLineCount(int count)
|
|
174 |
{
|
|
175 |
lines = count;
|
|
176 |
if (isVisible()) {
|
|
177 |
repolish();
|
|
178 |
}
|
|
179 |
}
|
|
180 |
|
|
181 |
QString BubbleHeadingWidget::layout() const
|
|
182 |
{
|
|
183 |
return layoutOption;
|
|
184 |
}
|
|
185 |
|
|
186 |
void BubbleHeadingWidget::setLayout(const QString& layout)
|
|
187 |
{
|
|
188 |
layoutOption = layout;
|
|
189 |
}
|
|
190 |
|
|
191 |
void BubbleHeadingWidget::updateTimerDisplayNow()
|
|
192 |
{
|
|
193 |
if ( mHeader && ( mHeader->callState() == BubbleManager::Active ) ) {
|
|
194 |
if ( mCallTimerTextLine == 2 ) {
|
|
195 |
mText2->setText(mHeader->timerCost());
|
|
196 |
mText2->setElideMode(Qt::ElideRight);
|
|
197 |
} else if ( mCallTimerTextLine == 3 ) {
|
|
198 |
mText3->setText(mHeader->timerCost());
|
|
199 |
mText3->setElideMode(Qt::ElideRight);
|
|
200 |
}
|
|
201 |
}
|
|
202 |
}
|
|
203 |
|
|
204 |
void BubbleHeadingWidget::changeEvent(QEvent *event)
|
|
205 |
{
|
|
206 |
if (event->type() == HbEvent::ThemeChanged) {
|
|
207 |
updatePrimitives();
|
|
208 |
}
|
|
209 |
|
|
210 |
HbWidget::changeEvent(event);
|
|
211 |
}
|
|
212 |
|
|
213 |
void BubbleHeadingWidget::showEvent(QShowEvent *event)
|
|
214 |
{
|
|
215 |
Q_UNUSED(event)
|
|
216 |
mStatusIcon->animator().startAnimation();
|
|
217 |
}
|