-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 45 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.h | 3 |
2 files changed, 45 insertions, 3 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 217d8d8..16ff4df 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp @@ -13,16 +13,17 @@ /* */ /* ---------------------------------------------------------------------- */ /* */ /* Ported Konsole to Qt/Embedded */ /* */ /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ /* */ /* -------------------------------------------------------------------------- */ +// enhancements added by L.J. Potter <ljp@llornkcor.com> #include <qpe/resource.h> #include <qdir.h> #include <qevent.h> #include <qdragobject.h> #include <qobjectlist.h> #include <qtoolbutton.h> @@ -196,17 +197,17 @@ void Konsole::initCommandList() } void Konsole::init(const char* _pgm, QStrList & _args) { b_scroll = TRUE; // histon; n_keytab = 0; n_render = 0; - + startUp=0; setCaption( tr("Terminal") ); setIcon( Resource::loadPixmap( "konsole" ) ); Config cfg("Konsole"); cfg.setGroup("Konsole"); QString tmp; // initialize the list of allowed fonts /////////////////////////////////// cfont = cfg.readNumEntry("FontID", 1); @@ -359,22 +360,22 @@ void Konsole::init(const char* _pgm, QStrList & _args) for (int i = 0; i < KeyTrans::count(); i++) { KeyTrans* s = KeyTrans::find(i); assert( s ); } se_pgm = _pgm; se_args = _args; +parseCommandLine(); // read and apply default values /////////////////////////////////////////// resize(321, 321); // Dummy. QSize currentSize = size(); if (currentSize != size()) defaultSize = size(); - } void Konsole::show() { if ( !nsessions ) { newSession(); } QMainWindow::show(); @@ -384,17 +385,17 @@ void Konsole::initSession(const char*, QStrList &) { QMainWindow::show(); } Konsole::~Konsole() { while (nsessions > 0) { doneSession(getTe()->currentSession, 0); - } + } Config cfg("Konsole"); cfg.setGroup("Konsole"); cfg.writeEntry("FontID", cfont); } void Konsole::fontChanged(int f) { @@ -838,8 +839,46 @@ void Konsole::editCommandListMenuSelected(int iD) if(iD == -23) { // "edit commands" CommandEditDialog *m = new CommandEditDialog(this); connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); m->showMaximized(); } } + +// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' +void Konsole::setDocument( const QString &cmd) { + newSession(); + TEWidget* te = getTe(); + if(cmd.find("-e", 0, TRUE) != -1) { + QString cmd2; + cmd2=cmd.right(cmd.length()-3)+" &"; + system(cmd2.latin1()); + if(startUp <= 1 && nsessions < 2) { + doneSession(getTe()->currentSession, 0); + exit(0); + } else + doneSession(getTe()->currentSession, 0); + } else { + if (te != 0) { + te->emitText(cmd+"\r"); + } + } + startUp++; +} + +void Konsole::parseCommandLine() { + QString cmd; + // newSession(); + for (int i=1;i< qApp->argc();i++) { + if( QString(qApp->argv()[i]) == "-e") { + i++; + for ( int j=i;j< qApp->argc();j++) { + cmd+=QString(qApp->argv()[j])+" "; + } + cmd.stripWhiteSpace(); + system(cmd.latin1()); + exit(0);//close(); + } // end -e switch + } + startUp++; +} diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h index b508cf8..40edaec 100644 --- a/core/apps/embeddedkonsole/konsole.h +++ b/core/apps/embeddedkonsole/konsole.h @@ -49,17 +49,19 @@ public: Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); Konsole(const char * name, const char* pgm, QStrList & _args, int histon); ~Konsole(); void setColLin(int columns, int lines); QPEToolBar *secondToolBar; void show(); void setColor(); int lastSelectedMenu; + int startUp; private slots: + void setDocument(const QString &); void doneSession(TESession*,int); void changeColumns(int); void fontChanged(int); void configMenuSelected(int ); void colorMenuSelected(int); void enterCommand(int); void hitEnter(); void hitSpace(); @@ -68,16 +70,17 @@ private slots: void hitUp(); void hitDown(); void switchSession(QWidget *); void newSession(); void changeCommand(const QString &, int); void initCommandList(); void scrollMenuSelected(int); void editCommandListMenuSelected(int); + void parseCommandLine(); private: void init(const char* _pgm, QStrList & _args); void initSession(const char* _pgm, QStrList & _args); void runSession(TESession* s); void setColorPixmaps(); void setHistory(bool); QSize calcSize(int columns, int lines); TEWidget* getTe(); |