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
@@ -7,166 +7,165 @@
7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ 7/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
8/* */ 8/* */
9/* This file is part of Konsole, an X terminal. */ 9/* This file is part of Konsole, an X terminal. */
10/* */ 10/* */
11/* The material contained in here more or less directly orginates from */ 11/* The material contained in here more or less directly orginates from */
12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ 12/* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */
13/* */ 13/* */
14/* ---------------------------------------------------------------------- */ 14/* ---------------------------------------------------------------------- */
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 21
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23 23
24#include <qdir.h> 24#include <qdir.h>
25#include <qevent.h> 25#include <qevent.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qobjectlist.h> 27#include <qobjectlist.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qpe/qpetoolbar.h> 29#include <qpe/qpetoolbar.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
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 }
80}; 79};
81 80
82class EKNumTabWidget : public QTabWidget { 81class EKNumTabWidget : public QTabWidget {
83public: 82public:
84 EKNumTabWidget(QWidget* parent) : QTabWidget(parent) 83 EKNumTabWidget(QWidget* parent) : QTabWidget(parent)
85 { 84 {
86 } 85 }
87 86
88 void addTab(QWidget* w) 87 void addTab(QWidget* w)
89 { 88 {
90 QTab* t = new QTab(QString::number(tabBar()->count()+1)); 89 QTab* t = new QTab(QString::number(tabBar()->count()+1));
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",
149 "ping", 148 "ping",
150 "mount", 149 "mount",
151 "more", 150 "more",
152 "sort", 151 "sort",
153 "touch", 152 "touch",
154 "umount", 153 "umount",
155 "mknod", 154 "mknod",
156 "netstat", 155 "netstat",
157*/ 156*/
158 157
159 "exit", 158 "exit",
160 NULL 159 NULL
161}; 160};
162 161
163 162
164Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : 163Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) :
165 QMainWindow(parent, name, fl) 164 QMainWindow(parent, name, fl)
166{ 165{
167 QStrList args; 166 QStrList args;
168 init("/bin/sh",args); 167 init("/bin/sh",args);
169} 168}
170 169
171Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) 170Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int)
172 : QMainWindow(0, name) 171 : QMainWindow(0, name)
@@ -252,100 +251,102 @@ void Konsole::init(const char* _pgm, QStrList & _args)
252 colorMenu->insertItem("Black on Red"); 251 colorMenu->insertItem("Black on Red");
253 colorMenu->insertItem("Red on Black"); 252 colorMenu->insertItem("Red on Black");
254 colorMenu->insertItem("Green on Yellow"); 253 colorMenu->insertItem("Green on Yellow");
255 colorMenu->insertItem("Blue on Magenta"); 254 colorMenu->insertItem("Blue on Magenta");
256 colorMenu->insertItem("Magenta on Blue"); 255 colorMenu->insertItem("Magenta on Blue");
257 colorMenu->insertItem("Cyan on White"); 256 colorMenu->insertItem("Cyan on White");
258 colorMenu->insertItem("White on Cyan"); 257 colorMenu->insertItem("White on Cyan");
259 colorMenu->insertItem("Blue on Black"); 258 colorMenu->insertItem("Blue on Black");
260 configMenu->insertItem("Colors",colorMenu); 259 configMenu->insertItem("Colors",colorMenu);
261 260
262 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); 261 connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) ));
263 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); 262 connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) ));
264 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); 263 connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) ));
265 264
266 menuBar->insertItem( tr("Font"), fontList ); 265 menuBar->insertItem( tr("Font"), fontList );
267 menuBar->insertItem( tr("Options"), configMenu ); 266 menuBar->insertItem( tr("Options"), configMenu );
268 267
269 QPEToolBar *toolbar = new QPEToolBar( this ); 268 QPEToolBar *toolbar = new QPEToolBar( this );
270 269
271 QAction *a; 270 QAction *a;
272 271
273 // Button Commands 272 // Button Commands
274 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); 273 a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 );
275 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); 274 connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar );
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;
328 329
329 // read and apply default values /////////////////////////////////////////// 330 // read and apply default values ///////////////////////////////////////////
330 resize(321, 321); // Dummy. 331 resize(321, 321); // Dummy.
331 QSize currentSize = size(); 332 QSize currentSize = size();
332 if (currentSize != size()) 333 if (currentSize != size())
333 defaultSize = size(); 334 defaultSize = size();
334 335
335} 336}
336 337
337void Konsole::show() 338void Konsole::show()
338{ 339{
339 if ( !nsessions ) { 340 if ( !nsessions ) {
340 newSession(); 341 newSession();
341 } 342 }
342 QMainWindow::show(); 343 QMainWindow::show();
343} 344}
344 345
345void Konsole::initSession(const char*, QStrList &) 346void Konsole::initSession(const char*, QStrList &)
346{ 347{
347 QMainWindow::show(); 348 QMainWindow::show();
348} 349}
349 350
350Konsole::~Konsole() 351Konsole::~Konsole()
351{ 352{