summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/embeddedkonsole/konsole.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp
index efcb1f2..f154bb8 100644
--- a/core/apps/embeddedkonsole/konsole.cpp
+++ b/core/apps/embeddedkonsole/konsole.cpp
@@ -31,49 +31,48 @@
31#include <qfontdialog.h> 31#include <qfontdialog.h>
32#include <qglobal.h> 32#include <qglobal.h>
33#include <qpainter.h> 33#include <qpainter.h>
34#include <qpe/qpemenubar.h> 34#include <qpe/qpemenubar.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <qaction.h> 36#include <qaction.h>
37#include <qapplication.h> 37#include <qapplication.h>
38#include <qfontmetrics.h> 38#include <qfontmetrics.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qevent.h> 40#include <qevent.h>
41#include <qtabwidget.h> 41#include <qtabwidget.h>
42#include <qtabbar.h> 42#include <qtabbar.h>
43#include <qpe/config.h> 43#include <qpe/config.h>
44#include <qstringlist.h> 44#include <qstringlist.h>
45#include <qpalette.h> 45#include <qpalette.h>
46 46
47#include <sys/wait.h> 47#include <sys/wait.h>
48#include <stdio.h> 48#include <stdio.h>
49#include <stdlib.h> 49#include <stdlib.h>
50#include <assert.h> 50#include <assert.h>
51 51
52#include "konsole.h" 52#include "konsole.h"
53#include "keytrans.h" 53#include "keytrans.h"
54 54
55
56class EKNumTabBar : public QTabBar { 55class EKNumTabBar : public QTabBar {
57public: 56public:
58 void numberTabs() 57 void numberTabs()
59 { 58 {
60 // Yes, it really is this messy. QTabWidget needs functions 59 // Yes, it really is this messy. QTabWidget needs functions
61 // that provide acces to tabs in a sequential way. 60 // that provide acces to tabs in a sequential way.
62 int m=INT_MIN; 61 int m=INT_MIN;
63 for (int i=0; i<count(); i++) { 62 for (int i=0; i<count(); i++) {
64 QTab* left=0; 63 QTab* left=0;
65 QListIterator<QTab> it(*tabList()); 64 QListIterator<QTab> it(*tabList());
66 int x=INT_MAX; 65 int x=INT_MAX;
67 for( QTab* t; (t=it.current()); ++it ) { 66 for( QTab* t; (t=it.current()); ++it ) {
68 int tx = t->rect().x(); 67 int tx = t->rect().x();
69 if ( tx<x && tx>m ) { 68 if ( tx<x && tx>m ) {
70 x = tx; 69 x = tx;
71 left = t; 70 left = t;
72 } 71 }
73 } 72 }
74 if ( left ) { 73 if ( left ) {
75 left->setText(QString::number(i+1)); 74 left->setText(QString::number(i+1));
76 m = left->rect().x(); 75 m = left->rect().x();
77 } 76 }
78 } 77 }
79 } 78 }
@@ -91,58 +90,58 @@ public:
91 QTabWidget::addTab(w,t); 90 QTabWidget::addTab(w,t);
92 } 91 }
93 92
94 void removeTab(QWidget* w) 93 void removeTab(QWidget* w)
95 { 94 {
96 removePage(w); 95 removePage(w);
97 ((EKNumTabBar*)tabBar())->numberTabs(); 96 ((EKNumTabBar*)tabBar())->numberTabs();
98 } 97 }
99}; 98};
100 99
101// This could be configurable or dynamicly generated from the bash history 100// This could be configurable or dynamicly generated from the bash history
102// file of the user 101// file of the user
103static const char *commonCmds[] = 102static const char *commonCmds[] =
104{ 103{
105 "ls ", // I left this here, cause it looks better than the first alpha 104 "ls ", // I left this here, cause it looks better than the first alpha
106 "cardctl eject", 105 "cardctl eject",
107 "cat ", 106 "cat ",
108 "cd ", 107 "cd ",
109 "chmod ", 108 "chmod ",
110 "cp ", 109 "cp ",
111 "dc ", 110 "dc ",
112 "df ", 111 "df ",
113 "dmesg", 112 "dmesg",
114 "echo ", 113 "echo ",
114 "env",
115 "find ", 115 "find ",
116 "free", 116 "free",
117 "grep ", 117 "grep ",
118 "ifconfig ", 118 "ifconfig ",
119 "ipkg ", 119 "ipkg ",
120 "mkdir ", 120 "mkdir ",
121 "mv ", 121 "mv ",
122 "nc localhost 7776", 122 "nc localhost 7776",
123 "nc localhost 7777", 123 "nc localhost 7777",
124 "netstat ",
125 "nslookup ", 124 "nslookup ",
126 "ping ", 125 "ping ",
127 "ps aux", 126 "ps aux",
128 "pwd ", 127 "pwd ",
129 "rm ", 128 "rm ",
130 "rmdir ", 129 "rmdir ",
131 "route ", 130 "route ",
132 "set ", 131 "set ",
133 "traceroute", 132 "traceroute",
134 133
135/* 134/*
136 "gzip", 135 "gzip",
137 "gunzip", 136 "gunzip",
138 "chgrp", 137 "chgrp",
139 "chown", 138 "chown",
140 "date", 139 "date",
141 "dd", 140 "dd",
142 "df", 141 "df",
143 "dmesg", 142 "dmesg",
144 "fuser", 143 "fuser",
145 "hostname", 144 "hostname",
146 "kill", 145 "kill",
147 "killall", 146 "killall",
148 "ln", 147 "ln",
@@ -276,52 +275,54 @@ void Konsole::init(const char* _pgm, QStrList & _args)
276 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); 275 a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 );
277 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); 276 connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar );
278 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); 277 a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 );
279 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); 278 connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar );
280 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); 279 a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 );
281 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); 280 connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar );
282 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); 281 a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 );
283 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 282 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
284 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); 283 a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 );
285 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 284 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
286 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); 285 a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
287 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); 286 connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar );
288/* 287/*
289 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); 288 a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 );
290 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); 289 connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar );
291 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); 290 a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 );
292 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); 291 connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar );
293*/ 292*/
294 293
295 secondToolBar = new QPEToolBar( this ); 294 secondToolBar = new QPEToolBar( this );
296 secondToolBar->setHorizontalStretchable( TRUE ); 295 secondToolBar->setHorizontalStretchable( TRUE );
297 296
298 commonCombo = new QComboBox( secondToolBar ); 297 commonCombo = new QComboBox( secondToolBar );
299 298
300 if( listHidden)
301 secondToolBar->hide();
302 configMenu->insertItem( "Edit Command List"); 299 configMenu->insertItem( "Edit Command List");
303 300 if( listHidden) {
301 secondToolBar->hide();
302 configMenu->setItemEnabled(-20 ,FALSE);
303 }
304
304 cfg.setGroup("Commands"); 305 cfg.setGroup("Commands");
305 commonCombo->setInsertionPolicy(QComboBox::AtCurrent); 306 commonCombo->setInsertionPolicy(QComboBox::AtCurrent);
306 307
307 for (int i = 0; commonCmds[i] != NULL; i++) { 308 for (int i = 0; commonCmds[i] != NULL; i++) {
308 commonCombo->insertItem( commonCmds[i], i ); 309 commonCombo->insertItem( commonCmds[i], i );
309 tmp = cfg.readEntry( QString::number(i),""); 310 tmp = cfg.readEntry( QString::number(i),"");
310 if(tmp != "") 311 if(tmp != "")
311 commonCombo->changeItem( tmp,i ); 312 commonCombo->changeItem( tmp,i );
312 } 313 }
313 314
314 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); 315 connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) ));
315 316
316 // create applications ///////////////////////////////////////////////////// 317 // create applications /////////////////////////////////////////////////////
317 setCentralWidget(tab); 318 setCentralWidget(tab);
318 319
319 // load keymaps //////////////////////////////////////////////////////////// 320 // load keymaps ////////////////////////////////////////////////////////////
320 KeyTrans::loadAll(); 321 KeyTrans::loadAll();
321 for (int i = 0; i < KeyTrans::count(); i++) 322 for (int i = 0; i < KeyTrans::count(); i++)
322 { KeyTrans* s = KeyTrans::find(i); 323 { KeyTrans* s = KeyTrans::find(i);
323 assert( s ); 324 assert( s );
324 } 325 }
325 326
326 se_pgm = _pgm; 327 se_pgm = _pgm;
327 se_args = _args; 328 se_args = _args;