19 |
19 |
20 #include <QGraphicsLinearLayout> |
20 #include <QGraphicsLinearLayout> |
21 #include <QWebFrame> |
21 #include <QWebFrame> |
22 |
22 |
23 // System includes |
23 // System includes |
24 #include <HbDocumentLoader> |
|
25 #include <HbToolbar> |
24 #include <HbToolbar> |
26 #include <HbAction> |
25 #include <HbAction> |
27 #include <HbProgressBar> |
26 #include <HbProgressBar> |
28 #include <HbScrollBar> |
27 #include <HbScrollBar> |
29 #include <HbScrollArea> |
28 #include <HbScrollArea> |
30 #include <HbWidget> |
29 #include <HbWidget> |
|
30 #include <HbMainWindow> |
31 |
31 |
32 // User includes |
32 // User includes |
|
33 #include "wlanlogindocumentloader.h" |
33 #include "wlanloginview.h" |
34 #include "wlanloginview.h" |
34 #include "wlanloginwebview.h" |
35 #include "wlanloginwebview.h" |
35 #include "wlanloginwebpage.h" |
36 #include "wlanloginwebpage.h" |
36 #include "wlanloginmainwindow.h" |
37 #include "wlanloginmainwindow.h" |
37 #include "wlanloginengine.h" |
38 #include "wlanloginengine.h" |
48 */ |
49 */ |
49 |
50 |
50 // External function prototypes |
51 // External function prototypes |
51 |
52 |
52 // Local constants |
53 // Local constants |
|
54 //! WLAN Login view docml file |
|
55 static const QString wlanLoginViewDocml(":/docml/wlanloginview.docml"); |
53 |
56 |
54 // ======== LOCAL FUNCTIONS ======== |
57 // ======== LOCAL FUNCTIONS ======== |
55 |
58 |
56 // ======== MEMBER FUNCTIONS ======== |
59 // ======== MEMBER FUNCTIONS ======== |
57 |
60 |
58 /*! |
61 /*! |
59 Constructor |
62 Constructor |
60 */ |
63 */ |
61 WlanLoginView::WlanLoginView(WlanLoginApplication* appRef): |
64 WlanLoginView::WlanLoginView(WlanLoginMainWindow* mainWindow): |
62 mAppRef(appRef), |
65 mMainWindow(mainWindow), |
63 mMainLayout(NULL), |
66 mDocLoader(new WlanLoginDocumentLoader(mainWindow)), |
64 mContentLayout(NULL), |
|
65 mProgressBar(NULL), |
67 mProgressBar(NULL), |
66 mScrollArea(NULL), |
|
67 mScrollAreaContent(NULL), |
68 mScrollAreaContent(NULL), |
68 mWebView(NULL), |
69 mWebView(NULL), |
69 mToolBar(NULL), |
|
70 mCancelAction(NULL), |
|
71 mNextAction(NULL), |
70 mNextAction(NULL), |
72 mContinueAction(NULL) |
71 mFirstIctsOkResult(true) |
73 { |
72 { |
74 OstTraceFunctionEntry0(WLANLOGINVIEW_WLANLOGINVIEW_ENTRY); |
73 OstTraceFunctionEntry0(WLANLOGINVIEW_WLANLOGINVIEW_ENTRY); |
75 |
74 |
|
75 loadDocml(); |
|
76 |
76 setTitleBarVisible(false); |
77 setTitleBarVisible(false); |
77 setStatusBarVisible(false); |
78 setStatusBarVisible(false); |
78 |
|
79 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
80 mMainLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
81 mMainLayout->setContentsMargins(0,0,0,0); |
|
82 setLayout(mMainLayout); |
|
83 |
|
84 mScrollArea = new HbScrollArea(); |
|
85 mScrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
86 mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
|
87 mScrollArea->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
|
88 mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal); |
|
89 mScrollArea->setClampingStyle( HbScrollArea::StrictClamping ); |
|
90 mScrollArea->setScrollingStyle( HbScrollArea::PanWithFollowOn ); |
|
91 mMainLayout->addItem(mScrollArea); |
|
92 |
|
93 mScrollAreaContent = new HbWidget(); |
|
94 mScrollAreaContent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
95 mContentLayout = new QGraphicsLinearLayout(Qt::Vertical); |
|
96 mContentLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
97 mContentLayout->setContentsMargins(0,0,0,0); |
|
98 mScrollAreaContent->setLayout(mContentLayout); |
|
99 mScrollArea->setContentWidget(mScrollAreaContent); |
|
100 |
79 |
101 // Set white background to content widget |
80 // Set white background to content widget |
102 QPixmap pixmap(10,10); |
81 QPixmap pixmap(10,10); |
103 pixmap.fill(Qt::white); |
82 pixmap.fill(Qt::white); |
104 QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap); |
83 QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap); |
105 mScrollAreaContent->setBackgroundItem(pixmapItem); |
84 mScrollAreaContent->setBackgroundItem(pixmapItem); |
106 |
85 |
107 //Note: Progress bar is added to layout when loadStarted signal is handled and |
86 mWebView->page()->setNetworkAccessManager(mMainWindow->application()->engine()->networkAccessManager()); |
108 //removed when loadFinished signal is handled |
|
109 mProgressBar = new HbProgressBar(); |
|
110 mProgressBar->setRange( 0,100); |
|
111 mProgressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
112 mProgressBar->setVisible(false); |
|
113 |
|
114 mWebView = new WlanLoginWebView(); |
|
115 mContentLayout->addItem(mWebView); |
|
116 mWebView->page()->setNetworkAccessManager(appRef->engine()->networkAccessManager()); |
|
117 |
|
118 //Create tool bar |
|
119 mToolBar = new HbToolBar(); |
|
120 mCancelAction = mToolBar->addAction(HbIcon("qtg_mono_exit"),""); |
|
121 mNextAction = mToolBar->addAction(HbIcon("qtg_mono_arrow_right"),""); |
|
122 mContinueAction = mToolBar->addAction(HbIcon("qtg_mono_tick"),""); |
|
123 |
|
124 setToolBar(mToolBar); |
|
125 setActiveToolBarAction(Cancel); |
|
126 |
|
127 mToolBar->show(); |
|
128 mWebView->show(); |
|
129 mScrollArea->show(); |
|
130 |
87 |
131 bool connectStatus = connect( |
88 bool connectStatus = connect( |
132 mWebView, |
89 mWebView, |
133 SIGNAL(loadStarted()), |
90 SIGNAL(loadStarted()), |
134 this, |
91 this, |
175 SIGNAL(triggered()), |
132 SIGNAL(triggered()), |
176 this, |
133 this, |
177 SLOT(handleNextAction())); |
134 SLOT(handleNextAction())); |
178 Q_ASSERT(connectStatus == true); |
135 Q_ASSERT(connectStatus == true); |
179 |
136 |
180 connectStatus = connect( |
|
181 mContinueAction, |
|
182 SIGNAL(triggered()), |
|
183 this, |
|
184 SLOT(handleContinueAction())); |
|
185 Q_ASSERT(connectStatus == true); |
|
186 |
|
187 show(); |
137 show(); |
188 |
138 |
189 OstTraceFunctionExit0(WLANLOGINVIEW_WLANLOGINVIEW_EXIT); |
139 OstTraceFunctionExit0(WLANLOGINVIEW_WLANLOGINVIEW_EXIT); |
190 } |
140 } |
191 |
141 |
|
142 /*! |
|
143 Loads widgets and objects from the docml file. |
|
144 */ |
|
145 void WlanLoginView::loadDocml() |
|
146 { |
|
147 OstTraceFunctionEntry0( WLANLOGINVIEW_LOADDOCML_ENTRY ); |
|
148 |
|
149 setObjectName(QString("wlanLoginView")); |
|
150 QObjectList objectList; |
|
151 objectList.append(this); |
|
152 mDocLoader->setObjectTree(objectList); |
|
153 |
|
154 bool ok = false; |
|
155 |
|
156 mDocLoader->load(wlanLoginViewDocml, &ok); |
|
157 Q_ASSERT(ok); |
|
158 |
|
159 //Fetch pointer for progress bar |
|
160 mProgressBar = reinterpret_cast<HbProgressBar *>( |
|
161 mDocLoader->findObject("progressBar")); |
|
162 Q_ASSERT(mProgressBar); |
|
163 |
|
164 //Fetch pointer for scroll area content |
|
165 mScrollAreaContent = reinterpret_cast<HbWidget *>( |
|
166 mDocLoader->findObject("scrollAreaContent")); |
|
167 Q_ASSERT(mScrollAreaContent); |
|
168 |
|
169 //Fetch pointer for Web View |
|
170 mWebView = reinterpret_cast<WlanLoginWebView *>( |
|
171 mDocLoader->findObject("webView")); |
|
172 Q_ASSERT(mWebView); |
|
173 |
|
174 //Fetch pointer for cancel action |
|
175 mCancelAction = qobject_cast<HbAction*> ( |
|
176 mDocLoader->findObject("cancelAction")); |
|
177 Q_ASSERT(mCancelAction != NULL); |
|
178 |
|
179 //Fetch pointer for next action |
|
180 mNextAction = qobject_cast<HbAction*> ( |
|
181 mDocLoader->findObject("nextAction")); |
|
182 Q_ASSERT(mNextAction != NULL); |
|
183 |
|
184 OstTraceFunctionExit0( WLANLOGINVIEW_LOADDOCML_EXIT ); |
|
185 } |
192 |
186 |
193 /*! |
187 /*! |
194 Destructor |
188 Destructor |
195 */ |
189 */ |
196 WlanLoginView::~WlanLoginView() |
190 WlanLoginView::~WlanLoginView() |
197 { |
191 { |
198 OstTraceFunctionEntry0(WLANLOGINVIEW_DESTRUCTOR_ENTRY); |
192 OstTraceFunctionEntry0(WLANLOGINVIEW_DESTRUCTOR_ENTRY); |
199 |
|
200 //delete progress bar here as it is not on the layout all the time and |
|
201 //thus may not have a parent at all. |
|
202 if (mProgressBar) { |
|
203 delete mProgressBar; |
|
204 } |
|
205 |
193 |
206 OstTraceFunctionExit0(WLANLOGINVIEW_DESTRUCTOR_EXIT); |
194 OstTraceFunctionExit0(WLANLOGINVIEW_DESTRUCTOR_EXIT); |
207 } |
195 } |
208 |
196 |
209 |
197 |
393 void WlanLoginView::handleNextAction() |
378 void WlanLoginView::handleNextAction() |
394 { |
379 { |
395 OstTraceFunctionEntry0(WLANLOGINVIEW_HANDLENEXTACTION_ENTRY); |
380 OstTraceFunctionEntry0(WLANLOGINVIEW_HANDLENEXTACTION_ENTRY); |
396 |
381 |
397 emit nextTriggered(); |
382 emit nextTriggered(); |
398 |
|
399 //Change toolabr action to "Continue" as we are going to background |
|
400 setActiveToolBarAction(Continue); |
|
401 |
383 |
402 OstTraceFunctionExit0(WLANLOGINVIEW_HANDLENEXTACTION_EXIT); |
384 OstTraceFunctionExit0(WLANLOGINVIEW_HANDLENEXTACTION_EXIT); |
403 } |
385 } |
404 |
386 |
405 |
387 |
406 /*! |
388 /*! |
407 This function handles triggered signal from "continue" button |
|
408 |
|
409 */ |
|
410 void WlanLoginView::handleContinueAction() |
|
411 { |
|
412 OstTraceFunctionEntry0(WLANLOGINVIEW_HANDLECONTINUEACTION_ENTRY); |
|
413 |
|
414 emit continueTriggered(); |
|
415 |
|
416 OstTraceFunctionExit0(WLANLOGINVIEW_HANDLECONTINUEACTION_EXIT); |
|
417 } |
|
418 |
|
419 |
|
420 /*! |
|
421 This function handles ictsOk signal from engine |
389 This function handles ictsOk signal from engine |
422 |
390 |
423 */ |
391 */ |
424 void WlanLoginView::handleIctsOk() |
392 void WlanLoginView::handleIctsOk() |
425 { |
393 { |
426 OstTraceFunctionEntry0(WLANLOGINVIEW_HANDLEICTSRESULT_ENTRY); |
394 OstTraceFunctionEntry0(WLANLOGINVIEW_HANDLEICTSRESULT_ENTRY); |
427 |
395 |
428 setActiveToolBarAction(Next); |
396 mNextAction->setEnabled(true); |
|
397 |
|
398 //Send application to background automatically only in first successfull login |
|
399 //as in other cases WLAN Wizard won't exist in the underneath |
|
400 if (mFirstIctsOkResult) { |
|
401 mFirstIctsOkResult = false; |
|
402 emit nextTriggered(); |
|
403 } |
429 |
404 |
430 OstTraceFunctionExit0(WLANLOGINVIEW_HANDLEICTSRESULT_EXIT); |
405 OstTraceFunctionExit0(WLANLOGINVIEW_HANDLEICTSRESULT_EXIT); |
431 } |
406 } |
432 |
407 |
433 /*! |
|
434 This function sets active action to the toolbar and hides other actions |
|
435 |
|
436 @param [in] newAction Action to be set to toolbar |
|
437 */ |
|
438 void WlanLoginView::setActiveToolBarAction(ActionType newAction) |
|
439 { |
|
440 OstTraceFunctionEntry0( WLANLOGINVIEW_SETACTIVETOOLBARACTION_ENTRY ); |
|
441 |
|
442 switch (newAction) { |
|
443 case Cancel: |
|
444 mNextAction->setEnabled(false); |
|
445 mNextAction->setVisible(false); |
|
446 |
|
447 mContinueAction->setEnabled(false); |
|
448 mContinueAction->setVisible(false); |
|
449 |
|
450 mCancelAction->setVisible(true); |
|
451 mCancelAction->setEnabled(true); |
|
452 break; |
|
453 |
|
454 case Next: |
|
455 mCancelAction->setEnabled(false); |
|
456 mCancelAction->setVisible(false); |
|
457 |
|
458 mContinueAction->setEnabled(false); |
|
459 mContinueAction->setVisible(false); |
|
460 |
|
461 mNextAction->setVisible(true); |
|
462 mNextAction->setEnabled(true); |
|
463 break; |
|
464 |
|
465 case Continue: |
|
466 mCancelAction->setEnabled(false); |
|
467 mCancelAction->setVisible(false); |
|
468 |
|
469 mNextAction->setEnabled(false); |
|
470 mNextAction->setVisible(false); |
|
471 |
|
472 mContinueAction->setVisible(true); |
|
473 mContinueAction->setEnabled(true); |
|
474 break; |
|
475 |
|
476 default: |
|
477 break; |
|
478 |
|
479 } |
|
480 |
|
481 OstTraceFunctionExit0( WLANLOGINVIEW_SETACTIVETOOLBARACTION_EXIT ); |
|
482 } |
|