1 /* |
|
2 * Copyright (c) 2010 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: Test application for SW install indicator plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "testindiapp.h" |
|
19 #include <hbmainwindow.h> |
|
20 #include <hbview.h> |
|
21 #include <QGraphicsLinearLayout> |
|
22 #include <hbtextitem.h> |
|
23 #include <hbpushbutton.h> |
|
24 #include <hbindicator.h> |
|
25 #include <hbmessagebox.h> |
|
26 #include <qvaluespacesubscriber.h> |
|
27 #include "../../inc/sifuiinstallindicatorparams.h" |
|
28 |
|
29 |
|
30 TestInstallIndicator::TestInstallIndicator(int& argc, char* argv[]) : HbApplication(argc, argv), |
|
31 mMainWindow(0), mMainView(0), mIndicator(0), mSubscriber(0) |
|
32 { |
|
33 mMainWindow = new HbMainWindow(); |
|
34 mMainView = new HbView(); |
|
35 mMainView->setTitle(tr("TestInstIndi")); |
|
36 |
|
37 mIndicator = new HbIndicator; |
|
38 |
|
39 mSubscriber = new QTM_PREPEND_NAMESPACE(QValueSpaceSubscriber(KSifUiInstallIndicatorStatusPath)); |
|
40 connect(mSubscriber, SIGNAL(contentsChanged()), this, SLOT(handleIndicatorActivity())); |
|
41 |
|
42 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical); |
|
43 |
|
44 HbTextItem *infoText = new HbTextItem; |
|
45 infoText->setText("Activate/deactivate SW install indicator in universal indicator popup."); |
|
46 infoText->setTextWrapping(Hb::TextWordWrap); |
|
47 layout->addItem(infoText); |
|
48 |
|
49 HbPushButton *activateButton = new HbPushButton("Activate install indicator"); |
|
50 connect(activateButton, SIGNAL(clicked()), this, SLOT(activatePressed())); |
|
51 layout->addItem(activateButton); |
|
52 |
|
53 HbPushButton *deactivateButton = new HbPushButton("Deactivate install indicator"); |
|
54 connect(deactivateButton, SIGNAL(clicked()), this, SLOT(deactivatePressed())); |
|
55 layout->addItem(deactivateButton); |
|
56 |
|
57 HbPushButton *closeButton = new HbPushButton("Close"); |
|
58 connect(closeButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
59 layout->addItem(closeButton); |
|
60 |
|
61 mMainView->setLayout(layout); |
|
62 mMainWindow->addView(mMainView); |
|
63 mMainWindow->show(); |
|
64 } |
|
65 |
|
66 TestInstallIndicator::~TestInstallIndicator() |
|
67 { |
|
68 delete mSubscriber; |
|
69 delete mIndicator; |
|
70 delete mMainView; |
|
71 delete mMainWindow; |
|
72 } |
|
73 |
|
74 bool TestInstallIndicator::isIndicatorActive() |
|
75 { |
|
76 bool isActive = false; |
|
77 if (mSubscriber) { |
|
78 QVariant variant = mSubscriber->value(); |
|
79 bool valueOk = false; |
|
80 int intValue = variant.toInt(&valueOk); |
|
81 if (valueOk && intValue) { |
|
82 isActive = true; |
|
83 } |
|
84 } |
|
85 return isActive; |
|
86 } |
|
87 |
|
88 void TestInstallIndicator::handleIndicatorActivity() |
|
89 { |
|
90 if (isIndicatorActive()) { |
|
91 HbMessageBox::information("Indicator activated"); |
|
92 } else { |
|
93 HbMessageBox::information("Indicator deactivated"); |
|
94 } |
|
95 } |
|
96 |
|
97 void TestInstallIndicator::activatePressed() |
|
98 { |
|
99 if (mIndicator) { |
|
100 if (isIndicatorActive()) { |
|
101 HbMessageBox::information("Already active"); |
|
102 } else { |
|
103 QVariant parameter(QString("Application")); |
|
104 mIndicator->activate(KSifUiInstallIndicatorType, parameter); |
|
105 } |
|
106 } |
|
107 } |
|
108 |
|
109 void TestInstallIndicator::deactivatePressed() |
|
110 { |
|
111 if (mIndicator) { |
|
112 if (isIndicatorActive()) { |
|
113 mIndicator->deactivate(KSifUiInstallIndicatorType); |
|
114 } else { |
|
115 HbMessageBox::information("Already deactive"); |
|
116 } |
|
117 } |
|
118 } |
|
119 |
|