diff -r 3ab5c078b490 -r c63ee96dbe5f activityfw/testapplications/activitytakeawhile/letterwidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/activityfw/testapplications/activitytakeawhile/letterwidget.cpp Thu Sep 16 12:11:40 2010 +0100 @@ -0,0 +1,126 @@ +/* +* 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: +* +*/ +#include "letterwidget.h" +#include +#include + + +letterwidget::letterwidget(QGraphicsItem *parent) + : HbWidget(parent) +{ + mA = new HbPushButton("A"); + mB = new HbPushButton("B"); + mC = new HbPushButton("C"); + + mSave = new HbPushButton("Save"); + mDel = new HbPushButton("Delete"); + mWait = new HbPushButton("Wait 10 s"); + mPanic = new HbPushButton("Panic client process"); + + + mGridLayout = new QGraphicsGridLayout(); + mGridLayout->addItem(mA, 3, 0, 1, 1); + mGridLayout->addItem(mB, 3, 1, 1, 1); + mGridLayout->addItem(mC, 3, 2, 1, 1); + mGridLayout->addItem(mSave, 4, 0, 1, 1); + mGridLayout->addItem(mDel, 4, 1, 1, 1); + mGridLayout->addItem(mWait, 4, 2, 1, 1); + mGridLayout->addItem(mPanic, 5, 0, 1, 3); + mGridLayout->setRowStretchFactor(0, 1); + mGridLayout->setRowStretchFactor(1, 1); + mGridLayout->setRowStretchFactor(2, 1); + setLayout(mGridLayout); + + connect(mA, SIGNAL(released()), this, SLOT(toA())); + connect(mB, SIGNAL(released()), this, SLOT(toB())); + connect(mC, SIGNAL(released()), this, SLOT(toC())); + connect(mWait, SIGNAL(released()), this, SLOT(wait())); + connect(mPanic, SIGNAL(released()), this, SLOT(panic())); + + connect(mSave, SIGNAL(released()), this, SIGNAL(save())); + connect(mDel, SIGNAL(released()), this, SIGNAL(del())); + + toA(); + +} + +letterwidget::~letterwidget() +{ + // TODO Auto-generated destructor stub +} + +void letterwidget::toA() +{ + mStatename = "A"; + update(); +} + +void letterwidget::toB() +{ + mStatename = "B"; + update(); +} + +void letterwidget::toC() +{ + mStatename = "C"; + update(); +} + +void letterwidget::wait() + { + User::After(10000000); //10 s + } + +void letterwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + HbWidget::paint(painter, option, widget); + + if ( mStatename.isNull() ) { + return; + } + else if ( mStatename == "A" ) { + painter->setPen(Qt::red); + } + else if ( mStatename == "B" ) { + painter->setPen(Qt::green); + } + else { + painter->setPen(Qt::blue); + } + + QFont font; + font.setPointSize(60); + painter->setFont(font); + painter->drawText(10, 140, mStatename); +} + +QString letterwidget::state() +{ + return mStatename; +} + +void letterwidget::setState( QString state ) +{ + mStatename = state; + update(); +} + +void letterwidget::panic() +{ + User::Panic(_L("forced panic"), 122); +}