1 /* |
|
2 * Copyright (c) 2009 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: Implementation of HtiAdmin main. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <hbmainwindow.h> |
|
20 #include <hbapplication.h> |
|
21 #include <hbmenu.h> |
|
22 #include <hbaction.h> |
|
23 #include <hblabel.h> |
|
24 #include <hbinputdialog.h> |
|
25 #include <qgraphicslinearlayout.h> |
|
26 #include <hbselectiondialog.h> |
|
27 #include <hbmessagebox.h> |
|
28 |
|
29 |
|
30 |
|
31 #include "htienginewrapper.h" |
|
32 #include "mainview.h" |
|
33 #include "hbtoolbar.h" |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 |
|
37 MainView::MainView(HbMainWindow &mainWindow, HtiEngineWrapper& engineWrapper): |
|
38 mMainWindow(mainWindow), |
|
39 mEngineWrapper(engineWrapper) |
|
40 { |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 |
|
45 MainView::~MainView() |
|
46 { |
|
47 |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 |
|
52 void MainView::init(HbApplication &app) |
|
53 { |
|
54 this->setTitle("Hti Admin"); |
|
55 createToolbar(); |
|
56 createMenu(app); |
|
57 createTexts(); |
|
58 |
|
59 mEngineWrapper.updateStatuses(); |
|
60 |
|
61 QString version; |
|
62 mEngineWrapper.getVersionIfo(version); |
|
63 mEngineWrapper.listCommPlugins(); |
|
64 |
|
65 mHtiVersionTxt->setPlainText("Hti Version: " + version); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 void MainView::createMenu(HbApplication& app) |
|
70 { |
|
71 |
|
72 HbMenu* menu = new HbMenu(); |
|
73 |
|
74 if (menu != NULL) { |
|
75 |
|
76 mActionExit = menu->addAction("Exit"); |
|
77 connect(mActionExit, SIGNAL(triggered()), &app, SLOT( quit() ) ); |
|
78 |
|
79 connect(mActionStartHti, SIGNAL(triggered()), this, SLOT( startHti() ) ); |
|
80 connect(mActionStopHti, SIGNAL(triggered()), this, SLOT( stopHti() ) ); |
|
81 |
|
82 mActionSelectComm = menu->addAction("Select Communication"); |
|
83 connect(mActionSelectComm, SIGNAL(triggered()), this, SLOT( enableComm() ) ); |
|
84 |
|
85 mActionSetPriority = menu->addAction("Set Priority"); |
|
86 connect(mActionSetPriority, SIGNAL(triggered()), this, SLOT( setPriority() ) ); |
|
87 |
|
88 mActionEnableAuto = menu->addAction("Enable Auto Start"); |
|
89 connect(mActionEnableAuto, SIGNAL(triggered()), this, SLOT( enableAutoStart() ) ); |
|
90 |
|
91 mActionDisableAuto = menu->addAction("Disable Auto Start"); |
|
92 connect(mActionDisableAuto, SIGNAL(triggered()), this, SLOT( disableAutoStart() ) ); |
|
93 |
|
94 mActionEnableWdog = menu->addAction("Enable Watchdog"); |
|
95 connect(mActionEnableWdog, SIGNAL(triggered()), this, SLOT( enableWatchdog() ) ); |
|
96 |
|
97 mActionDisableWdog = menu->addAction("Disable Watchdog"); |
|
98 connect(mActionDisableWdog, SIGNAL(triggered()), this, SLOT( disableWatchdog() ) ); |
|
99 |
|
100 mActionEnableConsole = menu->addAction("Enable Console"); |
|
101 connect(mActionEnableConsole, SIGNAL(triggered()), this, SLOT( enableConsole() ) ); |
|
102 |
|
103 mActionDisableConsole = menu->addAction("Disable Console"); |
|
104 connect(mActionDisableConsole, SIGNAL(triggered()), this, SLOT( disableConsole() ) ); |
|
105 |
|
106 mActionSetParameter = menu->addAction("Set Parameter"); |
|
107 connect(mActionSetParameter, SIGNAL(triggered()), this, SLOT( showParamList() ) ); |
|
108 |
|
109 this->setMenu(menu); |
|
110 } |
|
111 |
|
112 |
|
113 connect(&mEngineWrapper, SIGNAL(statusChanged(HtiEngineWrapper::HtiStatus)), this, SLOT(htiStatusChanged(HtiEngineWrapper::HtiStatus))); |
|
114 connect(&mEngineWrapper, SIGNAL(commSet(QString&)), this, SLOT(commStatusChanged(QString&))); |
|
115 connect(&mEngineWrapper, SIGNAL(commDetails(QString&)), this, SLOT(commDetailsChanged(QString&))); |
|
116 connect(&mEngineWrapper, SIGNAL(autostartSet(HtiEngineWrapper::AutoStartStatus)), this, SLOT(autostartStatusChanged(HtiEngineWrapper::AutoStartStatus))); |
|
117 connect(&mEngineWrapper, SIGNAL(consoleSet(bool)), this, SLOT(consoleStatusChanged(bool))); |
|
118 connect(&mEngineWrapper, SIGNAL(watchDogSet(bool)), this, SLOT(watchDogStatusChanged(bool))); |
|
119 connect(&mEngineWrapper, SIGNAL(commPluginsRetrieved(QStringList&)), this, SLOT(updatePluginInfo(QStringList&))); |
|
120 |
|
121 |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 void MainView::createTexts() |
|
126 { |
|
127 QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical, this); |
|
128 |
|
129 mCommDetailsTxt = new HbLabel(this); |
|
130 mHtiStatusTxt = new HbLabel(this); |
|
131 mHtiVersionTxt = new HbLabel(this); |
|
132 |
|
133 mHtiAutoStartStatusTxt = new HbLabel(this); |
|
134 mCommunicationTxt = new HbLabel(this); |
|
135 |
|
136 mHtiStatusTxt->setPlainText("Hti Status:"); |
|
137 mHtiVersionTxt->setPlainText("Hti Version:"); |
|
138 mHtiAutoStartStatusTxt->setPlainText("Auto Start:"); |
|
139 mCommunicationTxt->setPlainText("Communication "); |
|
140 |
|
141 layout->addItem(mHtiStatusTxt); |
|
142 layout->addItem(mHtiVersionTxt); |
|
143 layout->addItem(mHtiAutoStartStatusTxt); |
|
144 layout->addItem(mCommunicationTxt); |
|
145 layout->addItem(mCommDetailsTxt); |
|
146 |
|
147 layout->setMaximumHeight(300); |
|
148 this->setLayout(layout); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 void MainView::htiStatusChanged(HtiEngineWrapper::HtiStatus newStatus) |
|
153 { |
|
154 switch(newStatus) |
|
155 { |
|
156 case HtiEngineWrapper::Running: |
|
157 mHtiStatusTxt->setPlainText("Hti Status: Running" ); |
|
158 break; |
|
159 case HtiEngineWrapper::Stopped: |
|
160 mHtiStatusTxt->setPlainText("Hti Status: Stopped" ); |
|
161 break; |
|
162 case HtiEngineWrapper::Panic: |
|
163 mHtiStatusTxt->setPlainText("Hti Status: Panic" ); |
|
164 break; |
|
165 default: |
|
166 mHtiStatusTxt->setPlainText("Hti Status: Error" ); |
|
167 } |
|
168 |
|
169 // Update menu items status |
|
170 bool isRunning = (newStatus == HtiEngineWrapper::Running); |
|
171 mActionStartHti->setEnabled(!isRunning); |
|
172 mActionStopHti->setEnabled(isRunning); |
|
173 mActionSelectComm->setEnabled(!isRunning); |
|
174 mActionSetPriority->setEnabled(!isRunning); |
|
175 mActionEnableAuto->setEnabled(!isRunning); |
|
176 mActionDisableAuto->setEnabled(!isRunning); |
|
177 mActionEnableWdog->setEnabled(!isRunning); |
|
178 mActionDisableWdog->setEnabled(!isRunning); |
|
179 mActionEnableConsole->setEnabled(!isRunning); |
|
180 mActionDisableConsole->setEnabled(!isRunning); |
|
181 mActionSetParameter->setEnabled(!isRunning); |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 void MainView::commStatusChanged(QString& newStatus) |
|
186 { |
|
187 if (mCommunicationTxt) { |
|
188 mCommunicationTxt->setPlainText("Communication: " + newStatus); |
|
189 } |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 void MainView::commDetailsChanged(QString& newStatus) |
|
194 { |
|
195 if (mCommDetailsTxt) { |
|
196 mCommDetailsTxt->setPlainText(newStatus); |
|
197 } |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 void MainView::updatePluginInfo(QStringList& pluginList) |
|
202 { |
|
203 mPluginList = pluginList; |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 void MainView::autostartStatusChanged(HtiEngineWrapper::AutoStartStatus newStatus) |
|
208 { |
|
209 switch(newStatus) |
|
210 { |
|
211 case HtiEngineWrapper::AutoStartDisabled: |
|
212 mHtiAutoStartStatusTxt->setPlainText("Auto Start: Disabled" ); |
|
213 break; |
|
214 case HtiEngineWrapper::AutoStartEnabled: |
|
215 mHtiAutoStartStatusTxt->setPlainText("Auto Start: Enabled" ); |
|
216 break; |
|
217 default: |
|
218 mHtiAutoStartStatusTxt->setPlainText("Auto Start: Unknown" ); |
|
219 } |
|
220 |
|
221 bool isAutoStartEnabled = (newStatus == HtiEngineWrapper::AutoStartEnabled); |
|
222 mActionEnableAuto->setVisible(!isAutoStartEnabled); |
|
223 mActionDisableAuto->setVisible(isAutoStartEnabled); |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 void MainView::consoleStatusChanged(bool enabled) |
|
228 { |
|
229 mActionEnableConsole->setVisible(!enabled); |
|
230 mActionDisableConsole->setVisible(enabled); |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 void MainView::watchDogStatusChanged(bool enabled) |
|
235 { |
|
236 mActionEnableWdog->setVisible(!enabled); |
|
237 mActionDisableWdog->setVisible(enabled); |
|
238 } |
|
239 |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 |
|
243 void MainView::createToolbar() |
|
244 { |
|
245 mActionStartHti = toolBar()->addAction("Start Hti"); |
|
246 mActionStopHti = toolBar()->addAction("Stop Hti"); |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 |
|
251 void MainView::startHti() |
|
252 { |
|
253 mEngineWrapper.startHti(); |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 |
|
258 void MainView::stopHti() |
|
259 { |
|
260 mEngineWrapper.stopHti(); |
|
261 } |
|
262 |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 void MainView::enableComm() |
|
266 { |
|
267 //Get current selection |
|
268 QString currentComm; |
|
269 mEngineWrapper.getSelectedComm(currentComm); |
|
270 int curSelection = mPluginList.indexOf(currentComm, 0); |
|
271 openListDialog(mPluginList, curSelection, QString("Select Comm"), this, SLOT(doSelectComm(HbAction*))); |
|
272 } |
|
273 |
|
274 void MainView::doSelectComm(HbAction* action) |
|
275 { |
|
276 HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender()); |
|
277 if(dlg && dlg->selectedModelIndexes().count() && |
|
278 (!action || action == dlg->actions().at(0))) |
|
279 { |
|
280 int selectionIndex = dlg->selectedModelIndexes().at(0).row(); |
|
281 |
|
282 if (mPluginList[selectionIndex] == QString("Bt serial comm")) |
|
283 { |
|
284 enableBTComm(); |
|
285 } |
|
286 else if (mPluginList[selectionIndex] == QString("IP comm")) |
|
287 { |
|
288 enableIPComm(); |
|
289 } |
|
290 else if (mPluginList[selectionIndex] == QString("SERIAL comm")) |
|
291 { |
|
292 enableSerialComm(); |
|
293 } |
|
294 else |
|
295 { |
|
296 //All other comm plugins |
|
297 mEngineWrapper.enableOtherComm(mPluginList[selectionIndex]); |
|
298 } |
|
299 } |
|
300 } |
|
301 // --------------------------------------------------------------------------- |
|
302 void MainView::enableSerialComm() |
|
303 { |
|
304 QString heading = QString("Set Comm Port number"); |
|
305 HbInputDialog::getInteger(heading, this, SLOT(doEnableSerialComm(HbAction*)), 0, scene()); |
|
306 } |
|
307 |
|
308 void MainView::doEnableSerialComm(HbAction* action) |
|
309 { |
|
310 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
311 if (action == dlg->actions().at(0)) |
|
312 { |
|
313 QString strPortNumber = dlg->value().toString(); |
|
314 mEngineWrapper.enableSerial(strPortNumber); |
|
315 } |
|
316 } |
|
317 // --------------------------------------------------------------------------- |
|
318 void MainView::enableIPComm() |
|
319 { |
|
320 // Get IAPs list |
|
321 QStringList iapsList; |
|
322 mEngineWrapper.listIAPs(iapsList); |
|
323 if(iapsList.count() == 0) |
|
324 { |
|
325 HbMessageBox::warning(QString("No IAPs for selection!")); |
|
326 return; |
|
327 } |
|
328 |
|
329 // Get current selection |
|
330 QString curIapName; |
|
331 QString param = "IAPName"; |
|
332 mEngineWrapper.getIPCfgParam(param, curIapName); |
|
333 int curSelection = iapsList.indexOf(curIapName, 0); |
|
334 |
|
335 openListDialog(iapsList, curSelection, QString("Select IAP:"), this, SLOT(doSelectIAP(HbAction*))); |
|
336 } |
|
337 |
|
338 void MainView::doSelectIAP(HbAction* action) |
|
339 { |
|
340 HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender()); |
|
341 if(dlg && dlg->selectedModelIndexes().count() && |
|
342 (!action || action == dlg->actions().at(0))) |
|
343 { |
|
344 int selectionIndex = dlg->selectedModelIndexes().at(0).row(); |
|
345 mIapSelection = dlg->stringItems()[selectionIndex]; |
|
346 |
|
347 QStringList items; |
|
348 items <<"Listen" <<"Connect"; |
|
349 openListDialog(items, 0, QString("Select IP Comm"), this, SLOT(doSelectIpComm(HbAction*))); |
|
350 } |
|
351 } |
|
352 |
|
353 void MainView::doSelectIpComm(HbAction* action) |
|
354 { |
|
355 HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender()); |
|
356 if(dlg && dlg->selectedModelIndexes().count() && |
|
357 (!action || action == dlg->actions().at(0))) |
|
358 { |
|
359 int selectionIndex = dlg->selectedModelIndexes().at(0).row(); |
|
360 if(selectionIndex == 0) //Listen |
|
361 { |
|
362 HbInputDialog::getInteger(QString("Local port"), this, SLOT(doListenOnPort(HbAction*)), 0, scene()); |
|
363 } |
|
364 else //Connect |
|
365 { |
|
366 openIPAddressDialog(QString("Remote Host"), this, SLOT(doConnectRemoteHost(HbAction*))); |
|
367 } |
|
368 } |
|
369 } |
|
370 |
|
371 void MainView::doListenOnPort(HbAction* action) |
|
372 { |
|
373 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
374 if (action == dlg->actions().at(0)) |
|
375 { |
|
376 QString port = dlg->value().toString(); |
|
377 mEngineWrapper.ipListen(port, mIapSelection); |
|
378 } |
|
379 } |
|
380 |
|
381 void MainView::doConnectRemoteHost(HbAction* action) |
|
382 { |
|
383 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
384 if (action == dlg->actions().at(0)) |
|
385 { |
|
386 QString host = dlg->value(0).toString(); |
|
387 QString port = dlg->value(1).toString(); |
|
388 mEngineWrapper.ipConnect(host, port, mIapSelection); |
|
389 } |
|
390 } |
|
391 |
|
392 // --------------------------------------------------------------------------- |
|
393 void MainView::enableBTComm() |
|
394 { |
|
395 QStringList items; |
|
396 items <<"BT address" <<"BT name" <<"Search when starting" ; |
|
397 openListDialog(items, 0, QString("Bluetooth Comm"), this, SLOT(doSelectBTComm(HbAction*))); |
|
398 } |
|
399 |
|
400 void MainView::doSelectBTComm(HbAction* action) |
|
401 { |
|
402 HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender()); |
|
403 if(dlg && dlg->selectedModelIndexes().count() && |
|
404 (!action || action == dlg->actions().at(0))) |
|
405 { |
|
406 int selectionIndex = dlg->selectedModelIndexes().at(0).row(); |
|
407 if(selectionIndex == 0) |
|
408 { |
|
409 HbInputDialog::getText(QString("BT address"), this, SLOT(doEnableByBTAddress(HbAction*))); |
|
410 } |
|
411 else if(selectionIndex == 1) |
|
412 { |
|
413 HbInputDialog::getText(QString("BT name"), this, SLOT(doEnableByBTName(HbAction*))); |
|
414 } |
|
415 else if(selectionIndex == 2) |
|
416 { |
|
417 mEngineWrapper.btSearch(); |
|
418 } |
|
419 } |
|
420 } |
|
421 |
|
422 void MainView::doEnableByBTAddress(HbAction* action) |
|
423 { |
|
424 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
425 if (action == dlg->actions().at(0)) |
|
426 { |
|
427 QString address = dlg->value().toString(); |
|
428 mEngineWrapper.enableBtByAddress(address); |
|
429 } |
|
430 } |
|
431 void MainView::doEnableByBTName(HbAction* action) |
|
432 { |
|
433 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
434 if (action == dlg->actions().at(0)) |
|
435 { |
|
436 QString name = dlg->value().toString(); |
|
437 mEngineWrapper.enableBtByName(name); |
|
438 } |
|
439 } |
|
440 |
|
441 // --------------------------------------------------------------------------- |
|
442 void MainView::setPriority() |
|
443 { |
|
444 // Get current priority |
|
445 bool ok = false; |
|
446 QString curPriority; |
|
447 QString param = "Priority"; |
|
448 mEngineWrapper.getHtiCfgParam(param, curPriority); |
|
449 int curSelection = curPriority.toInt(&ok); |
|
450 if(ok){ |
|
451 curSelection--; |
|
452 } |
|
453 else{ |
|
454 curSelection = 2; |
|
455 } |
|
456 |
|
457 QStringList items; |
|
458 items <<"Backgroung" <<"Foregound" <<"High" << "Absolute High"; |
|
459 openListDialog(items, curSelection, QString("Select Hti Priority"), |
|
460 this, SLOT(doSetPriority(HbAction*))); |
|
461 } |
|
462 |
|
463 void MainView::doSetPriority(HbAction* action) |
|
464 { |
|
465 HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender()); |
|
466 if(dlg && dlg->selectedModelIndexes().count() && |
|
467 (!action || action == dlg->actions().at(0))) |
|
468 { |
|
469 int selectionIndex = dlg->selectedModelIndexes().at(0).row(); |
|
470 if(selectionIndex == 0) |
|
471 { |
|
472 mEngineWrapper.setPriorityBackground(); |
|
473 } |
|
474 else if(selectionIndex == 1) |
|
475 { |
|
476 mEngineWrapper.setPriorityForeground(); |
|
477 } |
|
478 else if(selectionIndex == 2) |
|
479 { |
|
480 mEngineWrapper.setPriorityHigh(); |
|
481 } |
|
482 else |
|
483 { |
|
484 mEngineWrapper.setPriorityAbsoluteHigh(); |
|
485 } |
|
486 } |
|
487 } |
|
488 // --------------------------------------------------------------------------- |
|
489 void MainView::enableAutoStart() |
|
490 { |
|
491 mEngineWrapper.autoStartEnable(true); |
|
492 } |
|
493 |
|
494 // --------------------------------------------------------------------------- |
|
495 void MainView::disableAutoStart() |
|
496 { |
|
497 mEngineWrapper.autoStartEnable(false); |
|
498 } |
|
499 |
|
500 // --------------------------------------------------------------------------- |
|
501 void MainView::enableWatchdog() |
|
502 { |
|
503 mEngineWrapper.watchDogEnable(true); |
|
504 } |
|
505 |
|
506 // --------------------------------------------------------------------------- |
|
507 void MainView::disableWatchdog() |
|
508 { |
|
509 mEngineWrapper.watchDogEnable(false); |
|
510 } |
|
511 |
|
512 // --------------------------------------------------------------------------- |
|
513 void MainView::enableConsole() |
|
514 { |
|
515 mEngineWrapper.consoleEnable(true); |
|
516 } |
|
517 |
|
518 // --------------------------------------------------------------------------- |
|
519 void MainView::disableConsole() |
|
520 { |
|
521 mEngineWrapper.consoleEnable(false); |
|
522 } |
|
523 |
|
524 // --------------------------------------------------------------------------- |
|
525 void MainView::showParamList() |
|
526 { |
|
527 QStringList items; |
|
528 items << "Hti.cfg" << "HtiBtComm.cfg" << "HtiSerialComm.cfg" << "HtiIPComm.cfg"; |
|
529 openListDialog(items, 0, QString("Select cfg file to modify"), |
|
530 this, SLOT(doSelectCfgFile(HbAction*))); |
|
531 } |
|
532 |
|
533 void MainView::doSelectCfgFile(HbAction* action) |
|
534 { |
|
535 HbSelectionDialog *dlg = static_cast<HbSelectionDialog*>(sender()); |
|
536 if(dlg && dlg->selectedModelIndexes().count() && |
|
537 (!action || action == dlg->actions().at(0))) |
|
538 { |
|
539 int selectionIndex = dlg->selectedModelIndexes().at(0).row(); |
|
540 QStringList items; |
|
541 if(selectionIndex == 0) |
|
542 { |
|
543 items <<"CommPlugin" <<"MaxMsgSize" <<"MaxQueueSize" <<"MaxHeapSize"<<"Priority" |
|
544 <<"ShowConsole"<<"MaxWaitTime"<<"StartUpDelay"<<"EnableHtiWatchDog" |
|
545 <<"EnableHtiAutoStart"<<"ShowErrorDialogs"<<"ReconnectDelay"; |
|
546 openListDialog(items, 0, QString("Hti.cfg"), this, SLOT(doModifyHtiCfgFile(HbAction*))); |
|
547 } |
|
548 else if(selectionIndex == 1) |
|
549 { |
|
550 items <<"BtDeviceName" <<"BtDeviceName"; |
|
551 openListDialog(items, 0, QString("HtiBtComm.cfg"), this, SLOT(doModifyBtCfgFile(HbAction*))); |
|
552 } |
|
553 else if(selectionIndex == 2) |
|
554 { |
|
555 items <<"CommPort" <<"DataRate"<<"Parity"<<"DataBits"<<"StopBits"<<"SendDelay"<<"Handshake"; |
|
556 openListDialog(items, 0, QString("HtiSerialComm.cfg"), this, SLOT(doModifySerialCfgFile(HbAction*))); |
|
557 } |
|
558 else |
|
559 { |
|
560 items <<"IAPName"<<"LocalPort"<<"RemoteHost"<<"RemotePort"<<"ConnectTimeout"; |
|
561 openListDialog(items, 0, QString("HtiIPComm.cfg"), this, SLOT(doModifyIPCfgFile(HbAction*))); |
|
562 } |
|
563 } |
|
564 } |
|
565 |
|
566 void MainView::doModifyHtiCfgFile(HbAction* action) |
|
567 { |
|
568 HbSelectionDialog *dlgSelection = static_cast<HbSelectionDialog*>(sender()); |
|
569 if(dlgSelection && dlgSelection->selectedModelIndexes().count() && |
|
570 (!action || action == dlgSelection->actions().at(0))) |
|
571 { |
|
572 int selectionIndex = dlgSelection->selectedModelIndexes().at(0).row(); |
|
573 HbInputDialog* dlgInput = new HbInputDialog(); |
|
574 dlgInput->setAttribute(Qt::WA_DeleteOnClose); |
|
575 dlgInput->setPromptText(dlgSelection->stringItems()[selectionIndex]); |
|
576 dlgInput->setInputMode(HbInputDialog::TextInput); |
|
577 |
|
578 HbLabel *title = new HbLabel(dlgInput); |
|
579 title->setPlainText(QString("Set parameter value")); |
|
580 dlgInput->setHeadingWidget(title); |
|
581 |
|
582 dlgInput->open(this, SLOT(doSetHtiCfgParameter(HbAction*))); |
|
583 } |
|
584 } |
|
585 |
|
586 void MainView::doSetHtiCfgParameter(HbAction* action) |
|
587 { |
|
588 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
589 if (action == dlg->actions().at(0)) |
|
590 { |
|
591 QString parameter = dlg->promptText(); |
|
592 QString value = dlg->value().toString(); |
|
593 mEngineWrapper.setHtiCfgParam(parameter, value); |
|
594 } |
|
595 } |
|
596 |
|
597 void MainView::doModifyBtCfgFile(HbAction* action) |
|
598 { |
|
599 HbSelectionDialog *dlgSelection = static_cast<HbSelectionDialog*>(sender()); |
|
600 if(dlgSelection && dlgSelection->selectedModelIndexes().count() && |
|
601 (!action || action == dlgSelection->actions().at(0))) |
|
602 { |
|
603 int selectionIndex = dlgSelection->selectedModelIndexes().at(0).row(); |
|
604 HbInputDialog* dlgInput = new HbInputDialog(); |
|
605 dlgInput->setAttribute(Qt::WA_DeleteOnClose); |
|
606 dlgInput->setPromptText(dlgSelection->stringItems()[selectionIndex]); |
|
607 dlgInput->setInputMode(HbInputDialog::TextInput); |
|
608 |
|
609 HbLabel *title = new HbLabel(dlgInput); |
|
610 title->setPlainText(QString("Set parameter value")); |
|
611 dlgInput->setHeadingWidget(title); |
|
612 |
|
613 dlgInput->open(this, SLOT(doSetBtCfgParameter(HbAction*))); |
|
614 } |
|
615 } |
|
616 |
|
617 void MainView::doSetBtCfgParameter(HbAction* action) |
|
618 { |
|
619 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
620 if (action == dlg->actions().at(0)) |
|
621 { |
|
622 QString parameter = dlg->promptText(); |
|
623 QString value = dlg->value().toString(); |
|
624 mEngineWrapper.setBtCfgParam(parameter, value); |
|
625 } |
|
626 } |
|
627 |
|
628 void MainView::doModifySerialCfgFile(HbAction* action) |
|
629 { |
|
630 HbSelectionDialog *dlgSelection = static_cast<HbSelectionDialog*>(sender()); |
|
631 if(dlgSelection && dlgSelection->selectedModelIndexes().count() && |
|
632 (!action || action == dlgSelection->actions().at(0))) |
|
633 { |
|
634 int selectionIndex = dlgSelection->selectedModelIndexes().at(0).row(); |
|
635 HbInputDialog* dlgInput = new HbInputDialog(); |
|
636 dlgInput->setAttribute(Qt::WA_DeleteOnClose); |
|
637 dlgInput->setPromptText(dlgSelection->stringItems()[selectionIndex]); |
|
638 dlgInput->setInputMode(HbInputDialog::TextInput); |
|
639 |
|
640 HbLabel *title = new HbLabel(dlgInput); |
|
641 title->setPlainText(QString("Set parameter value")); |
|
642 dlgInput->setHeadingWidget(title); |
|
643 |
|
644 dlgInput->open(this, SLOT(doSetSerialCfgParameter(HbAction*))); |
|
645 } |
|
646 } |
|
647 |
|
648 void MainView::doSetSerialCfgParameter(HbAction* action) |
|
649 { |
|
650 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
651 if (action == dlg->actions().at(0)) |
|
652 { |
|
653 QString parameter = dlg->promptText(); |
|
654 QString value = dlg->value().toString(); |
|
655 mEngineWrapper.setSerialCfgParam(parameter, value); |
|
656 } |
|
657 } |
|
658 |
|
659 void MainView::doModifyIPCfgFile(HbAction* action) |
|
660 { |
|
661 HbSelectionDialog *dlgSelection = static_cast<HbSelectionDialog*>(sender()); |
|
662 if(dlgSelection && dlgSelection->selectedModelIndexes().count() && |
|
663 (!action || action == dlgSelection->actions().at(0))) |
|
664 { |
|
665 int selectionIndex = dlgSelection->selectedModelIndexes().at(0).row(); |
|
666 HbInputDialog* dlgInput = new HbInputDialog(); |
|
667 dlgInput->setAttribute(Qt::WA_DeleteOnClose); |
|
668 dlgInput->setPromptText(dlgSelection->stringItems()[selectionIndex]); |
|
669 dlgInput->setInputMode(HbInputDialog::TextInput); |
|
670 |
|
671 HbLabel *title = new HbLabel(dlgInput); |
|
672 title->setPlainText(QString("Set parameter value")); |
|
673 dlgInput->setHeadingWidget(title); |
|
674 |
|
675 dlgInput->open(this, SLOT(doSetIPCfgParameter(HbAction*))); |
|
676 } |
|
677 } |
|
678 |
|
679 void MainView::doSetIPCfgParameter(HbAction* action) |
|
680 { |
|
681 HbInputDialog *dlg = static_cast<HbInputDialog*>(sender()); |
|
682 if (action == dlg->actions().at(0)) |
|
683 { |
|
684 QString parameter = dlg->promptText(); |
|
685 QString value = dlg->value().toString(); |
|
686 mEngineWrapper.setIPCfgParam(parameter, value); |
|
687 } |
|
688 } |
|
689 |
|
690 void MainView::openListDialog(const QStringList& items, const int currentSelection, |
|
691 const QString &titleText, QObject* receiver, const char* member) |
|
692 { |
|
693 // Create a list and some simple content for it |
|
694 HbSelectionDialog *dlg = new HbSelectionDialog(); |
|
695 dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
696 // Set items to be popup's content |
|
697 dlg->setStringItems(items); |
|
698 dlg->setSelectionMode(HbAbstractItemView::SingleSelection); |
|
699 QList<QVariant> current; |
|
700 current.append(QVariant(currentSelection)); |
|
701 dlg->setSelectedItems(current); |
|
702 |
|
703 HbLabel *title = new HbLabel(dlg); |
|
704 title->setPlainText(titleText); |
|
705 dlg->setHeadingWidget(title); |
|
706 |
|
707 // Launch popup and handle the user response: |
|
708 dlg->open(receiver, member); |
|
709 } |
|
710 |
|
711 void MainView::openIPAddressDialog(const QString &titleText, QObject* receiver, const char* member) |
|
712 { |
|
713 HbInputDialog* dlg = new HbInputDialog(); |
|
714 dlg->setAttribute(Qt::WA_DeleteOnClose); |
|
715 dlg->setAdditionalRowVisible(true); |
|
716 dlg->setPromptText(QString("IP Address:"), 0); |
|
717 dlg->setInputMode(HbInputDialog::IpInput, 0); |
|
718 dlg->setPromptText(QString("Port:"), 1); |
|
719 dlg->setInputMode(HbInputDialog::IntInput, 1); |
|
720 |
|
721 HbLabel *title = new HbLabel(dlg); |
|
722 title->setPlainText(titleText); |
|
723 dlg->setHeadingWidget(title); |
|
724 |
|
725 dlg->open(receiver, member); |
|
726 } |
|