author | harlekin <harlekin> | 2002-10-24 21:01:21 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-24 21:01:21 (UTC) |
commit | a8b95086dd331c67c728a346f56416c355142758 (patch) (unidiff) | |
tree | 1df20d3dfa7231005f9417c5cd318685d675efad | |
parent | 52266c9462d599ab3268bddb301698c90bb0212c (diff) | |
download | opie-a8b95086dd331c67c728a346f56416c355142758.zip opie-a8b95086dd331c67c728a346f56416c355142758.tar.gz opie-a8b95086dd331c67c728a346f56416c355142758.tar.bz2 |
give new connection a caption
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/modemconfigwidget.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index ccecdf8..c44b359 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -201,384 +201,385 @@ void MainWindow::initUI() { | |||
201 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 201 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
202 | QString::null, 0, this, 0 ); | 202 | QString::null, 0, this, 0 ); |
203 | m_connect->addTo( m_console ); | 203 | m_connect->addTo( m_console ); |
204 | connect(m_connect, SIGNAL(activated() ), | 204 | connect(m_connect, SIGNAL(activated() ), |
205 | this, SLOT(slotConnect() ) ); | 205 | this, SLOT(slotConnect() ) ); |
206 | 206 | ||
207 | /* | 207 | /* |
208 | * disconnect action | 208 | * disconnect action |
209 | */ | 209 | */ |
210 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 210 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
211 | QString::null, 0, this, 0 ); | 211 | QString::null, 0, this, 0 ); |
212 | m_disconnect->addTo( m_console ); | 212 | m_disconnect->addTo( m_console ); |
213 | connect(m_disconnect, SIGNAL(activated() ), | 213 | connect(m_disconnect, SIGNAL(activated() ), |
214 | this, SLOT(slotDisconnect() ) ); | 214 | this, SLOT(slotDisconnect() ) ); |
215 | 215 | ||
216 | m_console->insertSeparator(); | 216 | m_console->insertSeparator(); |
217 | 217 | ||
218 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 218 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
219 | 0, this, 0 ); | 219 | 0, this, 0 ); |
220 | m_transfer->addTo( m_console ); | 220 | m_transfer->addTo( m_console ); |
221 | connect(m_transfer, SIGNAL(activated() ), | 221 | connect(m_transfer, SIGNAL(activated() ), |
222 | this, SLOT(slotTransfer() ) ); | 222 | this, SLOT(slotTransfer() ) ); |
223 | 223 | ||
224 | 224 | ||
225 | /* | 225 | /* |
226 | * fullscreen | 226 | * fullscreen |
227 | */ | 227 | */ |
228 | m_isFullscreen = false; | 228 | m_isFullscreen = false; |
229 | 229 | ||
230 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 230 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
231 | , QString::null, 0, this, 0); | 231 | , QString::null, 0, this, 0); |
232 | m_fullscreen->addTo( m_console ); | 232 | m_fullscreen->addTo( m_console ); |
233 | connect( m_fullscreen, SIGNAL( activated() ), | 233 | connect( m_fullscreen, SIGNAL( activated() ), |
234 | this, SLOT( slotFullscreen() ) ); | 234 | this, SLOT( slotFullscreen() ) ); |
235 | 235 | ||
236 | m_console->insertSeparator(); | 236 | m_console->insertSeparator(); |
237 | /* | 237 | /* |
238 | * terminate action | 238 | * terminate action |
239 | */ | 239 | */ |
240 | m_terminate = new QAction(); | 240 | m_terminate = new QAction(); |
241 | m_terminate->setText( tr("Terminate") ); | 241 | m_terminate->setText( tr("Terminate") ); |
242 | m_terminate->addTo( m_console ); | 242 | m_terminate->addTo( m_console ); |
243 | connect(m_terminate, SIGNAL(activated() ), | 243 | connect(m_terminate, SIGNAL(activated() ), |
244 | this, SLOT(slotTerminate() ) ); | 244 | this, SLOT(slotTerminate() ) ); |
245 | 245 | ||
246 | m_closewindow = new QAction(); | 246 | m_closewindow = new QAction(); |
247 | m_closewindow->setText( tr("Close Window") ); | 247 | m_closewindow->setText( tr("Close Window") ); |
248 | m_closewindow->addTo( m_console ); | 248 | m_closewindow->addTo( m_console ); |
249 | connect( m_closewindow, SIGNAL(activated() ), | 249 | connect( m_closewindow, SIGNAL(activated() ), |
250 | this, SLOT(slotClose() ) ); | 250 | this, SLOT(slotClose() ) ); |
251 | 251 | ||
252 | 252 | ||
253 | /* | 253 | /* |
254 | * script actions | 254 | * script actions |
255 | */ | 255 | */ |
256 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 256 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
257 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 257 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
258 | 258 | ||
259 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 259 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
260 | m_recordScript->addTo(m_scripts); | 260 | m_recordScript->addTo(m_scripts); |
261 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 261 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
262 | 262 | ||
263 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 263 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
264 | m_saveScript->addTo(m_scripts); | 264 | m_saveScript->addTo(m_scripts); |
265 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 265 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
266 | 266 | ||
267 | 267 | ||
268 | /* | 268 | /* |
269 | * action that open/closes the keyboard | 269 | * action that open/closes the keyboard |
270 | */ | 270 | */ |
271 | m_openKeys = new QAction (tr("Open Keyboard..."), | 271 | m_openKeys = new QAction (tr("Open Keyboard..."), |
272 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 272 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
273 | QString::null, 0, this, 0); | 273 | QString::null, 0, this, 0); |
274 | m_openKeys->setToggleAction(true); | 274 | m_openKeys->setToggleAction(true); |
275 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 275 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
276 | 276 | ||
277 | /* insert the submenu */ | 277 | /* insert the submenu */ |
278 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 278 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
279 | -1, 0); | 279 | -1, 0); |
280 | 280 | ||
281 | /* insert the connection menu */ | 281 | /* insert the connection menu */ |
282 | m_bar->insertItem( tr("Connection"), m_console ); | 282 | m_bar->insertItem( tr("Connection"), m_console ); |
283 | 283 | ||
284 | /* the scripts menu */ | 284 | /* the scripts menu */ |
285 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 285 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
286 | 286 | ||
287 | /* and the keyboard */ | 287 | /* and the keyboard */ |
288 | m_keyBar = new QToolBar(this); | 288 | m_keyBar = new QToolBar(this); |
289 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 289 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
290 | m_keyBar->setHorizontalStretchable( TRUE ); | 290 | m_keyBar->setHorizontalStretchable( TRUE ); |
291 | m_keyBar->hide(); | 291 | m_keyBar->hide(); |
292 | 292 | ||
293 | m_kb = new FunctionKeyboard(m_keyBar); | 293 | m_kb = new FunctionKeyboard(m_keyBar); |
294 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 294 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), |
295 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 295 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); |
296 | 296 | ||
297 | 297 | ||
298 | QAction *a = new QAction(tr("Copy"), | 298 | QAction *a = new QAction(tr("Copy"), |
299 | Resource::loadPixmap("copy"), QString::null, | 299 | Resource::loadPixmap("copy"), QString::null, |
300 | 0, this, 0 ); | 300 | 0, this, 0 ); |
301 | //a->addTo( m_icons ); | 301 | //a->addTo( m_icons ); |
302 | connect( a, SIGNAL(activated() ), | 302 | connect( a, SIGNAL(activated() ), |
303 | this, SLOT(slotCopy() ) ); | 303 | this, SLOT(slotCopy() ) ); |
304 | 304 | ||
305 | QAction *paste = new QAction(tr("Paste"), | 305 | QAction *paste = new QAction(tr("Paste"), |
306 | Resource::loadPixmap("paste"), QString::null, | 306 | Resource::loadPixmap("paste"), QString::null, |
307 | 0, this, 0 ); | 307 | 0, this, 0 ); |
308 | connect( paste, SIGNAL(activated() ), | 308 | connect( paste, SIGNAL(activated() ), |
309 | this, SLOT(slotPaste() ) ); | 309 | this, SLOT(slotPaste() ) ); |
310 | 310 | ||
311 | 311 | ||
312 | newCon->addTo( m_icons ); | 312 | newCon->addTo( m_icons ); |
313 | m_setProfiles->addTo( m_icons ); | 313 | m_setProfiles->addTo( m_icons ); |
314 | paste->addTo( m_icons ); | 314 | paste->addTo( m_icons ); |
315 | m_openKeys->addTo(m_icons); | 315 | m_openKeys->addTo(m_icons); |
316 | m_fullscreen->addTo( m_icons ); | 316 | m_fullscreen->addTo( m_icons ); |
317 | 317 | ||
318 | m_connect->setEnabled( false ); | 318 | m_connect->setEnabled( false ); |
319 | m_disconnect->setEnabled( false ); | 319 | m_disconnect->setEnabled( false ); |
320 | m_terminate->setEnabled( false ); | 320 | m_terminate->setEnabled( false ); |
321 | m_transfer->setEnabled( false ); | 321 | m_transfer->setEnabled( false ); |
322 | m_scripts->setItemEnabled(m_runScript_id, false); | 322 | m_scripts->setItemEnabled(m_runScript_id, false); |
323 | m_recordScript->setEnabled( false ); | 323 | m_recordScript->setEnabled( false ); |
324 | m_saveScript->setEnabled( false ); | 324 | m_saveScript->setEnabled( false ); |
325 | m_fullscreen->setEnabled( false ); | 325 | m_fullscreen->setEnabled( false ); |
326 | m_closewindow->setEnabled( false ); | 326 | m_closewindow->setEnabled( false ); |
327 | 327 | ||
328 | /* | 328 | /* |
329 | * connect to the menu activation | 329 | * connect to the menu activation |
330 | */ | 330 | */ |
331 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 331 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
332 | this, SLOT(slotProfile( int ) ) ); | 332 | this, SLOT(slotProfile( int ) ) ); |
333 | 333 | ||
334 | m_consoleWindow = new TabWidget( this, "blah"); | 334 | m_consoleWindow = new TabWidget( this, "blah"); |
335 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 335 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
336 | this, SLOT(slotSessionChanged(Session*) ) ); | 336 | this, SLOT(slotSessionChanged(Session*) ) ); |
337 | setCentralWidget( m_consoleWindow ); | 337 | setCentralWidget( m_consoleWindow ); |
338 | 338 | ||
339 | } | 339 | } |
340 | 340 | ||
341 | ProfileManager* MainWindow::manager() { | 341 | ProfileManager* MainWindow::manager() { |
342 | return m_manager; | 342 | return m_manager; |
343 | } | 343 | } |
344 | TabWidget* MainWindow::tabWidget() { | 344 | TabWidget* MainWindow::tabWidget() { |
345 | return m_consoleWindow; | 345 | return m_consoleWindow; |
346 | } | 346 | } |
347 | void MainWindow::populateProfiles() { | 347 | void MainWindow::populateProfiles() { |
348 | m_sessionsPop->clear(); | 348 | m_sessionsPop->clear(); |
349 | Profile::ValueList list = manager()->all(); | 349 | Profile::ValueList list = manager()->all(); |
350 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 350 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
351 | m_sessionsPop->insertItem( (*it).name() ); | 351 | m_sessionsPop->insertItem( (*it).name() ); |
352 | } | 352 | } |
353 | 353 | ||
354 | } | 354 | } |
355 | 355 | ||
356 | void MainWindow::populateScripts() { | 356 | void MainWindow::populateScripts() { |
357 | m_scriptsPop->clear(); | 357 | m_scriptsPop->clear(); |
358 | m_scriptsData.clear(); | 358 | m_scriptsData.clear(); |
359 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 359 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
360 | QListIterator<DocLnk> dit(files.children()); | 360 | QListIterator<DocLnk> dit(files.children()); |
361 | for (; dit.current(); ++dit) { | 361 | for (; dit.current(); ++dit) { |
362 | if (*dit && (*dit)->name().length()>0) { | 362 | if (*dit && (*dit)->name().length()>0) { |
363 | QFileInfo info((*dit)->file()); | 363 | QFileInfo info((*dit)->file()); |
364 | if (info.extension(false) == "script") { | 364 | if (info.extension(false) == "script") { |
365 | m_scriptsData.append(new DocLnk(**dit)); | 365 | m_scriptsData.append(new DocLnk(**dit)); |
366 | m_scriptsPop->insertItem((*dit)->name()); | 366 | m_scriptsPop->insertItem((*dit)->name()); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | } | 371 | } |
372 | 372 | ||
373 | MainWindow::~MainWindow() { | 373 | MainWindow::~MainWindow() { |
374 | delete m_factory; | 374 | delete m_factory; |
375 | manager()->save(); | 375 | manager()->save(); |
376 | } | 376 | } |
377 | 377 | ||
378 | MetaFactory* MainWindow::factory() { | 378 | MetaFactory* MainWindow::factory() { |
379 | return m_factory; | 379 | return m_factory; |
380 | } | 380 | } |
381 | 381 | ||
382 | Session* MainWindow::currentSession() { | 382 | Session* MainWindow::currentSession() { |
383 | return m_curSession; | 383 | return m_curSession; |
384 | } | 384 | } |
385 | 385 | ||
386 | QList<Session> MainWindow::sessions() { | 386 | QList<Session> MainWindow::sessions() { |
387 | return m_sessions; | 387 | return m_sessions; |
388 | } | 388 | } |
389 | 389 | ||
390 | void MainWindow::slotNew() { | 390 | void MainWindow::slotNew() { |
391 | ProfileEditorDialog dlg(factory() ); | 391 | ProfileEditorDialog dlg(factory() ); |
392 | dlg.showMaximized(); | 392 | dlg.showMaximized(); |
393 | dlg.setCaption( tr("New Connection") ); | ||
393 | int ret = dlg.exec(); | 394 | int ret = dlg.exec(); |
394 | 395 | ||
395 | if ( ret == QDialog::Accepted ) { | 396 | if ( ret == QDialog::Accepted ) { |
396 | create( dlg.profile() ); | 397 | create( dlg.profile() ); |
397 | } | 398 | } |
398 | } | 399 | } |
399 | 400 | ||
400 | void MainWindow::slotRecordScript() { | 401 | void MainWindow::slotRecordScript() { |
401 | if (currentSession()) { | 402 | if (currentSession()) { |
402 | currentSession()->emulationHandler()->startRecording(); | 403 | currentSession()->emulationHandler()->startRecording(); |
403 | m_saveScript->setEnabled(true); | 404 | m_saveScript->setEnabled(true); |
404 | m_recordScript->setEnabled(false); | 405 | m_recordScript->setEnabled(false); |
405 | } | 406 | } |
406 | } | 407 | } |
407 | 408 | ||
408 | void MainWindow::slotSaveScript() { | 409 | void MainWindow::slotSaveScript() { |
409 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 410 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
410 | QMap<QString, QStringList> map; | 411 | QMap<QString, QStringList> map; |
411 | QStringList text; | 412 | QStringList text; |
412 | text << "text/plain"; | 413 | text << "text/plain"; |
413 | map.insert(tr("Script"), text ); | 414 | map.insert(tr("Script"), text ); |
414 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 415 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
415 | if (!filename.isEmpty()) { | 416 | if (!filename.isEmpty()) { |
416 | QFileInfo info(filename); | 417 | QFileInfo info(filename); |
417 | if (info.extension(FALSE) != "script") | 418 | if (info.extension(FALSE) != "script") |
418 | filename += ".script"; | 419 | filename += ".script"; |
419 | DocLnk nf; | 420 | DocLnk nf; |
420 | nf.setType("text/plain"); | 421 | nf.setType("text/plain"); |
421 | nf.setFile(filename); | 422 | nf.setFile(filename); |
422 | nf.setName(info.fileName()); | 423 | nf.setName(info.fileName()); |
423 | FileManager fm; | 424 | FileManager fm; |
424 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 425 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
425 | currentSession()->emulationHandler()->clearScript(); | 426 | currentSession()->emulationHandler()->clearScript(); |
426 | m_saveScript->setEnabled(false); | 427 | m_saveScript->setEnabled(false); |
427 | m_recordScript->setEnabled(true); | 428 | m_recordScript->setEnabled(true); |
428 | populateScripts(); | 429 | populateScripts(); |
429 | } | 430 | } |
430 | } | 431 | } |
431 | } | 432 | } |
432 | 433 | ||
433 | void MainWindow::slotRunScript(int id) { | 434 | void MainWindow::slotRunScript(int id) { |
434 | if (currentSession()) { | 435 | if (currentSession()) { |
435 | int index = m_scriptsPop->indexOf(id); | 436 | int index = m_scriptsPop->indexOf(id); |
436 | DocLnk *lnk = m_scriptsData.at(index); | 437 | DocLnk *lnk = m_scriptsData.at(index); |
437 | QString filePath = lnk->file(); | 438 | QString filePath = lnk->file(); |
438 | Script script(filePath); | 439 | Script script(filePath); |
439 | currentSession()->emulationHandler()->runScript(&script); | 440 | currentSession()->emulationHandler()->runScript(&script); |
440 | } | 441 | } |
441 | } | 442 | } |
442 | 443 | ||
443 | void MainWindow::slotConnect() { | 444 | void MainWindow::slotConnect() { |
444 | if ( currentSession() ) { | 445 | if ( currentSession() ) { |
445 | bool ret = currentSession()->layer()->open(); | 446 | bool ret = currentSession()->layer()->open(); |
446 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 447 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
447 | QObject::tr("Failed"), | 448 | QObject::tr("Failed"), |
448 | QObject::tr("Connecting failed for this session.")); | 449 | QObject::tr("Connecting failed for this session.")); |
449 | else { | 450 | else { |
450 | m_connect->setEnabled( false ); | 451 | m_connect->setEnabled( false ); |
451 | m_disconnect->setEnabled( true ); | 452 | m_disconnect->setEnabled( true ); |
452 | m_transfer->setEnabled( true ); | 453 | m_transfer->setEnabled( true ); |
453 | m_recordScript->setEnabled( true ); | 454 | m_recordScript->setEnabled( true ); |
454 | m_scripts->setItemEnabled(m_runScript_id, true); | 455 | m_scripts->setItemEnabled(m_runScript_id, true); |
455 | } | 456 | } |
456 | } | 457 | } |
457 | } | 458 | } |
458 | 459 | ||
459 | void MainWindow::slotDisconnect() { | 460 | void MainWindow::slotDisconnect() { |
460 | if ( currentSession() ) { | 461 | if ( currentSession() ) { |
461 | currentSession()->layer()->close(); | 462 | currentSession()->layer()->close(); |
462 | m_connect->setEnabled( true ); | 463 | m_connect->setEnabled( true ); |
463 | m_disconnect->setEnabled( false ); | 464 | m_disconnect->setEnabled( false ); |
464 | m_transfer->setEnabled( false ); | 465 | m_transfer->setEnabled( false ); |
465 | m_recordScript->setEnabled( false); | 466 | m_recordScript->setEnabled( false); |
466 | m_saveScript->setEnabled( false ); | 467 | m_saveScript->setEnabled( false ); |
467 | m_scripts->setItemEnabled(m_runScript_id, false); | 468 | m_scripts->setItemEnabled(m_runScript_id, false); |
468 | } | 469 | } |
469 | } | 470 | } |
470 | 471 | ||
471 | void MainWindow::slotTerminate() { | 472 | void MainWindow::slotTerminate() { |
472 | if ( currentSession() ) | 473 | if ( currentSession() ) |
473 | currentSession()->layer()->close(); | 474 | currentSession()->layer()->close(); |
474 | 475 | ||
475 | slotClose(); | 476 | slotClose(); |
476 | /* FIXME move to the next session */ | 477 | /* FIXME move to the next session */ |
477 | } | 478 | } |
478 | 479 | ||
479 | void MainWindow::slotConfigure() { | 480 | void MainWindow::slotConfigure() { |
480 | ConfigDialog conf( manager()->all(), factory() ); | 481 | ConfigDialog conf( manager()->all(), factory() ); |
481 | conf.showMaximized(); | 482 | conf.showMaximized(); |
482 | 483 | ||
483 | int ret = conf.exec(); | 484 | int ret = conf.exec(); |
484 | 485 | ||
485 | if ( QDialog::Accepted == ret ) { | 486 | if ( QDialog::Accepted == ret ) { |
486 | manager()->setProfiles( conf.list() ); | 487 | manager()->setProfiles( conf.list() ); |
487 | manager()->save(); | 488 | manager()->save(); |
488 | populateProfiles(); | 489 | populateProfiles(); |
489 | } | 490 | } |
490 | } | 491 | } |
491 | /* | 492 | /* |
492 | * we will remove | 493 | * we will remove |
493 | * this window from the tabwidget | 494 | * this window from the tabwidget |
494 | * remove it from the list | 495 | * remove it from the list |
495 | * delete it | 496 | * delete it |
496 | * and set the currentSession() | 497 | * and set the currentSession() |
497 | */ | 498 | */ |
498 | void MainWindow::slotClose() { | 499 | void MainWindow::slotClose() { |
499 | if (!currentSession() ) | 500 | if (!currentSession() ) |
500 | return; | 501 | return; |
501 | 502 | ||
502 | Session* ses = currentSession(); | 503 | Session* ses = currentSession(); |
503 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 504 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
504 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 505 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
505 | m_curSession = NULL; | 506 | m_curSession = NULL; |
506 | tabWidget()->remove( /*currentSession()*/ses ); | 507 | tabWidget()->remove( /*currentSession()*/ses ); |
507 | /*it's autodelete */ | 508 | /*it's autodelete */ |
508 | m_sessions.remove( ses ); | 509 | m_sessions.remove( ses ); |
509 | qWarning("after remove!!"); | 510 | qWarning("after remove!!"); |
510 | 511 | ||
511 | if (!currentSession() ) { | 512 | if (!currentSession() ) { |
512 | m_connect->setEnabled( false ); | 513 | m_connect->setEnabled( false ); |
513 | m_disconnect->setEnabled( false ); | 514 | m_disconnect->setEnabled( false ); |
514 | m_terminate->setEnabled( false ); | 515 | m_terminate->setEnabled( false ); |
515 | m_transfer->setEnabled( false ); | 516 | m_transfer->setEnabled( false ); |
516 | m_recordScript->setEnabled( false ); | 517 | m_recordScript->setEnabled( false ); |
517 | m_saveScript->setEnabled( false ); | 518 | m_saveScript->setEnabled( false ); |
518 | m_scripts->setItemEnabled(m_runScript_id, false); | 519 | m_scripts->setItemEnabled(m_runScript_id, false); |
519 | m_fullscreen->setEnabled( false ); | 520 | m_fullscreen->setEnabled( false ); |
520 | m_closewindow->setEnabled( false ); | 521 | m_closewindow->setEnabled( false ); |
521 | } | 522 | } |
522 | 523 | ||
523 | m_kb->loadDefaults(); | 524 | m_kb->loadDefaults(); |
524 | } | 525 | } |
525 | 526 | ||
526 | /* | 527 | /* |
527 | * We will get the name | 528 | * We will get the name |
528 | * Then the profile | 529 | * Then the profile |
529 | * and then we will make a profile | 530 | * and then we will make a profile |
530 | */ | 531 | */ |
531 | void MainWindow::slotProfile( int id) { | 532 | void MainWindow::slotProfile( int id) { |
532 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 533 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
533 | create( prof ); | 534 | create( prof ); |
534 | } | 535 | } |
535 | void MainWindow::create( const Profile& prof ) { | 536 | void MainWindow::create( const Profile& prof ) { |
536 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 537 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
537 | 538 | ||
538 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 539 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
539 | { | 540 | { |
540 | QMessageBox::warning(this, | 541 | QMessageBox::warning(this, |
541 | QObject::tr("Session failed"), | 542 | QObject::tr("Session failed"), |
542 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 543 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
543 | //if(ses) delete ses; | 544 | //if(ses) delete ses; |
544 | return; | 545 | return; |
545 | } | 546 | } |
546 | 547 | ||
547 | m_sessions.append( ses ); | 548 | m_sessions.append( ses ); |
548 | tabWidget()->add( ses ); | 549 | tabWidget()->add( ses ); |
549 | tabWidget()->repaint(); | 550 | tabWidget()->repaint(); |
550 | m_curSession = ses; | 551 | m_curSession = ses; |
551 | 552 | ||
552 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 553 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
553 | m_connect->setEnabled( true ); | 554 | m_connect->setEnabled( true ); |
554 | m_disconnect->setEnabled( false ); | 555 | m_disconnect->setEnabled( false ); |
555 | m_terminate->setEnabled( true ); | 556 | m_terminate->setEnabled( true ); |
556 | m_fullscreen->setEnabled( true ); | 557 | m_fullscreen->setEnabled( true ); |
557 | m_closewindow->setEnabled( true ); | 558 | m_closewindow->setEnabled( true ); |
558 | m_transfer->setEnabled( false ); | 559 | m_transfer->setEnabled( false ); |
559 | m_recordScript->setEnabled( false ); | 560 | m_recordScript->setEnabled( false ); |
560 | m_saveScript->setEnabled( false ); | 561 | m_saveScript->setEnabled( false ); |
561 | m_scripts->setItemEnabled(m_runScript_id, false); | 562 | m_scripts->setItemEnabled(m_runScript_id, false); |
562 | 563 | ||
563 | // is io_layer wants direct connection, then autoconnect | 564 | // is io_layer wants direct connection, then autoconnect |
564 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 565 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
565 | if (prof.autoConnect()) { | 566 | if (prof.autoConnect()) { |
566 | slotConnect(); | 567 | slotConnect(); |
567 | } | 568 | } |
568 | 569 | ||
569 | 570 | ||
570 | 571 | ||
571 | QWidget *w = currentSession()->widget(); | 572 | QWidget *w = currentSession()->widget(); |
572 | if(w) w->setFocus(); | 573 | if(w) w->setFocus(); |
573 | 574 | ||
574 | m_kb->load(currentSession()->profile()); | 575 | m_kb->load(currentSession()->profile()); |
575 | } | 576 | } |
576 | 577 | ||
577 | void MainWindow::slotTransfer() | 578 | void MainWindow::slotTransfer() |
578 | { | 579 | { |
579 | if ( currentSession() ) { | 580 | if ( currentSession() ) { |
580 | TransferDialog dlg(currentSession()->widgetStack(), this); | 581 | TransferDialog dlg(currentSession()->widgetStack(), this); |
581 | dlg.showMaximized(); | 582 | dlg.showMaximized(); |
582 | //currentSession()->widgetStack()->add(dlg); | 583 | //currentSession()->widgetStack()->add(dlg); |
583 | dlg.exec(); | 584 | dlg.exec(); |
584 | } | 585 | } |
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp index da5db83..ec83b9f 100644 --- a/noncore/apps/opie-console/modemconfigwidget.cpp +++ b/noncore/apps/opie-console/modemconfigwidget.cpp | |||
@@ -1,202 +1,203 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | #include <qhbox.h> | 6 | #include <qhbox.h> |
7 | #include <qregexp.h> | 7 | #include <qregexp.h> |
8 | 8 | ||
9 | #include "modemconfigwidget.h" | 9 | #include "modemconfigwidget.h" |
10 | #include "dialdialog.h" | 10 | #include "dialdialog.h" |
11 | 11 | ||
12 | namespace { | 12 | namespace { |
13 | void setCurrent( const QString& str, QComboBox* bo ) { | 13 | void setCurrent( const QString& str, QComboBox* bo ) { |
14 | uint b = bo->count(); | 14 | uint b = bo->count(); |
15 | for (int i = 0; i < bo->count(); i++ ) { | 15 | for (int i = 0; i < bo->count(); i++ ) { |
16 | if ( bo->text(i) == str ) { | 16 | if ( bo->text(i) == str ) { |
17 | bo->setCurrentItem( i ); | 17 | bo->setCurrentItem( i ); |
18 | return; | 18 | return; |
19 | } | 19 | } |
20 | } | 20 | } |
21 | bo->insertItem( str ); | 21 | bo->insertItem( str ); |
22 | bo->setCurrentItem( b ); | 22 | bo->setCurrentItem( b ); |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, | 26 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, |
27 | const char* na ) | 27 | const char* na ) |
28 | : ProfileDialogConnectionWidget( name, parent, na ) { | 28 | : ProfileDialogConnectionWidget( name, parent, na ) { |
29 | 29 | ||
30 | m_lay = new QVBoxLayout( this ); | 30 | m_lay = new QVBoxLayout( this ); |
31 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); | 31 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); |
32 | m_deviceCmb = new QComboBox(this ); | 32 | m_deviceCmb = new QComboBox(this ); |
33 | m_deviceCmb->setEditable( TRUE ); | 33 | m_deviceCmb->setEditable( TRUE ); |
34 | 34 | ||
35 | QLabel* telLabel = new QLabel( this ); | 35 | QLabel* telLabel = new QLabel( this ); |
36 | telLabel->setText( tr( "Enter telefon number here:" ) ); | 36 | telLabel->setText( tr( "Enter telefon number here:" ) ); |
37 | m_telNumber = new QLineEdit( this ); | 37 | m_telNumber = new QLineEdit( this ); |
38 | QHBox *buttonBox = new QHBox( this ); | 38 | QHBox *buttonBox = new QHBox( this ); |
39 | QPushButton *atButton = new QPushButton( buttonBox ); | 39 | QPushButton *atButton = new QPushButton( buttonBox ); |
40 | atButton->setText( tr( "AT commands" ) ); | 40 | atButton->setText( tr( "AT commands" ) ); |
41 | // disabled for now | ||
41 | atButton->hide(); | 42 | atButton->hide(); |
42 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); | 43 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); |
43 | 44 | ||
44 | QPushButton *dialButton = new QPushButton( buttonBox ); | 45 | QPushButton *dialButton = new QPushButton( buttonBox ); |
45 | dialButton->setText( tr( "Enter number" ) ); | 46 | dialButton->setText( tr( "Enter number" ) ); |
46 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); | 47 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); |
47 | 48 | ||
48 | 49 | ||
49 | m_base = new IOLayerBase( this, "base" ); | 50 | m_base = new IOLayerBase( this, "base" ); |
50 | 51 | ||
51 | m_lay->addWidget( m_device ); | 52 | m_lay->addWidget( m_device ); |
52 | m_lay->addWidget( m_deviceCmb ); | 53 | m_lay->addWidget( m_deviceCmb ); |
53 | m_lay->addWidget( telLabel ); | 54 | m_lay->addWidget( telLabel ); |
54 | m_lay->addWidget( m_telNumber ); | 55 | m_lay->addWidget( m_telNumber ); |
55 | m_lay->addWidget( buttonBox ); | 56 | m_lay->addWidget( buttonBox ); |
56 | m_lay->addWidget( m_base ); | 57 | m_lay->addWidget( m_base ); |
57 | 58 | ||
58 | m_deviceCmb->insertItem( "/dev/ttyS0" ); | 59 | m_deviceCmb->insertItem( "/dev/ttyS0" ); |
59 | m_deviceCmb->insertItem( "/dev/ttyS1" ); | 60 | m_deviceCmb->insertItem( "/dev/ttyS1" ); |
60 | m_deviceCmb->insertItem( "/dev/ttyS2" ); | 61 | m_deviceCmb->insertItem( "/dev/ttyS2" ); |
61 | 62 | ||
62 | atConf = new ATConfigDialog( this, "ATConfig", true ); | 63 | atConf = new ATConfigDialog( this, "ATConfig", true ); |
63 | } | 64 | } |
64 | 65 | ||
65 | ModemConfigWidget::~ModemConfigWidget() { | 66 | ModemConfigWidget::~ModemConfigWidget() { |
66 | 67 | ||
67 | } | 68 | } |
68 | void ModemConfigWidget::load( const Profile& prof ) { | 69 | void ModemConfigWidget::load( const Profile& prof ) { |
69 | 70 | ||
70 | int rad_flow = prof.readNumEntry( "Flow" ); | 71 | int rad_flow = prof.readNumEntry( "Flow" ); |
71 | int rad_parity = prof.readNumEntry( "Parity" ); | 72 | int rad_parity = prof.readNumEntry( "Parity" ); |
72 | int speed = prof.readNumEntry( "Speed" ); | 73 | int speed = prof.readNumEntry( "Speed" ); |
73 | QString number = prof.readEntry( "Number" ); | 74 | QString number = prof.readEntry( "Number" ); |
74 | 75 | ||
75 | if ( !number.isEmpty() ) { | 76 | if ( !number.isEmpty() ) { |
76 | m_telNumber->setText( number ); | 77 | m_telNumber->setText( number ); |
77 | } | 78 | } |
78 | 79 | ||
79 | if ( rad_flow == 1 ) { | 80 | if ( rad_flow == 1 ) { |
80 | m_base->setFlow( IOLayerBase::Hardware ); | 81 | m_base->setFlow( IOLayerBase::Hardware ); |
81 | } else if (rad_flow == 2) { | 82 | } else if (rad_flow == 2) { |
82 | m_base->setFlow( IOLayerBase::Software ); | 83 | m_base->setFlow( IOLayerBase::Software ); |
83 | } else if (rad_flow == 0) { | 84 | } else if (rad_flow == 0) { |
84 | m_base->setFlow( IOLayerBase::None ); | 85 | m_base->setFlow( IOLayerBase::None ); |
85 | } | 86 | } |
86 | 87 | ||
87 | 88 | ||
88 | if ( rad_parity == 1 ) { | 89 | if ( rad_parity == 1 ) { |
89 | m_base->setParity( IOLayerBase::Even ); | 90 | m_base->setParity( IOLayerBase::Even ); |
90 | } else if ( rad_parity == 2 ){ | 91 | } else if ( rad_parity == 2 ){ |
91 | m_base->setParity( IOLayerBase::Odd ); | 92 | m_base->setParity( IOLayerBase::Odd ); |
92 | } else { | 93 | } else { |
93 | m_base->setParity( IOLayerBase::NonePar ); | 94 | m_base->setParity( IOLayerBase::NonePar ); |
94 | } | 95 | } |
95 | 96 | ||
96 | switch( speed ) { | 97 | switch( speed ) { |
97 | case 115200: | 98 | case 115200: |
98 | m_base->setSpeed( IOLayerBase::Baud_115200 ); | 99 | m_base->setSpeed( IOLayerBase::Baud_115200 ); |
99 | break; | 100 | break; |
100 | case 57600: | 101 | case 57600: |
101 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | 102 | m_base->setSpeed( IOLayerBase::Baud_57600 ); |
102 | break; | 103 | break; |
103 | case 38400: | 104 | case 38400: |
104 | m_base->setSpeed( IOLayerBase::Baud_38400 ); | 105 | m_base->setSpeed( IOLayerBase::Baud_38400 ); |
105 | break; | 106 | break; |
106 | case 19200: | 107 | case 19200: |
107 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | 108 | m_base->setSpeed( IOLayerBase::Baud_19200 ); |
108 | break; | 109 | break; |
109 | case 9600: | 110 | case 9600: |
110 | default: | 111 | default: |
111 | m_base->setSpeed( IOLayerBase::Baud_9600 ); | 112 | m_base->setSpeed( IOLayerBase::Baud_9600 ); |
112 | break; | 113 | break; |
113 | } | 114 | } |
114 | 115 | ||
115 | if ( prof.readEntry( "Device" ).isEmpty() ) { | 116 | if ( prof.readEntry( "Device" ).isEmpty() ) { |
116 | return; | 117 | return; |
117 | } | 118 | } |
118 | setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); | 119 | setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); |
119 | 120 | ||
120 | atConf->readConfig( prof ); | 121 | atConf->readConfig( prof ); |
121 | } | 122 | } |
122 | 123 | ||
123 | /* | 124 | /* |
124 | * save speed, | 125 | * save speed, |
125 | * flow, | 126 | * flow, |
126 | * parity | 127 | * parity |
127 | */ | 128 | */ |
128 | void ModemConfigWidget::save( Profile& prof ) { | 129 | void ModemConfigWidget::save( Profile& prof ) { |
129 | int flow, parity, speed; | 130 | int flow, parity, speed; |
130 | flow = parity = speed = 0; | 131 | flow = parity = speed = 0; |
131 | prof.writeEntry( "Device", m_deviceCmb->currentText() ); | 132 | prof.writeEntry( "Device", m_deviceCmb->currentText() ); |
132 | 133 | ||
133 | 134 | ||
134 | switch( m_base->flow() ) { | 135 | switch( m_base->flow() ) { |
135 | case IOLayerBase::None: | 136 | case IOLayerBase::None: |
136 | flow = 0; | 137 | flow = 0; |
137 | break; | 138 | break; |
138 | case IOLayerBase::Software: | 139 | case IOLayerBase::Software: |
139 | flow = 2; | 140 | flow = 2; |
140 | break; | 141 | break; |
141 | case IOLayerBase::Hardware: | 142 | case IOLayerBase::Hardware: |
142 | flow = 1; | 143 | flow = 1; |
143 | break; | 144 | break; |
144 | } | 145 | } |
145 | 146 | ||
146 | switch( m_base->parity() ) { | 147 | switch( m_base->parity() ) { |
147 | case IOLayerBase::Odd: | 148 | case IOLayerBase::Odd: |
148 | parity = 2; | 149 | parity = 2; |
149 | break; | 150 | break; |
150 | case IOLayerBase::Even: | 151 | case IOLayerBase::Even: |
151 | parity = 1; | 152 | parity = 1; |
152 | break; | 153 | break; |
153 | case IOLayerBase::NonePar: | 154 | case IOLayerBase::NonePar: |
154 | parity = 0; | 155 | parity = 0; |
155 | break; | 156 | break; |
156 | } | 157 | } |
157 | 158 | ||
158 | switch( m_base->speed() ) { | 159 | switch( m_base->speed() ) { |
159 | case IOLayerBase::Baud_115200: | 160 | case IOLayerBase::Baud_115200: |
160 | speed = 115200; | 161 | speed = 115200; |
161 | break; | 162 | break; |
162 | case IOLayerBase::Baud_57600: | 163 | case IOLayerBase::Baud_57600: |
163 | speed = 57600; | 164 | speed = 57600; |
164 | break; | 165 | break; |
165 | case IOLayerBase::Baud_38400: | 166 | case IOLayerBase::Baud_38400: |
166 | speed = 38400; | 167 | speed = 38400; |
167 | break; | 168 | break; |
168 | case IOLayerBase::Baud_19200: | 169 | case IOLayerBase::Baud_19200: |
169 | speed = 19200; | 170 | speed = 19200; |
170 | break; | 171 | break; |
171 | case IOLayerBase::Baud_9600: | 172 | case IOLayerBase::Baud_9600: |
172 | speed = 9600; | 173 | speed = 9600; |
173 | break; | 174 | break; |
174 | } | 175 | } |
175 | 176 | ||
176 | prof.writeEntry( "Flow", flow ); | 177 | prof.writeEntry( "Flow", flow ); |
177 | prof.writeEntry( "Parity", parity ); | 178 | prof.writeEntry( "Parity", parity ); |
178 | prof.writeEntry( "Speed", speed ); | 179 | prof.writeEntry( "Speed", speed ); |
179 | prof.writeEntry( "Number", m_telNumber->text() ); | 180 | prof.writeEntry( "Number", m_telNumber->text() ); |
180 | 181 | ||
181 | 182 | ||
182 | atConf->writeConfig(prof); | 183 | atConf->writeConfig(prof); |
183 | } | 184 | } |
184 | 185 | ||
185 | void ModemConfigWidget::slotAT() { | 186 | void ModemConfigWidget::slotAT() { |
186 | // ATConfigDialog conf( this, "ATConfig", true ); | 187 | // ATConfigDialog conf( this, "ATConfig", true ); |
187 | atConf->showMaximized(); | 188 | atConf->showMaximized(); |
188 | if ( atConf->exec() != QDialog::Accepted ) { | 189 | if ( atConf->exec() != QDialog::Accepted ) { |
189 | // reload old settings | 190 | // reload old settings |
190 | } | 191 | } |
191 | } | 192 | } |
192 | 193 | ||
193 | void ModemConfigWidget::slotDial() { | 194 | void ModemConfigWidget::slotDial() { |
194 | DialDialog dial( this, "DialConfig", true ); | 195 | DialDialog dial( this, "DialConfig", true ); |
195 | if(!m_telNumber->text().isEmpty()) { | 196 | if(!m_telNumber->text().isEmpty()) { |
196 | dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), "")); | 197 | dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), "")); |
197 | } | 198 | } |
198 | dial.showMaximized(); | 199 | dial.showMaximized(); |
199 | if ( dial.exec() == QDialog::Accepted ) { | 200 | if ( dial.exec() == QDialog::Accepted ) { |
200 | m_telNumber->setText( dial.number() ); | 201 | m_telNumber->setText( dial.number() ); |
201 | } | 202 | } |
202 | } | 203 | } |