|
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 |
|
85 if (!mHeader->callImage().isEmpty() || |
|
86 header.showDefaultAvatar()) { |
|
87 mImage->setImage(header.callImage()); |
|
88 mImage->show(); |
|
89 } else { |
|
90 mImage->hide(); |
|
91 } |
|
92 |
|
93 setButtons(mHeader->actions()); |
|
94 } |
|
95 |
|
96 void BubbleExpandedHandler::setButtons(const QList<HbAction*>& actions) |
|
97 { |
|
98 if ( actions.count()==1 && mButtonCenter ) { |
|
99 HbAction* action = actions.at(0); |
|
100 mButtonCenter->setIcon( action->icon() ); |
|
101 connect(mButtonCenter, SIGNAL( clicked() ), |
|
102 action, SLOT( trigger() ) ); |
|
103 connect(mButtonCenter, SIGNAL( longPress(QPointF)), |
|
104 action, SLOT( trigger() ) ); |
|
105 BubbleUtils::setButtonStyleForAction(*mButtonCenter,*action); |
|
106 mButtonCenter->show(); |
|
107 } else if (actions.count()==2 && mButtonLeft && mButtonRight ) { |
|
108 // Left button |
|
109 HbAction* action1 = actions.at(0); |
|
110 mButtonLeft->setIcon(action1->icon()); |
|
111 connect( mButtonLeft, SIGNAL( clicked() ), |
|
112 action1, SLOT( trigger() ) ); |
|
113 connect( mButtonLeft, SIGNAL( longPress(QPointF)), |
|
114 action1, SLOT( trigger() ) ); |
|
115 BubbleUtils::setButtonStyleForAction(*mButtonLeft,*action1); |
|
116 mButtonLeft->show(); |
|
117 // Right button |
|
118 HbAction* action2 = actions.at(1); |
|
119 mButtonRight->setIcon( action2->icon() ); |
|
120 connect( mButtonRight, SIGNAL( clicked() ), |
|
121 action2, SLOT( trigger() ) ); |
|
122 connect( mButtonRight, SIGNAL( longPress(QPointF)), |
|
123 action2, SLOT( trigger() ) ); |
|
124 BubbleUtils::setButtonStyleForAction(*mButtonRight,*action2); |
|
125 mButtonRight->show(); |
|
126 } |
|
127 } |
|
128 |
|
129 QGraphicsWidget* BubbleExpandedHandler::graphicsWidgetForAction( |
|
130 HbAction* action ) const |
|
131 { |
|
132 if ( mButtonLeft->text() == action->text() ) { |
|
133 return mButtonLeft; |
|
134 } else if ( mButtonRight->text() == action->text() ) { |
|
135 return mButtonRight; |
|
136 } else if ( mButtonCenter->text() == action->text() ) { |
|
137 return mButtonCenter; |
|
138 } else { |
|
139 return 0; |
|
140 } |
|
141 } |
|
142 |
|
143 void BubbleExpandedHandler::updateTimerDisplayNow() |
|
144 { |
|
145 mHeading->updateTimerDisplayNow(); |
|
146 } |