31
|
1 |
/*
|
39
|
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 |
* WLAN Wizard Page: SSID Selection.
|
|
16 |
*/
|
31
|
17 |
|
|
18 |
// System includes
|
|
19 |
#include <HbDocumentLoader>
|
|
20 |
#include <HbMainWindow>
|
|
21 |
#include <HbWidget>
|
|
22 |
#include <HbLineEdit>
|
|
23 |
#include <HbEditorInterface>
|
|
24 |
#include <HbLabel>
|
|
25 |
#include <wlanqtutils.h>
|
|
26 |
|
|
27 |
// User includes
|
|
28 |
#include "wlanwizardpagessid.h"
|
|
29 |
#include "wlanwizard_p.h"
|
|
30 |
#include "wlanwizardutils.h"
|
|
31 |
#include "OstTraceDefinitions.h"
|
|
32 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
33 |
#include "wlanwizardpagessidTraces.h"
|
|
34 |
#endif
|
|
35 |
|
|
36 |
/*!
|
39
|
37 |
* Constructor method for the SSID query view object.
|
|
38 |
* @param [in] parent pointer to parent object.
|
31
|
39 |
*/
|
|
40 |
WlanWizardPageSsid::WlanWizardPageSsid(WlanWizardPrivate* parent) :
|
|
41 |
WlanWizardPageInternal(parent),
|
|
42 |
mWidget(NULL),
|
|
43 |
mLabel(NULL),
|
|
44 |
mSsid(NULL),
|
|
45 |
mLoader(NULL)
|
|
46 |
{
|
|
47 |
|
|
48 |
}
|
|
49 |
|
|
50 |
/*!
|
|
51 |
* Destructor. Loader widget is deleted.
|
|
52 |
* All document widgets are deleted by wlanwizard_p destructor.
|
|
53 |
*/
|
|
54 |
WlanWizardPageSsid::~WlanWizardPageSsid()
|
|
55 |
{
|
|
56 |
delete mLoader;
|
|
57 |
}
|
|
58 |
|
|
59 |
/*!
|
|
60 |
* Page initialization. If view is already loaded, does nothing.
|
39
|
61 |
* @return pointer to widget "occ_add_wlan_01".
|
31
|
62 |
*/
|
|
63 |
HbWidget* WlanWizardPageSsid::initializePage()
|
|
64 |
{
|
|
65 |
OstTrace0( TRACE_NORMAL, WLANWIZARDPAGESSID_INITIALIZEPAGE,
|
|
66 |
"WlanWizardPageSsid::initializePage" );
|
|
67 |
|
39
|
68 |
// It is not possible for this method to be called more than once during
|
|
69 |
// wizard lifetime.
|
|
70 |
Q_ASSERT(mWidget == NULL);
|
31
|
71 |
|
39
|
72 |
bool ok;
|
31
|
73 |
|
39
|
74 |
mLoader = new HbDocumentLoader(mWizard->mainWindow());
|
31
|
75 |
|
39
|
76 |
mLoader->load(":/docml/occ_add_wlan_01_04.docml", &ok);
|
|
77 |
Q_ASSERT(ok);
|
|
78 |
|
|
79 |
// Load orientation
|
|
80 |
loadDocmlSection(mWizard->mainWindow()->orientation());
|
31
|
81 |
|
39
|
82 |
// Load widgets
|
|
83 |
mWidget = qobject_cast<HbWidget*> (mLoader->findWidget(
|
|
84 |
"occ_add_wlan_01"));
|
|
85 |
Q_ASSERT(mWidget != NULL);
|
31
|
86 |
|
39
|
87 |
mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog"));
|
|
88 |
Q_ASSERT(mLabel != NULL);
|
31
|
89 |
|
39
|
90 |
mSsid = qobject_cast<HbLineEdit*> (mLoader->findWidget("lineEditKey"));
|
|
91 |
Q_ASSERT(mSsid != NULL);
|
|
92 |
|
|
93 |
mLabel->setPlainText(hbTrId(
|
|
94 |
"txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));
|
31
|
95 |
|
39
|
96 |
// Connect orientation signal from the main window to orientation
|
|
97 |
// loader.
|
|
98 |
ok = connect(mWizard->mainWindow(),
|
|
99 |
SIGNAL(orientationChanged(Qt::Orientation)), this,
|
|
100 |
SLOT(loadDocmlSection(Qt::Orientation)));
|
|
101 |
Q_ASSERT(ok);
|
31
|
102 |
|
39
|
103 |
// Connect text change-signal from input dialog to handler function
|
|
104 |
ok = connect(mSsid, SIGNAL(textChanged(const QString &)), this,
|
|
105 |
SLOT(textChanged(const QString &)));
|
|
106 |
Q_ASSERT(ok);
|
31
|
107 |
|
39
|
108 |
HbEditorInterface editInterface(mSsid);
|
|
109 |
|
|
110 |
// TODO: remove (HbEditorConstraints) type cast when
|
|
111 |
// Q_DECLARE_OPERATORS_FOR_FLAGS(HbEditorConstraints) is defined (SDK xxx)
|
|
112 |
editInterface.setInputConstraints(
|
|
113 |
(HbEditorConstraints)(HbEditorConstraintAutoCompletingField |
|
|
114 |
HbEditorConstraintLatinAlphabetOnly));
|
|
115 |
|
|
116 |
editInterface.setSmileyTheme(HbSmileyTheme());
|
|
117 |
editInterface.setEditorClass(HbInputEditorClassNetworkName);
|
|
118 |
mSsid->setInputMethodHints(
|
|
119 |
Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase);
|
|
120 |
mSsid->setMaxLength(WlanWizardUtils::SsidMaxLength);
|
31
|
121 |
|
39
|
122 |
return mWidget;
|
31
|
123 |
}
|
|
124 |
|
|
125 |
/*!
|
39
|
126 |
* This method is overrides the default implementation from WlanWizardPage.
|
|
127 |
* It indicates whether the Next-button should be enabled or not.
|
|
128 |
* @return true, if mSsid edit field is not empty.
|
|
129 |
*/
|
|
130 |
bool WlanWizardPageSsid::showPage()
|
|
131 |
{
|
|
132 |
// Initiate the scanning of public APs here.
|
|
133 |
mWizard->wlanQtUtils()->scanWlanAps();
|
|
134 |
|
|
135 |
// Open virtual keyboard by setting focus to line edit
|
|
136 |
mSsid->setFocus();
|
|
137 |
|
|
138 |
return !(mSsid->text().isEmpty());
|
|
139 |
}
|
|
140 |
|
|
141 |
/*!
|
|
142 |
* Stores the SSID selection in the configuration.
|
|
143 |
* @param [out] removeFromStack returns false.
|
|
144 |
* @return WlanWizardPageScanning page id.
|
31
|
145 |
*/
|
|
146 |
int WlanWizardPageSsid::nextId(bool &removeFromStack) const
|
|
147 |
{
|
|
148 |
removeFromStack = false;
|
|
149 |
|
39
|
150 |
// SSID is stored into configuration
|
|
151 |
mWizard->setConfiguration(WlanWizardPrivate::ConfSsid, mSsid->text());
|
|
152 |
|
|
153 |
return WlanWizardPageInternal::PageScanning;
|
31
|
154 |
}
|
|
155 |
|
|
156 |
/*!
|
39
|
157 |
* Loads the document orientation information from occ_add_wlan_01_04.docml
|
|
158 |
* This is called each time phone orientation changes.
|
|
159 |
* @param [in] orientation indicates whether the phone is in portrait or
|
|
160 |
* landscape mode.
|
31
|
161 |
*/
|
39
|
162 |
void WlanWizardPageSsid::loadDocmlSection(Qt::Orientation orientation)
|
31
|
163 |
{
|
|
164 |
OstTrace1( TRACE_FLOW, WLANWIZARDPAGESSID_LOADDOCML,
|
|
165 |
"WlanWizardPageSsid::loadDocml - orientation ;orientation=%x",
|
|
166 |
( TUint )( orientation ) );
|
|
167 |
|
39
|
168 |
WlanWizardPageInternal::loadDocmlSection(
|
|
169 |
mLoader,
|
|
170 |
orientation,
|
|
171 |
":/docml/occ_add_wlan_01_04.docml",
|
|
172 |
"portrait_section",
|
|
173 |
"landscape_section");
|
31
|
174 |
}
|
|
175 |
|
|
176 |
/*!
|
39
|
177 |
* Executed when changes have been made to the mSsid field (and the field is
|
|
178 |
* not empty).
|
|
179 |
* @param [in] text is not used at this point.
|
31
|
180 |
*/
|
39
|
181 |
void WlanWizardPageSsid::textChanged(const QString &text)
|
31
|
182 |
{
|
39
|
183 |
Q_UNUSED(text);
|
|
184 |
OstTrace0( TRACE_FLOW, WLANWIZARDPAGESSID_TEXTCHANGED,
|
|
185 |
"WlanWizardPageSsid::textChanged in text edit widget" );
|
31
|
186 |
|
39
|
187 |
mWizard->enableNextButton(!(mSsid->text().isEmpty()));
|
31
|
188 |
}
|