author | josef <josef> | 2002-10-26 11:56:08 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-26 11:56:08 (UTC) |
commit | 0d58e14f2bcfa2a1f5c9a197d5bb544571824207 (patch) (unidiff) | |
tree | 86a60a7b02f5458263982a77d2d05f3b49672ced | |
parent | 88504fa6ed3e4ec1c11d3e1cde13c821b1a9b846 (diff) | |
download | opie-0d58e14f2bcfa2a1f5c9a197d5bb544571824207.zip opie-0d58e14f2bcfa2a1f5c9a197d5bb544571824207.tar.gz opie-0d58e14f2bcfa2a1f5c9a197d5bb544571824207.tar.bz2 |
- Ah! That's how to use the widget stack
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index e3c3c38..936b1b2 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -495,197 +495,198 @@ void MainWindow::slotConfigure() { | |||
495 | manager()->save(); | 495 | manager()->save(); |
496 | populateProfiles(); | 496 | populateProfiles(); |
497 | } | 497 | } |
498 | } | 498 | } |
499 | /* | 499 | /* |
500 | * we will remove | 500 | * we will remove |
501 | * this window from the tabwidget | 501 | * this window from the tabwidget |
502 | * remove it from the list | 502 | * remove it from the list |
503 | * delete it | 503 | * delete it |
504 | * and set the currentSession() | 504 | * and set the currentSession() |
505 | */ | 505 | */ |
506 | void MainWindow::slotClose() { | 506 | void MainWindow::slotClose() { |
507 | if (!currentSession() ) | 507 | if (!currentSession() ) |
508 | return; | 508 | return; |
509 | 509 | ||
510 | Session* ses = currentSession(); | 510 | Session* ses = currentSession(); |
511 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 511 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
512 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 512 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
513 | m_curSession = NULL; | 513 | m_curSession = NULL; |
514 | tabWidget()->remove( /*currentSession()*/ses ); | 514 | tabWidget()->remove( /*currentSession()*/ses ); |
515 | /*it's autodelete */ | 515 | /*it's autodelete */ |
516 | m_sessions.remove( ses ); | 516 | m_sessions.remove( ses ); |
517 | qWarning("after remove!!"); | 517 | qWarning("after remove!!"); |
518 | 518 | ||
519 | if (!currentSession() ) { | 519 | if (!currentSession() ) { |
520 | m_connect->setEnabled( false ); | 520 | m_connect->setEnabled( false ); |
521 | m_disconnect->setEnabled( false ); | 521 | m_disconnect->setEnabled( false ); |
522 | m_terminate->setEnabled( false ); | 522 | m_terminate->setEnabled( false ); |
523 | m_transfer->setEnabled( false ); | 523 | m_transfer->setEnabled( false ); |
524 | m_recordScript->setEnabled( false ); | 524 | m_recordScript->setEnabled( false ); |
525 | m_saveScript->setEnabled( false ); | 525 | m_saveScript->setEnabled( false ); |
526 | m_scripts->setItemEnabled(m_runScript_id, false); | 526 | m_scripts->setItemEnabled(m_runScript_id, false); |
527 | m_fullscreen->setEnabled( false ); | 527 | m_fullscreen->setEnabled( false ); |
528 | m_closewindow->setEnabled( false ); | 528 | m_closewindow->setEnabled( false ); |
529 | } | 529 | } |
530 | 530 | ||
531 | m_kb->loadDefaults(); | 531 | m_kb->loadDefaults(); |
532 | } | 532 | } |
533 | 533 | ||
534 | /* | 534 | /* |
535 | * We will get the name | 535 | * We will get the name |
536 | * Then the profile | 536 | * Then the profile |
537 | * and then we will make a profile | 537 | * and then we will make a profile |
538 | */ | 538 | */ |
539 | void MainWindow::slotProfile( int id) { | 539 | void MainWindow::slotProfile( int id) { |
540 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 540 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
541 | create( prof ); | 541 | create( prof ); |
542 | } | 542 | } |
543 | void MainWindow::create( const Profile& prof ) { | 543 | void MainWindow::create( const Profile& prof ) { |
544 | if(m_curSession) | 544 | if(m_curSession) |
545 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 545 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
546 | 546 | ||
547 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 547 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
548 | 548 | ||
549 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 549 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
550 | { | 550 | { |
551 | QMessageBox::warning(this, | 551 | QMessageBox::warning(this, |
552 | QObject::tr("Session failed"), | 552 | QObject::tr("Session failed"), |
553 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 553 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
554 | //if(ses) delete ses; | 554 | //if(ses) delete ses; |
555 | return; | 555 | return; |
556 | } | 556 | } |
557 | 557 | ||
558 | m_sessions.append( ses ); | 558 | m_sessions.append( ses ); |
559 | tabWidget()->add( ses ); | 559 | tabWidget()->add( ses ); |
560 | tabWidget()->repaint(); | 560 | tabWidget()->repaint(); |
561 | m_curSession = ses; | 561 | m_curSession = ses; |
562 | 562 | ||
563 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 563 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
564 | m_connect->setEnabled( true ); | 564 | m_connect->setEnabled( true ); |
565 | m_disconnect->setEnabled( false ); | 565 | m_disconnect->setEnabled( false ); |
566 | m_terminate->setEnabled( true ); | 566 | m_terminate->setEnabled( true ); |
567 | m_fullscreen->setEnabled( true ); | 567 | m_fullscreen->setEnabled( true ); |
568 | m_closewindow->setEnabled( true ); | 568 | m_closewindow->setEnabled( true ); |
569 | m_transfer->setEnabled( false ); | 569 | m_transfer->setEnabled( false ); |
570 | m_recordScript->setEnabled( false ); | 570 | m_recordScript->setEnabled( false ); |
571 | m_saveScript->setEnabled( false ); | 571 | m_saveScript->setEnabled( false ); |
572 | m_scripts->setItemEnabled(m_runScript_id, false); | 572 | m_scripts->setItemEnabled(m_runScript_id, false); |
573 | 573 | ||
574 | // is io_layer wants direct connection, then autoconnect | 574 | // is io_layer wants direct connection, then autoconnect |
575 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 575 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
576 | if (prof.autoConnect()) { | 576 | if (prof.autoConnect()) { |
577 | slotConnect(); | 577 | slotConnect(); |
578 | } | 578 | } |
579 | 579 | ||
580 | 580 | ||
581 | QWidget *w = currentSession()->widget(); | 581 | QWidget *w = currentSession()->widget(); |
582 | if(w) w->setFocus(); | 582 | if(w) w->setFocus(); |
583 | 583 | ||
584 | m_kb->load(currentSession()->profile()); | 584 | m_kb->load(currentSession()->profile()); |
585 | } | 585 | } |
586 | 586 | ||
587 | void MainWindow::slotTransfer() | 587 | void MainWindow::slotTransfer() |
588 | { | 588 | { |
589 | if ( currentSession() ) { | 589 | if ( currentSession() ) { |
590 | Session *mysession = currentSession(); | 590 | Session *mysession = currentSession(); |
591 | TransferDialog dlg(mysession->widgetStack(), this); | 591 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); |
592 | mysession->setTransferDialog(&dlg); | 592 | mysession->setTransferDialog(&dlg); |
593 | dlg.show(); | 593 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); |
594 | //dlg.showMaximized(); | 594 | //dlg.showMaximized(); |
595 | //currentSession()->widgetStack()->add(dlg); | 595 | currentSession()->widgetStack()->addWidget(&dlg, -1); |
596 | dlg.show(); | ||
596 | //dlg.exec(); | 597 | //dlg.exec(); |
597 | while(dlg.isRunning()) qApp->processEvents(); | 598 | while(dlg.isRunning()) qApp->processEvents(); |
598 | mysession->setTransferDialog(0l); | 599 | mysession->setTransferDialog(0l); |
599 | } | 600 | } |
600 | } | 601 | } |
601 | 602 | ||
602 | 603 | ||
603 | void MainWindow::slotOpenKeb(bool state) { | 604 | void MainWindow::slotOpenKeb(bool state) { |
604 | 605 | ||
605 | if (state) m_keyBar->show(); | 606 | if (state) m_keyBar->show(); |
606 | else m_keyBar->hide(); | 607 | else m_keyBar->hide(); |
607 | 608 | ||
608 | } | 609 | } |
609 | 610 | ||
610 | 611 | ||
611 | void MainWindow::slotOpenButtons( bool state ) { | 612 | void MainWindow::slotOpenButtons( bool state ) { |
612 | 613 | ||
613 | if ( state ) { | 614 | if ( state ) { |
614 | m_buttonBar->show(); | 615 | m_buttonBar->show(); |
615 | } else { | 616 | } else { |
616 | m_buttonBar->hide(); | 617 | m_buttonBar->hide(); |
617 | } | 618 | } |
618 | } | 619 | } |
619 | 620 | ||
620 | 621 | ||
621 | 622 | ||
622 | void MainWindow::slotSessionChanged( Session* ses ) { | 623 | void MainWindow::slotSessionChanged( Session* ses ) { |
623 | qWarning("changed!"); | 624 | qWarning("changed!"); |
624 | 625 | ||
625 | if(m_curSession) | 626 | if(m_curSession) |
626 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 627 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
627 | if(ses) | 628 | if(ses) |
628 | if(ses->transferDialog()) ses->transferDialog()->show(); | 629 | if(ses->transferDialog()) ses->transferDialog()->show(); |
629 | 630 | ||
630 | if ( ses ) { | 631 | if ( ses ) { |
631 | m_curSession = ses; | 632 | m_curSession = ses; |
632 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 633 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
633 | if ( m_curSession->layer()->isConnected() ) { | 634 | if ( m_curSession->layer()->isConnected() ) { |
634 | m_connect->setEnabled( false ); | 635 | m_connect->setEnabled( false ); |
635 | m_disconnect->setEnabled( true ); | 636 | m_disconnect->setEnabled( true ); |
636 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 637 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
637 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 638 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
638 | m_scripts->setItemEnabled(m_runScript_id, true); | 639 | m_scripts->setItemEnabled(m_runScript_id, true); |
639 | } else { | 640 | } else { |
640 | m_connect->setEnabled( true ); | 641 | m_connect->setEnabled( true ); |
641 | m_disconnect->setEnabled( false ); | 642 | m_disconnect->setEnabled( false ); |
642 | m_recordScript->setEnabled( false ); | 643 | m_recordScript->setEnabled( false ); |
643 | m_saveScript->setEnabled( false ); | 644 | m_saveScript->setEnabled( false ); |
644 | m_scripts->setItemEnabled(m_runScript_id, false); | 645 | m_scripts->setItemEnabled(m_runScript_id, false); |
645 | } | 646 | } |
646 | 647 | ||
647 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 648 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
648 | m_transfer->setEnabled( false ); | 649 | m_transfer->setEnabled( false ); |
649 | } else { | 650 | } else { |
650 | m_transfer->setEnabled( true ); | 651 | m_transfer->setEnabled( true ); |
651 | } | 652 | } |
652 | 653 | ||
653 | QWidget *w = m_curSession->widget(); | 654 | QWidget *w = m_curSession->widget(); |
654 | if(w) w->setFocus(); | 655 | if(w) w->setFocus(); |
655 | 656 | ||
656 | m_kb->load(currentSession()->profile()); | 657 | m_kb->load(currentSession()->profile()); |
657 | } | 658 | } |
658 | } | 659 | } |
659 | 660 | ||
660 | void MainWindow::slotFullscreen() { | 661 | void MainWindow::slotFullscreen() { |
661 | 662 | ||
662 | 663 | ||
663 | 664 | ||
664 | if ( m_isFullscreen ) { | 665 | if ( m_isFullscreen ) { |
665 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 666 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
666 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 667 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
667 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 668 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
668 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 669 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
669 | 670 | ||
670 | } else { | 671 | } else { |
671 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 672 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
672 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 673 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
673 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 674 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
674 | , QPoint(0,0), false ); | 675 | , QPoint(0,0), false ); |
675 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 676 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
676 | ( m_curSession->widgetStack() )->setFocus(); | 677 | ( m_curSession->widgetStack() )->setFocus(); |
677 | ( m_curSession->widgetStack() )->show(); | 678 | ( m_curSession->widgetStack() )->show(); |
678 | 679 | ||
679 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 680 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
680 | 681 | ||
681 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 682 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
682 | } | 683 | } |
683 | 684 | ||
684 | m_isFullscreen = !m_isFullscreen; | 685 | m_isFullscreen = !m_isFullscreen; |
685 | } | 686 | } |
686 | 687 | ||
687 | 688 | ||
688 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 689 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
689 | 690 | ||
690 | if ( m_curSession ) { | 691 | if ( m_curSession ) { |
691 | 692 | ||