|
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: |
|
15 * Test application for wizards. |
|
16 */ |
|
17 |
|
18 #include <qgraphicswidget> |
|
19 #include <hbpushbutton.h> |
|
20 #include <hbdocumentloader.h> |
|
21 #include <hbcombobox.h> |
|
22 #include <hbcheckbox.h> |
|
23 #include <hblineedit.h> |
|
24 #include <hblabel.h> |
|
25 |
|
26 #include <qdebug.h> |
|
27 |
|
28 #include "firstview.h" |
|
29 #include "wlanwizard.h" |
|
30 |
|
31 FirstView::FirstView() : |
|
32 mWizard(NULL) |
|
33 { |
|
34 qDebug("FirstView::FirstView()"); |
|
35 bool ok = false; |
|
36 HbDocumentLoader loader; |
|
37 loader.load(":/docml/mainview.docml", &ok); |
|
38 Q_ASSERT_X(ok, "EAP Wizard EXE", "Invalid docml file"); |
|
39 |
|
40 QGraphicsWidget *widget = loader.findWidget("view"); |
|
41 Q_ASSERT_X(widget != 0, "TestEapWizard", "View not found"); |
|
42 |
|
43 HbPushButton *action = qobject_cast<HbPushButton *> (loader.findObject("startWizard")); |
|
44 Q_ASSERT_X(action != 0, "TestEapWizard", "startWizard not found"); |
|
45 connect(action, SIGNAL(clicked(bool)), this, SLOT(start(bool))); |
|
46 |
|
47 mUseConf = qobject_cast<HbCheckBox *> (loader.findWidget("useConf")); |
|
48 Q_ASSERT_X(mUseConf != 0, "TestEapWizard", "useConf not found"); |
|
49 |
|
50 mSsid = qobject_cast<HbLineEdit *> (loader.findWidget("ssid")); |
|
51 Q_ASSERT_X(mSsid != 0, "TestEapWizard", "ssid not found"); |
|
52 |
|
53 mNetworkMode = qobject_cast<HbComboBox *> (loader.findWidget("networkMode")); |
|
54 Q_ASSERT_X(mNetworkMode != 0, "TestEapWizard", "networkMode not found"); |
|
55 |
|
56 mSecurityMode = qobject_cast<HbComboBox *> (loader.findWidget("securityMode")); |
|
57 Q_ASSERT_X(mSecurityMode != 0, "TestEapWizard", "securityMode not found"); |
|
58 |
|
59 mUseWpaPsk = qobject_cast<HbCheckBox *> (loader.findWidget("useWpaPsk")); |
|
60 Q_ASSERT_X(mUseWpaPsk != 0, "TestEapWizard", "useWpaPsk not found"); |
|
61 |
|
62 mUseWps = qobject_cast<HbCheckBox *> (loader.findWidget("useWps")); |
|
63 Q_ASSERT_X(mUseConf != 0, "TestEapWizard", "useWps not found"); |
|
64 |
|
65 mStatus = qobject_cast<HbLabel *> (loader.findWidget("labelWizardStatus")); |
|
66 Q_ASSERT_X(mStatus != 0, "TestEapWizard", "labelWizardStatus not found"); |
|
67 |
|
68 setWidget(widget); |
|
69 qDebug("FirstView::FirstView() - done %d", action); |
|
70 } |
|
71 |
|
72 FirstView::~FirstView() |
|
73 { |
|
74 delete mWizard; |
|
75 } |
|
76 |
|
77 void FirstView::start(bool) |
|
78 { |
|
79 qDebug("FirstView::Start"); |
|
80 if (!mWizard) { |
|
81 mWizard = new WlanWizard(mainWindow()); |
|
82 |
|
83 connect(mWizard, SIGNAL(finished(int, bool)), this, SLOT(finished(int, bool))); |
|
84 connect(mWizard, SIGNAL(cancelled()), this, SLOT(cancelled())); |
|
85 } |
|
86 |
|
87 if (mUseConf->isChecked()) { |
|
88 mWizard->setParameters( |
|
89 mSsid->text(), |
|
90 mNetworkMode->currentIndex(), |
|
91 1 << mSecurityMode->currentIndex(), |
|
92 mUseWpaPsk->isChecked(), |
|
93 mUseWps->isChecked()); |
|
94 } |
|
95 |
|
96 mWizard->show(); |
|
97 } |
|
98 |
|
99 void FirstView::deleteWizard() |
|
100 { |
|
101 qDebug("FirstView::deleteWizard"); |
|
102 |
|
103 Q_ASSERT(mWizard); |
|
104 mWizard->deleteLater(); |
|
105 mWizard = NULL; |
|
106 |
|
107 } |
|
108 |
|
109 void FirstView::finished(int iapId, bool connected) |
|
110 { |
|
111 qDebug("FirstView::complete(), iap id: %d, connected: %d", iapId, connected); |
|
112 QString text; |
|
113 text.setNum(iapId); |
|
114 text.prepend("Finished, IAP ID: "); |
|
115 mStatus->setPlainText(text); |
|
116 deleteWizard(); |
|
117 } |
|
118 |
|
119 void FirstView::cancelled() |
|
120 { |
|
121 qDebug("FirstView::cancelled()"); |
|
122 mStatus->setPlainText("Cancelled"); |
|
123 deleteWizard(); |
|
124 } |