author | josef <josef> | 2002-10-20 16:39:25 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-20 16:39:25 (UTC) |
commit | 1f106a8b44ae659f30361588f53354e8f1985974 (patch) (unidiff) | |
tree | 7d5fc441c776ec8ad5313350ea78c3289cca2bc2 | |
parent | d3936c24518e9fea48a060eaef02e64a89646657 (diff) | |
download | opie-1f106a8b44ae659f30361588f53354e8f1985974.zip opie-1f106a8b44ae659f30361588f53354e8f1985974.tar.gz opie-1f106a8b44ae659f30361588f53354e8f1985974.tar.bz2 |
- fix focus handling:
If a new session is created, it gets the focus.
Likewise, if we switch the session.
Before the patch, one had to click inside the term window to be able to type.
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 49f9653..afac542 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -390,140 +390,146 @@ void MainWindow::slotClose() { | |||
390 | m_runScript->setEnabled( false ); | 390 | m_runScript->setEnabled( false ); |
391 | m_fullscreen->setEnabled( false ); | 391 | m_fullscreen->setEnabled( false ); |
392 | m_closewindow->setEnabled( false ); | 392 | m_closewindow->setEnabled( false ); |
393 | } | 393 | } |
394 | } | 394 | } |
395 | 395 | ||
396 | /* | 396 | /* |
397 | * We will get the name | 397 | * We will get the name |
398 | * Then the profile | 398 | * Then the profile |
399 | * and then we will make a profile | 399 | * and then we will make a profile |
400 | */ | 400 | */ |
401 | void MainWindow::slotProfile( int id) { | 401 | void MainWindow::slotProfile( int id) { |
402 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 402 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
403 | create( prof ); | 403 | create( prof ); |
404 | } | 404 | } |
405 | void MainWindow::create( const Profile& prof ) { | 405 | void MainWindow::create( const Profile& prof ) { |
406 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 406 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
407 | 407 | ||
408 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 408 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
409 | { | 409 | { |
410 | QMessageBox::warning(this, | 410 | QMessageBox::warning(this, |
411 | QObject::tr("Session failed"), | 411 | QObject::tr("Session failed"), |
412 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 412 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
413 | //if(ses) delete ses; | 413 | //if(ses) delete ses; |
414 | return; | 414 | return; |
415 | } | 415 | } |
416 | 416 | ||
417 | m_sessions.append( ses ); | 417 | m_sessions.append( ses ); |
418 | tabWidget()->add( ses ); | 418 | tabWidget()->add( ses ); |
419 | m_curSession = ses; | 419 | m_curSession = ses; |
420 | 420 | ||
421 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 421 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
422 | m_connect->setEnabled( true ); | 422 | m_connect->setEnabled( true ); |
423 | m_disconnect->setEnabled( false ); | 423 | m_disconnect->setEnabled( false ); |
424 | m_terminate->setEnabled( true ); | 424 | m_terminate->setEnabled( true ); |
425 | m_transfer->setEnabled( true ); | 425 | m_transfer->setEnabled( true ); |
426 | m_recordScript->setEnabled( true ); | 426 | m_recordScript->setEnabled( true ); |
427 | m_saveScript->setEnabled( true ); | 427 | m_saveScript->setEnabled( true ); |
428 | m_runScript->setEnabled( true ); | 428 | m_runScript->setEnabled( true ); |
429 | m_fullscreen->setEnabled( true ); | 429 | m_fullscreen->setEnabled( true ); |
430 | m_closewindow->setEnabled( true ); | 430 | m_closewindow->setEnabled( true ); |
431 | 431 | ||
432 | 432 | ||
433 | // is io_layer wants direct connection, then autoconnect | 433 | // is io_layer wants direct connection, then autoconnect |
434 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 434 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
435 | if (prof.autoConnect()) { | 435 | if (prof.autoConnect()) { |
436 | slotConnect(); | 436 | slotConnect(); |
437 | } | 437 | } |
438 | |||
439 | QWidget *w = currentSession()->widget(); | ||
440 | if(w) w->setFocus(); | ||
438 | } | 441 | } |
439 | 442 | ||
440 | void MainWindow::slotTransfer() | 443 | void MainWindow::slotTransfer() |
441 | { | 444 | { |
442 | if ( currentSession() ) { | 445 | if ( currentSession() ) { |
443 | TransferDialog dlg(currentSession()->widgetStack(), this); | 446 | TransferDialog dlg(currentSession()->widgetStack(), this); |
444 | dlg.showMaximized(); | 447 | dlg.showMaximized(); |
445 | //currentSession()->widgetStack()->add(dlg); | 448 | //currentSession()->widgetStack()->add(dlg); |
446 | dlg.exec(); | 449 | dlg.exec(); |
447 | } | 450 | } |
448 | } | 451 | } |
449 | 452 | ||
450 | 453 | ||
451 | void MainWindow::slotOpenKeb(bool state) { | 454 | void MainWindow::slotOpenKeb(bool state) { |
452 | 455 | ||
453 | if (state) m_keyBar->show(); | 456 | if (state) m_keyBar->show(); |
454 | else m_keyBar->hide(); | 457 | else m_keyBar->hide(); |
455 | 458 | ||
456 | } | 459 | } |
457 | 460 | ||
458 | 461 | ||
459 | void MainWindow::slotOpenButtons( bool state ) { | 462 | void MainWindow::slotOpenButtons( bool state ) { |
460 | 463 | ||
461 | if ( state ) { | 464 | if ( state ) { |
462 | m_buttonBar->show(); | 465 | m_buttonBar->show(); |
463 | } else { | 466 | } else { |
464 | m_buttonBar->hide(); | 467 | m_buttonBar->hide(); |
465 | } | 468 | } |
466 | } | 469 | } |
467 | 470 | ||
468 | 471 | ||
469 | 472 | ||
470 | void MainWindow::slotSessionChanged( Session* ses ) { | 473 | void MainWindow::slotSessionChanged( Session* ses ) { |
471 | qWarning("changed!"); | 474 | qWarning("changed!"); |
472 | if ( ses ) { | 475 | if ( ses ) { |
473 | m_curSession = ses; | 476 | m_curSession = ses; |
474 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 477 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
475 | if ( m_curSession->layer()->isConnected() ) { | 478 | if ( m_curSession->layer()->isConnected() ) { |
476 | m_connect->setEnabled( false ); | 479 | m_connect->setEnabled( false ); |
477 | m_disconnect->setEnabled( true ); | 480 | m_disconnect->setEnabled( true ); |
478 | } else { | 481 | } else { |
479 | m_connect->setEnabled( true ); | 482 | m_connect->setEnabled( true ); |
480 | m_disconnect->setEnabled( false ); | 483 | m_disconnect->setEnabled( false ); |
481 | } | 484 | } |
485 | |||
486 | QWidget *w = m_curSession->widget(); | ||
487 | if(w) w->setFocus(); | ||
482 | } | 488 | } |
483 | } | 489 | } |
484 | 490 | ||
485 | void MainWindow::slotFullscreen() { | 491 | void MainWindow::slotFullscreen() { |
486 | 492 | ||
487 | 493 | ||
488 | 494 | ||
489 | if ( m_isFullscreen ) { | 495 | if ( m_isFullscreen ) { |
490 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false ); | 496 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false ); |
491 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 497 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
492 | 498 | ||
493 | setCentralWidget( m_consoleWindow ); | 499 | setCentralWidget( m_consoleWindow ); |
494 | ( m_curSession->widgetStack() )->show(); | 500 | ( m_curSession->widgetStack() )->show(); |
495 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 501 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
496 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 502 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
497 | 503 | ||
498 | } else { | 504 | } else { |
499 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 505 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
500 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 506 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
501 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 507 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
502 | , QPoint(0,0), false ); | 508 | , QPoint(0,0), false ); |
503 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 509 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
504 | ( m_curSession->widgetStack() )->setFocus(); | 510 | ( m_curSession->widgetStack() )->setFocus(); |
505 | ( m_curSession->widgetStack() )->show(); | 511 | ( m_curSession->widgetStack() )->show(); |
506 | 512 | ||
507 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 513 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
508 | 514 | ||
509 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 515 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
510 | } | 516 | } |
511 | 517 | ||
512 | m_isFullscreen = !m_isFullscreen; | 518 | m_isFullscreen = !m_isFullscreen; |
513 | } | 519 | } |
514 | 520 | ||
515 | 521 | ||
516 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { | 522 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { |
517 | 523 | ||
518 | //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); | 524 | //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); |
519 | 525 | ||
520 | if ( m_curSession ) { | 526 | if ( m_curSession ) { |
521 | 527 | ||
522 | QEvent::Type state; | 528 | QEvent::Type state; |
523 | 529 | ||
524 | if (pressed) state = QEvent::KeyPress; | 530 | if (pressed) state = QEvent::KeyPress; |
525 | else state = QEvent::KeyRelease; | 531 | else state = QEvent::KeyRelease; |
526 | 532 | ||
527 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); | 533 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); |
528 | 534 | ||
529 | // where should i send this event? doesnt work sending it here | 535 | // where should i send this event? doesnt work sending it here |