summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 55e9836..27407d9 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,144 +1,142 @@
1#include <assert.h> 1#include <assert.h>
2 2
3
4
5#include <qaction.h> 3#include <qaction.h>
6#include <qmenubar.h> 4#include <qmenubar.h>
7#include <qlabel.h> 5#include <qlabel.h>
8#include <qpopupmenu.h> 6#include <qpopupmenu.h>
9#include <qtoolbar.h> 7#include <qtoolbar.h>
10#include <qmessagebox.h> 8#include <qmessagebox.h>
11#include <qpushbutton.h> 9#include <qpushbutton.h>
12#include <qwhatsthis.h> 10#include <qwhatsthis.h>
13 11
14#include <qpe/resource.h> 12#include <qpe/resource.h>
15#include <opie/ofiledialog.h>
16 13
14#include <opie/ofiledialog.h>
17 15
18#include "keytrans.h" 16#include "keytrans.h"
19#include "profileeditordialog.h" 17#include "profileeditordialog.h"
20#include "configdialog.h" 18#include "configdialog.h"
21#include "default.h" 19#include "default.h"
22#include "metafactory.h" 20#include "metafactory.h"
23#include "profile.h" 21#include "profile.h"
24#include "profilemanager.h" 22#include "profilemanager.h"
25#include "mainwindow.h" 23#include "mainwindow.h"
26#include "tabwidget.h" 24#include "tabwidget.h"
27#include "transferdialog.h" 25#include "transferdialog.h"
28#include "function_keyboard.h" 26#include "function_keyboard.h"
29#include "emulation_handler.h" 27#include "emulation_handler.h"
30#include "script.h" 28#include "script.h"
31#include "quick_button.h" 29#include "quick_button.h"
32 30
33 31
34 32
35MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 33MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
36 KeyTrans::loadAll(); 34 KeyTrans::loadAll();
37 for (int i = 0; i < KeyTrans::count(); i++ ) { 35 for (int i = 0; i < KeyTrans::count(); i++ ) {
38 KeyTrans* s = KeyTrans::find(i ); 36 KeyTrans* s = KeyTrans::find(i );
39 assert( s ); 37 assert( s );
40 } 38 }
41 m_factory = new MetaFactory(); 39 m_factory = new MetaFactory();
42 Default def(m_factory); 40 Default def(m_factory);
43 m_sessions.setAutoDelete( TRUE ); 41 m_sessions.setAutoDelete( TRUE );
44 m_curSession = 0; 42 m_curSession = 0;
45 m_manager = new ProfileManager( m_factory ); 43 m_manager = new ProfileManager( m_factory );
46 m_manager->load(); 44 m_manager->load();
47 45
48 initUI(); 46 initUI();
49 populateProfiles(); 47 populateProfiles();
50} 48}
51void MainWindow::initUI() { 49void MainWindow::initUI() {
52 setToolBarsMovable( FALSE ); 50 setToolBarsMovable( FALSE );
53 51
54 /* tool bar for the menu */ 52 /* tool bar for the menu */
55 m_tool = new QToolBar( this ); 53 m_tool = new QToolBar( this );
56 m_tool->setHorizontalStretchable( TRUE ); 54 m_tool->setHorizontalStretchable( TRUE );
57 55
58 m_bar = new QMenuBar( m_tool ); 56 m_bar = new QMenuBar( m_tool );
59 m_console = new QPopupMenu( this ); 57 m_console = new QPopupMenu( this );
60 m_scripts = new QPopupMenu( this ); 58 m_scripts = new QPopupMenu( this );
61 m_sessionsPop= new QPopupMenu( this ); 59 m_sessionsPop= new QPopupMenu( this );
62 //m_settings = new QPopupMenu( this ); 60 //m_settings = new QPopupMenu( this );
63 61
64 /* add a toolbar for icons */ 62 /* add a toolbar for icons */
65 m_icons = new QToolBar(this); 63 m_icons = new QToolBar(this);
66 64
67 65
68 66
69 67
70 /* 68 /*
71 * the settings action 69 * the settings action
72 */ 70 */
73 m_setProfiles = new QAction(tr("Configure Profiles"), 71 m_setProfiles = new QAction(tr("Configure Profiles"),
74 Resource::loadPixmap( "SettingsIcon" ), 72 Resource::loadPixmap( "SettingsIcon" ),
75 QString::null, 0, this, 0); 73 QString::null, 0, this, 0);
76 // m_setProfiles->addTo( m_settings ); 74 // m_setProfiles->addTo( m_settings );
77 m_setProfiles->addTo( m_icons ); 75 m_setProfiles->addTo( m_icons );
78 m_setProfiles->addTo( m_console ); 76 m_setProfiles->addTo( m_console );
79 connect( m_setProfiles, SIGNAL(activated() ), 77 connect( m_setProfiles, SIGNAL(activated() ),
80 this, SLOT(slotConfigure() ) ); 78 this, SLOT(slotConfigure() ) );
81 79
82 80
83 /* 81 /*
84 * new Action for new sessions 82 * new Action for new sessions
85 */ 83 */
86 QAction* a = new QAction(tr("New Connection"), 84 QAction* a = new QAction(tr("New Connection"),
87 Resource::loadPixmap( "new" ), 85 Resource::loadPixmap( "new" ),
88 QString::null, 0, this, 0); 86 QString::null, 0, this, 0);
89 a->addTo( m_console ); 87 a->addTo( m_console );
90 a->addTo( m_icons ); 88 a->addTo( m_icons );
91 connect(a, SIGNAL(activated() ), 89 connect(a, SIGNAL(activated() ),
92 this, SLOT(slotNew() ) ); 90 this, SLOT(slotNew() ) );
93 91
94 /* 92 /*
95 * connect action 93 * connect action
96 */ 94 */
97 m_connect = new QAction(); 95 m_connect = new QAction();
98 m_connect->setText( tr("Connect") ); 96 m_connect->setText( tr("Connect") );
99 m_connect->addTo( m_console ); 97 m_connect->addTo( m_console );
100 connect(m_connect, SIGNAL(activated() ), 98 connect(m_connect, SIGNAL(activated() ),
101 this, SLOT(slotConnect() ) ); 99 this, SLOT(slotConnect() ) );
102 100
103 /* 101 /*
104 * disconnect action 102 * disconnect action
105 */ 103 */
106 m_disconnect = new QAction(); 104 m_disconnect = new QAction();
107 m_disconnect->setText( tr("Disconnect") ); 105 m_disconnect->setText( tr("Disconnect") );
108 m_disconnect->addTo( m_console ); 106 m_disconnect->addTo( m_console );
109 connect(m_disconnect, SIGNAL(activated() ), 107 connect(m_disconnect, SIGNAL(activated() ),
110 this, SLOT(slotDisconnect() ) ); 108 this, SLOT(slotDisconnect() ) );
111 109
112 m_transfer = new QAction(); 110 m_transfer = new QAction();
113 m_transfer->setText( tr("Transfer file...") ); 111 m_transfer->setText( tr("Transfer file...") );
114 m_transfer->addTo( m_console ); 112 m_transfer->addTo( m_console );
115 connect(m_transfer, SIGNAL(activated() ), 113 connect(m_transfer, SIGNAL(activated() ),
116 this, SLOT(slotTransfer() ) ); 114 this, SLOT(slotTransfer() ) );
117 115
118 116
119 /* 117 /*
120 * fullscreen 118 * fullscreen
121 */ 119 */
122 m_isFullscreen = false; 120 m_isFullscreen = false;
123 121
124 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 122 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
125 , QString::null, 0, this, 0); 123 , QString::null, 0, this, 0);
126 m_fullscreen->addTo( m_console ); 124 m_fullscreen->addTo( m_console );
127 m_fullscreen->addTo( m_icons ); 125 m_fullscreen->addTo( m_icons );
128 connect( m_fullscreen, SIGNAL( activated() ), 126 connect( m_fullscreen, SIGNAL( activated() ),
129 this, SLOT( slotFullscreen() ) ); 127 this, SLOT( slotFullscreen() ) );
130 128
131 /* 129 /*
132 * terminate action 130 * terminate action
133 */ 131 */
134 m_terminate = new QAction(); 132 m_terminate = new QAction();
135 m_terminate->setText( tr("Terminate") ); 133 m_terminate->setText( tr("Terminate") );
136 m_terminate->addTo( m_console ); 134 m_terminate->addTo( m_console );
137 connect(m_terminate, SIGNAL(activated() ), 135 connect(m_terminate, SIGNAL(activated() ),
138 this, SLOT(slotTerminate() ) ); 136 this, SLOT(slotTerminate() ) );
139 137
140 m_closewindow = new QAction(); 138 m_closewindow = new QAction();
141 m_closewindow->setText( tr("Close Window") ); 139 m_closewindow->setText( tr("Close Window") );
142 m_closewindow->addTo( m_console ); 140 m_closewindow->addTo( m_console );
143 connect( m_closewindow, SIGNAL(activated() ), 141 connect( m_closewindow, SIGNAL(activated() ),
144 this, SLOT(slotClose() ) ); 142 this, SLOT(slotClose() ) );
@@ -361,171 +359,175 @@ void MainWindow::slotConfigure() {
361 manager()->setProfiles( conf.list() ); 359 manager()->setProfiles( conf.list() );
362 manager()->save(); 360 manager()->save();
363 populateProfiles(); 361 populateProfiles();
364 } 362 }
365} 363}
366/* 364/*
367 * we will remove 365 * we will remove
368 * this window from the tabwidget 366 * this window from the tabwidget
369 * remove it from the list 367 * remove it from the list
370 * delete it 368 * delete it
371 * and set the currentSession() 369 * and set the currentSession()
372 */ 370 */
373void MainWindow::slotClose() { 371void MainWindow::slotClose() {
374 if (!currentSession() ) 372 if (!currentSession() )
375 return; 373 return;
376 374
377 Session* ses = currentSession(); 375 Session* ses = currentSession();
378 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 376 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
379 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 377 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
380 m_curSession = NULL; 378 m_curSession = NULL;
381 tabWidget()->remove( /*currentSession()*/ses ); 379 tabWidget()->remove( /*currentSession()*/ses );
382 /*it's autodelete */ 380 /*it's autodelete */
383 m_sessions.remove( ses ); 381 m_sessions.remove( ses );
384 qWarning("after remove!!"); 382 qWarning("after remove!!");
385 383
386 if (!currentSession() ) { 384 if (!currentSession() ) {
387 m_connect->setEnabled( false ); 385 m_connect->setEnabled( false );
388 m_disconnect->setEnabled( false ); 386 m_disconnect->setEnabled( false );
389 m_terminate->setEnabled( false ); 387 m_terminate->setEnabled( false );
390 m_transfer->setEnabled( false ); 388 m_transfer->setEnabled( false );
391 m_recordScript->setEnabled( false ); 389 m_recordScript->setEnabled( false );
392 m_saveScript->setEnabled( false ); 390 m_saveScript->setEnabled( false );
393 m_runScript->setEnabled( false ); 391 m_runScript->setEnabled( false );
394 m_fullscreen->setEnabled( false ); 392 m_fullscreen->setEnabled( false );
395 m_closewindow->setEnabled( false ); 393 m_closewindow->setEnabled( false );
396 } 394 }
397} 395}
398 396
399/* 397/*
400 * We will get the name 398 * We will get the name
401 * Then the profile 399 * Then the profile
402 * and then we will make a profile 400 * and then we will make a profile
403 */ 401 */
404void MainWindow::slotProfile( int id) { 402void MainWindow::slotProfile( int id) {
405 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 403 Profile prof = manager()->profile( m_sessionsPop->text( id) );
406 create( prof ); 404 create( prof );
407} 405}
408void MainWindow::create( const Profile& prof ) { 406void MainWindow::create( const Profile& prof ) {
409 Session *ses = manager()->fromProfile( prof, tabWidget() ); 407 Session *ses = manager()->fromProfile( prof, tabWidget() );
410 408
411 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 409 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
412 { 410 {
413 QMessageBox::warning(this, 411 QMessageBox::warning(this,
414 QObject::tr("Session failed"), 412 QObject::tr("Session failed"),
415 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 413 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
416 //if(ses) delete ses; 414 //if(ses) delete ses;
417 return; 415 return;
418 } 416 }
419 417
420 m_sessions.append( ses ); 418 m_sessions.append( ses );
421 tabWidget()->add( ses ); 419 tabWidget()->add( ses );
422 m_curSession = ses; 420 m_curSession = ses;
423 421
424 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 422 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
425 m_connect->setEnabled( true ); 423 m_connect->setEnabled( true );
426 m_disconnect->setEnabled( false ); 424 m_disconnect->setEnabled( false );
427 m_terminate->setEnabled( true ); 425 m_terminate->setEnabled( true );
428 m_transfer->setEnabled( true ); 426 m_transfer->setEnabled( true );
429 m_recordScript->setEnabled( true ); 427 m_recordScript->setEnabled( true );
430 m_saveScript->setEnabled( true ); 428 m_saveScript->setEnabled( true );
431 m_runScript->setEnabled( true ); 429 m_runScript->setEnabled( true );
432 m_fullscreen->setEnabled( true ); 430 m_fullscreen->setEnabled( true );
433 m_closewindow->setEnabled( true ); 431 m_closewindow->setEnabled( true );
434 432
435 433
436 // is io_layer wants direct connection, then autoconnect 434 // is io_layer wants direct connection, then autoconnect
437 if ( ( m_curSession->layer() )->supports()[0] = 1 ) { 435 if ( ( m_curSession->layer() )->supports()[0] = 1 ) {
438 slotConnect(); 436 slotConnect();
439 } 437 }
440} 438}
441 439
442void MainWindow::slotTransfer() 440void MainWindow::slotTransfer()
443{ 441{
444 if ( currentSession() ) { 442 if ( currentSession() ) {
445 TransferDialog dlg(currentSession()->widgetStack(), this); 443 TransferDialog dlg(currentSession()->widgetStack(), this);
446 dlg.showMaximized(); 444 dlg.showMaximized();
447 //currentSession()->widgetStack()->add(dlg); 445 //currentSession()->widgetStack()->add(dlg);
448 dlg.exec(); 446 dlg.exec();
449 } 447 }
450} 448}
451 449
452 450
453void MainWindow::slotOpenKeb(bool state) { 451void MainWindow::slotOpenKeb(bool state) {
454 452
455 if (state) m_keyBar->show(); 453 if (state) m_keyBar->show();
456 else m_keyBar->hide(); 454 else m_keyBar->hide();
457 455
458} 456}
459 457
460 458
461void MainWindow::slotOpenButtons( bool state ) { 459void MainWindow::slotOpenButtons( bool state ) {
462 460
463 if ( state ) { 461 if ( state ) {
464 m_buttonBar->show(); 462 m_buttonBar->show();
465 } else { 463 } else {
466 m_buttonBar->hide(); 464 m_buttonBar->hide();
467 } 465 }
468} 466}
469 467
470 468
471 469
472void MainWindow::slotSessionChanged( Session* ses ) { 470void MainWindow::slotSessionChanged( Session* ses ) {
473 qWarning("changed!"); 471 qWarning("changed!");
474 if ( ses ) { 472 if ( ses ) {
475 m_curSession = ses; 473 m_curSession = ses;
476 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 474 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
477 if ( m_curSession->layer()->isConnected() ) { 475 if ( m_curSession->layer()->isConnected() ) {
478 m_connect->setEnabled( false ); 476 m_connect->setEnabled( false );
479 m_disconnect->setEnabled( true ); 477 m_disconnect->setEnabled( true );
480 } else { 478 } else {
481 m_connect->setEnabled( true ); 479 m_connect->setEnabled( true );
482 m_disconnect->setEnabled( false ); 480 m_disconnect->setEnabled( false );
483 } 481 }
484 } 482 }
485} 483}
486 484
487void MainWindow::slotFullscreen() { 485void MainWindow::slotFullscreen() {
488 486
487
488
489 if ( m_isFullscreen ) { 489 if ( m_isFullscreen ) {
490 ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); 490 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false );
491 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 491 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken );
492
492 setCentralWidget( m_consoleWindow ); 493 setCentralWidget( m_consoleWindow );
493 ( m_curSession->widgetStack() )->show(); 494 ( m_curSession->widgetStack() )->show();
494 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 495 ( m_curSession->emulationHandler() )->cornerButton()->hide();
495 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 496 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
496 497
497 } else { 498 } else {
499 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
498 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 500 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
499 ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 501 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
500 , QPoint(0,0), false ); 502 , QPoint(0,0), false );
501 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 503 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
502 ( m_curSession->widgetStack() )->setFocus(); 504 ( m_curSession->widgetStack() )->setFocus();
503 ( m_curSession->widgetStack() )->show(); 505 ( m_curSession->widgetStack() )->show();
504 506
505 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 507 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
506 508
507 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 509 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
508 } 510 }
509 511
510 m_isFullscreen = !m_isFullscreen; 512 m_isFullscreen = !m_isFullscreen;
511} 513}
512 514
513 515
514void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { 516void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) {
515 517
516 qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); 518 qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released");
517 519
518 if ( m_curSession ) { 520 if ( m_curSession ) {
519 521
520 QEvent::Type state; 522 QEvent::Type state;
521 523
522 if (pressed) state = QEvent::KeyPress; 524 if (pressed) state = QEvent::KeyPress;
523 else state = QEvent::KeyRelease; 525 else state = QEvent::KeyRelease;
524 526
525 QKeyEvent ke(state, q, u, 0, QString(QChar(u))); 527 QKeyEvent ke(state, q, u, 0, QString(QChar(u)));
526 528
527 // where should i send this event? doesnt work sending it here 529 // where should i send this event? doesnt work sending it here
528 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 530 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
529 ke.ignore(); 531 ke.ignore();
530 } 532 }
531} 533}