author | josef <josef> | 2002-10-18 09:43:59 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-18 09:43:59 (UTC) |
commit | c01fc99488d4ff9e1de2eb4d93fc200ed8e19a81 (patch) (unidiff) | |
tree | cabcb28b9b95c741dd15ddeb016d1ebf01cf9224 | |
parent | 997c466fd91843699280a770cbf34e6917dcee8a (diff) | |
download | opie-c01fc99488d4ff9e1de2eb4d93fc200ed8e19a81.zip opie-c01fc99488d4ff9e1de2eb4d93fc200ed8e19a81.tar.gz opie-c01fc99488d4ff9e1de2eb4d93fc200ed8e19a81.tar.bz2 |
- autoconnect after setting default values, otherwise connect/disconnect menu
items are overwritten
Please review!
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index b813442..9a226bb 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -328,202 +328,203 @@ void MainWindow::slotConnect() { | |||
328 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 328 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
329 | QObject::tr("Failed"), | 329 | QObject::tr("Failed"), |
330 | QObject::tr("Connecting failed for this session.")); | 330 | QObject::tr("Connecting failed for this session.")); |
331 | else { | 331 | else { |
332 | m_connect->setEnabled( false ); | 332 | m_connect->setEnabled( false ); |
333 | m_disconnect->setEnabled( true ); | 333 | m_disconnect->setEnabled( true ); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
338 | void MainWindow::slotDisconnect() { | 338 | void MainWindow::slotDisconnect() { |
339 | if ( currentSession() ) { | 339 | if ( currentSession() ) { |
340 | currentSession()->layer()->close(); | 340 | currentSession()->layer()->close(); |
341 | m_connect->setEnabled( true ); | 341 | m_connect->setEnabled( true ); |
342 | m_disconnect->setEnabled( false ); | 342 | m_disconnect->setEnabled( false ); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | void MainWindow::slotTerminate() { | 346 | void MainWindow::slotTerminate() { |
347 | if ( currentSession() ) | 347 | if ( currentSession() ) |
348 | currentSession()->layer()->close(); | 348 | currentSession()->layer()->close(); |
349 | 349 | ||
350 | slotClose(); | 350 | slotClose(); |
351 | /* FIXME move to the next session */ | 351 | /* FIXME move to the next session */ |
352 | } | 352 | } |
353 | 353 | ||
354 | void MainWindow::slotConfigure() { | 354 | void MainWindow::slotConfigure() { |
355 | ConfigDialog conf( manager()->all(), factory() ); | 355 | ConfigDialog conf( manager()->all(), factory() ); |
356 | conf.showMaximized(); | 356 | conf.showMaximized(); |
357 | 357 | ||
358 | int ret = conf.exec(); | 358 | int ret = conf.exec(); |
359 | 359 | ||
360 | if ( QDialog::Accepted == ret ) { | 360 | if ( QDialog::Accepted == ret ) { |
361 | manager()->setProfiles( conf.list() ); | 361 | manager()->setProfiles( conf.list() ); |
362 | manager()->save(); | 362 | manager()->save(); |
363 | populateProfiles(); | 363 | populateProfiles(); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | /* | 366 | /* |
367 | * we will remove | 367 | * we will remove |
368 | * this window from the tabwidget | 368 | * this window from the tabwidget |
369 | * remove it from the list | 369 | * remove it from the list |
370 | * delete it | 370 | * delete it |
371 | * and set the currentSession() | 371 | * and set the currentSession() |
372 | */ | 372 | */ |
373 | void MainWindow::slotClose() { | 373 | void MainWindow::slotClose() { |
374 | if (!currentSession() ) | 374 | if (!currentSession() ) |
375 | return; | 375 | return; |
376 | 376 | ||
377 | Session* ses = currentSession(); | 377 | Session* ses = currentSession(); |
378 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 378 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
379 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 379 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
380 | m_curSession = NULL; | 380 | m_curSession = NULL; |
381 | tabWidget()->remove( /*currentSession()*/ses ); | 381 | tabWidget()->remove( /*currentSession()*/ses ); |
382 | /*it's autodelete */ | 382 | /*it's autodelete */ |
383 | m_sessions.remove( ses ); | 383 | m_sessions.remove( ses ); |
384 | qWarning("after remove!!"); | 384 | qWarning("after remove!!"); |
385 | 385 | ||
386 | if (!currentSession() ) { | 386 | if (!currentSession() ) { |
387 | m_connect->setEnabled( false ); | 387 | m_connect->setEnabled( false ); |
388 | m_disconnect->setEnabled( false ); | 388 | m_disconnect->setEnabled( false ); |
389 | m_terminate->setEnabled( false ); | 389 | m_terminate->setEnabled( false ); |
390 | m_transfer->setEnabled( false ); | 390 | m_transfer->setEnabled( false ); |
391 | m_recordScript->setEnabled( false ); | 391 | m_recordScript->setEnabled( false ); |
392 | m_saveScript->setEnabled( false ); | 392 | m_saveScript->setEnabled( false ); |
393 | m_runScript->setEnabled( false ); | 393 | m_runScript->setEnabled( false ); |
394 | m_fullscreen->setEnabled( false ); | 394 | m_fullscreen->setEnabled( false ); |
395 | m_closewindow->setEnabled( false ); | 395 | m_closewindow->setEnabled( false ); |
396 | } | 396 | } |
397 | } | 397 | } |
398 | 398 | ||
399 | /* | 399 | /* |
400 | * We will get the name | 400 | * We will get the name |
401 | * Then the profile | 401 | * Then the profile |
402 | * and then we will make a profile | 402 | * and then we will make a profile |
403 | */ | 403 | */ |
404 | void MainWindow::slotProfile( int id) { | 404 | void MainWindow::slotProfile( int id) { |
405 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 405 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
406 | create( prof ); | 406 | create( prof ); |
407 | } | 407 | } |
408 | void MainWindow::create( const Profile& prof ) { | 408 | void MainWindow::create( const Profile& prof ) { |
409 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 409 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
410 | 410 | ||
411 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 411 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
412 | { | 412 | { |
413 | QMessageBox::warning(this, | 413 | QMessageBox::warning(this, |
414 | QObject::tr("Session failed"), | 414 | QObject::tr("Session failed"), |
415 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 415 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
416 | //if(ses) delete ses; | 416 | //if(ses) delete ses; |
417 | return; | 417 | return; |
418 | } | 418 | } |
419 | 419 | ||
420 | m_sessions.append( ses ); | 420 | m_sessions.append( ses ); |
421 | tabWidget()->add( ses ); | 421 | tabWidget()->add( ses ); |
422 | m_curSession = ses; | 422 | m_curSession = ses; |
423 | 423 | ||
424 | // is io_layer wants direct connection, then autoconnect | ||
425 | if ( ( m_curSession->layer() )->supports()[0] = 1 ) { | ||
426 | slotConnect(); | ||
427 | } | ||
428 | |||
429 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 424 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
430 | m_connect->setEnabled( true ); | 425 | m_connect->setEnabled( true ); |
431 | m_disconnect->setEnabled( false ); | 426 | m_disconnect->setEnabled( false ); |
432 | m_terminate->setEnabled( true ); | 427 | m_terminate->setEnabled( true ); |
433 | m_transfer->setEnabled( true ); | 428 | m_transfer->setEnabled( true ); |
434 | m_recordScript->setEnabled( true ); | 429 | m_recordScript->setEnabled( true ); |
435 | m_saveScript->setEnabled( true ); | 430 | m_saveScript->setEnabled( true ); |
436 | m_runScript->setEnabled( true ); | 431 | m_runScript->setEnabled( true ); |
437 | m_fullscreen->setEnabled( true ); | 432 | m_fullscreen->setEnabled( true ); |
438 | m_closewindow->setEnabled( true ); | 433 | m_closewindow->setEnabled( true ); |
434 | |||
435 | |||
436 | // is io_layer wants direct connection, then autoconnect | ||
437 | if ( ( m_curSession->layer() )->supports()[0] = 1 ) { | ||
438 | slotConnect(); | ||
439 | } | ||
439 | } | 440 | } |
440 | 441 | ||
441 | void MainWindow::slotTransfer() | 442 | void MainWindow::slotTransfer() |
442 | { | 443 | { |
443 | if ( currentSession() ) { | 444 | if ( currentSession() ) { |
444 | TransferDialog dlg(this); | 445 | TransferDialog dlg(this); |
445 | dlg.showMaximized(); | 446 | dlg.showMaximized(); |
446 | dlg.exec(); | 447 | dlg.exec(); |
447 | } | 448 | } |
448 | } | 449 | } |
449 | 450 | ||
450 | 451 | ||
451 | void MainWindow::slotOpenKeb(bool state) { | 452 | void MainWindow::slotOpenKeb(bool state) { |
452 | 453 | ||
453 | if (state) m_keyBar->show(); | 454 | if (state) m_keyBar->show(); |
454 | else m_keyBar->hide(); | 455 | else m_keyBar->hide(); |
455 | 456 | ||
456 | } | 457 | } |
457 | 458 | ||
458 | 459 | ||
459 | void MainWindow::slotOpenButtons( bool state ) { | 460 | void MainWindow::slotOpenButtons( bool state ) { |
460 | 461 | ||
461 | if ( state ) { | 462 | if ( state ) { |
462 | m_buttonBar->show(); | 463 | m_buttonBar->show(); |
463 | } else { | 464 | } else { |
464 | m_buttonBar->hide(); | 465 | m_buttonBar->hide(); |
465 | } | 466 | } |
466 | } | 467 | } |
467 | 468 | ||
468 | 469 | ||
469 | 470 | ||
470 | void MainWindow::slotSessionChanged( Session* ses ) { | 471 | void MainWindow::slotSessionChanged( Session* ses ) { |
471 | qWarning("changed!"); | 472 | qWarning("changed!"); |
472 | if ( ses ) { | 473 | if ( ses ) { |
473 | m_curSession = ses; | 474 | m_curSession = ses; |
474 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 475 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
475 | if ( m_curSession->layer()->isConnected() ) { | 476 | if ( m_curSession->layer()->isConnected() ) { |
476 | m_connect->setEnabled( false ); | 477 | m_connect->setEnabled( false ); |
477 | m_disconnect->setEnabled( true ); | 478 | m_disconnect->setEnabled( true ); |
478 | } else { | 479 | } else { |
479 | m_connect->setEnabled( true ); | 480 | m_connect->setEnabled( true ); |
480 | m_disconnect->setEnabled( false ); | 481 | m_disconnect->setEnabled( false ); |
481 | } | 482 | } |
482 | } | 483 | } |
483 | } | 484 | } |
484 | 485 | ||
485 | void MainWindow::slotFullscreen() { | 486 | void MainWindow::slotFullscreen() { |
486 | 487 | ||
487 | if ( m_isFullscreen ) { | 488 | if ( m_isFullscreen ) { |
488 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); | 489 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); |
489 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 490 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
490 | setCentralWidget( m_consoleWindow ); | 491 | setCentralWidget( m_consoleWindow ); |
491 | ( m_curSession->widgetStack() )->show(); | 492 | ( m_curSession->widgetStack() )->show(); |
492 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 493 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
493 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 494 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
494 | 495 | ||
495 | } else { | 496 | } else { |
496 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 497 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
497 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 498 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
498 | , QPoint(0,0), false ); | 499 | , QPoint(0,0), false ); |
499 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 500 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
500 | ( m_curSession->widgetStack() )->setFocus(); | 501 | ( m_curSession->widgetStack() )->setFocus(); |
501 | ( m_curSession->widgetStack() )->show(); | 502 | ( m_curSession->widgetStack() )->show(); |
502 | 503 | ||
503 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 504 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
504 | 505 | ||
505 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 506 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
506 | } | 507 | } |
507 | 508 | ||
508 | m_isFullscreen = !m_isFullscreen; | 509 | m_isFullscreen = !m_isFullscreen; |
509 | } | 510 | } |
510 | 511 | ||
511 | 512 | ||
512 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { | 513 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { |
513 | 514 | ||
514 | qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); | 515 | qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); |
515 | 516 | ||
516 | if ( m_curSession ) { | 517 | if ( m_curSession ) { |
517 | 518 | ||
518 | QEvent::Type state; | 519 | QEvent::Type state; |
519 | 520 | ||
520 | if (pressed) state = QEvent::KeyPress; | 521 | if (pressed) state = QEvent::KeyPress; |
521 | else state = QEvent::KeyRelease; | 522 | else state = QEvent::KeyRelease; |
522 | 523 | ||
523 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); | 524 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); |
524 | 525 | ||
525 | // where should i send this event? doesnt work sending it here | 526 | // where should i send this event? doesnt work sending it here |
526 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 527 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
527 | ke.ignore(); | 528 | ke.ignore(); |
528 | } | 529 | } |
529 | } | 530 | } |