summaryrefslogtreecommitdiff
path: root/core/apps/embeddedkonsole/konsole.cpp
authorllornkcor <llornkcor>2002-04-05 13:17:19 (UTC)
committer llornkcor <llornkcor>2002-04-05 13:17:19 (UTC)
commit1896c5fa43e465567595feb442013d75c476f090 (patch) (unidiff)
treee8ea13fd45277f0b8d7af52f4938f411fd9ed4af /core/apps/embeddedkonsole/konsole.cpp
parentdd5bc1f9d61cdd8cfde4c7a7fbba3b53b77b2670 (diff)
downloadopie-1896c5fa43e465567595feb442013d75c476f090.zip
opie-1896c5fa43e465567595feb442013d75c476f090.tar.gz
opie-1896c5fa43e465567595feb442013d75c476f090.tar.bz2
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.
Diffstat (limited to 'core/apps/embeddedkonsole/konsole.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp45
1 files changed, 42 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
@@ -15,12 +15,13 @@
15/* */ 15/* */
16/* Ported Konsole to Qt/Embedded */ 16/* Ported Konsole to Qt/Embedded */
17/* */ 17/* */
18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ 18/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
19/* */ 19/* */
20/* -------------------------------------------------------------------------- */ 20/* -------------------------------------------------------------------------- */
21// enhancements added by L.J. Potter <ljp@llornkcor.com>
21 22
22#include <qpe/resource.h> 23#include <qpe/resource.h>
23 24
24#include <qdir.h> 25#include <qdir.h>
25#include <qevent.h> 26#include <qevent.h>
26#include <qdragobject.h> 27#include <qdragobject.h>
@@ -198,13 +199,13 @@ void Konsole::initCommandList()
198 199
199void Konsole::init(const char* _pgm, QStrList & _args) 200void Konsole::init(const char* _pgm, QStrList & _args)
200{ 201{
201 b_scroll = TRUE; // histon; 202 b_scroll = TRUE; // histon;
202 n_keytab = 0; 203 n_keytab = 0;
203 n_render = 0; 204 n_render = 0;
204 205 startUp=0;
205 setCaption( tr("Terminal") ); 206 setCaption( tr("Terminal") );
206 setIcon( Resource::loadPixmap( "konsole" ) ); 207 setIcon( Resource::loadPixmap( "konsole" ) );
207 208
208 Config cfg("Konsole"); 209 Config cfg("Konsole");
209 cfg.setGroup("Konsole"); 210 cfg.setGroup("Konsole");
210 QString tmp; 211 QString tmp;
@@ -361,18 +362,18 @@ void Konsole::init(const char* _pgm, QStrList & _args)
361 assert( s ); 362 assert( s );
362 } 363 }
363 364
364 se_pgm = _pgm; 365 se_pgm = _pgm;
365 se_args = _args; 366 se_args = _args;
366 367
368parseCommandLine();
367 // read and apply default values /////////////////////////////////////////// 369 // read and apply default values ///////////////////////////////////////////
368 resize(321, 321); // Dummy. 370 resize(321, 321); // Dummy.
369 QSize currentSize = size(); 371 QSize currentSize = size();
370 if (currentSize != size()) 372 if (currentSize != size())
371 defaultSize = size(); 373 defaultSize = size();
372
373} 374}
374 375
375void Konsole::show() 376void Konsole::show()
376{ 377{
377 if ( !nsessions ) { 378 if ( !nsessions ) {
378 newSession(); 379 newSession();
@@ -386,13 +387,13 @@ void Konsole::initSession(const char*, QStrList &)
386} 387}
387 388
388Konsole::~Konsole() 389Konsole::~Konsole()
389{ 390{
390 while (nsessions > 0) { 391 while (nsessions > 0) {
391 doneSession(getTe()->currentSession, 0); 392 doneSession(getTe()->currentSession, 0);
392 } 393 }
393 394
394 Config cfg("Konsole"); 395 Config cfg("Konsole");
395 cfg.setGroup("Konsole"); 396 cfg.setGroup("Konsole");
396 cfg.writeEntry("FontID", cfont); 397 cfg.writeEntry("FontID", cfont);
397} 398}
398 399
@@ -840,6 +841,44 @@ void Konsole::editCommandListMenuSelected(int iD)
840 CommandEditDialog *m = new CommandEditDialog(this); 841 CommandEditDialog *m = new CommandEditDialog(this);
841 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); 842 connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList()));
842 m->showMaximized(); 843 m->showMaximized();
843 } 844 }
844 845
845} 846}
847
848// $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V'
849void Konsole::setDocument( const QString &cmd) {
850 newSession();
851 TEWidget* te = getTe();
852 if(cmd.find("-e", 0, TRUE) != -1) {
853 QString cmd2;
854 cmd2=cmd.right(cmd.length()-3)+" &";
855 system(cmd2.latin1());
856 if(startUp <= 1 && nsessions < 2) {
857 doneSession(getTe()->currentSession, 0);
858 exit(0);
859 } else
860 doneSession(getTe()->currentSession, 0);
861 } else {
862 if (te != 0) {
863 te->emitText(cmd+"\r");
864 }
865 }
866 startUp++;
867}
868
869void Konsole::parseCommandLine() {
870 QString cmd;
871 // newSession();
872 for (int i=1;i< qApp->argc();i++) {
873 if( QString(qApp->argv()[i]) == "-e") {
874 i++;
875 for ( int j=i;j< qApp->argc();j++) {
876 cmd+=QString(qApp->argv()[j])+" ";
877 }
878 cmd.stripWhiteSpace();
879 system(cmd.latin1());
880 exit(0);//close();
881 } // end -e switch
882 }
883 startUp++;
884}