summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-10-26 11:53:47 (UTC)
committer harlekin <harlekin>2002-10-26 11:53:47 (UTC)
commit88504fa6ed3e4ec1c11d3e1cde13c821b1a9b846 (patch) (unidiff)
treeb3acc8683f44c7fa960c4d422ae781ed7b854f65
parent2dc92ada34785bbfff8ca1202e4d53eb0606c362 (diff)
downloadopie-88504fa6ed3e4ec1c11d3e1cde13c821b1a9b846.zip
opie-88504fa6ed3e4ec1c11d3e1cde13c821b1a9b846.tar.gz
opie-88504fa6ed3e4ec1c11d3e1cde13c821b1a9b846.tar.bz2
only enable tranfer if layer supports it
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 5f6dc12..e3c3c38 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -357,314 +357,320 @@ 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
373MainWindow::~MainWindow() { 373MainWindow::~MainWindow() {
374 delete m_factory; 374 delete m_factory;
375 manager()->save(); 375 manager()->save();
376} 376}
377 377
378MetaFactory* MainWindow::factory() { 378MetaFactory* MainWindow::factory() {
379 return m_factory; 379 return m_factory;
380} 380}
381 381
382Session* MainWindow::currentSession() { 382Session* MainWindow::currentSession() {
383 return m_curSession; 383 return m_curSession;
384} 384}
385 385
386QList<Session> MainWindow::sessions() { 386QList<Session> MainWindow::sessions() {
387 return m_sessions; 387 return m_sessions;
388} 388}
389 389
390void MainWindow::slotNew() { 390void MainWindow::slotNew() {
391 ProfileEditorDialog dlg(factory() ); 391 ProfileEditorDialog dlg(factory() );
392 dlg.showMaximized(); 392 dlg.showMaximized();
393 dlg.setCaption( tr("New Connection") ); 393 dlg.setCaption( tr("New Connection") );
394 int ret = dlg.exec(); 394 int ret = dlg.exec();
395 395
396 if ( ret == QDialog::Accepted ) { 396 if ( ret == QDialog::Accepted ) {
397 create( dlg.profile() ); 397 create( dlg.profile() );
398 } 398 }
399} 399}
400 400
401void MainWindow::slotRecordScript() { 401void MainWindow::slotRecordScript() {
402 if (currentSession()) { 402 if (currentSession()) {
403 currentSession()->emulationHandler()->startRecording(); 403 currentSession()->emulationHandler()->startRecording();
404 m_saveScript->setEnabled(true); 404 m_saveScript->setEnabled(true);
405 m_recordScript->setEnabled(false); 405 m_recordScript->setEnabled(false);
406 } 406 }
407} 407}
408 408
409void MainWindow::slotSaveScript() { 409void MainWindow::slotSaveScript() {
410 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 410 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
411 QMap<QString, QStringList> map; 411 QMap<QString, QStringList> map;
412 QStringList text; 412 QStringList text;
413 text << "text/plain"; 413 text << "text/plain";
414 map.insert(tr("Script"), text ); 414 map.insert(tr("Script"), text );
415 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 415 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
416 if (!filename.isEmpty()) { 416 if (!filename.isEmpty()) {
417 QFileInfo info(filename); 417 QFileInfo info(filename);
418 if (info.extension(FALSE) != "script") 418 if (info.extension(FALSE) != "script")
419 filename += ".script"; 419 filename += ".script";
420 DocLnk nf; 420 DocLnk nf;
421 nf.setType("text/plain"); 421 nf.setType("text/plain");
422 nf.setFile(filename); 422 nf.setFile(filename);
423 nf.setName(info.fileName()); 423 nf.setName(info.fileName());
424 FileManager fm; 424 FileManager fm;
425 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); 425 fm.saveFile(nf, currentSession()->emulationHandler()->script()->script());
426 currentSession()->emulationHandler()->clearScript(); 426 currentSession()->emulationHandler()->clearScript();
427 m_saveScript->setEnabled(false); 427 m_saveScript->setEnabled(false);
428 m_recordScript->setEnabled(true); 428 m_recordScript->setEnabled(true);
429 populateScripts(); 429 populateScripts();
430 } 430 }
431 } 431 }
432} 432}
433 433
434void MainWindow::slotRunScript(int id) { 434void MainWindow::slotRunScript(int id) {
435 if (currentSession()) { 435 if (currentSession()) {
436 int index = m_scriptsPop->indexOf(id); 436 int index = m_scriptsPop->indexOf(id);
437 DocLnk *lnk = m_scriptsData.at(index); 437 DocLnk *lnk = m_scriptsData.at(index);
438 QString filePath = lnk->file(); 438 QString filePath = lnk->file();
439 Script script(filePath); 439 Script script(filePath);
440 currentSession()->emulationHandler()->runScript(&script); 440 currentSession()->emulationHandler()->runScript(&script);
441 } 441 }
442} 442}
443 443
444void MainWindow::slotConnect() { 444void MainWindow::slotConnect() {
445 if ( currentSession() ) { 445 if ( currentSession() ) {
446 bool ret = currentSession()->layer()->open(); 446 bool ret = currentSession()->layer()->open();
447 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 447 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
448 QObject::tr("Failed"), 448 QObject::tr("Failed"),
449 QObject::tr("Connecting failed for this session.")); 449 QObject::tr("Connecting failed for this session."));
450 else { 450 else {
451 m_connect->setEnabled( false ); 451 m_connect->setEnabled( false );
452 m_disconnect->setEnabled( true ); 452 m_disconnect->setEnabled( true );
453 m_transfer->setEnabled( true ); 453
454 // if it does not support file transfer, disable the menu entry
455 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
456 m_transfer->setEnabled( false );
457 } else {
458 m_transfer->setEnabled( true );
459 }
460
454 m_recordScript->setEnabled( true ); 461 m_recordScript->setEnabled( true );
455 m_scripts->setItemEnabled(m_runScript_id, true); 462 m_scripts->setItemEnabled(m_runScript_id, true);
456 } 463 }
457 } 464 }
458} 465}
459 466
460void MainWindow::slotDisconnect() { 467void MainWindow::slotDisconnect() {
461 if ( currentSession() ) { 468 if ( currentSession() ) {
462 currentSession()->layer()->close(); 469 currentSession()->layer()->close();
463 m_connect->setEnabled( true ); 470 m_connect->setEnabled( true );
464 m_disconnect->setEnabled( false ); 471 m_disconnect->setEnabled( false );
465 m_transfer->setEnabled( false ); 472 m_transfer->setEnabled( false );
466 m_recordScript->setEnabled( false); 473 m_recordScript->setEnabled( false);
467 m_saveScript->setEnabled( false ); 474 m_saveScript->setEnabled( false );
468 m_scripts->setItemEnabled(m_runScript_id, false); 475 m_scripts->setItemEnabled(m_runScript_id, false);
469 } 476 }
470} 477}
471 478
472void MainWindow::slotTerminate() { 479void MainWindow::slotTerminate() {
473 if ( currentSession() ) 480 if ( currentSession() )
474 currentSession()->layer()->close(); 481 currentSession()->layer()->close();
475 482
476 slotClose(); 483 slotClose();
477 /* FIXME move to the next session */ 484 /* FIXME move to the next session */
478} 485}
479 486
480void MainWindow::slotConfigure() { 487void MainWindow::slotConfigure() {
481 ConfigDialog conf( manager()->all(), factory() ); 488 ConfigDialog conf( manager()->all(), factory() );
482 conf.showMaximized(); 489 conf.showMaximized();
483 490
484 int ret = conf.exec(); 491 int ret = conf.exec();
485 492
486 if ( QDialog::Accepted == ret ) { 493 if ( QDialog::Accepted == ret ) {
487 manager()->setProfiles( conf.list() ); 494 manager()->setProfiles( conf.list() );
488 manager()->save(); 495 manager()->save();
489 populateProfiles(); 496 populateProfiles();
490 } 497 }
491} 498}
492/* 499/*
493 * we will remove 500 * we will remove
494 * this window from the tabwidget 501 * this window from the tabwidget
495 * remove it from the list 502 * remove it from the list
496 * delete it 503 * delete it
497 * and set the currentSession() 504 * and set the currentSession()
498 */ 505 */
499void MainWindow::slotClose() { 506void MainWindow::slotClose() {
500 if (!currentSession() ) 507 if (!currentSession() )
501 return; 508 return;
502 509
503 Session* ses = currentSession(); 510 Session* ses = currentSession();
504 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 511 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
505 /* 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 */
506 m_curSession = NULL; 513 m_curSession = NULL;
507 tabWidget()->remove( /*currentSession()*/ses ); 514 tabWidget()->remove( /*currentSession()*/ses );
508 /*it's autodelete */ 515 /*it's autodelete */
509 m_sessions.remove( ses ); 516 m_sessions.remove( ses );
510 qWarning("after remove!!"); 517 qWarning("after remove!!");
511 518
512 if (!currentSession() ) { 519 if (!currentSession() ) {
513 m_connect->setEnabled( false ); 520 m_connect->setEnabled( false );
514 m_disconnect->setEnabled( false ); 521 m_disconnect->setEnabled( false );
515 m_terminate->setEnabled( false ); 522 m_terminate->setEnabled( false );
516 m_transfer->setEnabled( false ); 523 m_transfer->setEnabled( false );
517 m_recordScript->setEnabled( false ); 524 m_recordScript->setEnabled( false );
518 m_saveScript->setEnabled( false ); 525 m_saveScript->setEnabled( false );
519 m_scripts->setItemEnabled(m_runScript_id, false); 526 m_scripts->setItemEnabled(m_runScript_id, false);
520 m_fullscreen->setEnabled( false ); 527 m_fullscreen->setEnabled( false );
521 m_closewindow->setEnabled( false ); 528 m_closewindow->setEnabled( false );
522 } 529 }
523 530
524 m_kb->loadDefaults(); 531 m_kb->loadDefaults();
525} 532}
526 533
527/* 534/*
528 * We will get the name 535 * We will get the name
529 * Then the profile 536 * Then the profile
530 * and then we will make a profile 537 * and then we will make a profile
531 */ 538 */
532void MainWindow::slotProfile( int id) { 539void MainWindow::slotProfile( int id) {
533 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 540 Profile prof = manager()->profile( m_sessionsPop->text( id) );
534 create( prof ); 541 create( prof );
535} 542}
536void MainWindow::create( const Profile& prof ) { 543void MainWindow::create( const Profile& prof ) {
537 if(m_curSession) 544 if(m_curSession)
538 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 545 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
539 546
540 Session *ses = manager()->fromProfile( prof, tabWidget() ); 547 Session *ses = manager()->fromProfile( prof, tabWidget() );
541 548
542 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 549 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
543 { 550 {
544 QMessageBox::warning(this, 551 QMessageBox::warning(this,
545 QObject::tr("Session failed"), 552 QObject::tr("Session failed"),
546 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>"));
547 //if(ses) delete ses; 554 //if(ses) delete ses;
548 return; 555 return;
549 } 556 }
550 557
551 m_sessions.append( ses ); 558 m_sessions.append( ses );
552 tabWidget()->add( ses ); 559 tabWidget()->add( ses );
553 tabWidget()->repaint(); 560 tabWidget()->repaint();
554 m_curSession = ses; 561 m_curSession = ses;
555 562
556 // 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
557 m_connect->setEnabled( true ); 564 m_connect->setEnabled( true );
558 m_disconnect->setEnabled( false ); 565 m_disconnect->setEnabled( false );
559 m_terminate->setEnabled( true ); 566 m_terminate->setEnabled( true );
560 m_fullscreen->setEnabled( true ); 567 m_fullscreen->setEnabled( true );
561 m_closewindow->setEnabled( true ); 568 m_closewindow->setEnabled( true );
562 m_transfer->setEnabled( false ); 569 m_transfer->setEnabled( false );
563 m_recordScript->setEnabled( false ); 570 m_recordScript->setEnabled( false );
564 m_saveScript->setEnabled( false ); 571 m_saveScript->setEnabled( false );
565 m_scripts->setItemEnabled(m_runScript_id, false); 572 m_scripts->setItemEnabled(m_runScript_id, false);
566 573
567 // is io_layer wants direct connection, then autoconnect 574 // is io_layer wants direct connection, then autoconnect
568 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 575 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
569 if (prof.autoConnect()) { 576 if (prof.autoConnect()) {
570 slotConnect(); 577 slotConnect();
571 } 578 }
572 579
573 580
574
575 QWidget *w = currentSession()->widget(); 581 QWidget *w = currentSession()->widget();
576 if(w) w->setFocus(); 582 if(w) w->setFocus();
577 583
578 m_kb->load(currentSession()->profile()); 584 m_kb->load(currentSession()->profile());
579} 585}
580 586
581void MainWindow::slotTransfer() 587void MainWindow::slotTransfer()
582{ 588{
583 if ( currentSession() ) { 589 if ( currentSession() ) {
584 Session *mysession = currentSession(); 590 Session *mysession = currentSession();
585 TransferDialog dlg(mysession->widgetStack(), this); 591 TransferDialog dlg(mysession->widgetStack(), this);
586 mysession->setTransferDialog(&dlg); 592 mysession->setTransferDialog(&dlg);
587 dlg.show(); 593 dlg.show();
588 //dlg.showMaximized(); 594 //dlg.showMaximized();
589 //currentSession()->widgetStack()->add(dlg); 595 //currentSession()->widgetStack()->add(dlg);
590 //dlg.exec(); 596 //dlg.exec();
591 while(dlg.isRunning()) qApp->processEvents(); 597 while(dlg.isRunning()) qApp->processEvents();
592 mysession->setTransferDialog(0l); 598 mysession->setTransferDialog(0l);
593 } 599 }
594} 600}
595 601
596 602
597void MainWindow::slotOpenKeb(bool state) { 603void MainWindow::slotOpenKeb(bool state) {
598 604
599 if (state) m_keyBar->show(); 605 if (state) m_keyBar->show();
600 else m_keyBar->hide(); 606 else m_keyBar->hide();
601 607
602} 608}
603 609
604 610
605void MainWindow::slotOpenButtons( bool state ) { 611void MainWindow::slotOpenButtons( bool state ) {
606 612
607 if ( state ) { 613 if ( state ) {
608 m_buttonBar->show(); 614 m_buttonBar->show();
609 } else { 615 } else {
610 m_buttonBar->hide(); 616 m_buttonBar->hide();
611 } 617 }
612} 618}
613 619
614 620
615 621
616void MainWindow::slotSessionChanged( Session* ses ) { 622void MainWindow::slotSessionChanged( Session* ses ) {
617 qWarning("changed!"); 623 qWarning("changed!");
618 624
619 if(m_curSession) 625 if(m_curSession)
620 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 626 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
621 if(ses) 627 if(ses)
622 if(ses->transferDialog()) ses->transferDialog()->show(); 628 if(ses->transferDialog()) ses->transferDialog()->show();
623 629
624 if ( ses ) { 630 if ( ses ) {
625 m_curSession = ses; 631 m_curSession = ses;
626 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 632 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
627 if ( m_curSession->layer()->isConnected() ) { 633 if ( m_curSession->layer()->isConnected() ) {
628 m_connect->setEnabled( false ); 634 m_connect->setEnabled( false );
629 m_disconnect->setEnabled( true ); 635 m_disconnect->setEnabled( true );
630 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 636 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
631 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 637 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
632 m_scripts->setItemEnabled(m_runScript_id, true); 638 m_scripts->setItemEnabled(m_runScript_id, true);
633 } else { 639 } else {
634 m_connect->setEnabled( true ); 640 m_connect->setEnabled( true );
635 m_disconnect->setEnabled( false ); 641 m_disconnect->setEnabled( false );
636 m_recordScript->setEnabled( false ); 642 m_recordScript->setEnabled( false );
637 m_saveScript->setEnabled( false ); 643 m_saveScript->setEnabled( false );
638 m_scripts->setItemEnabled(m_runScript_id, false); 644 m_scripts->setItemEnabled(m_runScript_id, false);
639 } 645 }
640 646
641 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 647 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
642 m_transfer->setEnabled( false ); 648 m_transfer->setEnabled( false );
643 } else { 649 } else {
644 m_transfer->setEnabled( true ); 650 m_transfer->setEnabled( true );
645 } 651 }
646 652
647 QWidget *w = m_curSession->widget(); 653 QWidget *w = m_curSession->widget();
648 if(w) w->setFocus(); 654 if(w) w->setFocus();
649 655
650 m_kb->load(currentSession()->profile()); 656 m_kb->load(currentSession()->profile());
651 } 657 }
652} 658}
653 659
654void MainWindow::slotFullscreen() { 660void MainWindow::slotFullscreen() {
655 661
656 662
657 663
658 if ( m_isFullscreen ) { 664 if ( m_isFullscreen ) {
659 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 665 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
660 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 666 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
661 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 667 ( m_curSession->emulationHandler() )->cornerButton()->hide();
662 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 668 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
663 669
664 } else { 670 } else {
665 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 671 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
666 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 672 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
667 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 673 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
668 , QPoint(0,0), false ); 674 , QPoint(0,0), false );
669 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 675 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
670 ( m_curSession->widgetStack() )->setFocus(); 676 ( m_curSession->widgetStack() )->setFocus();