summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp15
-rw-r--r--noncore/apps/opie-console/keytrans.cpp3
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp9
3 files changed, 20 insertions, 7 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 787de67..c67c7c7 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,41 +1,48 @@
1#include <qwidget.h> 1#include <qwidget.h>
2 2
3#include "TEWidget.h" 3#include "TEWidget.h"
4#include "TEmuVt102.h" 4#include "TEmuVt102.h"
5 5
6#include "emulation_handler.h" 6#include "emulation_handler.h"
7 7
8 8
9EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent, const char* name ) 9EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
10 : QObject(0, name ) 10 : QObject(0, name )
11{ 11{
12 load(prof ); 12 m_teWid = new TEWidget( parent, "TerminalMain");
13 m_teWid = new TEWidget( parent, "TerminalMain" ); 13 m_teWid->setMinimumSize(150, 70 );
14 parent->resize( m_teWid->calcSize(80, 24 ) ); 14 parent->resize( m_teWid->calcSize(80, 24 ) );
15 m_teEmu = new TEmuVt102(m_teWid ); 15 m_teEmu = new TEmuVt102(m_teWid );
16 16
17 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 17 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
18 this, SIGNAL(changeSize(int, int) ) ); 18 this, SIGNAL(changeSize(int, int) ) );
19 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 19 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
20 this, SLOT(recvEmulation(const char*, int) ) ); 20 this, SLOT(recvEmulation(const char*, int) ) );
21 m_teEmu->setConnect( true );
22 load( prof );
23
24
21 25
22} 26}
23EmulationHandler::~EmulationHandler() { 27EmulationHandler::~EmulationHandler() {
24 delete m_teEmu; 28 delete m_teEmu;
25 delete m_teWid; 29 delete m_teWid;
26} 30}
27void EmulationHandler::load( const Profile& ) { 31void EmulationHandler::load( const Profile& ) {
28 32 QFont font = QFont("Fixed", 12, QFont::Normal );
33 font.setFixedPitch(TRUE);
34 m_teWid->setVTFont( font );
35 m_teWid->setBackgroundColor(Qt::black );
29} 36}
30void EmulationHandler::recv( const QByteArray& ar) { 37void EmulationHandler::recv( const QByteArray& ar) {
31 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 38 m_teEmu->onRcvBlock(ar.data(), ar.count() );
32} 39}
33void EmulationHandler::recvEmulation(const char* src, int len ) { 40void EmulationHandler::recvEmulation(const char* src, int len ) {
34 QByteArray ar(len); 41 QByteArray ar(len);
35 memcpy(ar.data(), src, sizeof(char) * len ); 42 memcpy(ar.data(), src, sizeof(char) * len );
36 43
37 emit send(ar); 44 emit send(ar);
38} 45}
39QWidget* EmulationHandler::widget() { 46QWidget* EmulationHandler::widget() {
40 return m_teWid; 47 return m_teWid;
41} 48}
diff --git a/noncore/apps/opie-console/keytrans.cpp b/noncore/apps/opie-console/keytrans.cpp
index 5ea192e..d569ae0 100644
--- a/noncore/apps/opie-console/keytrans.cpp
+++ b/noncore/apps/opie-console/keytrans.cpp
@@ -246,464 +246,461 @@ void KeytabReader::getSymbol()
246 // regular char 246 // regular char
247 sc = cc; getCc(); 247 sc = cc; getCc();
248 } 248 }
249 res = res + (char)sc; 249 res = res + (char)sc;
250 len = len + 1; 250 len = len + 1;
251 } 251 }
252 if (cc != '"') return; 252 if (cc != '"') return;
253 getCc(); 253 getCc();
254 sym = SYMString; return; 254 sym = SYMString; return;
255 } 255 }
256} 256}
257 257
258void KeytabReader::ReportToken() // diagnostic 258void KeytabReader::ReportToken() // diagnostic
259{ 259{
260 printf("sym(%d): ",slinno); 260 printf("sym(%d): ",slinno);
261 switch(sym) 261 switch(sym)
262 { 262 {
263 case SYMEol : printf("End of line"); break; 263 case SYMEol : printf("End of line"); break;
264 case SYMEof : printf("End of file"); break; 264 case SYMEof : printf("End of file"); break;
265 case SYMName : printf("Name: %s",res.latin1()); break; 265 case SYMName : printf("Name: %s",res.latin1()); break;
266 case SYMOpr : printf("Opr : %s",res.latin1()); break; 266 case SYMOpr : printf("Opr : %s",res.latin1()); break;
267 case SYMString : printf("String len %d,%d ",res.length(),len); 267 case SYMString : printf("String len %d,%d ",res.length(),len);
268 for (unsigned i = 0; i < res.length(); i++) 268 for (unsigned i = 0; i < res.length(); i++)
269 printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?'); 269 printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?');
270 break; 270 break;
271 } 271 }
272 printf("\n"); 272 printf("\n");
273} 273}
274 274
275void KeytabReader::ReportError(const char* msg) // diagnostic 275void KeytabReader::ReportError(const char* msg) // diagnostic
276{ 276{
277 fprintf(stderr,"%s(%d,%d):error: %s.\n",path.ascii(),slinno,scolno,msg); 277 fprintf(stderr,"%s(%d,%d):error: %s.\n",path.ascii(),slinno,scolno,msg);
278} 278}
279 279
280// local symbol tables --------------------------------------------------------------------- 280// local symbol tables ---------------------------------------------------------------------
281 281
282class KeyTransSymbols 282class KeyTransSymbols
283{ 283{
284public: 284public:
285 KeyTransSymbols(); 285 KeyTransSymbols();
286protected: 286protected:
287 void defOprSyms(); 287 void defOprSyms();
288 void defModSyms(); 288 void defModSyms();
289 void defKeySyms(); 289 void defKeySyms();
290 void defKeySym(const char* key, int val); 290 void defKeySym(const char* key, int val);
291 void defOprSym(const char* key, int val); 291 void defOprSym(const char* key, int val);
292 void defModSym(const char* key, int val); 292 void defModSym(const char* key, int val);
293public: 293public:
294 QDict<QObject> keysyms; 294 QDict<QObject> keysyms;
295 QDict<QObject> modsyms; 295 QDict<QObject> modsyms;
296 QDict<QObject> oprsyms; 296 QDict<QObject> oprsyms;
297}; 297};
298 298
299static KeyTransSymbols * syms = 0L; 299static KeyTransSymbols * syms = 0L;
300 300
301// parser ---------------------------------------------------------------------------------- 301// parser ----------------------------------------------------------------------------------
302/* Syntax 302/* Syntax
303 - Line :: [KeyName { ("+" | "-") ModeName } ":" (String|CommandName)] "\n" 303 - Line :: [KeyName { ("+" | "-") ModeName } ":" (String|CommandName)] "\n"
304 - Comment :: '#' (any but \n)* 304 - Comment :: '#' (any but \n)*
305*/ 305*/
306 306
307KeyTrans* KeyTrans::fromDevice(QString path, QIODevice &buf) 307KeyTrans* KeyTrans::fromDevice(QString path, QIODevice &buf)
308{ 308{
309 KeyTrans* kt = new KeyTrans; 309 KeyTrans* kt = new KeyTrans;
310 kt->path = path; 310 kt->path = path;
311 KeytabReader ktr(path,buf); ktr.parseTo(kt); 311 KeytabReader ktr(path,buf); ktr.parseTo(kt);
312 return kt; 312 return kt;
313} 313}
314 314
315 315
316#define assertSyntax(Cond,Message) if (!(Cond)) { ReportError(Message); goto ERROR; } 316#define assertSyntax(Cond,Message) if (!(Cond)) { ReportError(Message); goto ERROR; }
317 317
318void KeytabReader::parseTo(KeyTrans* kt) 318void KeytabReader::parseTo(KeyTrans* kt)
319{ 319{
320 // Opening sequence 320 // Opening sequence
321 321
322 buf->open(IO_ReadOnly); 322 buf->open(IO_ReadOnly);
323 getCc(); 323 getCc();
324 linno = 1; 324 linno = 1;
325 colno = 1; 325 colno = 1;
326 getSymbol(); 326 getSymbol();
327 327
328Loop: 328Loop:
329 // syntax: ["key" KeyName { ("+" | "-") ModeName } ":" String/CommandName] ["#" Comment] 329 // syntax: ["key" KeyName { ("+" | "-") ModeName } ":" String/CommandName] ["#" Comment]
330 if (sym == SYMName && !strcmp(res.latin1(),"keyboard")) 330 if (sym == SYMName && !strcmp(res.latin1(),"keyboard"))
331 { 331 {
332 getSymbol(); assertSyntax(sym == SYMString, "Header expected") 332 getSymbol(); assertSyntax(sym == SYMString, "Header expected")
333 kt->hdr = res.latin1(); 333 kt->hdr = res.latin1();
334 getSymbol(); assertSyntax(sym == SYMEol, "Text unexpected") 334 getSymbol(); assertSyntax(sym == SYMEol, "Text unexpected")
335 getSymbol(); // eoln 335 getSymbol(); // eoln
336 goto Loop; 336 goto Loop;
337 } 337 }
338 if (sym == SYMName && !strcmp(res.latin1(),"key")) 338 if (sym == SYMName && !strcmp(res.latin1(),"key"))
339 { 339 {
340//printf("line %3d: ",startofsym); 340//printf("line %3d: ",startofsym);
341 getSymbol(); assertSyntax(sym == SYMName, "Name expected") 341 getSymbol(); assertSyntax(sym == SYMName, "Name expected")
342 assertSyntax(syms->keysyms[res], "Unknown key name") 342 assertSyntax(syms->keysyms[res], "Unknown key name")
343 int key = (int)syms->keysyms[res]-1; 343 int key = (int)syms->keysyms[res]-1;
344//printf(" key %s (%04x)",res.latin1(),(int)syms->keysyms[res]-1); 344//printf(" key %s (%04x)",res.latin1(),(int)syms->keysyms[res]-1);
345 getSymbol(); // + - : 345 getSymbol(); // + - :
346 int mode = 0; 346 int mode = 0;
347 int mask = 0; 347 int mask = 0;
348 while (sym == SYMOpr && (!strcmp(res.latin1(),"+") || !strcmp(res.latin1(),"-"))) 348 while (sym == SYMOpr && (!strcmp(res.latin1(),"+") || !strcmp(res.latin1(),"-")))
349 { 349 {
350 bool on = !strcmp(res.latin1(),"+"); 350 bool on = !strcmp(res.latin1(),"+");
351 getSymbol(); 351 getSymbol();
352 // mode name 352 // mode name
353 assertSyntax(sym == SYMName, "Name expected") 353 assertSyntax(sym == SYMName, "Name expected")
354 assertSyntax(syms->modsyms[res], "Unknown mode name") 354 assertSyntax(syms->modsyms[res], "Unknown mode name")
355 int bits = (int)syms->modsyms[res]-1; 355 int bits = (int)syms->modsyms[res]-1;
356 if (mask & (1 << bits)) 356 if (mask & (1 << bits))
357 { 357 {
358 fprintf(stderr,"%s(%d,%d): mode name used multible times.\n",path.ascii(),slinno,scolno); 358 fprintf(stderr,"%s(%d,%d): mode name used multible times.\n",path.ascii(),slinno,scolno);
359 } 359 }
360 else 360 else
361 { 361 {
362 mode |= (on << bits); 362 mode |= (on << bits);
363 mask |= (1 << bits); 363 mask |= (1 << bits);
364 } 364 }
365//printf(", mode %s(%d) %s",res.latin1(),(int)syms->modsyms[res]-1,on?"on":"off"); 365//printf(", mode %s(%d) %s",res.latin1(),(int)syms->modsyms[res]-1,on?"on":"off");
366 getSymbol(); 366 getSymbol();
367 } 367 }
368 assertSyntax(sym == SYMOpr && !strcmp(res.latin1(),":"), "':' expected") 368 assertSyntax(sym == SYMOpr && !strcmp(res.latin1(),":"), "':' expected")
369 getSymbol(); 369 getSymbol();
370 // string or command 370 // string or command
371 assertSyntax(sym == SYMName || sym == SYMString,"Command or string expected") 371 assertSyntax(sym == SYMName || sym == SYMString,"Command or string expected")
372 int cmd = 0; 372 int cmd = 0;
373 if (sym == SYMName) 373 if (sym == SYMName)
374 { 374 {
375 assertSyntax(syms->oprsyms[res], "Unknown operator name") 375 assertSyntax(syms->oprsyms[res], "Unknown operator name")
376 cmd = (int)syms->oprsyms[res]-1; 376 cmd = (int)syms->oprsyms[res]-1;
377//printf(": do %s(%d)",res.latin1(),(int)syms->oprsyms[res]-1); 377//printf(": do %s(%d)",res.latin1(),(int)syms->oprsyms[res]-1);
378 } 378 }
379 if (sym == SYMString) 379 if (sym == SYMString)
380 { 380 {
381 cmd = CMD_send; 381 cmd = CMD_send;
382//printf(": send"); 382//printf(": send");
383//for (unsigned i = 0; i < res.length(); i++) 383//for (unsigned i = 0; i < res.length(); i++)
384//printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?'); 384//printf(" %02x(%c)",res.latin1()[i],res.latin1()[i]>=' '?res.latin1()[i]:'?');
385 } 385 }
386//printf(". summary %04x,%02x,%02x,%d\n",key,mode,mask,cmd); 386//printf(". summary %04x,%02x,%02x,%d\n",key,mode,mask,cmd);
387 KeyTrans::KeyEntry* ke = kt->addEntry(slinno,key,mode,mask,cmd,res); 387 KeyTrans::KeyEntry* ke = kt->addEntry(slinno,key,mode,mask,cmd,res);
388 if (ke) 388 if (ke)
389 { 389 {
390 fprintf(stderr,"%s(%d): keystroke already assigned in line %d.\n",path.ascii(),slinno,ke->ref); 390 fprintf(stderr,"%s(%d): keystroke already assigned in line %d.\n",path.ascii(),slinno,ke->ref);
391 } 391 }
392 getSymbol(); 392 getSymbol();
393 assertSyntax(sym == SYMEol, "Unexpected text") 393 assertSyntax(sym == SYMEol, "Unexpected text")
394 goto Loop; 394 goto Loop;
395 } 395 }
396 if (sym == SYMEol) 396 if (sym == SYMEol)
397 { 397 {
398 getSymbol(); 398 getSymbol();
399 goto Loop; 399 goto Loop;
400 } 400 }
401 401
402 assertSyntax(sym == SYMEof, "Undecodable Line") 402 assertSyntax(sym == SYMEof, "Undecodable Line")
403 403
404 buf->close(); 404 buf->close();
405 return; 405 return;
406 406
407ERROR: 407ERROR:
408 while (sym != SYMEol && sym != SYMEof) getSymbol(); // eoln 408 while (sym != SYMEol && sym != SYMEof) getSymbol(); // eoln
409 goto Loop; 409 goto Loop;
410} 410}
411 411
412 412
413KeyTrans* KeyTrans::defaultKeyTrans() 413KeyTrans* KeyTrans::defaultKeyTrans()
414{ 414{
415 QCString txt = 415 QCString txt =
416#include "default.keytab.h" 416#include "default.keytab.h"
417 ; 417 ;
418 QBuffer buf(txt); 418 QBuffer buf(txt);
419 return fromDevice("[buildin]",buf); 419 return fromDevice("[buildin]",buf);
420} 420}
421 421
422KeyTrans* KeyTrans::fromFile(const char* path) 422KeyTrans* KeyTrans::fromFile(const char* path)
423{ 423{
424 QFile file(path); 424 QFile file(path);
425 return fromDevice(path,file); 425 return fromDevice(path,file);
426} 426}
427 427
428// local symbol tables --------------------------------------------------------------------- 428// local symbol tables ---------------------------------------------------------------------
429// material needed for parsing the config file. 429// material needed for parsing the config file.
430// This is incomplete work. 430// This is incomplete work.
431 431
432void KeyTransSymbols::defKeySym(const char* key, int val) 432void KeyTransSymbols::defKeySym(const char* key, int val)
433{ 433{
434 keysyms.insert(key,(QObject*)(val+1)); 434 keysyms.insert(key,(QObject*)(val+1));
435} 435}
436 436
437void KeyTransSymbols::defOprSym(const char* key, int val) 437void KeyTransSymbols::defOprSym(const char* key, int val)
438{ 438{
439 oprsyms.insert(key,(QObject*)(val+1)); 439 oprsyms.insert(key,(QObject*)(val+1));
440} 440}
441 441
442void KeyTransSymbols::defModSym(const char* key, int val) 442void KeyTransSymbols::defModSym(const char* key, int val)
443{ 443{
444 modsyms.insert(key,(QObject*)(val+1)); 444 modsyms.insert(key,(QObject*)(val+1));
445} 445}
446 446
447void KeyTransSymbols::defOprSyms() 447void KeyTransSymbols::defOprSyms()
448{ 448{
449 // Modifier 449 // Modifier
450 defOprSym("scrollLineUp", CMD_scrollLineUp ); 450 defOprSym("scrollLineUp", CMD_scrollLineUp );
451 defOprSym("scrollLineDown",CMD_scrollLineDown); 451 defOprSym("scrollLineDown",CMD_scrollLineDown);
452 defOprSym("scrollPageUp", CMD_scrollPageUp ); 452 defOprSym("scrollPageUp", CMD_scrollPageUp );
453 defOprSym("scrollPageDown",CMD_scrollPageDown); 453 defOprSym("scrollPageDown",CMD_scrollPageDown);
454 defOprSym("emitSelection", CMD_emitSelection ); 454 defOprSym("emitSelection", CMD_emitSelection );
455 defOprSym("prevSession", CMD_prevSession ); 455 defOprSym("prevSession", CMD_prevSession );
456 defOprSym("nextSession", CMD_nextSession ); 456 defOprSym("nextSession", CMD_nextSession );
457} 457}
458 458
459void KeyTransSymbols::defModSyms() 459void KeyTransSymbols::defModSyms()
460{ 460{
461 // Modifier 461 // Modifier
462 defModSym("Shift", BITS_Shift ); 462 defModSym("Shift", BITS_Shift );
463 defModSym("Control", BITS_Control ); 463 defModSym("Control", BITS_Control );
464 defModSym("Alt", BITS_Alt ); 464 defModSym("Alt", BITS_Alt );
465 // Modes 465 // Modes
466 defModSym("BsHack", BITS_BsHack ); // deprecated 466 defModSym("BsHack", BITS_BsHack ); // deprecated
467 defModSym("Ansi", BITS_Ansi ); 467 defModSym("Ansi", BITS_Ansi );
468 defModSym("NewLine", BITS_NewLine ); 468 defModSym("NewLine", BITS_NewLine );
469 defModSym("AppCuKeys", BITS_AppCuKeys ); 469 defModSym("AppCuKeys", BITS_AppCuKeys );
470} 470}
471 471
472void KeyTransSymbols::defKeySyms() 472void KeyTransSymbols::defKeySyms()
473{ 473{
474 // Grey keys 474 // Grey keys
475 defKeySym("Escape", Qt::Key_Escape ); 475 defKeySym("Escape", Qt::Key_Escape );
476 defKeySym("Tab", Qt::Key_Tab ); 476 defKeySym("Tab", Qt::Key_Tab );
477 defKeySym("Backtab", Qt::Key_Backtab ); 477 defKeySym("Backtab", Qt::Key_Backtab );
478 defKeySym("Backspace", Qt::Key_Backspace ); 478 defKeySym("Backspace", Qt::Key_Backspace );
479 defKeySym("Return", Qt::Key_Return ); 479 defKeySym("Return", Qt::Key_Return );
480 defKeySym("Enter", Qt::Key_Enter ); 480 defKeySym("Enter", Qt::Key_Enter );
481 defKeySym("Insert", Qt::Key_Insert ); 481 defKeySym("Insert", Qt::Key_Insert );
482 defKeySym("Delete", Qt::Key_Delete ); 482 defKeySym("Delete", Qt::Key_Delete );
483 defKeySym("Pause", Qt::Key_Pause ); 483 defKeySym("Pause", Qt::Key_Pause );
484 defKeySym("Print", Qt::Key_Print ); 484 defKeySym("Print", Qt::Key_Print );
485 defKeySym("SysReq", Qt::Key_SysReq ); 485 defKeySym("SysReq", Qt::Key_SysReq );
486 defKeySym("Home", Qt::Key_Home ); 486 defKeySym("Home", Qt::Key_Home );
487 defKeySym("End", Qt::Key_End ); 487 defKeySym("End", Qt::Key_End );
488 defKeySym("Left", Qt::Key_Left ); 488 defKeySym("Left", Qt::Key_Left );
489 defKeySym("Up", Qt::Key_Up ); 489 defKeySym("Up", Qt::Key_Up );
490 defKeySym("Right", Qt::Key_Right ); 490 defKeySym("Right", Qt::Key_Right );
491 defKeySym("Down", Qt::Key_Down ); 491 defKeySym("Down", Qt::Key_Down );
492 defKeySym("Prior", Qt::Key_Prior ); 492 defKeySym("Prior", Qt::Key_Prior );
493 defKeySym("Next", Qt::Key_Next ); 493 defKeySym("Next", Qt::Key_Next );
494 defKeySym("Shift", Qt::Key_Shift ); 494 defKeySym("Shift", Qt::Key_Shift );
495 defKeySym("Control", Qt::Key_Control ); 495 defKeySym("Control", Qt::Key_Control );
496 defKeySym("Meta", Qt::Key_Meta ); 496 defKeySym("Meta", Qt::Key_Meta );
497 defKeySym("Alt", Qt::Key_Alt ); 497 defKeySym("Alt", Qt::Key_Alt );
498 defKeySym("CapsLock", Qt::Key_CapsLock ); 498 defKeySym("CapsLock", Qt::Key_CapsLock );
499 defKeySym("NumLock", Qt::Key_NumLock ); 499 defKeySym("NumLock", Qt::Key_NumLock );
500 defKeySym("ScrollLock", Qt::Key_ScrollLock ); 500 defKeySym("ScrollLock", Qt::Key_ScrollLock );
501 defKeySym("F1", Qt::Key_F1 ); 501 defKeySym("F1", Qt::Key_F1 );
502 defKeySym("F2", Qt::Key_F2 ); 502 defKeySym("F2", Qt::Key_F2 );
503 defKeySym("F3", Qt::Key_F3 ); 503 defKeySym("F3", Qt::Key_F3 );
504 defKeySym("F4", Qt::Key_F4 ); 504 defKeySym("F4", Qt::Key_F4 );
505 defKeySym("F5", Qt::Key_F5 ); 505 defKeySym("F5", Qt::Key_F5 );
506 defKeySym("F6", Qt::Key_F6 ); 506 defKeySym("F6", Qt::Key_F6 );
507 defKeySym("F7", Qt::Key_F7 ); 507 defKeySym("F7", Qt::Key_F7 );
508 defKeySym("F8", Qt::Key_F8 ); 508 defKeySym("F8", Qt::Key_F8 );
509 defKeySym("F9", Qt::Key_F9 ); 509 defKeySym("F9", Qt::Key_F9 );
510 defKeySym("F10", Qt::Key_F10 ); 510 defKeySym("F10", Qt::Key_F10 );
511 defKeySym("F11", Qt::Key_F11 ); 511 defKeySym("F11", Qt::Key_F11 );
512 defKeySym("F12", Qt::Key_F12 ); 512 defKeySym("F12", Qt::Key_F12 );
513 defKeySym("F13", Qt::Key_F13 ); 513 defKeySym("F13", Qt::Key_F13 );
514 defKeySym("F14", Qt::Key_F14 ); 514 defKeySym("F14", Qt::Key_F14 );
515 defKeySym("F15", Qt::Key_F15 ); 515 defKeySym("F15", Qt::Key_F15 );
516 defKeySym("F16", Qt::Key_F16 ); 516 defKeySym("F16", Qt::Key_F16 );
517 defKeySym("F17", Qt::Key_F17 ); 517 defKeySym("F17", Qt::Key_F17 );
518 defKeySym("F18", Qt::Key_F18 ); 518 defKeySym("F18", Qt::Key_F18 );
519 defKeySym("F19", Qt::Key_F19 ); 519 defKeySym("F19", Qt::Key_F19 );
520 defKeySym("F20", Qt::Key_F20 ); 520 defKeySym("F20", Qt::Key_F20 );
521 defKeySym("F21", Qt::Key_F21 ); 521 defKeySym("F21", Qt::Key_F21 );
522 defKeySym("F22", Qt::Key_F22 ); 522 defKeySym("F22", Qt::Key_F22 );
523 defKeySym("F23", Qt::Key_F23 ); 523 defKeySym("F23", Qt::Key_F23 );
524 defKeySym("F24", Qt::Key_F24 ); 524 defKeySym("F24", Qt::Key_F24 );
525 defKeySym("F25", Qt::Key_F25 ); 525 defKeySym("F25", Qt::Key_F25 );
526 defKeySym("F26", Qt::Key_F26 ); 526 defKeySym("F26", Qt::Key_F26 );
527 defKeySym("F27", Qt::Key_F27 ); 527 defKeySym("F27", Qt::Key_F27 );
528 defKeySym("F28", Qt::Key_F28 ); 528 defKeySym("F28", Qt::Key_F28 );
529 defKeySym("F29", Qt::Key_F29 ); 529 defKeySym("F29", Qt::Key_F29 );
530 defKeySym("F30", Qt::Key_F30 ); 530 defKeySym("F30", Qt::Key_F30 );
531 defKeySym("F31", Qt::Key_F31 ); 531 defKeySym("F31", Qt::Key_F31 );
532 defKeySym("F32", Qt::Key_F32 ); 532 defKeySym("F32", Qt::Key_F32 );
533 defKeySym("F33", Qt::Key_F33 ); 533 defKeySym("F33", Qt::Key_F33 );
534 defKeySym("F34", Qt::Key_F34 ); 534 defKeySym("F34", Qt::Key_F34 );
535 defKeySym("F35", Qt::Key_F35 ); 535 defKeySym("F35", Qt::Key_F35 );
536 defKeySym("Super_L", Qt::Key_Super_L ); 536 defKeySym("Super_L", Qt::Key_Super_L );
537 defKeySym("Super_R", Qt::Key_Super_R ); 537 defKeySym("Super_R", Qt::Key_Super_R );
538 defKeySym("Menu", Qt::Key_Menu ); 538 defKeySym("Menu", Qt::Key_Menu );
539 defKeySym("Hyper_L", Qt::Key_Hyper_L ); 539 defKeySym("Hyper_L", Qt::Key_Hyper_L );
540 defKeySym("Hyper_R", Qt::Key_Hyper_R ); 540 defKeySym("Hyper_R", Qt::Key_Hyper_R );
541 541
542 // Regular keys 542 // Regular keys
543 defKeySym("Space", Qt::Key_Space ); 543 defKeySym("Space", Qt::Key_Space );
544 defKeySym("Exclam", Qt::Key_Exclam ); 544 defKeySym("Exclam", Qt::Key_Exclam );
545 defKeySym("QuoteDbl", Qt::Key_QuoteDbl ); 545 defKeySym("QuoteDbl", Qt::Key_QuoteDbl );
546 defKeySym("NumberSign", Qt::Key_NumberSign ); 546 defKeySym("NumberSign", Qt::Key_NumberSign );
547 defKeySym("Dollar", Qt::Key_Dollar ); 547 defKeySym("Dollar", Qt::Key_Dollar );
548 defKeySym("Percent", Qt::Key_Percent ); 548 defKeySym("Percent", Qt::Key_Percent );
549 defKeySym("Ampersand", Qt::Key_Ampersand ); 549 defKeySym("Ampersand", Qt::Key_Ampersand );
550 defKeySym("Apostrophe", Qt::Key_Apostrophe ); 550 defKeySym("Apostrophe", Qt::Key_Apostrophe );
551 defKeySym("ParenLeft", Qt::Key_ParenLeft ); 551 defKeySym("ParenLeft", Qt::Key_ParenLeft );
552 defKeySym("ParenRight", Qt::Key_ParenRight ); 552 defKeySym("ParenRight", Qt::Key_ParenRight );
553 defKeySym("Asterisk", Qt::Key_Asterisk ); 553 defKeySym("Asterisk", Qt::Key_Asterisk );
554 defKeySym("Plus", Qt::Key_Plus ); 554 defKeySym("Plus", Qt::Key_Plus );
555 defKeySym("Comma", Qt::Key_Comma ); 555 defKeySym("Comma", Qt::Key_Comma );
556 defKeySym("Minus", Qt::Key_Minus ); 556 defKeySym("Minus", Qt::Key_Minus );
557 defKeySym("Period", Qt::Key_Period ); 557 defKeySym("Period", Qt::Key_Period );
558 defKeySym("Slash", Qt::Key_Slash ); 558 defKeySym("Slash", Qt::Key_Slash );
559 defKeySym("0", Qt::Key_0 ); 559 defKeySym("0", Qt::Key_0 );
560 defKeySym("1", Qt::Key_1 ); 560 defKeySym("1", Qt::Key_1 );
561 defKeySym("2", Qt::Key_2 ); 561 defKeySym("2", Qt::Key_2 );
562 defKeySym("3", Qt::Key_3 ); 562 defKeySym("3", Qt::Key_3 );
563 defKeySym("4", Qt::Key_4 ); 563 defKeySym("4", Qt::Key_4 );
564 defKeySym("5", Qt::Key_5 ); 564 defKeySym("5", Qt::Key_5 );
565 defKeySym("6", Qt::Key_6 ); 565 defKeySym("6", Qt::Key_6 );
566 defKeySym("7", Qt::Key_7 ); 566 defKeySym("7", Qt::Key_7 );
567 defKeySym("8", Qt::Key_8 ); 567 defKeySym("8", Qt::Key_8 );
568 defKeySym("9", Qt::Key_9 ); 568 defKeySym("9", Qt::Key_9 );
569 defKeySym("Colon", Qt::Key_Colon ); 569 defKeySym("Colon", Qt::Key_Colon );
570 defKeySym("Semicolon", Qt::Key_Semicolon ); 570 defKeySym("Semicolon", Qt::Key_Semicolon );
571 defKeySym("Less", Qt::Key_Less ); 571 defKeySym("Less", Qt::Key_Less );
572 defKeySym("Equal", Qt::Key_Equal ); 572 defKeySym("Equal", Qt::Key_Equal );
573 defKeySym("Greater", Qt::Key_Greater ); 573 defKeySym("Greater", Qt::Key_Greater );
574 defKeySym("Question", Qt::Key_Question ); 574 defKeySym("Question", Qt::Key_Question );
575 defKeySym("At", Qt::Key_At ); 575 defKeySym("At", Qt::Key_At );
576 defKeySym("A", Qt::Key_A ); 576 defKeySym("A", Qt::Key_A );
577 defKeySym("B", Qt::Key_B ); 577 defKeySym("B", Qt::Key_B );
578 defKeySym("C", Qt::Key_C ); 578 defKeySym("C", Qt::Key_C );
579 defKeySym("D", Qt::Key_D ); 579 defKeySym("D", Qt::Key_D );
580 defKeySym("E", Qt::Key_E ); 580 defKeySym("E", Qt::Key_E );
581 defKeySym("F", Qt::Key_F ); 581 defKeySym("F", Qt::Key_F );
582 defKeySym("G", Qt::Key_G ); 582 defKeySym("G", Qt::Key_G );
583 defKeySym("H", Qt::Key_H ); 583 defKeySym("H", Qt::Key_H );
584 defKeySym("I", Qt::Key_I ); 584 defKeySym("I", Qt::Key_I );
585 defKeySym("J", Qt::Key_J ); 585 defKeySym("J", Qt::Key_J );
586 defKeySym("K", Qt::Key_K ); 586 defKeySym("K", Qt::Key_K );
587 defKeySym("L", Qt::Key_L ); 587 defKeySym("L", Qt::Key_L );
588 defKeySym("M", Qt::Key_M ); 588 defKeySym("M", Qt::Key_M );
589 defKeySym("N", Qt::Key_N ); 589 defKeySym("N", Qt::Key_N );
590 defKeySym("O", Qt::Key_O ); 590 defKeySym("O", Qt::Key_O );
591 defKeySym("P", Qt::Key_P ); 591 defKeySym("P", Qt::Key_P );
592 defKeySym("Q", Qt::Key_Q ); 592 defKeySym("Q", Qt::Key_Q );
593 defKeySym("R", Qt::Key_R ); 593 defKeySym("R", Qt::Key_R );
594 defKeySym("S", Qt::Key_S ); 594 defKeySym("S", Qt::Key_S );
595 defKeySym("T", Qt::Key_T ); 595 defKeySym("T", Qt::Key_T );
596 defKeySym("U", Qt::Key_U ); 596 defKeySym("U", Qt::Key_U );
597 defKeySym("V", Qt::Key_V ); 597 defKeySym("V", Qt::Key_V );
598 defKeySym("W", Qt::Key_W ); 598 defKeySym("W", Qt::Key_W );
599 defKeySym("X", Qt::Key_X ); 599 defKeySym("X", Qt::Key_X );
600 defKeySym("Y", Qt::Key_Y ); 600 defKeySym("Y", Qt::Key_Y );
601 defKeySym("Z", Qt::Key_Z ); 601 defKeySym("Z", Qt::Key_Z );
602 defKeySym("BracketLeft", Qt::Key_BracketLeft ); 602 defKeySym("BracketLeft", Qt::Key_BracketLeft );
603 defKeySym("Backslash", Qt::Key_Backslash ); 603 defKeySym("Backslash", Qt::Key_Backslash );
604 defKeySym("BracketRight", Qt::Key_BracketRight); 604 defKeySym("BracketRight", Qt::Key_BracketRight);
605 defKeySym("AsciiCircum", Qt::Key_AsciiCircum ); 605 defKeySym("AsciiCircum", Qt::Key_AsciiCircum );
606 defKeySym("Underscore", Qt::Key_Underscore ); 606 defKeySym("Underscore", Qt::Key_Underscore );
607 defKeySym("QuoteLeft", Qt::Key_QuoteLeft ); 607 defKeySym("QuoteLeft", Qt::Key_QuoteLeft );
608 defKeySym("BraceLeft", Qt::Key_BraceLeft ); 608 defKeySym("BraceLeft", Qt::Key_BraceLeft );
609 defKeySym("Bar", Qt::Key_Bar ); 609 defKeySym("Bar", Qt::Key_Bar );
610 defKeySym("BraceRight", Qt::Key_BraceRight ); 610 defKeySym("BraceRight", Qt::Key_BraceRight );
611 defKeySym("AsciiTilde", Qt::Key_AsciiTilde ); 611 defKeySym("AsciiTilde", Qt::Key_AsciiTilde );
612} 612}
613 613
614KeyTransSymbols::KeyTransSymbols() 614KeyTransSymbols::KeyTransSymbols()
615{ 615{
616 defModSyms(); 616 defModSyms();
617 defOprSyms(); 617 defOprSyms();
618 defKeySyms(); 618 defKeySyms();
619} 619}
620 620
621// Global material ----------------------------------------------------------- 621// Global material -----------------------------------------------------------
622 622
623static int keytab_serial = 0; //FIXME: remove,localize 623static int keytab_serial = 0; //FIXME: remove,localize
624 624
625static QIntDict<KeyTrans> * numb2keymap = 0L; 625static QIntDict<KeyTrans> * numb2keymap = 0L;
626static QDict<KeyTrans> * path2keymap = 0L; 626static QDict<KeyTrans> * path2keymap = 0L;
627 627
628KeyTrans* KeyTrans::find(int numb) 628KeyTrans* KeyTrans::find(int numb)
629{ 629{
630 loadAll();
631 KeyTrans* res = numb2keymap->find(numb); 630 KeyTrans* res = numb2keymap->find(numb);
632 return res ? res : numb2keymap->find(0); 631 return res ? res : numb2keymap->find(0);
633} 632}
634 633
635KeyTrans* KeyTrans::find(const char* path) 634KeyTrans* KeyTrans::find(const char* path)
636{ 635{
637 loadAll();
638 KeyTrans* res = path2keymap->find(path); 636 KeyTrans* res = path2keymap->find(path);
639 return res ? res : numb2keymap->find(0); 637 return res ? res : numb2keymap->find(0);
640} 638}
641 639
642int KeyTrans::count() 640int KeyTrans::count()
643{ 641{
644 loadAll();
645 return numb2keymap->count(); 642 return numb2keymap->count();
646} 643}
647 644
648void KeyTrans::addKeyTrans() 645void KeyTrans::addKeyTrans()
649{ 646{
650 this->numb = keytab_serial ++; 647 this->numb = keytab_serial ++;
651 numb2keymap->insert(numb,this); 648 numb2keymap->insert(numb,this);
652 path2keymap->insert(path,this); 649 path2keymap->insert(path,this);
653} 650}
654 651
655void KeyTrans::loadAll() 652void KeyTrans::loadAll()
656{ 653{
657 if (!numb2keymap) 654 if (!numb2keymap)
658 numb2keymap = new QIntDict<KeyTrans>; 655 numb2keymap = new QIntDict<KeyTrans>;
659 if (!path2keymap) 656 if (!path2keymap)
660 path2keymap = new QDict<KeyTrans>; 657 path2keymap = new QDict<KeyTrans>;
661 if (!syms) 658 if (!syms)
662 syms = new KeyTransSymbols; 659 syms = new KeyTransSymbols;
663 660
664 defaultKeyTrans()->addKeyTrans(); 661 defaultKeyTrans()->addKeyTrans();
665 662
666 663
667 QString path = QPEApplication::qpeDir() + "etc/keytabs"; 664 QString path = QPEApplication::qpeDir() + "etc/keytabs";
668 QDir dir(path); 665 QDir dir(path);
669 QStringList lst = dir.entryList("*.keytab"); 666 QStringList lst = dir.entryList("*.keytab");
670 667
671 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 668 for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
672 QFile file(path + "/" + *it); 669 QFile file(path + "/" + *it);
673 KeyTrans* sc = KeyTrans::fromDevice(*it, file); 670 KeyTrans* sc = KeyTrans::fromDevice(*it, file);
674 if (sc) { 671 if (sc) {
675 sc->addKeyTrans(); 672 sc->addKeyTrans();
676 } 673 }
677 } 674 }
678 675
679} 676}
680 677
681// Debugging material ----------------------------------------------------------- 678// Debugging material -----------------------------------------------------------
682/* 679/*
683void TestTokenizer(QBuffer &buf) 680void TestTokenizer(QBuffer &buf)
684{ 681{
685 // opening sequence 682 // opening sequence
686 683
687 buf.open(IO_ReadOnly); 684 buf.open(IO_ReadOnly);
688 cc = buf.getch(); 685 cc = buf.getch();
689 lineno = 1; 686 lineno = 1;
690 687
691 // Test tokenizer 688 // Test tokenizer
692 689
693 while (getSymbol(buf)) ReportToken(); 690 while (getSymbol(buf)) ReportToken();
694 691
695 buf.close(); 692 buf.close();
696} 693}
697 694
698void test() 695void test()
699{ 696{
700 // Opening sequence 697 // Opening sequence
701 698
702 QCString txt = 699 QCString txt =
703#include "default.keytab.h" 700#include "default.keytab.h"
704 ; 701 ;
705 QBuffer buf(txt); 702 QBuffer buf(txt);
706 if (0) TestTokenizer(buf); 703 if (0) TestTokenizer(buf);
707 if (1) { KeyTrans kt; kt.scanTable(buf); } 704 if (1) { KeyTrans kt; kt.scanTable(buf); }
708} 705}
709*/ 706*/
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 1d7a4be..02f8451 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,353 +1,362 @@
1#include <assert.h>
2
3
1 4
2#include <qaction.h> 5#include <qaction.h>
3#include <qmenubar.h> 6#include <qmenubar.h>
4#include <qlabel.h> 7#include <qlabel.h>
5#include <qpopupmenu.h> 8#include <qpopupmenu.h>
6#include <qtoolbar.h> 9#include <qtoolbar.h>
7#include <qpe/resource.h> 10#include <qpe/resource.h>
8#include <opie/ofiledialog.h> 11#include <opie/ofiledialog.h>
9#include <qmessagebox.h> 12#include <qmessagebox.h>
10 13
14#include "keytrans.h"
11#include "profileeditordialog.h" 15#include "profileeditordialog.h"
12#include "configdialog.h" 16#include "configdialog.h"
13#include "default.h" 17#include "default.h"
14#include "metafactory.h" 18#include "metafactory.h"
15#include "profile.h" 19#include "profile.h"
16#include "profilemanager.h" 20#include "profilemanager.h"
17#include "mainwindow.h" 21#include "mainwindow.h"
18#include "tabwidget.h" 22#include "tabwidget.h"
19#include "transferdialog.h" 23#include "transferdialog.h"
20#include "function_keyboard.h" 24#include "function_keyboard.h"
21#include "script.h" 25#include "script.h"
22 26
23MainWindow::MainWindow() { 27MainWindow::MainWindow() {
28 KeyTrans::loadAll();
29 for (int i = 0; i < KeyTrans::count(); i++ ) {
30 KeyTrans* s = KeyTrans::find(i );
31 assert( s );
32 }
24 m_factory = new MetaFactory(); 33 m_factory = new MetaFactory();
25 Default def(m_factory); 34 Default def(m_factory);
26 m_sessions.setAutoDelete( TRUE ); 35 m_sessions.setAutoDelete( TRUE );
27 m_curSession = 0; 36 m_curSession = 0;
28 m_manager = new ProfileManager( m_factory ); 37 m_manager = new ProfileManager( m_factory );
29 m_manager->load(); 38 m_manager->load();
30 39
31 initUI(); 40 initUI();
32 populateProfiles(); 41 populateProfiles();
33} 42}
34void MainWindow::initUI() { 43void MainWindow::initUI() {
35 setToolBarsMovable( FALSE ); 44 setToolBarsMovable( FALSE );
36 45
37 /* tool bar for the menu */ 46 /* tool bar for the menu */
38 m_tool = new QToolBar( this ); 47 m_tool = new QToolBar( this );
39 m_tool->setHorizontalStretchable( TRUE ); 48 m_tool->setHorizontalStretchable( TRUE );
40 49
41 m_bar = new QMenuBar( m_tool ); 50 m_bar = new QMenuBar( m_tool );
42 m_console = new QPopupMenu( this ); 51 m_console = new QPopupMenu( this );
43 m_scripts = new QPopupMenu( this ); 52 m_scripts = new QPopupMenu( this );
44 m_sessionsPop= new QPopupMenu( this ); 53 m_sessionsPop= new QPopupMenu( this );
45 m_settings = new QPopupMenu( this ); 54 m_settings = new QPopupMenu( this );
46 55
47 /* add a toolbar for icons */ 56 /* add a toolbar for icons */
48 m_icons = new QToolBar(this); 57 m_icons = new QToolBar(this);
49 58
50 /* 59 /*
51 * new Action for new sessions 60 * new Action for new sessions
52 */ 61 */
53 QAction* a = new QAction(tr("New Connection"), 62 QAction* a = new QAction(tr("New Connection"),
54 Resource::loadPixmap( "new" ), 63 Resource::loadPixmap( "new" ),
55 QString::null, 0, this, 0); 64 QString::null, 0, this, 0);
56 a->addTo( m_console ); 65 a->addTo( m_console );
57 a->addTo( m_icons ); 66 a->addTo( m_icons );
58 connect(a, SIGNAL(activated() ), 67 connect(a, SIGNAL(activated() ),
59 this, SLOT(slotNew() ) ); 68 this, SLOT(slotNew() ) );
60 69
61 /* 70 /*
62 * connect action 71 * connect action
63 */ 72 */
64 m_connect = new QAction(); 73 m_connect = new QAction();
65 m_connect->setText( tr("Connect") ); 74 m_connect->setText( tr("Connect") );
66 m_connect->addTo( m_console ); 75 m_connect->addTo( m_console );
67 connect(m_connect, SIGNAL(activated() ), 76 connect(m_connect, SIGNAL(activated() ),
68 this, SLOT(slotConnect() ) ); 77 this, SLOT(slotConnect() ) );
69 78
70 /* 79 /*
71 * disconnect action 80 * disconnect action
72 */ 81 */
73 m_disconnect = new QAction(); 82 m_disconnect = new QAction();
74 m_disconnect->setText( tr("Disconnect") ); 83 m_disconnect->setText( tr("Disconnect") );
75 m_disconnect->addTo( m_console ); 84 m_disconnect->addTo( m_console );
76 connect(m_disconnect, SIGNAL(activated() ), 85 connect(m_disconnect, SIGNAL(activated() ),
77 this, SLOT(slotDisconnect() ) ); 86 this, SLOT(slotDisconnect() ) );
78 87
79 m_transfer = new QAction(); 88 m_transfer = new QAction();
80 m_transfer->setText( tr("Transfer file...") ); 89 m_transfer->setText( tr("Transfer file...") );
81 m_transfer->addTo( m_console ); 90 m_transfer->addTo( m_console );
82 connect(m_transfer, SIGNAL(activated() ), 91 connect(m_transfer, SIGNAL(activated() ),
83 this, SLOT(slotTransfer() ) ); 92 this, SLOT(slotTransfer() ) );
84 93
85 /* 94 /*
86 * terminate action 95 * terminate action
87 */ 96 */
88 m_terminate = new QAction(); 97 m_terminate = new QAction();
89 m_terminate->setText( tr("Terminate") ); 98 m_terminate->setText( tr("Terminate") );
90 m_terminate->addTo( m_console ); 99 m_terminate->addTo( m_console );
91 connect(m_terminate, SIGNAL(activated() ), 100 connect(m_terminate, SIGNAL(activated() ),
92 this, SLOT(slotTerminate() ) ); 101 this, SLOT(slotTerminate() ) );
93 102
94 a = new QAction(); 103 a = new QAction();
95 a->setText( tr("Close Window") ); 104 a->setText( tr("Close Window") );
96 a->addTo( m_console ); 105 a->addTo( m_console );
97 connect(a, SIGNAL(activated() ), 106 connect(a, SIGNAL(activated() ),
98 this, SLOT(slotClose() ) ); 107 this, SLOT(slotClose() ) );
99 108
100 /* 109 /*
101 * the settings action 110 * the settings action
102 */ 111 */
103 m_setProfiles = new QAction(tr("Configure Profiles"), 112 m_setProfiles = new QAction(tr("Configure Profiles"),
104 Resource::loadPixmap( "SettingsIcon" ), 113 Resource::loadPixmap( "SettingsIcon" ),
105 QString::null, 0, this, 0); 114 QString::null, 0, this, 0);
106 m_setProfiles->addTo( m_settings ); 115 m_setProfiles->addTo( m_settings );
107 m_setProfiles->addTo( m_icons ); 116 m_setProfiles->addTo( m_icons );
108 connect( m_setProfiles, SIGNAL(activated() ), 117 connect( m_setProfiles, SIGNAL(activated() ),
109 this, SLOT(slotConfigure() ) ); 118 this, SLOT(slotConfigure() ) );
110 119
111 /* 120 /*
112 * script actions 121 * script actions
113 */ 122 */
114 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 123 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
115 m_recordScript->addTo(m_scripts); 124 m_recordScript->addTo(m_scripts);
116 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 125 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
117 126
118 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 127 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
119 m_saveScript->addTo(m_scripts); 128 m_saveScript->addTo(m_scripts);
120 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 129 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
121 130
122 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); 131 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
123 m_runScript->addTo(m_scripts); 132 m_runScript->addTo(m_scripts);
124 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); 133 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
125 134
126 /* 135 /*
127 * action that open/closes the keyboard 136 * action that open/closes the keyboard
128 */ 137 */
129 m_openKeys = new QAction (tr("Open Keyboard..."), 138 m_openKeys = new QAction (tr("Open Keyboard..."),
130 Resource::loadPixmap( "down" ), 139 Resource::loadPixmap( "down" ),
131 QString::null, 0, this, 0); 140 QString::null, 0, this, 0);
132 141
133 m_openKeys->setToggleAction(true); 142 m_openKeys->setToggleAction(true);
134 143
135 connect (m_openKeys, SIGNAL(toggled(bool)), 144 connect (m_openKeys, SIGNAL(toggled(bool)),
136 this, SLOT(slotOpenKeb(bool))); 145 this, SLOT(slotOpenKeb(bool)));
137 m_openKeys->addTo(m_icons); 146 m_openKeys->addTo(m_icons);
138 147
139 148
140 /* insert the submenu */ 149 /* insert the submenu */
141 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 150 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
142 -1, 0); 151 -1, 0);
143 152
144 /* insert the connection menu */ 153 /* insert the connection menu */
145 m_bar->insertItem( tr("Connection"), m_console ); 154 m_bar->insertItem( tr("Connection"), m_console );
146 155
147 /* the scripts menu */ 156 /* the scripts menu */
148 m_bar->insertItem( tr("Scripts"), m_scripts ); 157 m_bar->insertItem( tr("Scripts"), m_scripts );
149 158
150 /* the settings menu */ 159 /* the settings menu */
151 m_bar->insertItem( tr("Settings"), m_settings ); 160 m_bar->insertItem( tr("Settings"), m_settings );
152 161
153 /* and the keyboard */ 162 /* and the keyboard */
154 m_keyBar = new QToolBar(this); 163 m_keyBar = new QToolBar(this);
155 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 164 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
156 m_keyBar->setHorizontalStretchable( TRUE ); 165 m_keyBar->setHorizontalStretchable( TRUE );
157 m_keyBar->hide(); 166 m_keyBar->hide();
158 167
159 m_kb = new FunctionKeyboard(m_keyBar); 168 m_kb = new FunctionKeyboard(m_keyBar);
160 169
161 /* 170 /*
162 * connect to the menu activation 171 * connect to the menu activation
163 */ 172 */
164 connect( m_sessionsPop, SIGNAL(activated( int ) ), 173 connect( m_sessionsPop, SIGNAL(activated( int ) ),
165 this, SLOT(slotProfile( int ) ) ); 174 this, SLOT(slotProfile( int ) ) );
166 175
167 m_consoleWindow = new TabWidget( this, "blah"); 176 m_consoleWindow = new TabWidget( this, "blah");
168 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 177 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
169 this, SLOT(slotSessionChanged(Session*) ) ); 178 this, SLOT(slotSessionChanged(Session*) ) );
170 setCentralWidget( m_consoleWindow ); 179 setCentralWidget( m_consoleWindow );
171 180
172} 181}
173 182
174ProfileManager* MainWindow::manager() { 183ProfileManager* MainWindow::manager() {
175 return m_manager; 184 return m_manager;
176} 185}
177TabWidget* MainWindow::tabWidget() { 186TabWidget* MainWindow::tabWidget() {
178 return m_consoleWindow; 187 return m_consoleWindow;
179} 188}
180void MainWindow::populateProfiles() { 189void MainWindow::populateProfiles() {
181 m_sessionsPop->clear(); 190 m_sessionsPop->clear();
182 Profile::ValueList list = manager()->all(); 191 Profile::ValueList list = manager()->all();
183 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 192 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
184 m_sessionsPop->insertItem( (*it).name() ); 193 m_sessionsPop->insertItem( (*it).name() );
185 } 194 }
186 195
187} 196}
188MainWindow::~MainWindow() { 197MainWindow::~MainWindow() {
189 delete m_factory; 198 delete m_factory;
190 manager()->save(); 199 manager()->save();
191} 200}
192 201
193MetaFactory* MainWindow::factory() { 202MetaFactory* MainWindow::factory() {
194 return m_factory; 203 return m_factory;
195} 204}
196 205
197Session* MainWindow::currentSession() { 206Session* MainWindow::currentSession() {
198 return m_curSession; 207 return m_curSession;
199} 208}
200 209
201QList<Session> MainWindow::sessions() { 210QList<Session> MainWindow::sessions() {
202 return m_sessions; 211 return m_sessions;
203} 212}
204 213
205void MainWindow::slotNew() { 214void MainWindow::slotNew() {
206 qWarning("New Connection"); 215 qWarning("New Connection");
207 ProfileEditorDialog dlg(factory() ); 216 ProfileEditorDialog dlg(factory() );
208 dlg.showMaximized(); 217 dlg.showMaximized();
209 int ret = dlg.exec(); 218 int ret = dlg.exec();
210 219
211 if ( ret == QDialog::Accepted ) { 220 if ( ret == QDialog::Accepted ) {
212 create( dlg.profile() ); 221 create( dlg.profile() );
213 } 222 }
214} 223}
215 224
216void MainWindow::slotRecordScript() { 225void MainWindow::slotRecordScript() {
217/* if (currentSession()) { 226/* if (currentSession()) {
218 currentSession()->emulationLayer()->startRecording(); 227 currentSession()->emulationLayer()->startRecording();
219 } 228 }
220 */ 229 */
221} 230}
222 231
223void MainWindow::slotSaveScript() { 232void MainWindow::slotSaveScript() {
224/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { 233/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) {
225 MimeTypes types; 234 MimeTypes types;
226 QStringList script; 235 QStringList script;
227 script << "text/plain"; 236 script << "text/plain";
228 types.insert("Script", script); 237 types.insert("Script", script);
229 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 238 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
230 if (!filename.isEmpty()) { 239 if (!filename.isEmpty()) {
231 currentSession()->emulationLayer()->script()->saveTo(filename); 240 currentSession()->emulationLayer()->script()->saveTo(filename);
232 currentSession()->emulationLayer()->clearScript(); 241 currentSession()->emulationLayer()->clearScript();
233 } 242 }
234 } 243 }
235 */ 244 */
236} 245}
237 246
238void MainWindow::slotRunScript() { 247void MainWindow::slotRunScript() {
239/* 248/*
240 if (currentSession()) { 249 if (currentSession()) {
241 MimeTypes types; 250 MimeTypes types;
242 QStringList script; 251 QStringList script;
243 script << "text/plain"; 252 script << "text/plain";
244 types.insert("Script", script); 253 types.insert("Script", script);
245 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 254 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
246 if (!filename.isEmpty()) { 255 if (!filename.isEmpty()) {
247 Script script(DocLnk(filename).file()); 256 Script script(DocLnk(filename).file());
248 currentSession()->emulationLayer()->runScript(&script); 257 currentSession()->emulationLayer()->runScript(&script);
249 } 258 }
250 } 259 }
251 */ 260 */
252} 261}
253 262
254void MainWindow::slotConnect() { 263void MainWindow::slotConnect() {
255 if ( currentSession() ) 264 if ( currentSession() )
256 currentSession()->layer()->open(); 265 currentSession()->layer()->open();
257} 266}
258 267
259void MainWindow::slotDisconnect() { 268void MainWindow::slotDisconnect() {
260 if ( currentSession() ) 269 if ( currentSession() )
261 currentSession()->layer()->close(); 270 currentSession()->layer()->close();
262} 271}
263 272
264void MainWindow::slotTerminate() { 273void MainWindow::slotTerminate() {
265 if ( currentSession() ) 274 if ( currentSession() )
266 currentSession()->layer()->close(); 275 currentSession()->layer()->close();
267 276
268 slotClose(); 277 slotClose();
269 /* FIXME move to the next session */ 278 /* FIXME move to the next session */
270} 279}
271 280
272void MainWindow::slotConfigure() { 281void MainWindow::slotConfigure() {
273 qWarning("configure"); 282 qWarning("configure");
274 ConfigDialog conf( manager()->all(), factory() ); 283 ConfigDialog conf( manager()->all(), factory() );
275 conf.showMaximized(); 284 conf.showMaximized();
276 285
277 int ret = conf.exec(); 286 int ret = conf.exec();
278 287
279 if ( QDialog::Accepted == ret ) { 288 if ( QDialog::Accepted == ret ) {
280 qWarning("conf %d", conf.list().count() ); 289 qWarning("conf %d", conf.list().count() );
281 manager()->setProfiles( conf.list() ); 290 manager()->setProfiles( conf.list() );
282 manager()->save(); 291 manager()->save();
283 populateProfiles(); 292 populateProfiles();
284 } 293 }
285} 294}
286/* 295/*
287 * we will remove 296 * we will remove
288 * this window from the tabwidget 297 * this window from the tabwidget
289 * remove it from the list 298 * remove it from the list
290 * delete it 299 * delete it
291 * and set the currentSession() 300 * and set the currentSession()
292 */ 301 */
293void MainWindow::slotClose() { 302void MainWindow::slotClose() {
294 qWarning("close"); 303 qWarning("close");
295 if (!currentSession() ) 304 if (!currentSession() )
296 return; 305 return;
297 306
298 tabWidget()->remove( currentSession() ); 307 tabWidget()->remove( currentSession() );
299 /*it's autodelete */ 308 /*it's autodelete */
300 m_sessions.remove( m_curSession ); 309 m_sessions.remove( m_curSession );
301 m_curSession = m_sessions.first(); 310 m_curSession = m_sessions.first();
302 tabWidget()->setCurrent( m_curSession ); 311 tabWidget()->setCurrent( m_curSession );
303} 312}
304 313
305/* 314/*
306 * We will get the name 315 * We will get the name
307 * Then the profile 316 * Then the profile
308 * and then we will make a profile 317 * and then we will make a profile
309 */ 318 */
310void MainWindow::slotProfile( int id) { 319void MainWindow::slotProfile( int id) {
311 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 320 Profile prof = manager()->profile( m_sessionsPop->text( id) );
312 create( prof ); 321 create( prof );
313} 322}
314void MainWindow::create( const Profile& prof ) { 323void MainWindow::create( const Profile& prof ) {
315 Session *ses = manager()->fromProfile( prof, tabWidget() ); 324 Session *ses = manager()->fromProfile( prof, tabWidget() );
316 325
317 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 326 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
318 { 327 {
319 QMessageBox::warning(this, 328 QMessageBox::warning(this,
320 QObject::tr("Session failed"), 329 QObject::tr("Session failed"),
321 QObject::tr("Cannot open session: Not all components were found.")); 330 QObject::tr("Cannot open session: Not all components were found."));
322 //if(ses) delete ses; 331 //if(ses) delete ses;
323 return; 332 return;
324 } 333 }
325 334
326 m_sessions.append( ses ); 335 m_sessions.append( ses );
327 tabWidget()->add( ses ); 336 tabWidget()->add( ses );
328 m_curSession = ses; 337 m_curSession = ses;
329 338
330} 339}
331 340
332void MainWindow::slotTransfer() 341void MainWindow::slotTransfer()
333{ 342{
334 // if ( currentSession() ) { 343 // if ( currentSession() ) {
335 TransferDialog dlg(this); 344 TransferDialog dlg(this);
336 dlg.showMaximized(); 345 dlg.showMaximized();
337 dlg.exec(); 346 dlg.exec();
338 // } 347 // }
339} 348}
340 349
341 350
342void MainWindow::slotOpenKeb(bool state) { 351void MainWindow::slotOpenKeb(bool state) {
343 352
344 if (state) m_keyBar->show(); 353 if (state) m_keyBar->show();
345 else m_keyBar->hide(); 354 else m_keyBar->hide();
346 355
347} 356}
348void MainWindow::slotSessionChanged( Session* ses ) { 357void MainWindow::slotSessionChanged( Session* ses ) {
349 if ( ses ) { 358 if ( ses ) {
350 qWarning("changing %s", ses->name().latin1() ); 359 qWarning("changing %s", ses->name().latin1() );
351 m_curSession = ses; 360 m_curSession = ses;
352 } 361 }
353} 362}