author | llornkcor <llornkcor> | 2002-02-02 00:17:02 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-02 00:17:02 (UTC) |
commit | 612f02246dbb07db268e158f6959727a6598c6d5 (patch) (unidiff) | |
tree | 7dceba4874ad04c35bd6e0cf7c0d053d931ea6d2 | |
parent | 5a3c8bf8c1033882685f3a6d897c6fa5229403e3 (diff) | |
download | opie-612f02246dbb07db268e158f6959727a6598c6d5.zip opie-612f02246dbb07db268e158f6959727a6598c6d5.tar.gz opie-612f02246dbb07db268e158f6959727a6598c6d5.tar.bz2 |
startup command list edit enable bug fixed. added env to commandlist
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 11 |
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 | |||
@@ -1,495 +1,496 @@ | |||
1 | /* ---------------------------------------------------------------------- */ | 1 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [main.C] Konsole */ | 3 | /* [main.C] Konsole */ |
4 | /* */ | 4 | /* */ |
5 | /* ---------------------------------------------------------------------- */ | 5 | /* ---------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
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 | |||
56 | class EKNumTabBar : public QTabBar { | 55 | class EKNumTabBar : public QTabBar { |
57 | public: | 56 | public: |
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 | ||
82 | class EKNumTabWidget : public QTabWidget { | 81 | class EKNumTabWidget : public QTabWidget { |
83 | public: | 82 | public: |
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 |
103 | static const char *commonCmds[] = | 102 | static 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 | ||
164 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 163 | Konsole::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 | ||
171 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 170 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
172 | : QMainWindow(0, name) | 171 | : QMainWindow(0, name) |
173 | { | 172 | { |
174 | init(_pgm,_args); | 173 | init(_pgm,_args); |
175 | } | 174 | } |
176 | 175 | ||
177 | void Konsole::init(const char* _pgm, QStrList & _args) | 176 | void Konsole::init(const char* _pgm, QStrList & _args) |
178 | { | 177 | { |
179 | b_scroll = TRUE; // histon; | 178 | b_scroll = TRUE; // histon; |
180 | n_keytab = 0; | 179 | n_keytab = 0; |
181 | n_render = 0; | 180 | n_render = 0; |
182 | 181 | ||
183 | setCaption( tr("Terminal") ); | 182 | setCaption( tr("Terminal") ); |
184 | setIcon( Resource::loadPixmap( "konsole" ) ); | 183 | setIcon( Resource::loadPixmap( "konsole" ) ); |
185 | 184 | ||
186 | Config cfg("Konsole"); | 185 | Config cfg("Konsole"); |
187 | cfg.setGroup("Konsole"); | 186 | cfg.setGroup("Konsole"); |
188 | QString tmp; | 187 | QString tmp; |
189 | // initialize the list of allowed fonts /////////////////////////////////// | 188 | // initialize the list of allowed fonts /////////////////////////////////// |
190 | cfont = cfg.readNumEntry("FontID", 1); | 189 | cfont = cfg.readNumEntry("FontID", 1); |
191 | QFont f = QFont("Micro", 4, QFont::Normal); | 190 | QFont f = QFont("Micro", 4, QFont::Normal); |
192 | f.setFixedPitch(TRUE); | 191 | f.setFixedPitch(TRUE); |
193 | fonts.append(new VTFont(tr("Micro"), f)); | 192 | fonts.append(new VTFont(tr("Micro"), f)); |
194 | 193 | ||
195 | f = QFont("Fixed", 7, QFont::Normal); | 194 | f = QFont("Fixed", 7, QFont::Normal); |
196 | f.setFixedPitch(TRUE); | 195 | f.setFixedPitch(TRUE); |
197 | fonts.append(new VTFont(tr("Small Fixed"), f)); | 196 | fonts.append(new VTFont(tr("Small Fixed"), f)); |
198 | 197 | ||
199 | f = QFont("Fixed", 12, QFont::Normal); | 198 | f = QFont("Fixed", 12, QFont::Normal); |
200 | f.setFixedPitch(TRUE); | 199 | f.setFixedPitch(TRUE); |
201 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | 200 | fonts.append(new VTFont(tr("Medium Fixed"), f)); |
202 | 201 | ||
203 | // create terminal emulation framework //////////////////////////////////// | 202 | // create terminal emulation framework //////////////////////////////////// |
204 | nsessions = 0; | 203 | nsessions = 0; |
205 | 204 | ||
206 | tab = new EKNumTabWidget(this); | 205 | tab = new EKNumTabWidget(this); |
207 | 206 | ||
208 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 207 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
209 | 208 | ||
210 | // create terminal toolbar //////////////////////////////////////////////// | 209 | // create terminal toolbar //////////////////////////////////////////////// |
211 | setToolBarsMovable( FALSE ); | 210 | setToolBarsMovable( FALSE ); |
212 | QPEToolBar *menuToolBar = new QPEToolBar( this ); | 211 | QPEToolBar *menuToolBar = new QPEToolBar( this ); |
213 | menuToolBar->setHorizontalStretchable( TRUE ); | 212 | menuToolBar->setHorizontalStretchable( TRUE ); |
214 | 213 | ||
215 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); | 214 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); |
216 | 215 | ||
217 | fontList = new QPopupMenu( this ); | 216 | fontList = new QPopupMenu( this ); |
218 | for(uint i = 0; i < fonts.count(); i++) { | 217 | for(uint i = 0; i < fonts.count(); i++) { |
219 | VTFont *fnt = fonts.at(i); | 218 | VTFont *fnt = fonts.at(i); |
220 | fontList->insertItem(fnt->getName(), i); | 219 | fontList->insertItem(fnt->getName(), i); |
221 | } | 220 | } |
222 | fontChanged(cfont); | 221 | fontChanged(cfont); |
223 | 222 | ||
224 | configMenu = new QPopupMenu( this); | 223 | configMenu = new QPopupMenu( this); |
225 | colorMenu = new QPopupMenu( this); | 224 | colorMenu = new QPopupMenu( this); |
226 | 225 | ||
227 | bool listHidden; | 226 | bool listHidden; |
228 | cfg.setGroup("Menubar"); | 227 | cfg.setGroup("Menubar"); |
229 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 228 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
230 | configMenu->insertItem("Show command list"); | 229 | configMenu->insertItem("Show command list"); |
231 | listHidden=TRUE; | 230 | listHidden=TRUE; |
232 | } else { | 231 | } else { |
233 | configMenu->insertItem("Hide command list"); | 232 | configMenu->insertItem("Hide command list"); |
234 | listHidden=FALSE; | 233 | listHidden=FALSE; |
235 | } | 234 | } |
236 | 235 | ||
237 | cfg.setGroup("Tabs"); | 236 | cfg.setGroup("Tabs"); |
238 | tmp=cfg.readEntry("Position","Bottom"); | 237 | tmp=cfg.readEntry("Position","Bottom"); |
239 | if(tmp=="Top") { | 238 | if(tmp=="Top") { |
240 | tab->setTabPosition(QTabWidget::Top); | 239 | tab->setTabPosition(QTabWidget::Top); |
241 | configMenu->insertItem("Tabs on Bottom"); | 240 | configMenu->insertItem("Tabs on Bottom"); |
242 | } else { | 241 | } else { |
243 | tab->setTabPosition(QTabWidget::Bottom); | 242 | tab->setTabPosition(QTabWidget::Bottom); |
244 | configMenu->insertItem("Tabs on Top"); | 243 | configMenu->insertItem("Tabs on Top"); |
245 | } | 244 | } |
246 | configMenu->insertSeparator(2); | 245 | configMenu->insertSeparator(2); |
247 | 246 | ||
248 | colorMenu->insertItem("Green on Black"); | 247 | colorMenu->insertItem("Green on Black"); |
249 | colorMenu->insertItem("Black on White"); | 248 | colorMenu->insertItem("Black on White"); |
250 | colorMenu->insertItem("White on Black"); | 249 | colorMenu->insertItem("White on Black"); |
251 | colorMenu->insertItem("Black on Transparent"); | 250 | colorMenu->insertItem("Black on Transparent"); |
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 | ||
337 | void Konsole::show() | 338 | void 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 | ||
345 | void Konsole::initSession(const char*, QStrList &) | 346 | void Konsole::initSession(const char*, QStrList &) |
346 | { | 347 | { |
347 | QMainWindow::show(); | 348 | QMainWindow::show(); |
348 | } | 349 | } |
349 | 350 | ||
350 | Konsole::~Konsole() | 351 | Konsole::~Konsole() |
351 | { | 352 | { |
352 | while (nsessions > 0) { | 353 | while (nsessions > 0) { |
353 | doneSession(getTe()->currentSession, 0); | 354 | doneSession(getTe()->currentSession, 0); |
354 | } | 355 | } |
355 | 356 | ||
356 | Config cfg("Konsole"); | 357 | Config cfg("Konsole"); |
357 | cfg.setGroup("Konsole"); | 358 | cfg.setGroup("Konsole"); |
358 | cfg.writeEntry("FontID", cfont); | 359 | cfg.writeEntry("FontID", cfont); |
359 | } | 360 | } |
360 | 361 | ||
361 | void Konsole::fontChanged(int f) | 362 | void Konsole::fontChanged(int f) |
362 | { | 363 | { |
363 | VTFont* font = fonts.at(f); | 364 | VTFont* font = fonts.at(f); |
364 | if (font != 0) { | 365 | if (font != 0) { |
365 | for(uint i = 0; i < fonts.count(); i++) { | 366 | for(uint i = 0; i < fonts.count(); i++) { |
366 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 367 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
367 | } | 368 | } |
368 | 369 | ||
369 | cfont = f; | 370 | cfont = f; |
370 | 371 | ||
371 | TEWidget* te = getTe(); | 372 | TEWidget* te = getTe(); |
372 | if (te != 0) { | 373 | if (te != 0) { |
373 | te->setVTFont(font->getFont()); | 374 | te->setVTFont(font->getFont()); |
374 | } | 375 | } |
375 | } | 376 | } |
376 | } | 377 | } |
377 | 378 | ||
378 | 379 | ||
379 | void Konsole::enterCommand(int c) | 380 | void Konsole::enterCommand(int c) |
380 | { | 381 | { |
381 | TEWidget* te = getTe(); | 382 | TEWidget* te = getTe(); |
382 | if (te != 0) { | 383 | if (te != 0) { |
383 | if(!commonCombo->editable()) { | 384 | if(!commonCombo->editable()) { |
384 | QString text = commonCombo->text(c); //commonCmds[c]; | 385 | QString text = commonCombo->text(c); //commonCmds[c]; |
385 | te->emitText(text); | 386 | te->emitText(text); |
386 | } else { | 387 | } else { |
387 | changeCommand( commonCombo->text(c), c); | 388 | changeCommand( commonCombo->text(c), c); |
388 | } | 389 | } |
389 | } | 390 | } |
390 | } | 391 | } |
391 | 392 | ||
392 | void Konsole::hitEnter() | 393 | void Konsole::hitEnter() |
393 | { | 394 | { |
394 | TEWidget* te = getTe(); | 395 | TEWidget* te = getTe(); |
395 | if (te != 0) { | 396 | if (te != 0) { |
396 | te->emitText(QString("\r")); | 397 | te->emitText(QString("\r")); |
397 | } | 398 | } |
398 | } | 399 | } |
399 | 400 | ||
400 | void Konsole::hitSpace() | 401 | void Konsole::hitSpace() |
401 | { | 402 | { |
402 | TEWidget* te = getTe(); | 403 | TEWidget* te = getTe(); |
403 | if (te != 0) { | 404 | if (te != 0) { |
404 | te->emitText(QString(" ")); | 405 | te->emitText(QString(" ")); |
405 | } | 406 | } |
406 | } | 407 | } |
407 | 408 | ||
408 | void Konsole::hitTab() | 409 | void Konsole::hitTab() |
409 | { | 410 | { |
410 | TEWidget* te = getTe(); | 411 | TEWidget* te = getTe(); |
411 | if (te != 0) { | 412 | if (te != 0) { |
412 | te->emitText(QString("\t")); | 413 | te->emitText(QString("\t")); |
413 | } | 414 | } |
414 | } | 415 | } |
415 | 416 | ||
416 | void Konsole::hitPaste() | 417 | void Konsole::hitPaste() |
417 | { | 418 | { |
418 | TEWidget* te = getTe(); | 419 | TEWidget* te = getTe(); |
419 | if (te != 0) { | 420 | if (te != 0) { |
420 | te->pasteClipboard(); | 421 | te->pasteClipboard(); |
421 | } | 422 | } |
422 | } | 423 | } |
423 | 424 | ||
424 | void Konsole::hitUp() | 425 | void Konsole::hitUp() |
425 | { | 426 | { |
426 | TEWidget* te = getTe(); | 427 | TEWidget* te = getTe(); |
427 | if (te != 0) { | 428 | if (te != 0) { |
428 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 429 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
429 | QApplication::sendEvent( te, &ke ); | 430 | QApplication::sendEvent( te, &ke ); |
430 | } | 431 | } |
431 | } | 432 | } |
432 | 433 | ||
433 | void Konsole::hitDown() | 434 | void Konsole::hitDown() |
434 | { | 435 | { |
435 | TEWidget* te = getTe(); | 436 | TEWidget* te = getTe(); |
436 | if (te != 0) { | 437 | if (te != 0) { |
437 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 438 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
438 | QApplication::sendEvent( te, &ke ); | 439 | QApplication::sendEvent( te, &ke ); |
439 | } | 440 | } |
440 | } | 441 | } |
441 | 442 | ||
442 | /** | 443 | /** |
443 | This function calculates the size of the external widget | 444 | This function calculates the size of the external widget |
444 | needed for the internal widget to be | 445 | needed for the internal widget to be |
445 | */ | 446 | */ |
446 | QSize Konsole::calcSize(int columns, int lines) { | 447 | QSize Konsole::calcSize(int columns, int lines) { |
447 | TEWidget* te = getTe(); | 448 | TEWidget* te = getTe(); |
448 | if (te != 0) { | 449 | if (te != 0) { |
449 | QSize size = te->calcSize(columns, lines); | 450 | QSize size = te->calcSize(columns, lines); |
450 | return size; | 451 | return size; |
451 | } else { | 452 | } else { |
452 | QSize size; | 453 | QSize size; |
453 | return size; | 454 | return size; |
454 | } | 455 | } |
455 | } | 456 | } |
456 | 457 | ||
457 | /** | 458 | /** |
458 | sets application window to a size based on columns X lines of the te | 459 | sets application window to a size based on columns X lines of the te |
459 | guest widget. Call with (0,0) for setting default size. | 460 | guest widget. Call with (0,0) for setting default size. |
460 | */ | 461 | */ |
461 | 462 | ||
462 | void Konsole::setColLin(int columns, int lines) | 463 | void Konsole::setColLin(int columns, int lines) |
463 | { | 464 | { |
464 | if ((columns==0) || (lines==0)) | 465 | if ((columns==0) || (lines==0)) |
465 | { | 466 | { |
466 | if (defaultSize.isEmpty()) // not in config file : set default value | 467 | if (defaultSize.isEmpty()) // not in config file : set default value |
467 | { | 468 | { |
468 | defaultSize = calcSize(80,24); | 469 | defaultSize = calcSize(80,24); |
469 | // notifySize(24,80); // set menu items (strange arg order !) | 470 | // notifySize(24,80); // set menu items (strange arg order !) |
470 | } | 471 | } |
471 | resize(defaultSize); | 472 | resize(defaultSize); |
472 | } else { | 473 | } else { |
473 | resize(calcSize(columns, lines)); | 474 | resize(calcSize(columns, lines)); |
474 | // notifySize(lines,columns); // set menu items (strange arg order !) | 475 | // notifySize(lines,columns); // set menu items (strange arg order !) |
475 | } | 476 | } |
476 | } | 477 | } |
477 | 478 | ||
478 | /* | 479 | /* |
479 | void Konsole::setFont(int fontno) | 480 | void Konsole::setFont(int fontno) |
480 | { | 481 | { |
481 | QFont f; | 482 | QFont f; |
482 | if (fontno == 0) | 483 | if (fontno == 0) |
483 | f = defaultFont = QFont( "Helvetica", 12 ); | 484 | f = defaultFont = QFont( "Helvetica", 12 ); |
484 | else | 485 | else |
485 | if (fonts[fontno][0] == '-') | 486 | if (fonts[fontno][0] == '-') |
486 | f.setRawName( fonts[fontno] ); | 487 | f.setRawName( fonts[fontno] ); |
487 | else | 488 | else |
488 | { | 489 | { |
489 | f.setFamily(fonts[fontno]); | 490 | f.setFamily(fonts[fontno]); |
490 | f.setRawMode( TRUE ); | 491 | f.setRawMode( TRUE ); |
491 | } | 492 | } |
492 | if ( !f.exactMatch() && fontno != 0) | 493 | if ( !f.exactMatch() && fontno != 0) |
493 | { | 494 | { |
494 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 495 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
495 | QMessageBox(this, msg); | 496 | QMessageBox(this, msg); |