|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <EIKENV.H> |
|
19 #include "starterwidget.h" |
|
20 #include <QRect> |
|
21 #include <QPainter> |
|
22 #include <QFont> |
|
23 #include <QFile> |
|
24 #include <QTimer> |
|
25 #include <hbmainwindow.h> |
|
26 #include <hbinstance.h> |
|
27 |
|
28 |
|
29 |
|
30 starterwidget::starterwidget( QGraphicsItem* parent ) |
|
31 : HbWidget( parent ) |
|
32 { |
|
33 mStart1 = new HbPushButton( "Start Search" ); |
|
34 mStart2 = new HbPushButton( "Start FileBrowser" ); |
|
35 |
|
36 mGridLayout = new QGraphicsGridLayout(); |
|
37 mGridLayout->addItem( mStart1, 1, 0, 1, 1 ); |
|
38 mGridLayout->addItem( mStart2, 2, 0, 1, 1 ); |
|
39 mGridLayout->setRowStretchFactor ( 0, 1 ); |
|
40 mGridLayout->setRowStretchFactor ( 1, 1 ); |
|
41 mGridLayout->setRowStretchFactor ( 2, 1 ); |
|
42 setLayout(mGridLayout); |
|
43 |
|
44 mTimer1 = new QTimer( this ); |
|
45 mTimer2 = new QTimer( this ); |
|
46 connect( mStart1, SIGNAL(released()), this, SLOT(startopen1() ) ); |
|
47 connect( mTimer1, SIGNAL(timeout()), this, SLOT(acivate1() ) ); |
|
48 connect( mStart2, SIGNAL(released()), this, SLOT(startopen2() ) ); |
|
49 connect( mTimer2, SIGNAL(timeout()), this, SLOT(acivate2() ) ); |
|
50 } |
|
51 |
|
52 starterwidget::~starterwidget() |
|
53 { |
|
54 |
|
55 } |
|
56 |
|
57 void starterwidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
58 { |
|
59 HbWidget::paint(painter, option, widget); |
|
60 |
|
61 if ( mMessage.isEmpty() || mMessage == "" ) |
|
62 { |
|
63 return; |
|
64 } |
|
65 QFont font; |
|
66 font.setPointSize(30); |
|
67 painter->setFont(font); |
|
68 painter->drawText(10, 100, mMessage ); |
|
69 } |
|
70 |
|
71 void starterwidget::startopen1() |
|
72 { |
|
73 mTimer1->start( 5000 ); |
|
74 } |
|
75 |
|
76 void starterwidget::startopen2() |
|
77 { |
|
78 mTimer2->start( 5000 ); |
|
79 } |
|
80 |
|
81 void starterwidget::acivate1() |
|
82 { |
|
83 bool ok = QProcess::startDetached("Searchapplication"); |
|
84 if ( !ok ) |
|
85 { |
|
86 mMessage = "Not Found 1"; |
|
87 } |
|
88 |
|
89 update(); |
|
90 mTimer1->stop(); |
|
91 } |
|
92 |
|
93 void starterwidget::acivate2() |
|
94 { |
|
95 bool ok = QProcess::startDetached("FileBrowser"); |
|
96 if ( !ok ) |
|
97 { |
|
98 mMessage = "Not Found 2"; |
|
99 } |
|
100 |
|
101 update(); |
|
102 mTimer2->stop(); |
|
103 } |
|
104 |
|
105 |