From 1896c5fa43e465567595feb442013d75c476f090 Mon Sep 17 00:00:00 2001 From: llornkcor Date: Fri, 05 Apr 2002 13:17:19 +0000 Subject: Folded in changes I forgot about. Added -e argument to execute a command and leave the konsole, and also setDocument to exec command in new session if open. so a command run like $OPIEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' will run that command in a new session (tab). So now scripts can be run from an icon, and such. --- (limited to 'core/apps') 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 @@ -18,6 +18,7 @@ /* Copyright (C) 2000 by John Ryland */ /* */ /* -------------------------------------------------------------------------- */ +// enhancements added by L.J. Potter #include @@ -201,7 +202,7 @@ 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" ) ); @@ -364,12 +365,12 @@ void Konsole::init(const char* _pgm, QStrList & _args) 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() @@ -389,7 +390,7 @@ Konsole::~Konsole() { while (nsessions > 0) { doneSession(getTe()->currentSession, 0); - } + } Config cfg("Konsole"); cfg.setGroup("Konsole"); @@ -843,3 +844,41 @@ void Konsole::editCommandListMenuSelected(int iD) } } + +// $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 @@ -54,7 +54,9 @@ public: void show(); void setColor(); int lastSelectedMenu; + int startUp; private slots: + void setDocument(const QString &); void doneSession(TESession*,int); void changeColumns(int); void fontChanged(int); @@ -73,6 +75,7 @@ private slots: 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); -- cgit v0.9.0.2