-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/profile.cpp | 11 | ||||
-rw-r--r-- | noncore/apps/opie-console/profile.h | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 2 |
6 files changed, 25 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index cf1fbc3..5900785 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -339,193 +339,194 @@ void MainWindow::slotDisconnect() { | |||
339 | m_connect->setEnabled( true ); | 339 | m_connect->setEnabled( true ); |
340 | m_disconnect->setEnabled( false ); | 340 | m_disconnect->setEnabled( false ); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | 343 | ||
344 | void MainWindow::slotTerminate() { | 344 | void MainWindow::slotTerminate() { |
345 | if ( currentSession() ) | 345 | if ( currentSession() ) |
346 | currentSession()->layer()->close(); | 346 | currentSession()->layer()->close(); |
347 | 347 | ||
348 | slotClose(); | 348 | slotClose(); |
349 | /* FIXME move to the next session */ | 349 | /* FIXME move to the next session */ |
350 | } | 350 | } |
351 | 351 | ||
352 | void MainWindow::slotConfigure() { | 352 | void MainWindow::slotConfigure() { |
353 | ConfigDialog conf( manager()->all(), factory() ); | 353 | ConfigDialog conf( manager()->all(), factory() ); |
354 | conf.showMaximized(); | 354 | conf.showMaximized(); |
355 | 355 | ||
356 | int ret = conf.exec(); | 356 | int ret = conf.exec(); |
357 | 357 | ||
358 | if ( QDialog::Accepted == ret ) { | 358 | if ( QDialog::Accepted == ret ) { |
359 | manager()->setProfiles( conf.list() ); | 359 | manager()->setProfiles( conf.list() ); |
360 | manager()->save(); | 360 | manager()->save(); |
361 | populateProfiles(); | 361 | populateProfiles(); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | /* | 364 | /* |
365 | * we will remove | 365 | * we will remove |
366 | * this window from the tabwidget | 366 | * this window from the tabwidget |
367 | * remove it from the list | 367 | * remove it from the list |
368 | * delete it | 368 | * delete it |
369 | * and set the currentSession() | 369 | * and set the currentSession() |
370 | */ | 370 | */ |
371 | void MainWindow::slotClose() { | 371 | void MainWindow::slotClose() { |
372 | if (!currentSession() ) | 372 | if (!currentSession() ) |
373 | return; | 373 | return; |
374 | 374 | ||
375 | Session* ses = currentSession(); | 375 | Session* ses = currentSession(); |
376 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 376 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
377 | /* 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 */ |
378 | m_curSession = NULL; | 378 | m_curSession = NULL; |
379 | tabWidget()->remove( /*currentSession()*/ses ); | 379 | tabWidget()->remove( /*currentSession()*/ses ); |
380 | /*it's autodelete */ | 380 | /*it's autodelete */ |
381 | m_sessions.remove( ses ); | 381 | m_sessions.remove( ses ); |
382 | qWarning("after remove!!"); | 382 | qWarning("after remove!!"); |
383 | 383 | ||
384 | if (!currentSession() ) { | 384 | if (!currentSession() ) { |
385 | m_connect->setEnabled( false ); | 385 | m_connect->setEnabled( false ); |
386 | m_disconnect->setEnabled( false ); | 386 | m_disconnect->setEnabled( false ); |
387 | m_terminate->setEnabled( false ); | 387 | m_terminate->setEnabled( false ); |
388 | m_transfer->setEnabled( false ); | 388 | m_transfer->setEnabled( false ); |
389 | m_recordScript->setEnabled( false ); | 389 | m_recordScript->setEnabled( false ); |
390 | m_saveScript->setEnabled( false ); | 390 | m_saveScript->setEnabled( false ); |
391 | m_runScript->setEnabled( false ); | 391 | m_runScript->setEnabled( false ); |
392 | m_fullscreen->setEnabled( false ); | 392 | m_fullscreen->setEnabled( false ); |
393 | m_closewindow->setEnabled( false ); | 393 | m_closewindow->setEnabled( false ); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | 396 | ||
397 | /* | 397 | /* |
398 | * We will get the name | 398 | * We will get the name |
399 | * Then the profile | 399 | * Then the profile |
400 | * and then we will make a profile | 400 | * and then we will make a profile |
401 | */ | 401 | */ |
402 | void MainWindow::slotProfile( int id) { | 402 | void MainWindow::slotProfile( int id) { |
403 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 403 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
404 | create( prof ); | 404 | create( prof ); |
405 | } | 405 | } |
406 | void MainWindow::create( const Profile& prof ) { | 406 | void MainWindow::create( const Profile& prof ) { |
407 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 407 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
408 | 408 | ||
409 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 409 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
410 | { | 410 | { |
411 | QMessageBox::warning(this, | 411 | QMessageBox::warning(this, |
412 | QObject::tr("Session failed"), | 412 | QObject::tr("Session failed"), |
413 | 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>")); |
414 | //if(ses) delete ses; | 414 | //if(ses) delete ses; |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | 417 | ||
418 | m_sessions.append( ses ); | 418 | m_sessions.append( ses ); |
419 | tabWidget()->add( ses ); | 419 | tabWidget()->add( ses ); |
420 | m_curSession = ses; | 420 | m_curSession = ses; |
421 | 421 | ||
422 | // 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 |
423 | m_connect->setEnabled( true ); | 423 | m_connect->setEnabled( true ); |
424 | m_disconnect->setEnabled( false ); | 424 | m_disconnect->setEnabled( false ); |
425 | m_terminate->setEnabled( true ); | 425 | m_terminate->setEnabled( true ); |
426 | m_transfer->setEnabled( true ); | 426 | m_transfer->setEnabled( true ); |
427 | m_recordScript->setEnabled( true ); | 427 | m_recordScript->setEnabled( true ); |
428 | m_saveScript->setEnabled( true ); | 428 | m_saveScript->setEnabled( true ); |
429 | m_runScript->setEnabled( true ); | 429 | m_runScript->setEnabled( true ); |
430 | m_fullscreen->setEnabled( true ); | 430 | m_fullscreen->setEnabled( true ); |
431 | m_closewindow->setEnabled( true ); | 431 | m_closewindow->setEnabled( true ); |
432 | 432 | ||
433 | 433 | ||
434 | // is io_layer wants direct connection, then autoconnect | 434 | // is io_layer wants direct connection, then autoconnect |
435 | if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 435 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
436 | if (prof.autoConnect()) { | ||
436 | slotConnect(); | 437 | slotConnect(); |
437 | } | 438 | } |
438 | } | 439 | } |
439 | 440 | ||
440 | void MainWindow::slotTransfer() | 441 | void MainWindow::slotTransfer() |
441 | { | 442 | { |
442 | if ( currentSession() ) { | 443 | if ( currentSession() ) { |
443 | TransferDialog dlg(currentSession()->widgetStack(), this); | 444 | TransferDialog dlg(currentSession()->widgetStack(), this); |
444 | dlg.showMaximized(); | 445 | dlg.showMaximized(); |
445 | //currentSession()->widgetStack()->add(dlg); | 446 | //currentSession()->widgetStack()->add(dlg); |
446 | dlg.exec(); | 447 | dlg.exec(); |
447 | } | 448 | } |
448 | } | 449 | } |
449 | 450 | ||
450 | 451 | ||
451 | void MainWindow::slotOpenKeb(bool state) { | 452 | void MainWindow::slotOpenKeb(bool state) { |
452 | 453 | ||
453 | if (state) m_keyBar->show(); | 454 | if (state) m_keyBar->show(); |
454 | else m_keyBar->hide(); | 455 | else m_keyBar->hide(); |
455 | 456 | ||
456 | } | 457 | } |
457 | 458 | ||
458 | 459 | ||
459 | void MainWindow::slotOpenButtons( bool state ) { | 460 | void MainWindow::slotOpenButtons( bool state ) { |
460 | 461 | ||
461 | if ( state ) { | 462 | if ( state ) { |
462 | m_buttonBar->show(); | 463 | m_buttonBar->show(); |
463 | } else { | 464 | } else { |
464 | m_buttonBar->hide(); | 465 | m_buttonBar->hide(); |
465 | } | 466 | } |
466 | } | 467 | } |
467 | 468 | ||
468 | 469 | ||
469 | 470 | ||
470 | void MainWindow::slotSessionChanged( Session* ses ) { | 471 | void MainWindow::slotSessionChanged( Session* ses ) { |
471 | qWarning("changed!"); | 472 | qWarning("changed!"); |
472 | if ( ses ) { | 473 | if ( ses ) { |
473 | m_curSession = ses; | 474 | m_curSession = ses; |
474 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 475 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
475 | if ( m_curSession->layer()->isConnected() ) { | 476 | if ( m_curSession->layer()->isConnected() ) { |
476 | m_connect->setEnabled( false ); | 477 | m_connect->setEnabled( false ); |
477 | m_disconnect->setEnabled( true ); | 478 | m_disconnect->setEnabled( true ); |
478 | } else { | 479 | } else { |
479 | m_connect->setEnabled( true ); | 480 | m_connect->setEnabled( true ); |
480 | m_disconnect->setEnabled( false ); | 481 | m_disconnect->setEnabled( false ); |
481 | } | 482 | } |
482 | } | 483 | } |
483 | } | 484 | } |
484 | 485 | ||
485 | void MainWindow::slotFullscreen() { | 486 | void MainWindow::slotFullscreen() { |
486 | 487 | ||
487 | 488 | ||
488 | 489 | ||
489 | if ( m_isFullscreen ) { | 490 | if ( m_isFullscreen ) { |
490 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false ); | 491 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), false ); |
491 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 492 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
492 | 493 | ||
493 | setCentralWidget( m_consoleWindow ); | 494 | setCentralWidget( m_consoleWindow ); |
494 | ( m_curSession->widgetStack() )->show(); | 495 | ( m_curSession->widgetStack() )->show(); |
495 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 496 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
496 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 497 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
497 | 498 | ||
498 | } else { | 499 | } else { |
499 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 500 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
500 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 501 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
501 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 502 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
502 | , QPoint(0,0), false ); | 503 | , QPoint(0,0), false ); |
503 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 504 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
504 | ( m_curSession->widgetStack() )->setFocus(); | 505 | ( m_curSession->widgetStack() )->setFocus(); |
505 | ( m_curSession->widgetStack() )->show(); | 506 | ( m_curSession->widgetStack() )->show(); |
506 | 507 | ||
507 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 508 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
508 | 509 | ||
509 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 510 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
510 | } | 511 | } |
511 | 512 | ||
512 | m_isFullscreen = !m_isFullscreen; | 513 | m_isFullscreen = !m_isFullscreen; |
513 | } | 514 | } |
514 | 515 | ||
515 | 516 | ||
516 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { | 517 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { |
517 | 518 | ||
518 | //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); | 519 | //qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); |
519 | 520 | ||
520 | if ( m_curSession ) { | 521 | if ( m_curSession ) { |
521 | 522 | ||
522 | QEvent::Type state; | 523 | QEvent::Type state; |
523 | 524 | ||
524 | if (pressed) state = QEvent::KeyPress; | 525 | if (pressed) state = QEvent::KeyPress; |
525 | else state = QEvent::KeyRelease; | 526 | else state = QEvent::KeyRelease; |
526 | 527 | ||
527 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); | 528 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); |
528 | 529 | ||
529 | // where should i send this event? doesnt work sending it here | 530 | // where should i send this event? doesnt work sending it here |
530 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 531 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
531 | ke.ignore(); | 532 | ke.ignore(); |
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp index 1a94619..51d1aa8 100644 --- a/noncore/apps/opie-console/profile.cpp +++ b/noncore/apps/opie-console/profile.cpp | |||
@@ -1,119 +1,128 @@ | |||
1 | #include "profile.h" | 1 | #include "profile.h" |
2 | 2 | ||
3 | Profile::Profile() { | 3 | Profile::Profile() { |
4 | 4 | ||
5 | } | 5 | } |
6 | Profile::Profile( const QString& name, | 6 | Profile::Profile( const QString& name, |
7 | const QCString& iolayerName, | 7 | const QCString& iolayerName, |
8 | const QCString& termName, | 8 | const QCString& termName, |
9 | int background, | 9 | int background, |
10 | int foreground, | 10 | int foreground, |
11 | int terminal ) | 11 | int terminal ) |
12 | : m_name( name ), m_ioLayer( iolayerName ), m_term( termName), | 12 | : m_name( name ), m_ioLayer( iolayerName ), m_term( termName), m_autoConnect(0), |
13 | m_back( background ), m_fore( foreground ), m_terminal( terminal ) | 13 | m_back( background ), m_fore( foreground ), m_terminal( terminal ) |
14 | {} | 14 | {} |
15 | Profile::Profile( const Profile& prof ) | 15 | Profile::Profile( const Profile& prof ) |
16 | { | 16 | { |
17 | (*this) = prof; | 17 | (*this) = prof; |
18 | } | 18 | } |
19 | bool Profile::operator==( const Profile& prof ) { | 19 | bool Profile::operator==( const Profile& prof ) { |
20 | if ( m_name == prof.m_name ) return true; | 20 | if ( m_name == prof.m_name ) return true; |
21 | 21 | ||
22 | return false; | 22 | return false; |
23 | } | 23 | } |
24 | Profile &Profile::operator=( const Profile& prof ) { | 24 | Profile &Profile::operator=( const Profile& prof ) { |
25 | m_name = prof.m_name; | 25 | m_name = prof.m_name; |
26 | m_ioLayer = prof.m_ioLayer; | 26 | m_ioLayer = prof.m_ioLayer; |
27 | m_autoConnect = prof.m_autoConnect; | ||
27 | m_back = prof.m_back; | 28 | m_back = prof.m_back; |
28 | m_fore = prof.m_fore; | 29 | m_fore = prof.m_fore; |
29 | m_terminal = prof.m_terminal; | 30 | m_terminal = prof.m_terminal; |
30 | m_conf = prof.m_conf; | 31 | m_conf = prof.m_conf; |
31 | m_term = prof.m_term; | 32 | m_term = prof.m_term; |
32 | 33 | ||
33 | return *this; | 34 | return *this; |
34 | } | 35 | } |
35 | Profile::~Profile() { | 36 | Profile::~Profile() { |
36 | } | 37 | } |
37 | QMap<QString, QString> Profile::conf()const { | 38 | QMap<QString, QString> Profile::conf()const { |
38 | return m_conf; | 39 | return m_conf; |
39 | } | 40 | } |
40 | QString Profile::name()const { | 41 | QString Profile::name()const { |
41 | return m_name; | 42 | return m_name; |
42 | } | 43 | } |
43 | QCString Profile::ioLayerName()const { | 44 | QCString Profile::ioLayerName()const { |
44 | return m_ioLayer; | 45 | return m_ioLayer; |
45 | } | 46 | } |
46 | QCString Profile::terminalName( )const { | 47 | QCString Profile::terminalName( )const { |
47 | return m_term; | 48 | return m_term; |
48 | } | 49 | } |
50 | bool Profile::autoConnect()const { | ||
51 | |||
52 | return m_autoConnect; | ||
53 | } | ||
49 | int Profile::foreground()const { | 54 | int Profile::foreground()const { |
50 | return m_fore; | 55 | return m_fore; |
51 | } | 56 | } |
52 | int Profile::background()const { | 57 | int Profile::background()const { |
53 | return m_back; | 58 | return m_back; |
54 | } | 59 | } |
55 | int Profile::terminal()const { | 60 | int Profile::terminal()const { |
56 | return m_terminal; | 61 | return m_terminal; |
57 | } | 62 | } |
58 | void Profile::setName( const QString& str ) { | 63 | void Profile::setName( const QString& str ) { |
59 | m_name = str; | 64 | m_name = str; |
60 | } | 65 | } |
61 | void Profile::setIOLayer( const QCString& name ) { | 66 | void Profile::setIOLayer( const QCString& name ) { |
62 | m_ioLayer = name; | 67 | m_ioLayer = name; |
63 | } | 68 | } |
64 | void Profile::setTerminalName( const QCString& str ) { | 69 | void Profile::setTerminalName( const QCString& str ) { |
65 | m_term = str; | 70 | m_term = str; |
66 | } | 71 | } |
72 | void Profile::setAutoConnect( const bool c) { | ||
73 | |||
74 | m_autoConnect = c; | ||
75 | } | ||
67 | void Profile::setBackground( int back ) { | 76 | void Profile::setBackground( int back ) { |
68 | m_back = back; | 77 | m_back = back; |
69 | } | 78 | } |
70 | void Profile::setForeground( int fore ) { | 79 | void Profile::setForeground( int fore ) { |
71 | m_fore = fore; | 80 | m_fore = fore; |
72 | } | 81 | } |
73 | void Profile::setTerminal( int term ) { | 82 | void Profile::setTerminal( int term ) { |
74 | m_terminal = term; | 83 | m_terminal = term; |
75 | } | 84 | } |
76 | /* config stuff */ | 85 | /* config stuff */ |
77 | void Profile::clearConf() { | 86 | void Profile::clearConf() { |
78 | m_conf.clear(); | 87 | m_conf.clear(); |
79 | } | 88 | } |
80 | void Profile::writeEntry( const QString& key, const QString& value ) { | 89 | void Profile::writeEntry( const QString& key, const QString& value ) { |
81 | m_conf.replace( key, value ); | 90 | m_conf.replace( key, value ); |
82 | } | 91 | } |
83 | void Profile::writeEntry( const QString& key, int num ) { | 92 | void Profile::writeEntry( const QString& key, int num ) { |
84 | writeEntry( key, QString::number( num ) ); | 93 | writeEntry( key, QString::number( num ) ); |
85 | } | 94 | } |
86 | void Profile::writeEntry( const QString& key, bool b ) { | 95 | void Profile::writeEntry( const QString& key, bool b ) { |
87 | writeEntry( key, QString::number(b) ); | 96 | writeEntry( key, QString::number(b) ); |
88 | } | 97 | } |
89 | void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) { | 98 | void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) { |
90 | writeEntry( key, lis.join(sep) ); | 99 | writeEntry( key, lis.join(sep) ); |
91 | } | 100 | } |
92 | QString Profile::readEntry( const QString& key, const QString& deflt )const { | 101 | QString Profile::readEntry( const QString& key, const QString& deflt )const { |
93 | QMap<QString, QString>::ConstIterator it; | 102 | QMap<QString, QString>::ConstIterator it; |
94 | it = m_conf.find( key ); | 103 | it = m_conf.find( key ); |
95 | 104 | ||
96 | if ( it != m_conf.end() ) | 105 | if ( it != m_conf.end() ) |
97 | return it.data(); | 106 | return it.data(); |
98 | 107 | ||
99 | return deflt; | 108 | return deflt; |
100 | } | 109 | } |
101 | int Profile::readNumEntry( const QString& key, int def )const { | 110 | int Profile::readNumEntry( const QString& key, int def )const { |
102 | QMap<QString, QString>::ConstIterator it; | 111 | QMap<QString, QString>::ConstIterator it; |
103 | it = m_conf.find( key ); | 112 | it = m_conf.find( key ); |
104 | 113 | ||
105 | if ( it != m_conf.end() ) { | 114 | if ( it != m_conf.end() ) { |
106 | bool ok; | 115 | bool ok; |
107 | int val = it.data().toInt(&ok); | 116 | int val = it.data().toInt(&ok); |
108 | 117 | ||
109 | if (ok) | 118 | if (ok) |
110 | return val; | 119 | return val; |
111 | } | 120 | } |
112 | return def; | 121 | return def; |
113 | } | 122 | } |
114 | bool Profile::readBoolEntry( const QString& key, bool def )const { | 123 | bool Profile::readBoolEntry( const QString& key, bool def )const { |
115 | return readNumEntry( key, def ); | 124 | return readNumEntry( key, def ); |
116 | } | 125 | } |
117 | void Profile::setConf( const QMap<QString, QString>& conf ) { | 126 | void Profile::setConf( const QMap<QString, QString>& conf ) { |
118 | m_conf = conf; | 127 | m_conf = conf; |
119 | }; | 128 | }; |
diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h index 64eb022..4f9e9c2 100644 --- a/noncore/apps/opie-console/profile.h +++ b/noncore/apps/opie-console/profile.h | |||
@@ -1,73 +1,76 @@ | |||
1 | #ifndef OPIE_PROFILE_H | 1 | #ifndef OPIE_PROFILE_H |
2 | #define OPIE_PROFILE_H | 2 | #define OPIE_PROFILE_H |
3 | 3 | ||
4 | #include <qmap.h> | 4 | #include <qmap.h> |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | #include <qvaluelist.h> | 7 | #include <qvaluelist.h> |
8 | /** | 8 | /** |
9 | * A session will be generated from a saved | 9 | * A session will be generated from a saved |
10 | * profile. A profile contains the iolayername | 10 | * profile. A profile contains the iolayername |
11 | * a name. | 11 | * a name. |
12 | * We can generate a Session from a Profile | 12 | * We can generate a Session from a Profile |
13 | * Configuration is contained here too | 13 | * Configuration is contained here too |
14 | */ | 14 | */ |
15 | class Profile { | 15 | class Profile { |
16 | public: | 16 | public: |
17 | typedef QValueList<Profile> ValueList; | 17 | typedef QValueList<Profile> ValueList; |
18 | enum Color { Black = 0, | 18 | enum Color { Black = 0, |
19 | White, | 19 | White, |
20 | Gray, | 20 | Gray, |
21 | Green, | 21 | Green, |
22 | Orange}; | 22 | Orange}; |
23 | enum Terminal {VT102 = 0, VT100 }; | 23 | enum Terminal {VT102 = 0, VT100 }; |
24 | enum Font { Micro = 0, Small, Medium }; | 24 | enum Font { Micro = 0, Small, Medium }; |
25 | Profile(); | 25 | Profile(); |
26 | Profile( const QString& name, | 26 | Profile( const QString& name, |
27 | const QCString& iolayerName, | 27 | const QCString& iolayerName, |
28 | const QCString& termName, | 28 | const QCString& termName, |
29 | int background, | 29 | int background, |
30 | int foreground, | 30 | int foreground, |
31 | int terminal); | 31 | int terminal); |
32 | Profile( const Profile& ); | 32 | Profile( const Profile& ); |
33 | Profile &operator=( const Profile& ); | 33 | Profile &operator=( const Profile& ); |
34 | bool operator==( const Profile& prof ); | 34 | bool operator==( const Profile& prof ); |
35 | 35 | ||
36 | ~Profile(); | 36 | ~Profile(); |
37 | QString name()const; | 37 | QString name()const; |
38 | QCString ioLayerName()const; | 38 | QCString ioLayerName()const; |
39 | QCString terminalName()const; | 39 | QCString terminalName()const; |
40 | bool autoConnect()const; | ||
40 | int foreground()const; | 41 | int foreground()const; |
41 | int background()const; | 42 | int background()const; |
42 | int terminal()const; | 43 | int terminal()const; |
43 | 44 | ||
44 | /* | 45 | /* |
45 | * config stuff | 46 | * config stuff |
46 | */ | 47 | */ |
47 | QMap<QString, QString> conf()const; | 48 | QMap<QString, QString> conf()const; |
48 | void clearConf(); | 49 | void clearConf(); |
49 | void writeEntry( const QString& key, const QString& value ); | 50 | void writeEntry( const QString& key, const QString& value ); |
50 | void writeEntry( const QString& key, int num ); | 51 | void writeEntry( const QString& key, int num ); |
51 | void writeEntry( const QString& key, bool b ); | 52 | void writeEntry( const QString& key, bool b ); |
52 | void writeEntry( const QString& key, const QStringList&, const QChar& ); | 53 | void writeEntry( const QString& key, const QStringList&, const QChar& ); |
53 | QString readEntry( const QString& key, const QString& deflt = QString::null)const; | 54 | QString readEntry( const QString& key, const QString& deflt = QString::null)const; |
54 | int readNumEntry( const QString& key, int = -1 )const; | 55 | int readNumEntry( const QString& key, int = -1 )const; |
55 | bool readBoolEntry( const QString& key, bool = FALSE )const; | 56 | bool readBoolEntry( const QString& key, bool = FALSE )const; |
56 | 57 | ||
57 | void setName( const QString& ); | 58 | void setName( const QString& ); |
58 | void setIOLayer( const QCString& ); | 59 | void setIOLayer( const QCString& ); |
59 | void setTerminalName( const QCString& ); | 60 | void setTerminalName( const QCString& ); |
61 | void setAutoConnect( const bool ); | ||
60 | void setBackground( int back ); | 62 | void setBackground( int back ); |
61 | void setForeground( int fore ); | 63 | void setForeground( int fore ); |
62 | void setTerminal( int term ); | 64 | void setTerminal( int term ); |
63 | void setConf( const QMap<QString, QString>& ); | 65 | void setConf( const QMap<QString, QString>& ); |
64 | private: | 66 | private: |
65 | QMap<QString, QString> m_conf; | 67 | QMap<QString, QString> m_conf; |
66 | QString m_name; | 68 | QString m_name; |
67 | QCString m_ioLayer, m_term; | 69 | QCString m_ioLayer, m_term; |
70 | bool m_autoConnect; | ||
68 | int m_back; | 71 | int m_back; |
69 | int m_fore; | 72 | int m_fore; |
70 | int m_terminal; | 73 | int m_terminal; |
71 | }; | 74 | }; |
72 | 75 | ||
73 | #endif | 76 | #endif |
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 5c5c2b3..c48ea53 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -1,193 +1,198 @@ | |||
1 | #include <qlayout.h> | 1 | #include <qlayout.h> |
2 | #include <qlineedit.h> | 2 | #include <qlineedit.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qmessagebox.h> | 4 | #include <qmessagebox.h> |
5 | #include <qstringlist.h> | 5 | #include <qstringlist.h> |
6 | #include <qcombobox.h> | 6 | #include <qcombobox.h> |
7 | #include <qcheckbox.h> | ||
7 | 8 | ||
8 | 9 | ||
9 | #include "profileeditorplugins.h" | 10 | //#include "profileeditorplugins.h" |
10 | #include "metafactory.h" | 11 | #include "metafactory.h" |
11 | #include "profileeditordialog.h" | 12 | #include "profileeditordialog.h" |
12 | 13 | ||
13 | namespace { | 14 | namespace { |
14 | void setCurrent( const QString& str, QComboBox* bo ) { | 15 | void setCurrent( const QString& str, QComboBox* bo ) { |
15 | for (uint i = 0; i < bo->count(); i++ ) { | 16 | for (uint i = 0; i < bo->count(); i++ ) { |
16 | if ( bo->text(i) == str ) { | 17 | if ( bo->text(i) == str ) { |
17 | bo->setCurrentItem( i ); | 18 | bo->setCurrentItem( i ); |
18 | } | 19 | } |
19 | } | 20 | } |
20 | } | 21 | } |
21 | 22 | ||
22 | 23 | ||
23 | } | 24 | } |
24 | 25 | ||
25 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 26 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
26 | const Profile& prof ) | 27 | const Profile& prof ) |
27 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) | 28 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) |
28 | { | 29 | { |
29 | initUI(); | 30 | initUI(); |
30 | 31 | ||
31 | // Apply current profile | 32 | // Apply current profile |
32 | // plugin_plugin->load(profile); | 33 | // plugin_plugin->load(profile); |
33 | // ... (reset profile name line edit etc.) | 34 | // ... (reset profile name line edit etc.) |
34 | } | 35 | } |
35 | 36 | ||
36 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | 37 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) |
37 | : QDialog(0, 0, TRUE), m_fact( fact ) | 38 | : QDialog(0, 0, TRUE), m_fact( fact ) |
38 | { | 39 | { |
39 | // Default profile | 40 | // Default profile |
40 | m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); | 41 | m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); |
41 | 42 | ||
42 | initUI(); | 43 | initUI(); |
43 | 44 | ||
44 | // Apply current profile | 45 | // Apply current profile |
45 | // plugin_plugin->load(profile); | 46 | // plugin_plugin->load(profile); |
46 | } | 47 | } |
47 | 48 | ||
48 | Profile ProfileEditorDialog::profile() const | 49 | Profile ProfileEditorDialog::profile() const |
49 | { | 50 | { |
50 | return m_prof; | 51 | return m_prof; |
51 | } | 52 | } |
52 | 53 | ||
53 | void ProfileEditorDialog::initUI() | 54 | void ProfileEditorDialog::initUI() |
54 | { | 55 | { |
55 | m_con = m_term = 0l; | 56 | m_con = m_term = 0l; |
56 | 57 | ||
57 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 58 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
58 | tabWidget = new OTabWidget( this ); | 59 | tabWidget = new OTabWidget( this ); |
59 | tabWidget->setTabStyle(OTabWidget::TextTab); | 60 | tabWidget->setTabStyle(OTabWidget::TextTab); |
60 | mainLayout->add(tabWidget); | 61 | mainLayout->add(tabWidget); |
61 | 62 | ||
62 | QWidget *tabprof; | 63 | QWidget *tabprof; |
63 | 64 | ||
64 | /* base tabs */ | 65 | /* base tabs */ |
65 | tabprof = new QWidget(this); | 66 | tabprof = new QWidget(this); |
66 | m_tabTerm = new QWidget(this); | 67 | m_tabTerm = new QWidget(this); |
67 | m_tabCon = new QWidget(this); | 68 | m_tabCon = new QWidget(this); |
68 | 69 | ||
69 | /* base layout for tabs */ | 70 | /* base layout for tabs */ |
70 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); | 71 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); |
71 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); | 72 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); |
72 | 73 | ||
73 | // profile tab | 74 | // profile tab |
74 | 75 | ||
75 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 76 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
76 | m_name = new QLineEdit(tabprof); | 77 | m_name = new QLineEdit(tabprof); |
77 | QLabel *con = new QLabel(tr("Connection"), tabprof ); | 78 | QLabel *con = new QLabel(tr("Connection"), tabprof ); |
78 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); | 79 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); |
79 | m_conCmb = new QComboBox( tabprof ); | 80 | m_conCmb = new QComboBox( tabprof ); |
80 | m_termCmb = new QComboBox( tabprof ); | 81 | m_termCmb = new QComboBox( tabprof ); |
82 | m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); | ||
81 | 83 | ||
82 | // layouting | 84 | // layouting |
83 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 85 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
84 | vbox3->add(name); | 86 | vbox3->add(name); |
85 | vbox3->add(m_name); | 87 | vbox3->add(m_name); |
86 | vbox3->add(con ); | 88 | vbox3->add(con ); |
87 | vbox3->add(m_conCmb ); | 89 | vbox3->add(m_conCmb ); |
88 | vbox3->add(term ); | 90 | vbox3->add(term ); |
89 | vbox3->add(m_termCmb ); | 91 | vbox3->add(m_termCmb ); |
92 | vbox3->add(m_autoConnect); | ||
90 | vbox3->addStretch(1); | 93 | vbox3->addStretch(1); |
91 | 94 | ||
92 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); | 95 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); |
93 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); | 96 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); |
94 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); | 97 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); |
95 | tabWidget->setCurrentTab( tabprof ); | 98 | tabWidget->setCurrentTab( tabprof ); |
96 | 99 | ||
97 | 100 | ||
98 | // fill the comboboxes | 101 | // fill the comboboxes |
99 | QStringList list = m_fact->connectionWidgets(); | 102 | QStringList list = m_fact->connectionWidgets(); |
100 | QStringList::Iterator it; | 103 | QStringList::Iterator it; |
101 | for (it =list.begin(); it != list.end(); ++it ) { | 104 | for (it =list.begin(); it != list.end(); ++it ) { |
102 | m_conCmb->insertItem( (*it) ); | 105 | m_conCmb->insertItem( (*it) ); |
103 | } | 106 | } |
104 | list = m_fact->terminalWidgets(); | 107 | list = m_fact->terminalWidgets(); |
105 | for (it =list.begin(); it != list.end(); ++it ) { | 108 | for (it =list.begin(); it != list.end(); ++it ) { |
106 | m_termCmb->insertItem( (*it) ); | 109 | m_termCmb->insertItem( (*it) ); |
107 | } | 110 | } |
108 | 111 | ||
109 | // load profile values | 112 | // load profile values |
110 | m_name->setText(m_prof.name()); | 113 | m_name->setText(m_prof.name()); |
111 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); | 114 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); |
112 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); | 115 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); |
113 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); | 116 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); |
114 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); | 117 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); |
118 | m_autoConnect->setChecked(m_prof.autoConnect()); | ||
115 | 119 | ||
116 | 120 | ||
117 | // signal and slots | 121 | // signal and slots |
118 | connect(m_conCmb, SIGNAL(activated(const QString& ) ), | 122 | connect(m_conCmb, SIGNAL(activated(const QString& ) ), |
119 | this, SLOT(slotConActivated(const QString&) ) ); | 123 | this, SLOT(slotConActivated(const QString&) ) ); |
120 | connect(m_termCmb, SIGNAL(activated(const QString& ) ), | 124 | connect(m_termCmb, SIGNAL(activated(const QString& ) ), |
121 | this, SLOT(slotTermActivated(const QString& ) ) ); | 125 | this, SLOT(slotTermActivated(const QString& ) ) ); |
122 | 126 | ||
123 | } | 127 | } |
124 | 128 | ||
125 | ProfileEditorDialog::~ProfileEditorDialog() { | 129 | ProfileEditorDialog::~ProfileEditorDialog() { |
126 | 130 | ||
127 | } | 131 | } |
128 | void ProfileEditorDialog::accept() | 132 | void ProfileEditorDialog::accept() |
129 | { | 133 | { |
130 | if(profName().isEmpty()) | 134 | if(profName().isEmpty()) |
131 | { | 135 | { |
132 | QMessageBox::information(this, | 136 | QMessageBox::information(this, |
133 | QObject::tr("Invalid profile"), | 137 | QObject::tr("Invalid profile"), |
134 | QObject::tr("Please enter a profile name.")); | 138 | QObject::tr("Please enter a profile name.")); |
135 | return; | 139 | return; |
136 | } | 140 | } |
137 | // Save profile and plugin profile | 141 | // Save profile and plugin profile |
138 | //if(plugin_plugin) plugin_plugin->save(); | 142 | //if(plugin_plugin) plugin_plugin->save(); |
139 | 143 | ||
140 | // Save general values | 144 | // Save general values |
141 | m_prof.setName(profName()); | 145 | m_prof.setName(profName()); |
142 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); | 146 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); |
143 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); | 147 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); |
148 | m_prof.setAutoConnect( m_autoConnect->isChecked() ); | ||
144 | 149 | ||
145 | if (m_con ) | 150 | if (m_con ) |
146 | m_con->save( m_prof ); | 151 | m_con->save( m_prof ); |
147 | if (m_term ) | 152 | if (m_term ) |
148 | m_term->save( m_prof ); | 153 | m_term->save( m_prof ); |
149 | 154 | ||
150 | QDialog::accept(); | 155 | QDialog::accept(); |
151 | } | 156 | } |
152 | 157 | ||
153 | 158 | ||
154 | QString ProfileEditorDialog::profName()const | 159 | QString ProfileEditorDialog::profName()const |
155 | { | 160 | { |
156 | return m_name->text(); | 161 | return m_name->text(); |
157 | } | 162 | } |
158 | 163 | ||
159 | QCString ProfileEditorDialog::profType()const | 164 | QCString ProfileEditorDialog::profType()const |
160 | { | 165 | { |
161 | /*QStringList w = m_fact->configWidgets(); | 166 | /*QStringList w = m_fact->configWidgets(); |
162 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 167 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
163 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 168 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
164 | */ | 169 | */ |
165 | return QCString(); | 170 | return QCString(); |
166 | } | 171 | } |
167 | /* | 172 | /* |
168 | * we need to switch the widget | 173 | * we need to switch the widget |
169 | */ | 174 | */ |
170 | void ProfileEditorDialog::slotConActivated( const QString& str ) { | 175 | void ProfileEditorDialog::slotConActivated( const QString& str ) { |
171 | delete m_con; | 176 | delete m_con; |
172 | m_con = m_fact->newConnectionPlugin( str, m_tabCon ); | 177 | m_con = m_fact->newConnectionPlugin( str, m_tabCon ); |
173 | 178 | ||
174 | if ( m_con ) { | 179 | if ( m_con ) { |
175 | m_con->load( m_prof ); | 180 | m_con->load( m_prof ); |
176 | m_layCon->addWidget( m_con ); | 181 | m_layCon->addWidget( m_con ); |
177 | } else { | 182 | } else { |
178 | tabWidget->removePage( m_tabCon ); | 183 | tabWidget->removePage( m_tabCon ); |
179 | } | 184 | } |
180 | } | 185 | } |
181 | /* | 186 | /* |
182 | * we need to switch the widget | 187 | * we need to switch the widget |
183 | */ | 188 | */ |
184 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { | 189 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { |
185 | delete m_term; | 190 | delete m_term; |
186 | m_term = m_fact->newTerminalPlugin( str, m_tabTerm ); | 191 | m_term = m_fact->newTerminalPlugin( str, m_tabTerm ); |
187 | 192 | ||
188 | if (m_term) { | 193 | if (m_term) { |
189 | m_term->load(m_prof ); | 194 | m_term->load(m_prof ); |
190 | m_layTerm->addWidget( m_term ); | 195 | m_layTerm->addWidget( m_term ); |
191 | } | 196 | } |
192 | } | 197 | } |
193 | 198 | ||
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h index 6fde839..e01e636 100644 --- a/noncore/apps/opie-console/profileeditordialog.h +++ b/noncore/apps/opie-console/profileeditordialog.h | |||
@@ -1,53 +1,55 @@ | |||
1 | #ifndef PROFILE_EDITOR_DIALOG | 1 | #ifndef PROFILE_EDITOR_DIALOG |
2 | #define PROFILE_EDITOR_DIALOG | 2 | #define PROFILE_EDITOR_DIALOG |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | #include <opie/otabwidget.h> | 5 | #include <opie/otabwidget.h> |
6 | 6 | ||
7 | #include "profile.h" | 7 | #include "profile.h" |
8 | 8 | ||
9 | class MetaFactory; | 9 | class MetaFactory; |
10 | class EditBase; | 10 | class EditBase; |
11 | class QTabWidget; | 11 | class QTabWidget; |
12 | class QHBoxLayout; | 12 | class QHBoxLayout; |
13 | class QLineEdit; | 13 | class QLineEdit; |
14 | class QComboBox; | 14 | class QComboBox; |
15 | class QCheckBox; | ||
15 | class QLabel; | 16 | class QLabel; |
16 | class ProfileDialogWidget; | 17 | class ProfileDialogWidget; |
17 | 18 | ||
18 | class ProfileEditorDialog : public QDialog { | 19 | class ProfileEditorDialog : public QDialog { |
19 | Q_OBJECT | 20 | Q_OBJECT |
20 | public: | 21 | public: |
21 | ProfileEditorDialog(MetaFactory* fact, | 22 | ProfileEditorDialog(MetaFactory* fact, |
22 | const Profile& prof ); | 23 | const Profile& prof ); |
23 | ProfileEditorDialog(MetaFactory* fact ); | 24 | ProfileEditorDialog(MetaFactory* fact ); |
24 | ~ProfileEditorDialog(); | 25 | ~ProfileEditorDialog(); |
25 | Profile profile()const; | 26 | Profile profile()const; |
26 | 27 | ||
27 | 28 | ||
28 | 29 | ||
29 | public slots: | 30 | public slots: |
30 | void accept(); | 31 | void accept(); |
31 | 32 | ||
32 | private slots: | 33 | private slots: |
33 | void slotConActivated(const QString& ); | 34 | void slotConActivated(const QString& ); |
34 | void slotTermActivated( const QString& ); | 35 | void slotTermActivated( const QString& ); |
35 | private: | 36 | private: |
36 | void initUI(); | 37 | void initUI(); |
37 | QString profName()const; | 38 | QString profName()const; |
38 | QCString profType()const; | 39 | QCString profType()const; |
39 | 40 | ||
40 | MetaFactory* m_fact; | 41 | MetaFactory* m_fact; |
41 | QHBoxLayout* m_lay; | 42 | QHBoxLayout* m_lay; |
42 | Profile m_prof; | 43 | Profile m_prof; |
43 | 44 | ||
44 | QLineEdit *m_name; | 45 | QLineEdit *m_name; |
45 | QComboBox *m_conCmb, *m_termCmb; | 46 | QComboBox *m_conCmb, *m_termCmb; |
47 | QCheckBox *m_autoConnect; | ||
46 | 48 | ||
47 | QWidget *m_tabCon, *m_tabTerm; | 49 | QWidget *m_tabCon, *m_tabTerm; |
48 | ProfileDialogWidget* m_con, *m_term; | 50 | ProfileDialogWidget* m_con, *m_term; |
49 | QHBoxLayout *m_layCon, *m_layTerm; | 51 | QHBoxLayout *m_layCon, *m_layTerm; |
50 | OTabWidget *tabWidget; | 52 | OTabWidget *tabWidget; |
51 | }; | 53 | }; |
52 | 54 | ||
53 | #endif | 55 | #endif |
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index 7c15560..5d39d96 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp | |||
@@ -1,135 +1,137 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qhbox.h> | 5 | #include <qhbox.h> |
6 | #include <qlayout.h> | 6 | #include <qlayout.h> |
7 | #include <qwidgetstack.h> | 7 | #include <qwidgetstack.h> |
8 | 8 | ||
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | 10 | ||
11 | #include "emulation_handler.h" | 11 | #include "emulation_handler.h" |
12 | #include "widget_layer.h" | 12 | #include "widget_layer.h" |
13 | #include "emulation_widget.h" | 13 | #include "emulation_widget.h" |
14 | #include "metafactory.h" | 14 | #include "metafactory.h" |
15 | #include "profileconfig.h" | 15 | #include "profileconfig.h" |
16 | #include "profilemanager.h" | 16 | #include "profilemanager.h" |
17 | 17 | ||
18 | ProfileManager::ProfileManager( MetaFactory* fact ) | 18 | ProfileManager::ProfileManager( MetaFactory* fact ) |
19 | : m_fact( fact ) | 19 | : m_fact( fact ) |
20 | { | 20 | { |
21 | 21 | ||
22 | } | 22 | } |
23 | ProfileManager::~ProfileManager() { | 23 | ProfileManager::~ProfileManager() { |
24 | 24 | ||
25 | } | 25 | } |
26 | void ProfileManager::load() { | 26 | void ProfileManager::load() { |
27 | m_list.clear(); | 27 | m_list.clear(); |
28 | ProfileConfig conf("opie-console-profiles"); | 28 | ProfileConfig conf("opie-console-profiles"); |
29 | QStringList groups = conf.groups(); | 29 | QStringList groups = conf.groups(); |
30 | QStringList::Iterator it; | 30 | QStringList::Iterator it; |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * for each profile | 33 | * for each profile |
34 | */ | 34 | */ |
35 | for ( it = groups.begin(); it != groups.end(); ++it ) { | 35 | for ( it = groups.begin(); it != groups.end(); ++it ) { |
36 | conf.setGroup( (*it) ); | 36 | conf.setGroup( (*it) ); |
37 | Profile prof; | 37 | Profile prof; |
38 | prof.setName( conf.readEntry("name") ); | 38 | prof.setName( conf.readEntry("name") ); |
39 | prof.setIOLayer( conf.readEntry("iolayer").utf8() ); | 39 | prof.setIOLayer( conf.readEntry("iolayer").utf8() ); |
40 | prof.setTerminalName( conf.readEntry("term").utf8() ); | 40 | prof.setTerminalName( conf.readEntry("term").utf8() ); |
41 | prof.setAutoConnect( conf.readBoolEntry("autoConnect") ); | ||
41 | prof.setBackground( conf.readNumEntry("back") ); | 42 | prof.setBackground( conf.readNumEntry("back") ); |
42 | prof.setForeground( conf.readNumEntry("fore") ); | 43 | prof.setForeground( conf.readNumEntry("fore") ); |
43 | prof.setTerminal( conf.readNumEntry("terminal") ); | 44 | prof.setTerminal( conf.readNumEntry("terminal") ); |
44 | 45 | ||
45 | // THIS is evil because all data get's reset | 46 | // THIS is evil because all data get's reset |
46 | prof.setConf( conf.items( (*it) ) ); | 47 | prof.setConf( conf.items( (*it) ) ); |
47 | 48 | ||
48 | /* now add it */ | 49 | /* now add it */ |
49 | m_list.append( prof ); | 50 | m_list.append( prof ); |
50 | } | 51 | } |
51 | 52 | ||
52 | } | 53 | } |
53 | void ProfileManager::clear() { | 54 | void ProfileManager::clear() { |
54 | m_list.clear(); | 55 | m_list.clear(); |
55 | } | 56 | } |
56 | Profile::ValueList ProfileManager::all()const { | 57 | Profile::ValueList ProfileManager::all()const { |
57 | return m_list; | 58 | return m_list; |
58 | } | 59 | } |
59 | /* | 60 | /* |
60 | * Our goal is to create a Session | 61 | * Our goal is to create a Session |
61 | * We will load the the IOLayer and EmulationLayer | 62 | * We will load the the IOLayer and EmulationLayer |
62 | * from the factory | 63 | * from the factory |
63 | * we will generate a QWidgetStack | 64 | * we will generate a QWidgetStack |
64 | * add a dummy widget with layout | 65 | * add a dummy widget with layout |
65 | * add "Widget" to the layout | 66 | * add "Widget" to the layout |
66 | * add the dummy to the stack | 67 | * add the dummy to the stack |
67 | * raise the dummy | 68 | * raise the dummy |
68 | * call session->connect(= | 69 | * call session->connect(= |
69 | * this way we only need to reparent | 70 | * this way we only need to reparent |
70 | * in TabWidget | 71 | * in TabWidget |
71 | */ | 72 | */ |
72 | Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { | 73 | Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { |
73 | /* TEST PROFILE!!! | 74 | /* TEST PROFILE!!! |
74 | Profile prof; | 75 | Profile prof; |
75 | QString str = "/dev/ttyS0"; | 76 | QString str = "/dev/ttyS0"; |
76 | prof.writeEntry("Device",str ); | 77 | prof.writeEntry("Device",str ); |
77 | prof.writeEntry("Baud", 115200 ); | 78 | prof.writeEntry("Baud", 115200 ); |
78 | prof.setIOLayer("serial"); | 79 | prof.setIOLayer("serial"); |
79 | prof.setName( "test"); | 80 | prof.setName( "test"); |
80 | */ | 81 | */ |
81 | Session* session = new Session(); | 82 | Session* session = new Session(); |
82 | session->setName( prof.name() ); | 83 | session->setName( prof.name() ); |
83 | /* translate the internal name to the external */ | 84 | /* translate the internal name to the external */ |
84 | session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , | 85 | session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , |
85 | prof) ); | 86 | prof) ); |
86 | 87 | ||
87 | QWidgetStack *stack = new QWidgetStack( parent ); | 88 | QWidgetStack *stack = new QWidgetStack( parent ); |
88 | session->setWidgetStack( stack ); | 89 | session->setWidgetStack( stack ); |
89 | QWidget* dummy = new QHBox( stack ); | 90 | QWidget* dummy = new QHBox( stack ); |
90 | stack->raiseWidget( dummy ); | 91 | stack->raiseWidget( dummy ); |
91 | 92 | ||
92 | EmulationHandler* handler = new EmulationHandler(prof,dummy ); | 93 | EmulationHandler* handler = new EmulationHandler(prof,dummy ); |
93 | session->setEmulationHandler( handler ); | 94 | session->setEmulationHandler( handler ); |
94 | session->connect(); | 95 | session->connect(); |
95 | 96 | ||
96 | return session; | 97 | return session; |
97 | } | 98 | } |
98 | void ProfileManager::save( ) { | 99 | void ProfileManager::save( ) { |
99 | QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); | 100 | QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); |
100 | ProfileConfig conf("opie-console-profiles"); | 101 | ProfileConfig conf("opie-console-profiles"); |
101 | Profile::ValueList::Iterator it2; | 102 | Profile::ValueList::Iterator it2; |
102 | for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { | 103 | for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { |
103 | conf.setGroup( (*it2).name() ); | 104 | conf.setGroup( (*it2).name() ); |
104 | 105 | ||
105 | /* now the config stuff */ | 106 | /* now the config stuff */ |
106 | QMap<QString, QString> map = (*it2).conf(); | 107 | QMap<QString, QString> map = (*it2).conf(); |
107 | QMap<QString, QString>::Iterator confIt; | 108 | QMap<QString, QString>::Iterator confIt; |
108 | for ( confIt = map.begin(); confIt != map.end(); ++confIt ) { | 109 | for ( confIt = map.begin(); confIt != map.end(); ++confIt ) { |
109 | conf.writeEntry( confIt.key(), confIt.data() ); | 110 | conf.writeEntry( confIt.key(), confIt.data() ); |
110 | } | 111 | } |
111 | 112 | ||
112 | conf.writeEntry( "name", (*it2).name() ); | 113 | conf.writeEntry( "name", (*it2).name() ); |
113 | QString str = QString::fromUtf8( (*it2).ioLayerName() ); | 114 | QString str = QString::fromUtf8( (*it2).ioLayerName() ); |
114 | 115 | ||
115 | conf.writeEntry( "iolayer", str ); | 116 | conf.writeEntry( "iolayer", str ); |
116 | conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) ); | 117 | conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) ); |
118 | conf.writeEntry( "autoConnect", (*it2).autoConnect()); | ||
117 | conf.writeEntry( "back", (*it2).background() ); | 119 | conf.writeEntry( "back", (*it2).background() ); |
118 | conf.writeEntry( "fore", (*it2).foreground() ); | 120 | conf.writeEntry( "fore", (*it2).foreground() ); |
119 | conf.writeEntry( "terminal", (*it2).terminal() ); | 121 | conf.writeEntry( "terminal", (*it2).terminal() ); |
120 | } | 122 | } |
121 | } | 123 | } |
122 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { | 124 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { |
123 | m_list = list; | 125 | m_list = list; |
124 | }; | 126 | }; |
125 | Profile ProfileManager::profile( const QString& name )const { | 127 | Profile ProfileManager::profile( const QString& name )const { |
126 | Profile prof; | 128 | Profile prof; |
127 | Profile::ValueList::ConstIterator it; | 129 | Profile::ValueList::ConstIterator it; |
128 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 130 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
129 | if ( name == (*it).name() ) { | 131 | if ( name == (*it).name() ) { |
130 | prof = (*it); | 132 | prof = (*it); |
131 | break; | 133 | break; |
132 | } | 134 | } |
133 | } | 135 | } |
134 | return prof; | 136 | return prof; |
135 | } | 137 | } |