summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp54
1 files changed, 49 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 1a5a59f..a0622d4 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -21,24 +21,25 @@ using namespace Opie::Ui;
21/* QT */ 21/* QT */
22#include <qaction.h> 22#include <qaction.h>
23#include <qmenubar.h> 23#include <qmenubar.h>
24#include <qtoolbar.h> 24#include <qtoolbar.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qwhatsthis.h> 26#include <qwhatsthis.h>
27#include <qfileinfo.h> 27#include <qfileinfo.h>
28 28
29/* STD */ 29/* STD */
30#include <assert.h> 30#include <assert.h>
31 31
32MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 32MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
33
33#ifdef FSCKED_DISTRI 34#ifdef FSCKED_DISTRI
34 FixIt fix; 35 FixIt fix;
35 fix.fixIt(); 36 fix.fixIt();
36#endif 37#endif
37 38
38 setCaption(QObject::tr("Opie Console") ); 39 setCaption(QObject::tr("Opie Console") );
39 KeyTrans::loadAll(); 40 KeyTrans::loadAll();
40 for (int i = 0; i < KeyTrans::count(); i++ ) { 41 for (int i = 0; i < KeyTrans::count(); i++ ) {
41 KeyTrans* s = KeyTrans::find(i ); 42 KeyTrans* s = KeyTrans::find(i );
42 assert( s ); 43 assert( s );
43 } 44 }
44 m_factory = new MetaFactory(); 45 m_factory = new MetaFactory();
@@ -113,29 +114,30 @@ void MainWindow::initUI() {
113 114
114 /* 115 /*
115 * disconnect action 116 * disconnect action
116 */ 117 */
117 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 118 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
118 QString::null, 0, this, 0 ); 119 QString::null, 0, this, 0 );
119 m_disconnect->addTo( m_console ); 120 m_disconnect->addTo( m_console );
120 connect(m_disconnect, SIGNAL(activated() ), 121 connect(m_disconnect, SIGNAL(activated() ),
121 this, SLOT(slotDisconnect() ) ); 122 this, SLOT(slotDisconnect() ) );
122 123
123 m_console->insertSeparator(); 124 m_console->insertSeparator();
124 125
125 126#ifndef EAST
126 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); 127 m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 );
127 m_quickLaunch->addTo( m_icons ); 128 m_quickLaunch->addTo( m_icons );
128 connect( m_quickLaunch, SIGNAL( activated() ), 129 connect( m_quickLaunch, SIGNAL( activated() ),
129 this, SLOT( slotQuickLaunch() ) ); 130 this, SLOT( slotQuickLaunch() ) );
131#endif
130 132
131 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); 133 QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) );
132 134
133 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 135 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
134 0, this, 0 ); 136 0, this, 0 );
135 m_transfer->addTo( m_console ); 137 m_transfer->addTo( m_console );
136 connect(m_transfer, SIGNAL(activated() ), 138 connect(m_transfer, SIGNAL(activated() ),
137 this, SLOT(slotTransfer() ) ); 139 this, SLOT(slotTransfer() ) );
138 140
139 141
140 142
141 /* 143 /*
@@ -151,24 +153,31 @@ void MainWindow::initUI() {
151 * fullscreen 153 * fullscreen
152 */ 154 */
153 m_isFullscreen = false; 155 m_isFullscreen = false;
154 156
155 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 157 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
156 , QString::null, 0, this, 0 ); 158 , QString::null, 0, this, 0 );
157 m_fullscreen->addTo( m_console ); 159 m_fullscreen->addTo( m_console );
158 connect( m_fullscreen, SIGNAL( activated() ), 160 connect( m_fullscreen, SIGNAL( activated() ),
159 this, SLOT( slotFullscreen() ) ); 161 this, SLOT( slotFullscreen() ) );
160 162
161 m_console->insertSeparator(); 163 m_console->insertSeparator();
162 164
165 m_recordLog = new QAction();
166 m_recordLog->setText( tr("Start log") );
167 m_recordLog->addTo( m_console );
168 connect(m_recordLog, SIGNAL(activated() ),
169 this, SLOT( slotSaveLog() ) );
170 m_recordingLog = false;
171
163 QAction *a = new QAction(); 172 QAction *a = new QAction();
164 a->setText( tr("Save history") ); 173 a->setText( tr("Save history") );
165 a->addTo( m_console ); 174 a->addTo( m_console );
166 connect(a, SIGNAL(activated() ), 175 connect(a, SIGNAL(activated() ),
167 this, SLOT(slotSaveHistory() ) ); 176 this, SLOT(slotSaveHistory() ) );
168 /* 177 /*
169 * terminate action 178 * terminate action
170 */ 179 */
171 m_terminate = new QAction(); 180 m_terminate = new QAction();
172 m_terminate->setText( tr("Terminate") ); 181 m_terminate->setText( tr("Terminate") );
173 m_terminate->addTo( m_console ); 182 m_terminate->addTo( m_console );
174 connect(m_terminate, SIGNAL(activated() ), 183 connect(m_terminate, SIGNAL(activated() ),
@@ -413,38 +422,37 @@ void MainWindow::slotDisconnect() {
413} 422}
414 423
415void MainWindow::slotTerminate() { 424void MainWindow::slotTerminate() {
416 if ( currentSession() ) 425 if ( currentSession() )
417 currentSession()->layer()->close(); 426 currentSession()->layer()->close();
418 427
419 slotClose(); 428 slotClose();
420 /* FIXME move to the next session */ 429 /* FIXME move to the next session */
421} 430}
422 431
423 432
424 433
425
426
427
428void MainWindow::slotQuickLaunch() { 434void MainWindow::slotQuickLaunch() {
435
429 Profile prof = manager()->profile( "default" ); 436 Profile prof = manager()->profile( "default" );
430 if ( prof.name() == "default" ) { 437 if ( prof.name() == "default" ) {
431 create( prof ); 438 create( prof );
432 } else { 439 } else {
440 #ifndef EAST
433 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); 441 Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
434 newProf.setAutoConnect( true ); 442 newProf.setAutoConnect( true );
435 create( newProf ); 443 create( newProf );
436 slotSaveSession(); 444 slotSaveSession();
445 #endif
437 } 446 }
438
439} 447}
440 448
441void MainWindow::slotConfigure() { 449void MainWindow::slotConfigure() {
442 ConfigDialog conf( manager()->all(), factory() ); 450 ConfigDialog conf( manager()->all(), factory() );
443 451
444 int ret = QPEApplication::execDialog( &conf ); 452 int ret = QPEApplication::execDialog( &conf );
445 453
446 if ( QDialog::Accepted == ret ) { 454 if ( QDialog::Accepted == ret ) {
447 manager()->setProfiles( conf.list() ); 455 manager()->setProfiles( conf.list() );
448 manager()->save(); 456 manager()->save();
449 populateProfiles(); 457 populateProfiles();
450 } 458 }
@@ -599,24 +607,30 @@ void MainWindow::slotSessionChanged( Session* ses ) {
599 m_disconnect->setEnabled( true ); 607 m_disconnect->setEnabled( true );
600 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 608 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
601 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 609 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
602 m_scripts->setItemEnabled(m_runScript_id, true); 610 m_scripts->setItemEnabled(m_runScript_id, true);
603 } else { 611 } else {
604 m_connect->setEnabled( true ); 612 m_connect->setEnabled( true );
605 m_disconnect->setEnabled( false ); 613 m_disconnect->setEnabled( false );
606 m_recordScript->setEnabled( false ); 614 m_recordScript->setEnabled( false );
607 m_saveScript->setEnabled( false ); 615 m_saveScript->setEnabled( false );
608 m_scripts->setItemEnabled(m_runScript_id, false); 616 m_scripts->setItemEnabled(m_runScript_id, false);
609 } 617 }
610 618
619 if ( ( currentSession()->emulationHandler()->isLogging() ) ) {
620 m_recordLog->setText( tr("Stop log") );
621 } else {
622 m_recordLog->setText( tr("Start log") );
623 }
624
611 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 625 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
612 m_transfer->setEnabled( false ); 626 m_transfer->setEnabled( false );
613 } else { 627 } else {
614 m_transfer->setEnabled( true ); 628 m_transfer->setEnabled( true );
615 } 629 }
616 630
617 QWidget *w = m_curSession->widget(); 631 QWidget *w = m_curSession->widget();
618 if(w) w->setFocus(); 632 if(w) w->setFocus();
619 633
620 if(currentSession()->profile().readNumEntry("Wrap", 80)){ 634 if(currentSession()->profile().readNumEntry("Wrap", 80)){
621 m_isWrapped = true; 635 m_isWrapped = true;
622 } else { 636 } else {
@@ -698,24 +712,54 @@ void MainWindow::slotPaste() {
698 */ 712 */
699 713
700void MainWindow::slotSaveSession() { 714void MainWindow::slotSaveSession() {
701 if (!currentSession() ) { 715 if (!currentSession() ) {
702 QMessageBox::information(this, tr("Save Connection"), 716 QMessageBox::information(this, tr("Save Connection"),
703 tr("<qt>There is no Connection.</qt>"), 1 ); 717 tr("<qt>There is no Connection.</qt>"), 1 );
704 return; 718 return;
705 } 719 }
706 manager()->add( currentSession()->profile() ); 720 manager()->add( currentSession()->profile() );
707 manager()->save(); 721 manager()->save();
708 populateProfiles(); 722 populateProfiles();
709} 723}
724
725
726
727void MainWindow::slotSaveLog() {
728
729 if( currentSession()->emulationHandler()->isLogging() ) {
730 DocLnk nf;
731 QString m_logName = currentSession()->emulationHandler()->logFileName();
732 QFileInfo info(m_logName);
733 nf.setType("text/plain");
734 nf.setFile(m_logName);
735 nf.setName(info.fileName());
736 nf.writeLink();
737 m_recordLog->setText( tr("Start log") );
738 m_recordingLog = false;
739 currentSession()->emulationHandler()->clearLog();
740 } else {
741 QMap<QString, QStringList> map;
742 QStringList text;
743 text << "text/plain";
744 map.insert(tr("Log"), text );
745 QString m_logName = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
746 if (m_logName.isEmpty() ) return;
747
748 m_recordLog->setText( tr("Stop log") );
749 m_recordingLog = true;
750 currentSession()->emulationHandler()->startLogging(m_logName);
751 }
752}
753
710void MainWindow::slotSaveHistory() { 754void MainWindow::slotSaveHistory() {
711 QMap<QString, QStringList> map; 755 QMap<QString, QStringList> map;
712 QStringList text; 756 QStringList text;
713 text << "text/plain"; 757 text << "text/plain";
714 map.insert(tr("History"), text ); 758 map.insert(tr("History"), text );
715 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 759 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
716 if (filename.isEmpty() ) return; 760 if (filename.isEmpty() ) return;
717 761
718 QFileInfo info(filename); 762 QFileInfo info(filename);
719 763
720 DocLnk nf; 764 DocLnk nf;
721 nf.setType("text/plain"); 765 nf.setType("text/plain");