diff -r 40a3f856b14d -r 41a7f70b3818 phoneuis/bubblemanager2/bubblecore/src/bubbleexpandedhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/phoneuis/bubblemanager2/bubblecore/src/bubbleexpandedhandler.cpp Tue Aug 31 15:14:29 2010 +0300 @@ -0,0 +1,146 @@ +/*! +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Expanded call bubble handler. +* +*/ + +#include +#include +#include + +#include "bubblemanager2.h" +#include "bubbleexpandedhandler.h" +#include "bubbleheader.h" +#include "bubbleutils.h" +#include "bubbleimagewidget.h" +#include "bubbleheadingwidget.h" +#include "bubblebutton.h" + +BubbleExpandedHandler::BubbleExpandedHandler( + BubbleWidgetManager& widgetManager, + BubbleWidgetManager::View view, + BubbleWidgetManager::Container container, + QObject* parent ) + : BubbleHandler(widgetManager,view,container,parent) +{ + mHeading = qobject_cast( + widget(BubbleWidgetManager::Heading)); + Q_ASSERT(mHeading); + + mImage = qobject_cast( + widget(BubbleWidgetManager::Image)); + Q_ASSERT(mImage); + + mButtonCenter = qobject_cast( + widget(BubbleWidgetManager::CenterButton)); + Q_ASSERT(mButtonCenter); + mButtonLeft = qobject_cast( + widget(BubbleWidgetManager::LeftButton)); + Q_ASSERT(mButtonLeft); + mButtonRight = qobject_cast( + widget(BubbleWidgetManager::RightButton)); + Q_ASSERT(mButtonRight); + + reset(); +} + +BubbleExpandedHandler::~BubbleExpandedHandler() +{ +} + +void BubbleExpandedHandler::reset() +{ + mHeader = 0; + mButtonCenter->hide(); + mButtonCenter->setDown(false); + mButtonCenter->disconnect(); + mButtonLeft->hide(); + mButtonLeft->setDown(false); + mButtonLeft->disconnect(); + mButtonRight->hide(); + mButtonRight->setDown(false); + mButtonRight->disconnect(); + mImage->hide(); + mHeading->reset(); +} + +void BubbleExpandedHandler::readBubbleHeader( + const BubbleHeader& header ) +{ + mHeader = &header; + + mHeading->readBubbleHeader(header); + + if (!mHeader->callImage().isEmpty() || + header.showDefaultAvatar()) { + mImage->setImage(header.callImage()); + mImage->show(); + } else { + mImage->hide(); + } + + setButtons(mHeader->actions()); +} + +void BubbleExpandedHandler::setButtons(const QList& actions) +{ + if ( actions.count()==1 && mButtonCenter ) { + HbAction* action = actions.at(0); + mButtonCenter->setIcon( action->icon() ); + connect(mButtonCenter, SIGNAL( clicked() ), + action, SLOT( trigger() ) ); + connect(mButtonCenter, SIGNAL( longPress(QPointF)), + action, SLOT( trigger() ) ); + BubbleUtils::setButtonStyleForAction(*mButtonCenter,*action); + mButtonCenter->show(); + } else if (actions.count()==2 && mButtonLeft && mButtonRight ) { + // Left button + HbAction* action1 = actions.at(0); + mButtonLeft->setIcon(action1->icon()); + connect( mButtonLeft, SIGNAL( clicked() ), + action1, SLOT( trigger() ) ); + connect( mButtonLeft, SIGNAL( longPress(QPointF)), + action1, SLOT( trigger() ) ); + BubbleUtils::setButtonStyleForAction(*mButtonLeft,*action1); + mButtonLeft->show(); + // Right button + HbAction* action2 = actions.at(1); + mButtonRight->setIcon( action2->icon() ); + connect( mButtonRight, SIGNAL( clicked() ), + action2, SLOT( trigger() ) ); + connect( mButtonRight, SIGNAL( longPress(QPointF)), + action2, SLOT( trigger() ) ); + BubbleUtils::setButtonStyleForAction(*mButtonRight,*action2); + mButtonRight->show(); + } +} + +QGraphicsWidget* BubbleExpandedHandler::graphicsWidgetForAction( + HbAction* action ) const +{ + if ( mButtonLeft->text() == action->text() ) { + return mButtonLeft; + } else if ( mButtonRight->text() == action->text() ) { + return mButtonRight; + } else if ( mButtonCenter->text() == action->text() ) { + return mButtonCenter; + } else { + return 0; + } +} + +void BubbleExpandedHandler::updateTimerDisplayNow() +{ + mHeading->updateTimerDisplayNow(); +}