author | hgs |
Mon, 04 Oct 2010 16:06:10 +0300 | |
changeset 76 | cfea66083b62 |
parent 65 | 2a5d4ab426d3 |
permissions | -rw-r--r-- |
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: Expanded call bubble handler. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include <QtGui> |
|
19 |
#include <hbaction.h> |
|
20 |
#include <hbtextitem.h> |
|
21 |
||
22 |
#include "bubblemanager2.h" |
|
23 |
#include "bubbleexpandedhandler.h" |
|
24 |
#include "bubbleheader.h" |
|
25 |
#include "bubbleutils.h" |
|
26 |
#include "bubbleimagewidget.h" |
|
27 |
#include "bubbleheadingwidget.h" |
|
28 |
#include "bubblebutton.h" |
|
29 |
||
30 |
BubbleExpandedHandler::BubbleExpandedHandler( |
|
31 |
BubbleWidgetManager& widgetManager, |
|
32 |
BubbleWidgetManager::View view, |
|
33 |
BubbleWidgetManager::Container container, |
|
34 |
QObject* parent ) |
|
35 |
: BubbleHandler(widgetManager,view,container,parent) |
|
36 |
{ |
|
37 |
mHeading = qobject_cast<BubbleHeadingWidget*>( |
|
38 |
widget(BubbleWidgetManager::Heading)); |
|
39 |
Q_ASSERT(mHeading); |
|
40 |
||
41 |
mImage = qobject_cast<BubbleImageWidget*>( |
|
42 |
widget(BubbleWidgetManager::Image)); |
|
43 |
Q_ASSERT(mImage); |
|
44 |
||
45 |
mButtonCenter = qobject_cast<BubbleButton*>( |
|
46 |
widget(BubbleWidgetManager::CenterButton)); |
|
47 |
Q_ASSERT(mButtonCenter); |
|
48 |
mButtonLeft = qobject_cast<BubbleButton*>( |
|
49 |
widget(BubbleWidgetManager::LeftButton)); |
|
50 |
Q_ASSERT(mButtonLeft); |
|
51 |
mButtonRight = qobject_cast<BubbleButton*>( |
|
52 |
widget(BubbleWidgetManager::RightButton)); |
|
53 |
Q_ASSERT(mButtonRight); |
|
54 |
||
55 |
reset(); |
|
56 |
} |
|
57 |
||
58 |
BubbleExpandedHandler::~BubbleExpandedHandler() |
|
59 |
{ |
|
60 |
} |
|
61 |
||
62 |
void BubbleExpandedHandler::reset() |
|
63 |
{ |
|
64 |
mHeader = 0; |
|
65 |
mButtonCenter->hide(); |
|
66 |
mButtonCenter->setDown(false); |
|
67 |
mButtonCenter->disconnect(); |
|
68 |
mButtonLeft->hide(); |
|
69 |
mButtonLeft->setDown(false); |
|
70 |
mButtonLeft->disconnect(); |
|
71 |
mButtonRight->hide(); |
|
72 |
mButtonRight->setDown(false); |
|
73 |
mButtonRight->disconnect(); |
|
74 |
mImage->hide(); |
|
75 |
mHeading->reset(); |
|
76 |
} |
|
77 |
||
78 |
void BubbleExpandedHandler::readBubbleHeader( |
|
79 |
const BubbleHeader& header ) |
|
80 |
{ |
|
81 |
mHeader = &header; |
|
82 |
||
83 |
mHeading->readBubbleHeader(header); |
|
84 |
||
76 | 85 |
if (!header.callImage().isEmpty() || |
37 | 86 |
header.showDefaultAvatar()) { |
65 | 87 |
mImage->setImageName(header.callImage()); |
76 | 88 |
if (header.callFlags()&BubbleManagerIF::EmergencyCall) { |
89 |
mImage->displayEmergencyCallIcon(); |
|
90 |
} |
|
37 | 91 |
mImage->show(); |
92 |
} else { |
|
93 |
mImage->hide(); |
|
94 |
} |
|
95 |
||
96 |
setButtons(mHeader->actions()); |
|
97 |
} |
|
98 |
||
99 |
void BubbleExpandedHandler::setButtons(const QList<HbAction*>& actions) |
|
100 |
{ |
|
101 |
if ( actions.count()==1 && mButtonCenter ) { |
|
102 |
HbAction* action = actions.at(0); |
|
103 |
mButtonCenter->setIcon( action->icon() ); |
|
104 |
connect(mButtonCenter, SIGNAL( clicked() ), |
|
105 |
action, SLOT( trigger() ) ); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
106 |
connect(mButtonCenter, SIGNAL( longPress(QPointF)), |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
107 |
action, SLOT( trigger() ) ); |
37 | 108 |
BubbleUtils::setButtonStyleForAction(*mButtonCenter,*action); |
109 |
mButtonCenter->show(); |
|
110 |
} else if (actions.count()==2 && mButtonLeft && mButtonRight ) { |
|
111 |
// Left button |
|
112 |
HbAction* action1 = actions.at(0); |
|
113 |
mButtonLeft->setIcon(action1->icon()); |
|
114 |
connect( mButtonLeft, SIGNAL( clicked() ), |
|
115 |
action1, SLOT( trigger() ) ); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
116 |
connect( mButtonLeft, SIGNAL( longPress(QPointF)), |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
117 |
action1, SLOT( trigger() ) ); |
37 | 118 |
BubbleUtils::setButtonStyleForAction(*mButtonLeft,*action1); |
119 |
mButtonLeft->show(); |
|
120 |
// Right button |
|
121 |
HbAction* action2 = actions.at(1); |
|
122 |
mButtonRight->setIcon( action2->icon() ); |
|
123 |
connect( mButtonRight, SIGNAL( clicked() ), |
|
124 |
action2, SLOT( trigger() ) ); |
|
45
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
125 |
connect( mButtonRight, SIGNAL( longPress(QPointF)), |
6b911d05207e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
126 |
action2, SLOT( trigger() ) ); |
37 | 127 |
BubbleUtils::setButtonStyleForAction(*mButtonRight,*action2); |
128 |
mButtonRight->show(); |
|
129 |
} |
|
130 |
} |
|
131 |
||
132 |
QGraphicsWidget* BubbleExpandedHandler::graphicsWidgetForAction( |
|
133 |
HbAction* action ) const |
|
134 |
{ |
|
135 |
if ( mButtonLeft->text() == action->text() ) { |
|
136 |
return mButtonLeft; |
|
137 |
} else if ( mButtonRight->text() == action->text() ) { |
|
138 |
return mButtonRight; |
|
139 |
} else if ( mButtonCenter->text() == action->text() ) { |
|
140 |
return mButtonCenter; |
|
141 |
} else { |
|
142 |
return 0; |
|
143 |
} |
|
144 |
} |
|
145 |
||
146 |
void BubbleExpandedHandler::updateTimerDisplayNow() |
|
147 |
{ |
|
148 |
mHeading->updateTimerDisplayNow(); |
|
149 |
} |