-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 8ca55fe..70acc42 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,790 +1,790 @@ | |||
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 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
22 | //#define QT_QWS_OPIE | 22 | #define QT_QWS_OPIE |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qevent.h> | 27 | #include <qevent.h> |
28 | #include <qdragobject.h> | 28 | #include <qdragobject.h> |
29 | #include <qobjectlist.h> | 29 | #include <qobjectlist.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | #include <qpe/qpetoolbar.h> | 31 | #include <qpe/qpetoolbar.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qfontdialog.h> | 33 | #include <qfontdialog.h> |
34 | #include <qglobal.h> | 34 | #include <qglobal.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <qaction.h> | 38 | #include <qaction.h> |
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #include <qfontmetrics.h> | 40 | #include <qfontmetrics.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qevent.h> | 42 | #include <qevent.h> |
43 | #include <qtabwidget.h> | 43 | #include <qtabwidget.h> |
44 | #include <qtabbar.h> | 44 | #include <qtabbar.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qpalette.h> | 47 | #include <qpalette.h> |
48 | 48 | ||
49 | #include <sys/wait.h> | 49 | #include <sys/wait.h> |
50 | #include <stdio.h> | 50 | #include <stdio.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <assert.h> | 52 | #include <assert.h> |
53 | 53 | ||
54 | #include "konsole.h" | 54 | #include "konsole.h" |
55 | #include "keytrans.h" | 55 | #include "keytrans.h" |
56 | #include "commandeditdialog.h" | 56 | #include "commandeditdialog.h" |
57 | 57 | ||
58 | #ifdef QT_QWS_OPIE | 58 | #ifdef QT_QWS_OPIE |
59 | #include <opie/colorpopupmenu.h> | 59 | #include <opie/colorpopupmenu.h> |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | class EKNumTabBar : public QTabBar { | 62 | class EKNumTabBar : public QTabBar { |
63 | public: | 63 | public: |
64 | void numberTabs() | 64 | void numberTabs() |
65 | { | 65 | { |
66 | // Yes, it really is this messy. QTabWidget needs functions | 66 | // Yes, it really is this messy. QTabWidget needs functions |
67 | // that provide acces to tabs in a sequential way. | 67 | // that provide acces to tabs in a sequential way. |
68 | int m=INT_MIN; | 68 | int m=INT_MIN; |
69 | for (int i=0; i<count(); i++) { | 69 | for (int i=0; i<count(); i++) { |
70 | QTab* left=0; | 70 | QTab* left=0; |
71 | QListIterator<QTab> it(*tabList()); | 71 | QListIterator<QTab> it(*tabList()); |
72 | int x=INT_MAX; | 72 | int x=INT_MAX; |
73 | for( QTab* t; (t=it.current()); ++it ) { | 73 | for( QTab* t; (t=it.current()); ++it ) { |
74 | int tx = t->rect().x(); | 74 | int tx = t->rect().x(); |
75 | if ( tx<x && tx>m ) { | 75 | if ( tx<x && tx>m ) { |
76 | x = tx; | 76 | x = tx; |
77 | left = t; | 77 | left = t; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | if ( left ) { | 80 | if ( left ) { |
81 | left->setText(QString::number(i+1)); | 81 | left->setText(QString::number(i+1)); |
82 | m = left->rect().x(); | 82 | m = left->rect().x(); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | } | 85 | } |
86 | }; | 86 | }; |
87 | 87 | ||
88 | class EKNumTabWidget : public QTabWidget { | 88 | class EKNumTabWidget : public QTabWidget { |
89 | public: | 89 | public: |
90 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 90 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
91 | { | 91 | { |
92 | } | 92 | } |
93 | 93 | ||
94 | void addTab(QWidget* w) | 94 | void addTab(QWidget* w) |
95 | { | 95 | { |
96 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 96 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
97 | QTabWidget::addTab(w,t); | 97 | QTabWidget::addTab(w,t); |
98 | } | 98 | } |
99 | 99 | ||
100 | void removeTab(QWidget* w) | 100 | void removeTab(QWidget* w) |
101 | { | 101 | { |
102 | removePage(w); | 102 | removePage(w); |
103 | ((EKNumTabBar*)tabBar())->numberTabs(); | 103 | ((EKNumTabBar*)tabBar())->numberTabs(); |
104 | } | 104 | } |
105 | }; | 105 | }; |
106 | 106 | ||
107 | // This could be configurable or dynamicly generated from the bash history | 107 | // This could be configurable or dynamicly generated from the bash history |
108 | // file of the user | 108 | // file of the user |
109 | static const char *commonCmds[] = | 109 | static const char *commonCmds[] = |
110 | { | 110 | { |
111 | "ls ", // I left this here, cause it looks better than the first alpha | 111 | "ls ", // I left this here, cause it looks better than the first alpha |
112 | "cardctl eject", | 112 | "cardctl eject", |
113 | "cat ", | 113 | "cat ", |
114 | "cd ", | 114 | "cd ", |
115 | "chmod ", | 115 | "chmod ", |
116 | "clear", | 116 | "clear", |
117 | "cp ", | 117 | "cp ", |
118 | "dc ", | 118 | "dc ", |
119 | "df ", | 119 | "df ", |
120 | "dmesg", | 120 | "dmesg", |
121 | "echo ", | 121 | "echo ", |
122 | "env", | 122 | "env", |
123 | "find ", | 123 | "find ", |
124 | "free", | 124 | "free", |
125 | "grep ", | 125 | "grep ", |
126 | "ifconfig ", | 126 | "ifconfig ", |
127 | "ipkg ", | 127 | "ipkg ", |
128 | "mkdir ", | 128 | "mkdir ", |
129 | "mv ", | 129 | "mv ", |
130 | "nc localhost 7776", | 130 | "nc localhost 7776", |
131 | "nc localhost 7777", | 131 | "nc localhost 7777", |
132 | "netstat ", | 132 | "netstat ", |
133 | "nslookup ", | 133 | "nslookup ", |
134 | "ping ", | 134 | "ping ", |
135 | "ps aux", | 135 | "ps aux", |
136 | "pwd ", | 136 | "pwd ", |
137 | "qcop QPE/System 'linkChanged(QString)' ''", | 137 | "qcop QPE/System 'linkChanged(QString)' ''", |
138 | "qcop QPE/System 'restart()'", | 138 | "qcop QPE/System 'restart()'", |
139 | "qcop QPE/System 'quit()'", | 139 | "qcop QPE/System 'quit()'", |
140 | "rm ", | 140 | "rm ", |
141 | "rmdir ", | 141 | "rmdir ", |
142 | "route ", | 142 | "route ", |
143 | "set ", | 143 | "set ", |
144 | "traceroute", | 144 | "traceroute", |
145 | 145 | ||
146 | /* | 146 | /* |
147 | "gzip", | 147 | "gzip", |
148 | "gunzip", | 148 | "gunzip", |
149 | "chgrp", | 149 | "chgrp", |
150 | "chown", | 150 | "chown", |
151 | "date", | 151 | "date", |
152 | "dd", | 152 | "dd", |
153 | "df", | 153 | "df", |
154 | "dmesg", | 154 | "dmesg", |
155 | "fuser", | 155 | "fuser", |
156 | "hostname", | 156 | "hostname", |
157 | "kill", | 157 | "kill", |
158 | "killall", | 158 | "killall", |
159 | "ln", | 159 | "ln", |
160 | "ping", | 160 | "ping", |
161 | "mount", | 161 | "mount", |
162 | "more", | 162 | "more", |
163 | "sort", | 163 | "sort", |
164 | "touch", | 164 | "touch", |
165 | "umount", | 165 | "umount", |
166 | "mknod", | 166 | "mknod", |
167 | "netstat", | 167 | "netstat", |
168 | */ | 168 | */ |
169 | 169 | ||
170 | "exit", | 170 | "exit", |
171 | NULL | 171 | NULL |
172 | }; | 172 | }; |
173 | 173 | ||
174 | 174 | ||
175 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 175 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
176 | QMainWindow(parent, name, fl) | 176 | QMainWindow(parent, name, fl) |
177 | { | 177 | { |
178 | QStrList args; | 178 | QStrList args; |
179 | init("/bin/sh",args); | 179 | init("/bin/sh",args); |
180 | } | 180 | } |
181 | 181 | ||
182 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 182 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
183 | : QMainWindow(0, name) | 183 | : QMainWindow(0, name) |
184 | { | 184 | { |
185 | init(_pgm,_args); | 185 | init(_pgm,_args); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Konsole::initCommandList() | 188 | void Konsole::initCommandList() |
189 | { | 189 | { |
190 | // qDebug("Konsole::initCommandList"); | 190 | // qDebug("Konsole::initCommandList"); |
191 | Config cfg("Konsole"); | 191 | Config cfg("Konsole"); |
192 | cfg.setGroup("Commands"); | 192 | cfg.setGroup("Commands"); |
193 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 193 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
194 | commonCombo->clear(); | 194 | commonCombo->clear(); |
195 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { | 195 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { |
196 | for (int i = 0; commonCmds[i] != NULL; i++) { | 196 | for (int i = 0; commonCmds[i] != NULL; i++) { |
197 | commonCombo->insertItem(commonCmds[i],i); | 197 | commonCombo->insertItem(commonCmds[i],i); |
198 | } | 198 | } |
199 | } else { | 199 | } else { |
200 | for (int i = 0; i < 100; i++) { | 200 | for (int i = 0; i < 100; i++) { |
201 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 201 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
202 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); | 202 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | void Konsole::init(const char* _pgm, QStrList & _args) | 208 | void Konsole::init(const char* _pgm, QStrList & _args) |
209 | { | 209 | { |
210 | b_scroll = TRUE; // histon; | 210 | b_scroll = TRUE; // histon; |
211 | n_keytab = 0; | 211 | n_keytab = 0; |
212 | n_render = 0; | 212 | n_render = 0; |
213 | startUp=0; | 213 | startUp=0; |
214 | fromMenu = FALSE; | 214 | fromMenu = FALSE; |
215 | 215 | ||
216 | setCaption( tr("Terminal") ); | 216 | setCaption( tr("Terminal") ); |
217 | setIcon( Resource::loadPixmap( "konsole" ) ); | 217 | setIcon( Resource::loadPixmap( "konsole" ) ); |
218 | 218 | ||
219 | Config cfg("Konsole"); | 219 | Config cfg("Konsole"); |
220 | cfg.setGroup("Konsole"); | 220 | cfg.setGroup("Konsole"); |
221 | QString tmp; | 221 | QString tmp; |
222 | // initialize the list of allowed fonts /////////////////////////////////// | 222 | // initialize the list of allowed fonts /////////////////////////////////// |
223 | cfont = cfg.readNumEntry("FontID", 1); | 223 | cfont = cfg.readNumEntry("FontID", 1); |
224 | QFont f = QFont("Micro", 4, QFont::Normal); | 224 | QFont f = QFont("Micro", 4, QFont::Normal); |
225 | f.setFixedPitch(TRUE); | 225 | f.setFixedPitch(TRUE); |
226 | fonts.append(new VTFont(tr("Micro"), f)); | 226 | fonts.append(new VTFont(tr("Micro"), f)); |
227 | 227 | ||
228 | f = QFont("Fixed", 7, QFont::Normal); | 228 | f = QFont("Fixed", 7, QFont::Normal); |
229 | f.setFixedPitch(TRUE); | 229 | f.setFixedPitch(TRUE); |
230 | fonts.append(new VTFont(tr("Small Fixed"), f)); | 230 | fonts.append(new VTFont(tr("Small Fixed"), f)); |
231 | 231 | ||
232 | f = QFont("Fixed", 12, QFont::Normal); | 232 | f = QFont("Fixed", 12, QFont::Normal); |
233 | f.setFixedPitch(TRUE); | 233 | f.setFixedPitch(TRUE); |
234 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | 234 | fonts.append(new VTFont(tr("Medium Fixed"), f)); |
235 | 235 | ||
236 | // create terminal emulation framework //////////////////////////////////// | 236 | // create terminal emulation framework //////////////////////////////////// |
237 | nsessions = 0; | 237 | nsessions = 0; |
238 | 238 | ||
239 | tab = new EKNumTabWidget(this); | 239 | tab = new EKNumTabWidget(this); |
240 | 240 | ||
241 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 241 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
242 | 242 | ||
243 | // create terminal toolbar //////////////////////////////////////////////// | 243 | // create terminal toolbar //////////////////////////////////////////////// |
244 | setToolBarsMovable( FALSE ); | 244 | setToolBarsMovable( FALSE ); |
245 | QPEToolBar *menuToolBar = new QPEToolBar( this ); | 245 | QPEToolBar *menuToolBar = new QPEToolBar( this ); |
246 | menuToolBar->setHorizontalStretchable( TRUE ); | 246 | menuToolBar->setHorizontalStretchable( TRUE ); |
247 | 247 | ||
248 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); | 248 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); |
249 | 249 | ||
250 | fontList = new QPopupMenu( this ); | 250 | fontList = new QPopupMenu( this ); |
251 | for(uint i = 0; i < fonts.count(); i++) { | 251 | for(uint i = 0; i < fonts.count(); i++) { |
252 | VTFont *fnt = fonts.at(i); | 252 | VTFont *fnt = fonts.at(i); |
253 | fontList->insertItem(fnt->getName(), i); | 253 | fontList->insertItem(fnt->getName(), i); |
254 | } | 254 | } |
255 | fontChanged(cfont); | 255 | fontChanged(cfont); |
256 | 256 | ||
257 | configMenu = new QPopupMenu( this); | 257 | configMenu = new QPopupMenu( this); |
258 | colorMenu = new QPopupMenu( this); | 258 | colorMenu = new QPopupMenu( this); |
259 | scrollMenu = new QPopupMenu( this); | 259 | scrollMenu = new QPopupMenu( this); |
260 | editCommandListMenu = new QPopupMenu( this); | 260 | editCommandListMenu = new QPopupMenu( this); |
261 | 261 | ||
262 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 262 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
263 | 263 | ||
264 | bool listHidden; | 264 | bool listHidden; |
265 | cfg.setGroup("Menubar"); | 265 | cfg.setGroup("Menubar"); |
266 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 266 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
267 | editCommandListMenu->insertItem( tr( "Show command list" )); | 267 | editCommandListMenu->insertItem( tr( "Show command list" )); |
268 | listHidden=TRUE; | 268 | listHidden=TRUE; |
269 | } else { | 269 | } else { |
270 | editCommandListMenu->insertItem( tr( "Hide command list" )); | 270 | editCommandListMenu->insertItem( tr( "Hide command list" )); |
271 | listHidden=FALSE; | 271 | listHidden=FALSE; |
272 | } | 272 | } |
273 | 273 | ||
274 | cfg.setGroup("Tabs"); | 274 | cfg.setGroup("Tabs"); |
275 | tmp=cfg.readEntry("Position","Bottom"); | 275 | tmp=cfg.readEntry("Position","Bottom"); |
276 | if(tmp=="Top") { | 276 | if(tmp=="Top") { |
277 | tab->setTabPosition(QTabWidget::Top); | 277 | tab->setTabPosition(QTabWidget::Top); |
278 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); | 278 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); |
279 | } else { | 279 | } else { |
280 | tab->setTabPosition(QTabWidget::Bottom); | 280 | tab->setTabPosition(QTabWidget::Bottom); |
281 | configMenu->insertItem(tr("Tabs on Top")); | 281 | configMenu->insertItem(tr("Tabs on Top")); |
282 | } | 282 | } |
283 | configMenu->insertSeparator(2); | 283 | configMenu->insertSeparator(2); |
284 | 284 | ||
285 | colorMenu->insertItem(tr( "Green on Black")); | 285 | colorMenu->insertItem(tr( "Green on Black")); |
286 | colorMenu->insertItem(tr( "Black on White")); | 286 | colorMenu->insertItem(tr( "Black on White")); |
287 | colorMenu->insertItem(tr( "White on Black")); | 287 | colorMenu->insertItem(tr( "White on Black")); |
288 | colorMenu->insertItem(tr( "Black on Transparent")); | 288 | colorMenu->insertItem(tr( "Black on Transparent")); |
289 | colorMenu->insertItem(tr( "Black on Red")); | 289 | colorMenu->insertItem(tr( "Black on Red")); |
290 | colorMenu->insertItem(tr( "Red on Black")); | 290 | colorMenu->insertItem(tr( "Red on Black")); |
291 | colorMenu->insertItem(tr( "Green on Yellow")); | 291 | colorMenu->insertItem(tr( "Green on Yellow")); |
292 | colorMenu->insertItem(tr( "Blue on Magenta")); | 292 | colorMenu->insertItem(tr( "Blue on Magenta")); |
293 | colorMenu->insertItem(tr( "Magenta on Blue")); | 293 | colorMenu->insertItem(tr( "Magenta on Blue")); |
294 | colorMenu->insertItem(tr( "Cyan on White")); | 294 | colorMenu->insertItem(tr( "Cyan on White")); |
295 | colorMenu->insertItem(tr( "White on Cyan")); | 295 | colorMenu->insertItem(tr( "White on Cyan")); |
296 | colorMenu->insertItem(tr( "Blue on Black")); | 296 | colorMenu->insertItem(tr( "Blue on Black")); |
297 | colorMenu->insertItem(tr( "Amber on Black")); | 297 | colorMenu->insertItem(tr( "Amber on Black")); |
298 | 298 | ||
299 | #ifdef QT_QWS_OPIE | 299 | #ifdef QT_QWS_OPIE |
300 | colorMenu->insertItem(tr( "Custom")); | 300 | colorMenu->insertItem(tr( "Custom")); |
301 | #endif | 301 | #endif |
302 | 302 | ||
303 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 303 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
304 | 304 | ||
305 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 305 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
306 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 306 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
307 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 307 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
308 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 308 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
309 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 309 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
310 | menuBar->insertItem( tr("Font"), fontList ); | 310 | menuBar->insertItem( tr("Font"), fontList ); |
311 | menuBar->insertItem( tr("Options"), configMenu ); | 311 | menuBar->insertItem( tr("Options"), configMenu ); |
312 | 312 | ||
313 | QPEToolBar *toolbar = new QPEToolBar( this ); | 313 | QPEToolBar *toolbar = new QPEToolBar( this ); |
314 | 314 | ||
315 | QAction *a; | 315 | QAction *a; |
316 | 316 | ||
317 | // Button Commands | 317 | // Button Commands |
318 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 318 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
319 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 319 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
320 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 320 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
321 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 321 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
322 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 322 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
323 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 323 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
324 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 324 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
325 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 325 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
326 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 326 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
328 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 328 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
330 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 330 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
331 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 331 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
332 | /* | 332 | /* |
333 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 333 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
334 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 334 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
335 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 335 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
336 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 336 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
337 | */ | 337 | */ |
338 | 338 | ||
339 | secondToolBar = new QPEToolBar( this ); | 339 | secondToolBar = new QPEToolBar( this ); |
340 | secondToolBar->setHorizontalStretchable( TRUE ); | 340 | secondToolBar->setHorizontalStretchable( TRUE ); |
341 | 341 | ||
342 | commonCombo = new QComboBox( secondToolBar ); | 342 | commonCombo = new QComboBox( secondToolBar ); |
343 | commonCombo->setMaximumWidth(236); | 343 | commonCombo->setMaximumWidth(236); |
344 | 344 | ||
345 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 345 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
346 | if( listHidden) { | 346 | if( listHidden) { |
347 | secondToolBar->hide(); | 347 | secondToolBar->hide(); |
348 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 348 | editCommandListMenu->setItemEnabled(-23 ,FALSE); |
349 | } | 349 | } |
350 | editCommandListMenu->insertItem(tr( "Edit" ) ); | 350 | editCommandListMenu->insertItem(tr( "Edit" ) ); |
351 | 351 | ||
352 | cfg.setGroup("Commands"); | 352 | cfg.setGroup("Commands"); |
353 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 353 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
354 | 354 | ||
355 | initCommandList(); | 355 | initCommandList(); |
356 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 356 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
357 | // commonCombo->insertItem( commonCmds[i], i ); | 357 | // commonCombo->insertItem( commonCmds[i], i ); |
358 | // tmp = cfg.readEntry( QString::number(i),""); | 358 | // tmp = cfg.readEntry( QString::number(i),""); |
359 | // if(tmp != "") | 359 | // if(tmp != "") |
360 | // commonCombo->changeItem( tmp,i ); | 360 | // commonCombo->changeItem( tmp,i ); |
361 | // } | 361 | // } |
362 | 362 | ||
363 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 363 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
364 | 364 | ||
365 | scrollMenu->insertItem(tr( "None" )); | 365 | scrollMenu->insertItem(tr( "None" )); |
366 | scrollMenu->insertItem(tr( "Left" )); | 366 | scrollMenu->insertItem(tr( "Left" )); |
367 | scrollMenu->insertItem(tr( "Right" )); | 367 | scrollMenu->insertItem(tr( "Right" )); |
368 | // scrollMenu->insertSeparator(4); | 368 | // scrollMenu->insertSeparator(4); |
369 | // scrollMenu->insertItem(tr( "Horizontal" )); | 369 | // scrollMenu->insertItem(tr( "Horizontal" )); |
370 | 370 | ||
371 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 371 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
372 | 372 | ||
373 | int jut = configMenu->insertItem(tr( "Wrap" )); | 373 | int jut = configMenu->insertItem(tr( "Wrap" )); |
374 | cfg.setGroup("ScrollBar"); | 374 | cfg.setGroup("ScrollBar"); |
375 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); | 375 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); |
376 | 376 | ||
377 | jut = configMenu->insertItem(tr( "Use Beep" )); | 377 | jut = configMenu->insertItem(tr( "Use Beep" )); |
378 | cfg.setGroup("Menubar"); | 378 | cfg.setGroup("Menubar"); |
379 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | 379 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); |
380 | 380 | ||
381 | 381 | ||
382 | //scrollMenuSelected(-29); | 382 | //scrollMenuSelected(-29); |
383 | // cfg.setGroup("ScrollBar"); | 383 | // cfg.setGroup("ScrollBar"); |
384 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 384 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
385 | // if(cfg.readNumEntry("Position",2) == 0) | 385 | // if(cfg.readNumEntry("Position",2) == 0) |
386 | // te->setScrollbarLocation(1); | 386 | // te->setScrollbarLocation(1); |
387 | // else | 387 | // else |
388 | // te->setScrollbarLocation(0); | 388 | // te->setScrollbarLocation(0); |
389 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 389 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
390 | // te->setWrapAt(120); | 390 | // te->setWrapAt(120); |
391 | // } | 391 | // } |
392 | // create applications ///////////////////////////////////////////////////// | 392 | // create applications ///////////////////////////////////////////////////// |
393 | setCentralWidget(tab); | 393 | setCentralWidget(tab); |
394 | 394 | ||
395 | // load keymaps //////////////////////////////////////////////////////////// | 395 | // load keymaps //////////////////////////////////////////////////////////// |
396 | KeyTrans::loadAll(); | 396 | KeyTrans::loadAll(); |
397 | for (int i = 0; i < KeyTrans::count(); i++) | 397 | for (int i = 0; i < KeyTrans::count(); i++) |
398 | { KeyTrans* s = KeyTrans::find(i); | 398 | { KeyTrans* s = KeyTrans::find(i); |
399 | assert( s ); | 399 | assert( s ); |
400 | } | 400 | } |
401 | 401 | ||
402 | se_pgm = _pgm; | 402 | se_pgm = _pgm; |
403 | se_args = _args; | 403 | se_args = _args; |
404 | se_args.prepend("--login"); | 404 | se_args.prepend("--login"); |
405 | parseCommandLine(); | 405 | parseCommandLine(); |
406 | // read and apply default values /////////////////////////////////////////// | 406 | // read and apply default values /////////////////////////////////////////// |
407 | resize(321, 321); // Dummy. | 407 | resize(321, 321); // Dummy. |
408 | QSize currentSize = size(); | 408 | QSize currentSize = size(); |
409 | if (currentSize != size()) | 409 | if (currentSize != size()) |
410 | defaultSize = size(); | 410 | defaultSize = size(); |
411 | } | 411 | } |
412 | 412 | ||
413 | void Konsole::show() | 413 | void Konsole::show() |
414 | { | 414 | { |
415 | if ( !nsessions ) { | 415 | if ( !nsessions ) { |
416 | newSession(); | 416 | newSession(); |
417 | } | 417 | } |
418 | QMainWindow::show(); | 418 | QMainWindow::show(); |
419 | 419 | ||
420 | } | 420 | } |
421 | 421 | ||
422 | void Konsole::initSession(const char*, QStrList &) | 422 | void Konsole::initSession(const char*, QStrList &) |
423 | { | 423 | { |
424 | QMainWindow::show(); | 424 | QMainWindow::show(); |
425 | } | 425 | } |
426 | 426 | ||
427 | Konsole::~Konsole() | 427 | Konsole::~Konsole() |
428 | { | 428 | { |
429 | while (nsessions > 0) { | 429 | while (nsessions > 0) { |
430 | doneSession(getTe()->currentSession, 0); | 430 | doneSession(getTe()->currentSession, 0); |
431 | } | 431 | } |
432 | 432 | ||
433 | Config cfg("Konsole"); | 433 | Config cfg("Konsole"); |
434 | cfg.setGroup("Konsole"); | 434 | cfg.setGroup("Konsole"); |
435 | cfg.writeEntry("FontID", cfont); | 435 | cfg.writeEntry("FontID", cfont); |
436 | } | 436 | } |
437 | 437 | ||
438 | void Konsole::fontChanged(int f) | 438 | void Konsole::fontChanged(int f) |
439 | { | 439 | { |
440 | VTFont* font = fonts.at(f); | 440 | VTFont* font = fonts.at(f); |
441 | if (font != 0) { | 441 | if (font != 0) { |
442 | for(uint i = 0; i < fonts.count(); i++) { | 442 | for(uint i = 0; i < fonts.count(); i++) { |
443 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 443 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
444 | } | 444 | } |
445 | 445 | ||
446 | cfont = f; | 446 | cfont = f; |
447 | 447 | ||
448 | TEWidget* te = getTe(); | 448 | TEWidget* te = getTe(); |
449 | if (te != 0) { | 449 | if (te != 0) { |
450 | te->setVTFont(font->getFont()); | 450 | te->setVTFont(font->getFont()); |
451 | } | 451 | } |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | 455 | ||
456 | void Konsole::enterCommand(int c) | 456 | void Konsole::enterCommand(int c) |
457 | { | 457 | { |
458 | TEWidget* te = getTe(); | 458 | TEWidget* te = getTe(); |
459 | if (te != 0) { | 459 | if (te != 0) { |
460 | if(!commonCombo->editable()) { | 460 | if(!commonCombo->editable()) { |
461 | QString text = commonCombo->text(c); //commonCmds[c]; | 461 | QString text = commonCombo->text(c); //commonCmds[c]; |
462 | te->emitText(text); | 462 | te->emitText(text); |
463 | } else { | 463 | } else { |
464 | changeCommand( commonCombo->text(c), c); | 464 | changeCommand( commonCombo->text(c), c); |
465 | } | 465 | } |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
469 | void Konsole::hitEnter() | 469 | void Konsole::hitEnter() |
470 | { | 470 | { |
471 | TEWidget* te = getTe(); | 471 | TEWidget* te = getTe(); |
472 | if (te != 0) { | 472 | if (te != 0) { |
473 | te->emitText(QString("\r")); | 473 | te->emitText(QString("\r")); |
474 | } | 474 | } |
475 | } | 475 | } |
476 | 476 | ||
477 | void Konsole::hitSpace() | 477 | void Konsole::hitSpace() |
478 | { | 478 | { |
479 | TEWidget* te = getTe(); | 479 | TEWidget* te = getTe(); |
480 | if (te != 0) { | 480 | if (te != 0) { |
481 | te->emitText(QString(" ")); | 481 | te->emitText(QString(" ")); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | 484 | ||
485 | void Konsole::hitTab() | 485 | void Konsole::hitTab() |
486 | { | 486 | { |
487 | TEWidget* te = getTe(); | 487 | TEWidget* te = getTe(); |
488 | if (te != 0) { | 488 | if (te != 0) { |
489 | te->emitText(QString("\t")); | 489 | te->emitText(QString("\t")); |
490 | } | 490 | } |
491 | } | 491 | } |
492 | 492 | ||
493 | void Konsole::hitPaste() | 493 | void Konsole::hitPaste() |
494 | { | 494 | { |
495 | TEWidget* te = getTe(); | 495 | TEWidget* te = getTe(); |
496 | if (te != 0) { | 496 | if (te != 0) { |
497 | te->pasteClipboard(); | 497 | te->pasteClipboard(); |
498 | } | 498 | } |
499 | } | 499 | } |
500 | 500 | ||
501 | void Konsole::hitUp() | 501 | void Konsole::hitUp() |
502 | { | 502 | { |
503 | TEWidget* te = getTe(); | 503 | TEWidget* te = getTe(); |
504 | if (te != 0) { | 504 | if (te != 0) { |
505 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 505 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
506 | QApplication::sendEvent( te, &ke ); | 506 | QApplication::sendEvent( te, &ke ); |
507 | } | 507 | } |
508 | } | 508 | } |
509 | 509 | ||
510 | void Konsole::hitDown() | 510 | void Konsole::hitDown() |
511 | { | 511 | { |
512 | TEWidget* te = getTe(); | 512 | TEWidget* te = getTe(); |
513 | if (te != 0) { | 513 | if (te != 0) { |
514 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 514 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
515 | QApplication::sendEvent( te, &ke ); | 515 | QApplication::sendEvent( te, &ke ); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | 518 | ||
519 | /** | 519 | /** |
520 | This function calculates the size of the external widget | 520 | This function calculates the size of the external widget |
521 | needed for the internal widget to be | 521 | needed for the internal widget to be |
522 | */ | 522 | */ |
523 | QSize Konsole::calcSize(int columns, int lines) { | 523 | QSize Konsole::calcSize(int columns, int lines) { |
524 | TEWidget* te = getTe(); | 524 | TEWidget* te = getTe(); |
525 | if (te != 0) { | 525 | if (te != 0) { |
526 | QSize size = te->calcSize(columns, lines); | 526 | QSize size = te->calcSize(columns, lines); |
527 | return size; | 527 | return size; |
528 | } else { | 528 | } else { |
529 | QSize size; | 529 | QSize size; |
530 | return size; | 530 | return size; |
531 | } | 531 | } |
532 | } | 532 | } |
533 | 533 | ||
534 | /** | 534 | /** |
535 | sets application window to a size based on columns X lines of the te | 535 | sets application window to a size based on columns X lines of the te |
536 | guest widget. Call with (0,0) for setting default size. | 536 | guest widget. Call with (0,0) for setting default size. |
537 | */ | 537 | */ |
538 | 538 | ||
539 | void Konsole::setColLin(int columns, int lines) | 539 | void Konsole::setColLin(int columns, int lines) |
540 | { | 540 | { |
541 | qDebug("konsole::setColLin:: Columns %d", columns); | 541 | qDebug("konsole::setColLin:: Columns %d", columns); |
542 | 542 | ||
543 | if ((columns==0) || (lines==0)) | 543 | if ((columns==0) || (lines==0)) |
544 | { | 544 | { |
545 | if (defaultSize.isEmpty()) // not in config file : set default value | 545 | if (defaultSize.isEmpty()) // not in config file : set default value |
546 | { | 546 | { |
547 | defaultSize = calcSize(80,24); | 547 | defaultSize = calcSize(80,24); |
548 | // notifySize(24,80); // set menu items (strange arg order !) | 548 | // notifySize(24,80); // set menu items (strange arg order !) |
549 | } | 549 | } |
550 | resize(defaultSize); | 550 | resize(defaultSize); |
551 | } else { | 551 | } else { |
552 | resize(calcSize(columns, lines)); | 552 | resize(calcSize(columns, lines)); |
553 | // notifySize(lines,columns); // set menu items (strange arg order !) | 553 | // notifySize(lines,columns); // set menu items (strange arg order !) |
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | /* | 557 | /* |
558 | void Konsole::setFont(int fontno) | 558 | void Konsole::setFont(int fontno) |
559 | { | 559 | { |
560 | QFont f; | 560 | QFont f; |
561 | if (fontno == 0) | 561 | if (fontno == 0) |
562 | f = defaultFont = QFont( "Helvetica", 12 ); | 562 | f = defaultFont = QFont( "Helvetica", 12 ); |
563 | else | 563 | else |
564 | if (fonts[fontno][0] == '-') | 564 | if (fonts[fontno][0] == '-') |
565 | f.setRawName( fonts[fontno] ); | 565 | f.setRawName( fonts[fontno] ); |
566 | else | 566 | else |
567 | { | 567 | { |
568 | f.setFamily(fonts[fontno]); | 568 | f.setFamily(fonts[fontno]); |
569 | f.setRawMode( TRUE ); | 569 | f.setRawMode( TRUE ); |
570 | } | 570 | } |
571 | if ( !f.exactMatch() && fontno != 0) | 571 | if ( !f.exactMatch() && fontno != 0) |
572 | { | 572 | { |
573 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 573 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
574 | QMessageBox(this, msg); | 574 | QMessageBox(this, msg); |
575 | return; | 575 | return; |
576 | } | 576 | } |
577 | if (se) se->setFontNo(fontno); | 577 | if (se) se->setFontNo(fontno); |
578 | te->setVTFont(f); | 578 | te->setVTFont(f); |
579 | n_font = fontno; | 579 | n_font = fontno; |
580 | } | 580 | } |
581 | */ | 581 | */ |
582 | 582 | ||
583 | // --| color selection |------------------------------------------------------- | 583 | // --| color selection |------------------------------------------------------- |
584 | 584 | ||
585 | void Konsole::changeColumns(int columns) | 585 | void Konsole::changeColumns(int columns) |
586 | { | 586 | { |
587 | qDebug("change columns"); | 587 | qDebug("change columns"); |
588 | TEWidget* te = getTe(); | 588 | TEWidget* te = getTe(); |
589 | if (te != 0) { | 589 | if (te != 0) { |
590 | setColLin(columns,te->Lines()); | 590 | setColLin(columns,te->Lines()); |
591 | te->update(); | 591 | te->update(); |
592 | } | 592 | } |
593 | } | 593 | } |
594 | 594 | ||
595 | //FIXME: If a child dies during session swap, | 595 | //FIXME: If a child dies during session swap, |
596 | // this routine might be called before | 596 | // this routine might be called before |
597 | // session swap is completed. | 597 | // session swap is completed. |
598 | 598 | ||
599 | void Konsole::doneSession(TESession*, int ) | 599 | void Konsole::doneSession(TESession*, int ) |
600 | { | 600 | { |
601 | TEWidget *te = getTe(); | 601 | TEWidget *te = getTe(); |
602 | if (te != 0) { | 602 | if (te != 0) { |
603 | te->currentSession->setConnect(FALSE); | 603 | te->currentSession->setConnect(FALSE); |
604 | tab->removeTab(te); | 604 | tab->removeTab(te); |
605 | delete te->currentSession; | 605 | delete te->currentSession; |
606 | delete te; | 606 | delete te; |
607 | nsessions--; | 607 | nsessions--; |
608 | } | 608 | } |
609 | 609 | ||
610 | if (nsessions == 0) { | 610 | if (nsessions == 0) { |
611 | close(); | 611 | close(); |
612 | } | 612 | } |
613 | } | 613 | } |
614 | 614 | ||
615 | void Konsole::newSession() { | 615 | void Konsole::newSession() { |
616 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 616 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
617 | TEWidget* te = new TEWidget(tab); | 617 | TEWidget* te = new TEWidget(tab); |
618 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 618 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
619 | te->setVTFont(fonts.at(cfont)->getFont()); | 619 | te->setVTFont(fonts.at(cfont)->getFont()); |
620 | tab->addTab(te); | 620 | tab->addTab(te); |
621 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 621 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
622 | te->currentSession = se; | 622 | te->currentSession = se; |
623 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); | 623 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); |
624 | se->run(); | 624 | se->run(); |
625 | se->setConnect(TRUE); | 625 | se->setConnect(TRUE); |
626 | se->setHistory(b_scroll); | 626 | se->setHistory(b_scroll); |
627 | tab->setCurrentPage(nsessions); | 627 | tab->setCurrentPage(nsessions); |
628 | nsessions++; | 628 | nsessions++; |
629 | doWrap(); | 629 | doWrap(); |
630 | setColor(); | 630 | setColor(); |
631 | } | 631 | } |
632 | } | 632 | } |
633 | 633 | ||
634 | TEWidget* Konsole::getTe() { | 634 | TEWidget* Konsole::getTe() { |
635 | if (nsessions) { | 635 | if (nsessions) { |
636 | return (TEWidget *) tab->currentPage(); | 636 | return (TEWidget *) tab->currentPage(); |
637 | } else { | 637 | } else { |
638 | return 0; | 638 | return 0; |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | void Konsole::switchSession(QWidget* w) { | 642 | void Konsole::switchSession(QWidget* w) { |
643 | TEWidget* te = (TEWidget *) w; | 643 | TEWidget* te = (TEWidget *) w; |
644 | 644 | ||
645 | QFont teFnt = te->getVTFont(); | 645 | QFont teFnt = te->getVTFont(); |
646 | for(uint i = 0; i < fonts.count(); i++) { | 646 | for(uint i = 0; i < fonts.count(); i++) { |
647 | VTFont *fnt = fonts.at(i); | 647 | VTFont *fnt = fonts.at(i); |
648 | bool cf = fnt->getFont() == teFnt; | 648 | bool cf = fnt->getFont() == teFnt; |
649 | fontList->setItemChecked(i, cf); | 649 | fontList->setItemChecked(i, cf); |
650 | if (cf) { | 650 | if (cf) { |
651 | cfont = i; | 651 | cfont = i; |
652 | } | 652 | } |
653 | } | 653 | } |
654 | } | 654 | } |
655 | 655 | ||
656 | void Konsole::colorMenuIsSelected(int iD) { | 656 | void Konsole::colorMenuIsSelected(int iD) { |
657 | fromMenu = TRUE; | 657 | fromMenu = TRUE; |
658 | colorMenuSelected(iD); | 658 | colorMenuSelected(iD); |
659 | } | 659 | } |
660 | 660 | ||
661 | /// ------------------------------- some new stuff by L.J. Potter | 661 | /// ------------------------------- some new stuff by L.J. Potter |
662 | void Konsole::colorMenuSelected(int iD) | 662 | void Konsole::colorMenuSelected(int iD) |
663 | { // this is NOT pretty, elegant or anything else besides functional | 663 | { // this is NOT pretty, elegant or anything else besides functional |
664 | // QString temp; | 664 | // QString temp; |
665 | // qDebug( temp.sprintf("colormenu %d", iD)); | 665 | // qDebug( temp.sprintf("colormenu %d", iD)); |
666 | TEWidget* te = getTe(); | 666 | TEWidget* te = getTe(); |
667 | Config cfg("Konsole"); | 667 | Config cfg("Konsole"); |
668 | cfg.setGroup("Colors"); | 668 | cfg.setGroup("Colors"); |
669 | // QColor foreground; | 669 | // QColor foreground; |
670 | // QColor background; | 670 | // QColor background; |
671 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | 671 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); |
672 | ColorEntry m_table[TABLE_COLORS]; | 672 | ColorEntry m_table[TABLE_COLORS]; |
673 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 673 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
674 | /////////// fore back | 674 | /////////// fore back |
675 | int i; | 675 | int i; |
676 | if(iD==-9) { // default default | 676 | if(iD==-9) { // default default |
677 | for (i = 0; i < TABLE_COLORS; i++) { | 677 | for (i = 0; i < TABLE_COLORS; i++) { |
678 | m_table[i].color = defaultCt[i].color; | 678 | m_table[i].color = defaultCt[i].color; |
679 | if(i==1 || i == 11) | 679 | if(i==1 || i == 11) |
680 | m_table[i].transparent=1; | 680 | m_table[i].transparent=1; |
681 | cfg.writeEntry("Schema","9"); | 681 | cfg.writeEntry("Schema","9"); |
682 | colorMenu->setItemChecked(-9,TRUE); | 682 | colorMenu->setItemChecked(-9,TRUE); |
683 | } | 683 | } |
684 | } else { | 684 | } else { |
685 | if(iD==-6) { // green black | 685 | if(iD==-6) { // green black |
686 | foreground.setRgb(0x18,255,0x18); | 686 | foreground.setRgb(0x18,255,0x18); |
687 | background.setRgb(0x00,0x00,0x00); | 687 | background.setRgb(0x00,0x00,0x00); |
688 | cfg.writeEntry("Schema","6"); | 688 | cfg.writeEntry("Schema","6"); |
689 | colorMenu->setItemChecked(-6,TRUE); | 689 | colorMenu->setItemChecked(-6,TRUE); |
690 | } | 690 | } |
691 | if(iD==-7) { // black white | 691 | if(iD==-7) { // black white |
692 | foreground.setRgb(0x00,0x00,0x00); | 692 | foreground.setRgb(0x00,0x00,0x00); |
693 | background.setRgb(0xFF,0xFF,0xFF); | 693 | background.setRgb(0xFF,0xFF,0xFF); |
694 | cfg.writeEntry("Schema","7"); | 694 | cfg.writeEntry("Schema","7"); |
695 | colorMenu->setItemChecked(-7,TRUE); | 695 | colorMenu->setItemChecked(-7,TRUE); |
696 | } | 696 | } |
697 | if(iD==-8) { // white black | 697 | if(iD==-8) { // white black |
698 | foreground.setRgb(0xFF,0xFF,0xFF); | 698 | foreground.setRgb(0xFF,0xFF,0xFF); |
699 | background.setRgb(0x00,0x00,0x00); | 699 | background.setRgb(0x00,0x00,0x00); |
700 | cfg.writeEntry("Schema","8"); | 700 | cfg.writeEntry("Schema","8"); |
701 | colorMenu->setItemChecked(-8,TRUE); | 701 | colorMenu->setItemChecked(-8,TRUE); |
702 | } | 702 | } |
703 | if(iD==-10) {// Black, Red | 703 | if(iD==-10) {// Black, Red |
704 | foreground.setRgb(0x00,0x00,0x00); | 704 | foreground.setRgb(0x00,0x00,0x00); |
705 | background.setRgb(0xB2,0x18,0x18); | 705 | background.setRgb(0xB2,0x18,0x18); |
706 | cfg.writeEntry("Schema","10"); | 706 | cfg.writeEntry("Schema","10"); |
707 | colorMenu->setItemChecked(-10,TRUE); | 707 | colorMenu->setItemChecked(-10,TRUE); |
708 | } | 708 | } |
709 | if(iD==-11) {// Red, Black | 709 | if(iD==-11) {// Red, Black |
710 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 | 710 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 |
711 | background.setRgb(0x00,0x00,0x00); | 711 | background.setRgb(0x00,0x00,0x00); |
712 | cfg.writeEntry("Schema","11"); | 712 | cfg.writeEntry("Schema","11"); |
713 | colorMenu->setItemChecked(-11,TRUE); | 713 | colorMenu->setItemChecked(-11,TRUE); |
714 | } | 714 | } |
715 | if(iD==-12) {// Green, Yellow - is ugly | 715 | if(iD==-12) {// Green, Yellow - is ugly |
716 | // foreground.setRgb(0x18,0xB2,0x18); | 716 | // foreground.setRgb(0x18,0xB2,0x18); |
717 | foreground.setRgb(36,139,10); | 717 | foreground.setRgb(36,139,10); |
718 | // background.setRgb(0xB2,0x68,0x18); | 718 | // background.setRgb(0xB2,0x68,0x18); |
719 | background.setRgb(255,255,0); | 719 | background.setRgb(255,255,0); |
720 | cfg.writeEntry("Schema","12"); | 720 | cfg.writeEntry("Schema","12"); |
721 | colorMenu->setItemChecked(-12,TRUE); | 721 | colorMenu->setItemChecked(-12,TRUE); |
722 | } | 722 | } |
723 | if(iD==-13) {// Blue, Magenta | 723 | if(iD==-13) {// Blue, Magenta |
724 | foreground.setRgb(0x18,0xB2,0xB2); | 724 | foreground.setRgb(0x18,0xB2,0xB2); |
725 | background.setRgb(0x18,0x18,0xB2); | 725 | background.setRgb(0x18,0x18,0xB2); |
726 | cfg.writeEntry("Schema","13"); | 726 | cfg.writeEntry("Schema","13"); |
727 | colorMenu->setItemChecked(-13,TRUE); | 727 | colorMenu->setItemChecked(-13,TRUE); |
728 | } | 728 | } |
729 | if(iD==-14) {// Magenta, Blue | 729 | if(iD==-14) {// Magenta, Blue |
730 | foreground.setRgb(0x18,0x18,0xB2); | 730 | foreground.setRgb(0x18,0x18,0xB2); |
731 | background.setRgb(0x18,0xB2,0xB2); | 731 | background.setRgb(0x18,0xB2,0xB2); |
732 | cfg.writeEntry("Schema","14"); | 732 | cfg.writeEntry("Schema","14"); |
733 | colorMenu->setItemChecked(-14,TRUE); | 733 | colorMenu->setItemChecked(-14,TRUE); |
734 | } | 734 | } |
735 | if(iD==-15) {// Cyan, White | 735 | if(iD==-15) {// Cyan, White |
736 | foreground.setRgb(0x18,0xB2,0xB2); | 736 | foreground.setRgb(0x18,0xB2,0xB2); |
737 | background.setRgb(0xFF,0xFF,0xFF); | 737 | background.setRgb(0xFF,0xFF,0xFF); |
738 | cfg.writeEntry("Schema","15"); | 738 | cfg.writeEntry("Schema","15"); |
739 | colorMenu->setItemChecked(-15,TRUE); | 739 | colorMenu->setItemChecked(-15,TRUE); |
740 | } | 740 | } |
741 | if(iD==-16) {// White, Cyan | 741 | if(iD==-16) {// White, Cyan |
742 | background.setRgb(0x18,0xB2,0xB2); | 742 | background.setRgb(0x18,0xB2,0xB2); |
743 | foreground.setRgb(0xFF,0xFF,0xFF); | 743 | foreground.setRgb(0xFF,0xFF,0xFF); |
744 | cfg.writeEntry("Schema","16"); | 744 | cfg.writeEntry("Schema","16"); |
745 | colorMenu->setItemChecked(-16,TRUE); | 745 | colorMenu->setItemChecked(-16,TRUE); |
746 | } | 746 | } |
747 | if(iD==-17) {// Black, Blue | 747 | if(iD==-17) {// Black, Blue |
748 | background.setRgb(0x00,0x00,0x00); | 748 | background.setRgb(0x00,0x00,0x00); |
749 | foreground.setRgb(0x18,0xB2,0xB2); | 749 | foreground.setRgb(0x18,0xB2,0xB2); |
750 | cfg.writeEntry("Schema","17"); | 750 | cfg.writeEntry("Schema","17"); |
751 | colorMenu->setItemChecked(-17,TRUE); | 751 | colorMenu->setItemChecked(-17,TRUE); |
752 | } | 752 | } |
753 | if(iD==-18) {// Black, Gold | 753 | if(iD==-18) {// Black, Gold |
754 | background.setRgb(0x00,0x00,0x00); | 754 | background.setRgb(0x00,0x00,0x00); |
755 | foreground.setRgb(255,215,0); | 755 | foreground.setRgb(255,215,0); |
756 | cfg.writeEntry("Schema","18"); | 756 | cfg.writeEntry("Schema","18"); |
757 | colorMenu->setItemChecked(-18,TRUE); | 757 | colorMenu->setItemChecked(-18,TRUE); |
758 | } | 758 | } |
759 | #ifdef QT_QWS_OPIE | 759 | #ifdef QT_QWS_OPIE |
760 | if(iD==-19) { | 760 | if(iD==-19) { |
761 | // Custom | 761 | // Custom |
762 | qDebug("do custom"); | 762 | qDebug("do custom"); |
763 | if(fromMenu) { | 763 | if(fromMenu) { |
764 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); | 764 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); |
765 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 765 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
766 | SLOT(changeForegroundColor(const QColor&))); | 766 | SLOT(changeForegroundColor(const QColor&))); |
767 | penColorPopupMenu->exec(); | 767 | penColorPopupMenu->exec(); |
768 | } | 768 | } |
769 | cfg.writeEntry("Schema","19"); | 769 | cfg.writeEntry("Schema","19"); |
770 | if(!fromMenu) { | 770 | if(!fromMenu) { |
771 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 771 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
772 | background.setNamedColor(cfg.readEntry("background","")); | 772 | background.setNamedColor(cfg.readEntry("background","")); |
773 | } | 773 | } |
774 | fromMenu=FALSE; | 774 | fromMenu=FALSE; |
775 | colorMenu->setItemChecked(-19,TRUE); | 775 | colorMenu->setItemChecked(-19,TRUE); |
776 | } | 776 | } |
777 | #endif | 777 | #endif |
778 | for (i = 0; i < TABLE_COLORS; i++) { | 778 | for (i = 0; i < TABLE_COLORS; i++) { |
779 | if(i==0 || i == 10) { | 779 | if(i==0 || i == 10) { |
780 | m_table[i].color = foreground; | 780 | m_table[i].color = foreground; |
781 | } | 781 | } |
782 | else if(i==1 || i == 11) { | 782 | else if(i==1 || i == 11) { |
783 | m_table[i].color = background; m_table[i].transparent=0; | 783 | m_table[i].color = background; m_table[i].transparent=0; |
784 | } | 784 | } |
785 | else | 785 | else |
786 | m_table[i].color = defaultCt[i].color; | 786 | m_table[i].color = defaultCt[i].color; |
787 | } | 787 | } |
788 | } | 788 | } |
789 | lastSelectedMenu = iD; | 789 | lastSelectedMenu = iD; |
790 | te->setColorTable(m_table); | 790 | te->setColorTable(m_table); |