taskswitcher/testapplications/appiconstarter/starterwidget.cpp
author Jaakko Haukipuro (Nokia-MS/Oulu) <Jaakko.Haukipuro@nokia.com>
Thu, 16 Sep 2010 12:11:40 +0100
changeset 117 c63ee96dbe5f
permissions -rw-r--r--
Missing activityfw and taskswitcher components - fix for Bug 3670

/*
* 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 <EIKENV.H>
#include "starterwidget.h"
#include <QRect>
#include <QPainter>
#include <QFont>
#include <QFile>
#include <QTimer>
#include <hbmainwindow.h>
#include <hbinstance.h>



starterwidget::starterwidget( QGraphicsItem* parent )
    : HbWidget( parent )
	{	
	mStart1 = new HbPushButton( "Start Search" );
	mStart2 = new HbPushButton( "Start FileBrowser" );
	
	mGridLayout = new QGraphicsGridLayout();
	mGridLayout->addItem( mStart1, 1, 0, 1, 1 );	
	mGridLayout->addItem( mStart2, 2, 0, 1, 1 );	
	mGridLayout->setRowStretchFactor ( 0, 1 );
	mGridLayout->setRowStretchFactor ( 1, 1 );
	mGridLayout->setRowStretchFactor ( 2, 1 );
	setLayout(mGridLayout);
	
    mTimer1 = new QTimer( this );
    mTimer2 = new QTimer( this );
	connect( mStart1, SIGNAL(released()), this, SLOT(startopen1() ) );	
	connect( mTimer1, SIGNAL(timeout()), this, SLOT(acivate1() ) );
    connect( mStart2, SIGNAL(released()), this, SLOT(startopen2() ) );	
	connect( mTimer2, SIGNAL(timeout()), this, SLOT(acivate2() ) );
	}

starterwidget::~starterwidget()
	{

	}

void starterwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
	{
	HbWidget::paint(painter, option, widget);
	
	if ( mMessage.isEmpty() || mMessage == "" )	
		{
		return;
		}
	QFont font;
	font.setPointSize(30);
	painter->setFont(font);
	painter->drawText(10, 100, mMessage );
	}

void starterwidget::startopen1()
	{
	mTimer1->start( 5000 );
	}

void starterwidget::startopen2()
	{
	mTimer2->start( 5000 );
	}

void starterwidget::acivate1()
	{
    bool ok = QProcess::startDetached("Searchapplication");
	if ( !ok )
		{
		mMessage = "Not Found 1";
		}
		
	update();
	mTimer1->stop();
	}
	
void starterwidget::acivate2()
	{
    bool ok = QProcess::startDetached("FileBrowser");
	if ( !ok )
		{
		mMessage = "Not Found 2";
		}
		
	update();
	mTimer2->stop();
	}