diff -r 3ab5c078b490 -r c63ee96dbe5f taskswitcher/testapplications/tstestdogapp/lunchwidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taskswitcher/testapplications/tstestdogapp/lunchwidget.cpp Thu Sep 16 12:11:40 2010 +0100 @@ -0,0 +1,175 @@ +/* +* 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 "lunchwidget.h" +#include +#include +#include +#include +#include +#include +#include "tstasksettings.h" + + + +#define hbApp qobject_cast(qApp) + +lunchwidget::lunchwidget(QGraphicsItem *parent) + : HbWidget(parent) +{ + mClient = new TsTaskSettings; + + mAnimal1 = new QPixmap(":/images/bernardyn.jpg"); + mAnimal2 = new QPixmap(":/images/newfunland.jpg"); + + mResultLabel = new HbLabel; + mPhotoLabel= new HbLabel; + // mPriorityLabel = new HbLabel("Priority"); + + mRegisterButton = new HbPushButton("Register"); + mUnregisterButton = new HbPushButton("Unregister"); + mHideButton = new HbPushButton("Hide me"); + mShowButton = new HbPushButton("Show me"); + mAnimal1Button = new HbPushButton("Bernardyn"); + mAnimal2Button = new HbPushButton("Newfunland"); + mClearButton = new HbPushButton("Clear"); + + /*mPriorityCombo = new HbComboBox(); + mPriorityCombo->addItem("default"); + mPriorityCombo->addItem("low"); + mPriorityCombo->addItem("medium"); + mPriorityCombo->addItem("high");*/ + + mGridLayout = new QGraphicsGridLayout(); + mGridLayout->addItem(mPhotoLabel, 0, 0, 6, 6); + mGridLayout->addItem(mResultLabel, 6, 0, 1, 3); + mGridLayout->addItem(mClearButton, 6, 4, 1, 3); + //mGridLayout->addItem(mPriorityLabel, 7, 0, 1, 3); + //mGridLayout->addItem(mPriorityCombo, 7, 4, 1, 3); + mGridLayout->addItem(mRegisterButton, 7, 0, 1, 3); + mGridLayout->addItem(mUnregisterButton, 7, 4, 1, 3); + mGridLayout->addItem(mAnimal1Button, 8, 0, 1, 3); + mGridLayout->addItem(mAnimal2Button, 8, 4, 1, 3); + mGridLayout->addItem(mHideButton, 9, 0, 1, 3); + mGridLayout->addItem(mShowButton, 9, 4, 1, 3); + mGridLayout->setRowFixedHeight(0, 300); + setLayout(mGridLayout); + + connect( mRegisterButton, SIGNAL(released()), this, SLOT(regScr()) ); + connect( mUnregisterButton, SIGNAL(released()), this, SLOT(unregScr()) ); + connect( mHideButton, SIGNAL(released()), this, SLOT(hideMe()) ); + connect( mShowButton, SIGNAL(released()), this, SLOT(showMe()) ); + connect( mAnimal1Button, SIGNAL(released()), this, SLOT(animal1()) ); + connect( mAnimal2Button, SIGNAL(released()), this, SLOT(animal2()) ); + connect( mClearButton, SIGNAL(released()), this, SLOT(clear()) ); +} + +lunchwidget::~lunchwidget() +{ + delete mClient; + delete mAnimal1; + delete mAnimal2; +} + +void lunchwidget::regScr() +{ + HbMainWindow *mainWindow = hbInstance->allMainWindows().first(); + QPixmap screenshot = QPixmap::grabWidget(mainWindow, mainWindow->rect()); + + Before(); + bool ok = mClient->registerScreenshot(screenshot); + After(); + Result(); + setResult(ok); +} + +void lunchwidget::unregScr() +{ + Before(); + bool ok = mClient->unregisterScreenshot(); + After(); + Result(); + setResult(ok); +} + +void lunchwidget::hideMe() +{ + Before(); + bool ok = mClient->setVisibility(false); + After(); + Result(); + setResult(ok); +} + +void lunchwidget::showMe() +{ + Before(); + bool ok = mClient->setVisibility(true); + After(); + Result(); + setResult(ok); +} + +void lunchwidget::Before() +{ + TTime time; + time.HomeTime(); + iBefore = time.Int64(); +} + +void lunchwidget::After() +{ + TTime time; + time.HomeTime(); + iAfter = time.Int64(); +} + +void lunchwidget::Result() +{ + TInt64 res(0); + res = iAfter-iBefore; + res = res/1000; + iResult = res; +} + +void lunchwidget::animal1() +{ + mPhotoLabel->setIcon(QIcon(*mAnimal1)); +} + +void lunchwidget::animal2() +{ + mPhotoLabel->setIcon(QIcon(*mAnimal2)); +} + +void lunchwidget::clear() +{ + mPhotoLabel->setIcon(QIcon()); + mResultLabel->setPlainText(""); +} + +void lunchwidget::setResult(bool ok) +{ + if ( ok ) { + QString msg; + msg = tr("%1 ms").arg(iResult); + mResultLabel->setPlainText(msg); + } + else { + mResultLabel->setPlainText("Fail"); + } + +}