summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index c7750be..406586c 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -292,260 +292,276 @@ void MainWindow::slotNew() {
292void MainWindow::slotRecordScript() { 292void MainWindow::slotRecordScript() {
293 if (currentSession()) { 293 if (currentSession()) {
294 currentSession()->emulationHandler()->startRecording(); 294 currentSession()->emulationHandler()->startRecording();
295 } 295 }
296} 296}
297 297
298void MainWindow::slotSaveScript() { 298void MainWindow::slotSaveScript() {
299 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 299 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
300 MimeTypes types; 300 MimeTypes types;
301 QStringList script; 301 QStringList script;
302 script << "text/plain"; 302 script << "text/plain";
303 script << "text/all"; 303 script << "text/all";
304 script << "application/octet-stream"; 304 script << "application/octet-stream";
305 types.insert("Script", script); 305 types.insert("Script", script);
306 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 306 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
307 if (!filename.isEmpty()) { 307 if (!filename.isEmpty()) {
308 currentSession()->emulationHandler()->script()->saveTo(filename); 308 currentSession()->emulationHandler()->script()->saveTo(filename);
309 currentSession()->emulationHandler()->clearScript(); 309 currentSession()->emulationHandler()->clearScript();
310 } 310 }
311 } 311 }
312} 312}
313 313
314void MainWindow::slotRunScript() { 314void MainWindow::slotRunScript() {
315 if (currentSession()) { 315 if (currentSession()) {
316 MimeTypes types; 316 MimeTypes types;
317 QStringList script; 317 QStringList script;
318 script << "text/plain"; 318 script << "text/plain";
319 script << "text/all"; 319 script << "text/all";
320 script << "application/octet-stream"; 320 script << "application/octet-stream";
321 types.insert("Script", script); 321 types.insert("Script", script);
322 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 322 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
323 if (!filename.isEmpty()) { 323 if (!filename.isEmpty()) {
324 Script script(DocLnk(filename).file()); 324 Script script(DocLnk(filename).file());
325 currentSession()->emulationHandler()->runScript(&script); 325 currentSession()->emulationHandler()->runScript(&script);
326 } 326 }
327 } 327 }
328} 328}
329 329
330void MainWindow::slotConnect() { 330void MainWindow::slotConnect() {
331 if ( currentSession() ) { 331 if ( currentSession() ) {
332 bool ret = currentSession()->layer()->open(); 332 bool ret = currentSession()->layer()->open();
333 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 333 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
334 QObject::tr("Failed"), 334 QObject::tr("Failed"),
335 QObject::tr("Connecting failed for this session.")); 335 QObject::tr("Connecting failed for this session."));
336 else { 336 else {
337 m_connect->setEnabled( false ); 337 m_connect->setEnabled( false );
338 m_disconnect->setEnabled( true ); 338 m_disconnect->setEnabled( true );
339 m_transfer->setEnabled( true ); 339 m_transfer->setEnabled( true );
340 m_recordScript->setEnabled( true );
341 m_saveScript->setEnabled( true );
342 m_runScript->setEnabled( true );
340 } 343 }
341 } 344 }
342} 345}
343 346
344void MainWindow::slotDisconnect() { 347void MainWindow::slotDisconnect() {
345 if ( currentSession() ) { 348 if ( currentSession() ) {
346 currentSession()->layer()->close(); 349 currentSession()->layer()->close();
347 m_connect->setEnabled( true ); 350 m_connect->setEnabled( true );
348 m_disconnect->setEnabled( false ); 351 m_disconnect->setEnabled( false );
349 m_transfer->setEnabled( false ); 352 m_transfer->setEnabled( false );
353 m_recordScript->setEnabled( false);
354 m_saveScript->setEnabled( false );
355 m_runScript->setEnabled( false );
350 } 356 }
351} 357}
352 358
353void MainWindow::slotTerminate() { 359void MainWindow::slotTerminate() {
354 if ( currentSession() ) 360 if ( currentSession() )
355 currentSession()->layer()->close(); 361 currentSession()->layer()->close();
356 362
357 slotClose(); 363 slotClose();
358 /* FIXME move to the next session */ 364 /* FIXME move to the next session */
359} 365}
360 366
361void MainWindow::slotConfigure() { 367void MainWindow::slotConfigure() {
362 ConfigDialog conf( manager()->all(), factory() ); 368 ConfigDialog conf( manager()->all(), factory() );
363 conf.showMaximized(); 369 conf.showMaximized();
364 370
365 int ret = conf.exec(); 371 int ret = conf.exec();
366 372
367 if ( QDialog::Accepted == ret ) { 373 if ( QDialog::Accepted == ret ) {
368 manager()->setProfiles( conf.list() ); 374 manager()->setProfiles( conf.list() );
369 manager()->save(); 375 manager()->save();
370 populateProfiles(); 376 populateProfiles();
371 } 377 }
372} 378}
373/* 379/*
374 * we will remove 380 * we will remove
375 * this window from the tabwidget 381 * this window from the tabwidget
376 * remove it from the list 382 * remove it from the list
377 * delete it 383 * delete it
378 * and set the currentSession() 384 * and set the currentSession()
379 */ 385 */
380void MainWindow::slotClose() { 386void MainWindow::slotClose() {
381 if (!currentSession() ) 387 if (!currentSession() )
382 return; 388 return;
383 389
384 Session* ses = currentSession(); 390 Session* ses = currentSession();
385 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 391 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
386 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 392 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
387 m_curSession = NULL; 393 m_curSession = NULL;
388 tabWidget()->remove( /*currentSession()*/ses ); 394 tabWidget()->remove( /*currentSession()*/ses );
389 /*it's autodelete */ 395 /*it's autodelete */
390 m_sessions.remove( ses ); 396 m_sessions.remove( ses );
391 qWarning("after remove!!"); 397 qWarning("after remove!!");
392 398
393 if (!currentSession() ) { 399 if (!currentSession() ) {
394 m_connect->setEnabled( false ); 400 m_connect->setEnabled( false );
395 m_disconnect->setEnabled( false ); 401 m_disconnect->setEnabled( false );
396 m_terminate->setEnabled( false ); 402 m_terminate->setEnabled( false );
397 m_transfer->setEnabled( false ); 403 m_transfer->setEnabled( false );
398 m_recordScript->setEnabled( false ); 404 m_recordScript->setEnabled( false );
399 m_saveScript->setEnabled( false ); 405 m_saveScript->setEnabled( false );
400 m_runScript->setEnabled( false ); 406 m_runScript->setEnabled( false );
401 m_fullscreen->setEnabled( false ); 407 m_fullscreen->setEnabled( false );
402 m_closewindow->setEnabled( false ); 408 m_closewindow->setEnabled( false );
403 } 409 }
404} 410}
405 411
406/* 412/*
407 * We will get the name 413 * We will get the name
408 * Then the profile 414 * Then the profile
409 * and then we will make a profile 415 * and then we will make a profile
410 */ 416 */
411void MainWindow::slotProfile( int id) { 417void MainWindow::slotProfile( int id) {
412 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 418 Profile prof = manager()->profile( m_sessionsPop->text( id) );
413 create( prof ); 419 create( prof );
414} 420}
415void MainWindow::create( const Profile& prof ) { 421void MainWindow::create( const Profile& prof ) {
416 Session *ses = manager()->fromProfile( prof, tabWidget() ); 422 Session *ses = manager()->fromProfile( prof, tabWidget() );
417 423
418 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 424 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
419 { 425 {
420 QMessageBox::warning(this, 426 QMessageBox::warning(this,
421 QObject::tr("Session failed"), 427 QObject::tr("Session failed"),
422 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 428 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
423 //if(ses) delete ses; 429 //if(ses) delete ses;
424 return; 430 return;
425 } 431 }
426 432
427 m_sessions.append( ses ); 433 m_sessions.append( ses );
428 tabWidget()->add( ses ); 434 tabWidget()->add( ses );
429 tabWidget()->repaint(); 435 tabWidget()->repaint();
430 m_curSession = ses; 436 m_curSession = ses;
431 437
432 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 438 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
433 m_connect->setEnabled( true ); 439 m_connect->setEnabled( true );
434 m_disconnect->setEnabled( false ); 440 m_disconnect->setEnabled( false );
435 m_terminate->setEnabled( true ); 441 m_terminate->setEnabled( true );
436 m_recordScript->setEnabled( true );
437 m_saveScript->setEnabled( true );
438 m_runScript->setEnabled( true );
439 m_fullscreen->setEnabled( true ); 442 m_fullscreen->setEnabled( true );
440 m_closewindow->setEnabled( true ); 443 m_closewindow->setEnabled( true );
441 m_transfer->setEnabled( false ); 444 m_transfer->setEnabled( false );
445 m_recordScript->setEnabled( false );
446 m_saveScript->setEnabled( false );
447 m_runScript->setEnabled( false );
442 448
443 // is io_layer wants direct connection, then autoconnect 449 // is io_layer wants direct connection, then autoconnect
444 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 450 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
445 if (prof.autoConnect()) { 451 if (prof.autoConnect()) {
446 slotConnect(); 452 slotConnect();
447 } 453 }
448 454
449 455
450 456
451 QWidget *w = currentSession()->widget(); 457 QWidget *w = currentSession()->widget();
452 if(w) w->setFocus(); 458 if(w) w->setFocus();
453} 459}
454 460
455void MainWindow::slotTransfer() 461void MainWindow::slotTransfer()
456{ 462{
457 if ( currentSession() ) { 463 if ( currentSession() ) {
458 TransferDialog dlg(currentSession()->widgetStack(), this); 464 TransferDialog dlg(currentSession()->widgetStack(), this);
459 dlg.showMaximized(); 465 dlg.showMaximized();
460 //currentSession()->widgetStack()->add(dlg); 466 //currentSession()->widgetStack()->add(dlg);
461 dlg.exec(); 467 dlg.exec();
462 } 468 }
463} 469}
464 470
465 471
466void MainWindow::slotOpenKeb(bool state) { 472void MainWindow::slotOpenKeb(bool state) {
467 473
468 if (state) m_keyBar->show(); 474 if (state) m_keyBar->show();
469 else m_keyBar->hide(); 475 else m_keyBar->hide();
470 476
471} 477}
472 478
473 479
474void MainWindow::slotOpenButtons( bool state ) { 480void MainWindow::slotOpenButtons( bool state ) {
475 481
476 if ( state ) { 482 if ( state ) {
477 m_buttonBar->show(); 483 m_buttonBar->show();
478 } else { 484 } else {
479 m_buttonBar->hide(); 485 m_buttonBar->hide();
480 } 486 }
481} 487}
482 488
483 489
484 490
485void MainWindow::slotSessionChanged( Session* ses ) { 491void MainWindow::slotSessionChanged( Session* ses ) {
486 qWarning("changed!"); 492 qWarning("changed!");
487 if ( ses ) { 493 if ( ses ) {
488 m_curSession = ses; 494 m_curSession = ses;
489 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 495 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
490 if ( m_curSession->layer()->isConnected() ) { 496 if ( m_curSession->layer()->isConnected() ) {
491 m_connect->setEnabled( false ); 497 m_connect->setEnabled( false );
492 m_disconnect->setEnabled( true ); 498 m_disconnect->setEnabled( true );
499 m_recordScript->setEnabled( true );
500 m_saveScript->setEnabled( true );
501 m_runScript->setEnabled( true );
493 } else { 502 } else {
494 m_connect->setEnabled( true ); 503 m_connect->setEnabled( true );
495 m_disconnect->setEnabled( false ); 504 m_disconnect->setEnabled( false );
505 m_recordScript->setEnabled( false );
506 m_saveScript->setEnabled( false );
507 m_runScript->setEnabled( false );
496 } 508 }
497 509
498 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 510 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
499 m_transfer->setEnabled( false ); 511 m_transfer->setEnabled( false );
500 } else { 512 } else {
501 m_transfer->setEnabled( true ); 513 m_transfer->setEnabled( true );
502 } 514 }
503 515
516
517
518
519
504 QWidget *w = m_curSession->widget(); 520 QWidget *w = m_curSession->widget();
505 if(w) w->setFocus(); 521 if(w) w->setFocus();
506 } 522 }
507} 523}
508 524
509void MainWindow::slotFullscreen() { 525void MainWindow::slotFullscreen() {
510 526
511 527
512 528
513 if ( m_isFullscreen ) { 529 if ( m_isFullscreen ) {
514 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 530 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
515 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 531 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
516 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 532 ( m_curSession->emulationHandler() )->cornerButton()->hide();
517 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 533 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
518 534
519 } else { 535 } else {
520 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 536 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
521 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 537 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
522 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 538 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
523 , QPoint(0,0), false ); 539 , QPoint(0,0), false );
524 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 540 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
525 ( m_curSession->widgetStack() )->setFocus(); 541 ( m_curSession->widgetStack() )->setFocus();
526 ( m_curSession->widgetStack() )->show(); 542 ( m_curSession->widgetStack() )->show();
527 543
528 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 544 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
529 545
530 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 546 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
531 } 547 }
532 548
533 m_isFullscreen = !m_isFullscreen; 549 m_isFullscreen = !m_isFullscreen;
534} 550}
535 551
536 552
537void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 553void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
538 554
539 if ( m_curSession ) { 555 if ( m_curSession ) {
540 556
541 QEvent::Type state; 557 QEvent::Type state;
542 558
543 if (pressed) state = QEvent::KeyPress; 559 if (pressed) state = QEvent::KeyPress;
544 else state = QEvent::KeyRelease; 560 else state = QEvent::KeyRelease;
545 561
546 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 562 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
547 563
548 // where should i send this event? doesnt work sending it here 564 // where should i send this event? doesnt work sending it here
549 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 565 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
550 ke.ignore(); 566 ke.ignore();
551 } 567 }