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