-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 9c1167b..c324c35 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -3,1060 +3,1060 @@ | |||
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("Font"), fontList ); | 303 | configMenu->insertItem( tr("Font"), fontList ); |
304 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 304 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
305 | 305 | ||
306 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 306 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
307 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 307 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
308 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 308 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
309 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 309 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
310 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 310 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
311 | 311 | ||
312 | menuBar->insertItem( tr("Options"), configMenu ); | 312 | menuBar->insertItem( tr("Options"), configMenu ); |
313 | 313 | ||
314 | QPEToolBar *toolbar = new QPEToolBar( this ); | 314 | QPEToolBar *toolbar = new QPEToolBar( this ); |
315 | 315 | ||
316 | QAction *a; | 316 | QAction *a; |
317 | 317 | ||
318 | // Button Commands | 318 | // Button Commands |
319 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 319 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
320 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 320 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
321 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 321 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
322 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 322 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
323 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 323 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
324 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 324 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
325 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 325 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
326 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 326 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
327 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 327 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
328 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 328 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
329 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 329 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
330 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 330 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
331 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 331 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
332 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 332 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
333 | /* | 333 | /* |
334 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 334 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
335 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 335 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
336 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 336 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
337 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 337 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
338 | */ | 338 | */ |
339 | 339 | ||
340 | secondToolBar = new QPEToolBar( this ); | 340 | secondToolBar = new QPEToolBar( this ); |
341 | secondToolBar->setHorizontalStretchable( TRUE ); | 341 | secondToolBar->setHorizontalStretchable( TRUE ); |
342 | 342 | ||
343 | commonCombo = new QComboBox( secondToolBar ); | 343 | commonCombo = new QComboBox( secondToolBar ); |
344 | commonCombo->setMaximumWidth(236); | 344 | commonCombo->setMaximumWidth(236); |
345 | 345 | ||
346 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 346 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
347 | if( listHidden) { | 347 | if( listHidden) { |
348 | secondToolBar->hide(); | 348 | secondToolBar->hide(); |
349 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 349 | editCommandListMenu->setItemEnabled(-23 ,FALSE); |
350 | } | 350 | } |
351 | editCommandListMenu->insertItem(tr( "Edit" ) ); | 351 | editCommandListMenu->insertItem(tr( "Edit" ) ); |
352 | 352 | ||
353 | cfg.setGroup("Commands"); | 353 | cfg.setGroup("Commands"); |
354 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 354 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
355 | 355 | ||
356 | initCommandList(); | 356 | initCommandList(); |
357 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 357 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
358 | // commonCombo->insertItem( commonCmds[i], i ); | 358 | // commonCombo->insertItem( commonCmds[i], i ); |
359 | // tmp = cfg.readEntry( QString::number(i),""); | 359 | // tmp = cfg.readEntry( QString::number(i),""); |
360 | // if(tmp != "") | 360 | // if(tmp != "") |
361 | // commonCombo->changeItem( tmp,i ); | 361 | // commonCombo->changeItem( tmp,i ); |
362 | // } | 362 | // } |
363 | 363 | ||
364 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 364 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
365 | 365 | ||
366 | scrollMenu->insertItem(tr( "None" )); | 366 | scrollMenu->insertItem(tr( "None" )); |
367 | scrollMenu->insertItem(tr( "Left" )); | 367 | scrollMenu->insertItem(tr( "Left" )); |
368 | scrollMenu->insertItem(tr( "Right" )); | 368 | scrollMenu->insertItem(tr( "Right" )); |
369 | // scrollMenu->insertSeparator(4); | 369 | // scrollMenu->insertSeparator(4); |
370 | // scrollMenu->insertItem(tr( "Horizontal" )); | 370 | // scrollMenu->insertItem(tr( "Horizontal" )); |
371 | 371 | ||
372 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 372 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
373 | 373 | ||
374 | int jut = configMenu->insertItem(tr( "Wrap" )); | 374 | int jut = configMenu->insertItem(tr( "Wrap" )); |
375 | cfg.setGroup("ScrollBar"); | 375 | cfg.setGroup("ScrollBar"); |
376 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); | 376 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); |
377 | 377 | ||
378 | jut = configMenu->insertItem(tr( "Use Beep" )); | 378 | jut = configMenu->insertItem(tr( "Use Beep" )); |
379 | cfg.setGroup("Menubar"); | 379 | cfg.setGroup("Menubar"); |
380 | 380 | ||
381 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | 381 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); |
382 | 382 | ||
383 | 383 | ||
384 | //scrollMenuSelected(-29); | 384 | //scrollMenuSelected(-29); |
385 | // cfg.setGroup("ScrollBar"); | 385 | // cfg.setGroup("ScrollBar"); |
386 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 386 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
387 | // if(cfg.readNumEntry("Position",2) == 0) | 387 | // if(cfg.readNumEntry("Position",2) == 0) |
388 | // te->setScrollbarLocation(1); | 388 | // te->setScrollbarLocation(1); |
389 | // else | 389 | // else |
390 | // te->setScrollbarLocation(0); | 390 | // te->setScrollbarLocation(0); |
391 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 391 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
392 | // te->setWrapAt(120); | 392 | // te->setWrapAt(120); |
393 | // } | 393 | // } |
394 | // create applications ///////////////////////////////////////////////////// | 394 | // create applications ///////////////////////////////////////////////////// |
395 | setCentralWidget(tab); | 395 | setCentralWidget(tab); |
396 | 396 | ||
397 | // load keymaps //////////////////////////////////////////////////////////// | 397 | // load keymaps //////////////////////////////////////////////////////////// |
398 | KeyTrans::loadAll(); | 398 | KeyTrans::loadAll(); |
399 | for (int i = 0; i < KeyTrans::count(); i++) | 399 | for (int i = 0; i < KeyTrans::count(); i++) |
400 | { KeyTrans* s = KeyTrans::find(i); | 400 | { KeyTrans* s = KeyTrans::find(i); |
401 | assert( s ); | 401 | assert( s ); |
402 | } | 402 | } |
403 | 403 | ||
404 | se_pgm = _pgm; | 404 | se_pgm = _pgm; |
405 | se_args = _args; | 405 | se_args = _args; |
406 | se_args.prepend("--login"); | 406 | se_args.prepend("--login"); |
407 | parseCommandLine(); | 407 | parseCommandLine(); |
408 | // read and apply default values /////////////////////////////////////////// | 408 | // read and apply default values /////////////////////////////////////////// |
409 | resize(321, 321); // Dummy. | 409 | resize(321, 321); // Dummy. |
410 | QSize currentSize = size(); | 410 | QSize currentSize = size(); |
411 | if (currentSize != size()) | 411 | if (currentSize != size()) |
412 | defaultSize = size(); | 412 | defaultSize = size(); |
413 | } | 413 | } |
414 | 414 | ||
415 | void Konsole::show() | 415 | void Konsole::show() |
416 | { | 416 | { |
417 | if ( !nsessions ) { | 417 | if ( !nsessions ) { |
418 | newSession(); | 418 | newSession(); |
419 | } | 419 | } |
420 | QMainWindow::show(); | 420 | QMainWindow::show(); |
421 | 421 | ||
422 | } | 422 | } |
423 | 423 | ||
424 | void Konsole::initSession(const char*, QStrList &) | 424 | void Konsole::initSession(const char*, QStrList &) |
425 | { | 425 | { |
426 | QMainWindow::show(); | 426 | QMainWindow::show(); |
427 | } | 427 | } |
428 | 428 | ||
429 | Konsole::~Konsole() | 429 | Konsole::~Konsole() |
430 | { | 430 | { |
431 | while (nsessions > 0) { | 431 | while (nsessions > 0) { |
432 | doneSession(getTe()->currentSession, 0); | 432 | doneSession(getTe()->currentSession, 0); |
433 | } | 433 | } |
434 | 434 | ||
435 | Config cfg("Konsole"); | 435 | Config cfg("Konsole"); |
436 | cfg.setGroup("Konsole"); | 436 | cfg.setGroup("Konsole"); |
437 | cfg.writeEntry("FontID", cfont); | 437 | cfg.writeEntry("FontID", cfont); |
438 | } | 438 | } |
439 | 439 | ||
440 | void Konsole::fontChanged(int f) | 440 | void Konsole::fontChanged(int f) |
441 | { | 441 | { |
442 | VTFont* font = fonts.at(f); | 442 | VTFont* font = fonts.at(f); |
443 | if (font != 0) { | 443 | if (font != 0) { |
444 | for(uint i = 0; i < fonts.count(); i++) { | 444 | for(uint i = 0; i < fonts.count(); i++) { |
445 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 445 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
446 | } | 446 | } |
447 | 447 | ||
448 | cfont = f; | 448 | cfont = f; |
449 | 449 | ||
450 | TEWidget* te = getTe(); | 450 | TEWidget* te = getTe(); |
451 | if (te != 0) { | 451 | if (te != 0) { |
452 | te->setVTFont(font->getFont()); | 452 | te->setVTFont(font->getFont()); |
453 | } | 453 | } |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | 457 | ||
458 | void Konsole::enterCommand(int c) | 458 | void Konsole::enterCommand(int c) |
459 | { | 459 | { |
460 | TEWidget* te = getTe(); | 460 | TEWidget* te = getTe(); |
461 | if (te != 0) { | 461 | if (te != 0) { |
462 | if(!commonCombo->editable()) { | 462 | if(!commonCombo->editable()) { |
463 | QString text = commonCombo->text(c); //commonCmds[c]; | 463 | QString text = commonCombo->text(c); //commonCmds[c]; |
464 | te->emitText(text); | 464 | te->emitText(text); |
465 | } else { | 465 | } else { |
466 | changeCommand( commonCombo->text(c), c); | 466 | changeCommand( commonCombo->text(c), c); |
467 | } | 467 | } |
468 | } | 468 | } |
469 | } | 469 | } |
470 | 470 | ||
471 | void Konsole::hitEnter() | 471 | void Konsole::hitEnter() |
472 | { | 472 | { |
473 | TEWidget* te = getTe(); | 473 | TEWidget* te = getTe(); |
474 | if (te != 0) { | 474 | if (te != 0) { |
475 | te->emitText(QString("\r")); | 475 | te->emitText(QString("\r")); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | void Konsole::hitSpace() | 479 | void Konsole::hitSpace() |
480 | { | 480 | { |
481 | TEWidget* te = getTe(); | 481 | TEWidget* te = getTe(); |
482 | if (te != 0) { | 482 | if (te != 0) { |
483 | te->emitText(QString(" ")); | 483 | te->emitText(QString(" ")); |
484 | } | 484 | } |
485 | } | 485 | } |
486 | 486 | ||
487 | void Konsole::hitTab() | 487 | void Konsole::hitTab() |
488 | { | 488 | { |
489 | TEWidget* te = getTe(); | 489 | TEWidget* te = getTe(); |
490 | if (te != 0) { | 490 | if (te != 0) { |
491 | te->emitText(QString("\t")); | 491 | te->emitText(QString("\t")); |
492 | } | 492 | } |
493 | } | 493 | } |
494 | 494 | ||
495 | void Konsole::hitPaste() | 495 | void Konsole::hitPaste() |
496 | { | 496 | { |
497 | TEWidget* te = getTe(); | 497 | TEWidget* te = getTe(); |
498 | if (te != 0) { | 498 | if (te != 0) { |
499 | te->pasteClipboard(); | 499 | te->pasteClipboard(); |
500 | } | 500 | } |
501 | } | 501 | } |
502 | 502 | ||
503 | void Konsole::hitUp() | 503 | void Konsole::hitUp() |
504 | { | 504 | { |
505 | TEWidget* te = getTe(); | 505 | TEWidget* te = getTe(); |
506 | if (te != 0) { | 506 | if (te != 0) { |
507 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 507 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
508 | QApplication::sendEvent( te, &ke ); | 508 | QApplication::sendEvent( te, &ke ); |
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | void Konsole::hitDown() | 512 | void Konsole::hitDown() |
513 | { | 513 | { |
514 | TEWidget* te = getTe(); | 514 | TEWidget* te = getTe(); |
515 | if (te != 0) { | 515 | if (te != 0) { |
516 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 516 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
517 | QApplication::sendEvent( te, &ke ); | 517 | QApplication::sendEvent( te, &ke ); |
518 | } | 518 | } |
519 | } | 519 | } |
520 | 520 | ||
521 | /** | 521 | /** |
522 | This function calculates the size of the external widget | 522 | This function calculates the size of the external widget |
523 | needed for the internal widget to be | 523 | needed for the internal widget to be |
524 | */ | 524 | */ |
525 | QSize Konsole::calcSize(int columns, int lines) { | 525 | QSize Konsole::calcSize(int columns, int lines) { |
526 | TEWidget* te = getTe(); | 526 | TEWidget* te = getTe(); |
527 | if (te != 0) { | 527 | if (te != 0) { |
528 | QSize size = te->calcSize(columns, lines); | 528 | QSize size = te->calcSize(columns, lines); |
529 | return size; | 529 | return size; |
530 | } else { | 530 | } else { |
531 | QSize size; | 531 | QSize size; |
532 | return size; | 532 | return size; |
533 | } | 533 | } |
534 | } | 534 | } |
535 | 535 | ||
536 | /** | 536 | /** |
537 | sets application window to a size based on columns X lines of the te | 537 | sets application window to a size based on columns X lines of the te |
538 | guest widget. Call with (0,0) for setting default size. | 538 | guest widget. Call with (0,0) for setting default size. |
539 | */ | 539 | */ |
540 | 540 | ||
541 | void Konsole::setColLin(int columns, int lines) | 541 | void Konsole::setColLin(int columns, int lines) |
542 | { | 542 | { |
543 | qDebug("konsole::setColLin:: Columns %d", columns); | 543 | qDebug("konsole::setColLin:: Columns %d", columns); |
544 | 544 | ||
545 | if ((columns==0) || (lines==0)) | 545 | if ((columns==0) || (lines==0)) |
546 | { | 546 | { |
547 | if (defaultSize.isEmpty()) // not in config file : set default value | 547 | if (defaultSize.isEmpty()) // not in config file : set default value |
548 | { | 548 | { |
549 | defaultSize = calcSize(80,24); | 549 | defaultSize = calcSize(80,24); |
550 | // notifySize(24,80); // set menu items (strange arg order !) | 550 | // notifySize(24,80); // set menu items (strange arg order !) |
551 | } | 551 | } |
552 | resize(defaultSize); | 552 | resize(defaultSize); |
553 | } else { | 553 | } else { |
554 | resize(calcSize(columns, lines)); | 554 | resize(calcSize(columns, lines)); |
555 | // notifySize(lines,columns); // set menu items (strange arg order !) | 555 | // notifySize(lines,columns); // set menu items (strange arg order !) |
556 | } | 556 | } |
557 | } | 557 | } |
558 | 558 | ||
559 | /* | 559 | /* |
560 | void Konsole::setFont(int fontno) | 560 | void Konsole::setFont(int fontno) |
561 | { | 561 | { |
562 | QFont f; | 562 | QFont f; |
563 | if (fontno == 0) | 563 | if (fontno == 0) |
564 | f = defaultFont = QFont( "Helvetica", 12 ); | 564 | f = defaultFont = QFont( "Helvetica", 12 ); |
565 | else | 565 | else |
566 | if (fonts[fontno][0] == '-') | 566 | if (fonts[fontno][0] == '-') |
567 | f.setRawName( fonts[fontno] ); | 567 | f.setRawName( fonts[fontno] ); |
568 | else | 568 | else |
569 | { | 569 | { |
570 | f.setFamily(fonts[fontno]); | 570 | f.setFamily(fonts[fontno]); |
571 | f.setRawMode( TRUE ); | 571 | f.setRawMode( TRUE ); |
572 | } | 572 | } |
573 | if ( !f.exactMatch() && fontno != 0) | 573 | if ( !f.exactMatch() && fontno != 0) |
574 | { | 574 | { |
575 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 575 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
576 | QMessageBox(this, msg); | 576 | QMessageBox(this, msg); |
577 | return; | 577 | return; |
578 | } | 578 | } |
579 | if (se) se->setFontNo(fontno); | 579 | if (se) se->setFontNo(fontno); |
580 | te->setVTFont(f); | 580 | te->setVTFont(f); |
581 | n_font = fontno; | 581 | n_font = fontno; |
582 | } | 582 | } |
583 | */ | 583 | */ |
584 | 584 | ||
585 | // --| color selection |------------------------------------------------------- | 585 | // --| color selection |------------------------------------------------------- |
586 | 586 | ||
587 | void Konsole::changeColumns(int columns) | 587 | void Konsole::changeColumns(int columns) |
588 | { //FIXME this seems to cause silliness when reset command is executed | 588 | { //FIXME this seems to cause silliness when reset command is executed |
589 | // qDebug("change columns"); | 589 | // qDebug("change columns"); |
590 | // TEWidget* te = getTe(); | 590 | // TEWidget* te = getTe(); |
591 | // if (te != 0) { | 591 | // if (te != 0) { |
592 | // setColLin(columns,te->Lines()); | 592 | // setColLin(columns,te->Lines()); |
593 | // te->update(); | 593 | // te->update(); |
594 | // } | 594 | // } |
595 | } | 595 | } |
596 | 596 | ||
597 | //FIXME: If a child dies during session swap, | 597 | //FIXME: If a child dies during session swap, |
598 | // this routine might be called before | 598 | // this routine might be called before |
599 | // session swap is completed. | 599 | // session swap is completed. |
600 | 600 | ||
601 | void Konsole::doneSession(TESession*, int ) | 601 | void Konsole::doneSession(TESession*, int ) |
602 | { | 602 | { |
603 | TEWidget *te = getTe(); | 603 | TEWidget *te = getTe(); |
604 | if (te != 0) { | 604 | if (te != 0) { |
605 | te->currentSession->setConnect(FALSE); | 605 | te->currentSession->setConnect(FALSE); |
606 | tab->removeTab(te); | 606 | tab->removeTab(te); |
607 | delete te->currentSession; | 607 | delete te->currentSession; |
608 | delete te; | 608 | delete te; |
609 | nsessions--; | 609 | nsessions--; |
610 | } | 610 | } |
611 | 611 | ||
612 | if (nsessions == 0) { | 612 | if (nsessions == 0) { |
613 | close(); | 613 | close(); |
614 | } | 614 | } |
615 | } | 615 | } |
616 | 616 | ||
617 | void Konsole::newSession() { | 617 | void Konsole::newSession() { |
618 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 618 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
619 | TEWidget* te = new TEWidget(tab); | 619 | TEWidget* te = new TEWidget(tab); |
620 | Config c("Konsole"); | 620 | Config c("Konsole"); |
621 | c.setGroup("Menubar"); | 621 | c.setGroup("Menubar"); |
622 | te->useBeep=c.readBoolEntry("useBeep",0); | 622 | te->useBeep=c.readBoolEntry("useBeep",0); |
623 | 623 | ||
624 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 624 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
625 | te->setVTFont(fonts.at(cfont)->getFont()); | 625 | te->setVTFont(fonts.at(cfont)->getFont()); |
626 | tab->addTab(te); | 626 | tab->addTab(te); |
627 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 627 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
628 | te->currentSession = se; | 628 | te->currentSession = se; |
629 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); | 629 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); |
630 | se->run(); | 630 | se->run(); |
631 | se->setConnect(TRUE); | 631 | se->setConnect(TRUE); |
632 | se->setHistory(b_scroll); | 632 | se->setHistory(b_scroll); |
633 | tab->setCurrentPage(nsessions); | 633 | tab->setCurrentPage(nsessions); |
634 | nsessions++; | 634 | nsessions++; |
635 | doWrap(); | 635 | doWrap(); |
636 | setColor(); | 636 | setColor(); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | 639 | ||
640 | TEWidget* Konsole::getTe() { | 640 | TEWidget* Konsole::getTe() { |
641 | if (nsessions) { | 641 | if (nsessions) { |
642 | return (TEWidget *) tab->currentPage(); | 642 | return (TEWidget *) tab->currentPage(); |
643 | } else { | 643 | } else { |
644 | return 0; | 644 | return 0; |
645 | } | 645 | } |
646 | } | 646 | } |
647 | 647 | ||
648 | void Konsole::switchSession(QWidget* w) { | 648 | void Konsole::switchSession(QWidget* w) { |
649 | TEWidget* te = (TEWidget *) w; | 649 | TEWidget* te = (TEWidget *) w; |
650 | 650 | ||
651 | QFont teFnt = te->getVTFont(); | 651 | QFont teFnt = te->getVTFont(); |
652 | for(uint i = 0; i < fonts.count(); i++) { | 652 | for(uint i = 0; i < fonts.count(); i++) { |
653 | VTFont *fnt = fonts.at(i); | 653 | VTFont *fnt = fonts.at(i); |
654 | bool cf = fnt->getFont() == teFnt; | 654 | bool cf = fnt->getFont() == teFnt; |
655 | fontList->setItemChecked(i, cf); | 655 | fontList->setItemChecked(i, cf); |
656 | if (cf) { | 656 | if (cf) { |
657 | cfont = i; | 657 | cfont = i; |
658 | } | 658 | } |
659 | } | 659 | } |
660 | } | 660 | } |
661 | 661 | ||
662 | void Konsole::colorMenuIsSelected(int iD) { | 662 | void Konsole::colorMenuIsSelected(int iD) { |
663 | fromMenu = TRUE; | 663 | fromMenu = TRUE; |
664 | colorMenuSelected(iD); | 664 | colorMenuSelected(iD); |
665 | } | 665 | } |
666 | 666 | ||
667 | /// ------------------------------- some new stuff by L.J. Potter | 667 | /// ------------------------------- some new stuff by L.J. Potter |
668 | void Konsole::colorMenuSelected(int iD) | 668 | void Konsole::colorMenuSelected(int iD) |
669 | { // this is NOT pretty, elegant or anything else besides functional | 669 | { // this is NOT pretty, elegant or anything else besides functional |
670 | // QString temp; | 670 | // QString temp; |
671 | // qDebug( temp.sprintf("colormenu %d", iD)); | 671 | // qDebug( temp.sprintf("colormenu %d", iD)); |
672 | 672 | ||
673 | TEWidget* te = getTe(); | 673 | TEWidget* te = getTe(); |
674 | Config cfg("Konsole"); | 674 | Config cfg("Konsole"); |
675 | cfg.setGroup("Colors"); | 675 | cfg.setGroup("Colors"); |
676 | // QColor foreground; | 676 | // QColor foreground; |
677 | // QColor background; | 677 | // QColor background; |
678 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | 678 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); |
679 | ColorEntry m_table[TABLE_COLORS]; | 679 | ColorEntry m_table[TABLE_COLORS]; |
680 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 680 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
681 | /////////// fore back | 681 | /////////// fore back |
682 | int i; | 682 | int i; |
683 | if(iD==-9) { // default default | 683 | if(iD==-9) { // default default |
684 | for (i = 0; i < TABLE_COLORS; i++) { | 684 | for (i = 0; i < TABLE_COLORS; i++) { |
685 | m_table[i].color = defaultCt[i].color; | 685 | m_table[i].color = defaultCt[i].color; |
686 | if(i==1 || i == 11) | 686 | if(i==1 || i == 11) |
687 | m_table[i].transparent=1; | 687 | m_table[i].transparent=1; |
688 | cfg.writeEntry("Schema","9"); | 688 | cfg.writeEntry("Schema","9"); |
689 | colorMenu->setItemChecked(-9,TRUE); | 689 | colorMenu->setItemChecked(-9,TRUE); |
690 | } | 690 | } |
691 | } else { | 691 | } else { |
692 | if(iD==-6) { // green black | 692 | if(iD==-6) { // green black |
693 | foreground.setRgb(0x18,255,0x18); | 693 | foreground.setRgb(0x18,255,0x18); |
694 | background.setRgb(0x00,0x00,0x00); | 694 | background.setRgb(0x00,0x00,0x00); |
695 | cfg.writeEntry("Schema","6"); | 695 | cfg.writeEntry("Schema","6"); |
696 | colorMenu->setItemChecked(-6,TRUE); | 696 | colorMenu->setItemChecked(-6,TRUE); |
697 | } | 697 | } |
698 | if(iD==-7) { // black white | 698 | if(iD==-7) { // black white |
699 | foreground.setRgb(0x00,0x00,0x00); | 699 | foreground.setRgb(0x00,0x00,0x00); |
700 | background.setRgb(0xFF,0xFF,0xFF); | 700 | background.setRgb(0xFF,0xFF,0xFF); |
701 | cfg.writeEntry("Schema","7"); | 701 | cfg.writeEntry("Schema","7"); |
702 | colorMenu->setItemChecked(-7,TRUE); | 702 | colorMenu->setItemChecked(-7,TRUE); |
703 | } | 703 | } |
704 | if(iD==-8) { // white black | 704 | if(iD==-8) { // white black |
705 | foreground.setRgb(0xFF,0xFF,0xFF); | 705 | foreground.setRgb(0xFF,0xFF,0xFF); |
706 | background.setRgb(0x00,0x00,0x00); | 706 | background.setRgb(0x00,0x00,0x00); |
707 | cfg.writeEntry("Schema","8"); | 707 | cfg.writeEntry("Schema","8"); |
708 | colorMenu->setItemChecked(-8,TRUE); | 708 | colorMenu->setItemChecked(-8,TRUE); |
709 | } | 709 | } |
710 | if(iD==-10) {// Black, Red | 710 | if(iD==-10) {// Black, Red |
711 | foreground.setRgb(0x00,0x00,0x00); | 711 | foreground.setRgb(0x00,0x00,0x00); |
712 | background.setRgb(0xB2,0x18,0x18); | 712 | background.setRgb(0xB2,0x18,0x18); |
713 | cfg.writeEntry("Schema","10"); | 713 | cfg.writeEntry("Schema","10"); |
714 | colorMenu->setItemChecked(-10,TRUE); | 714 | colorMenu->setItemChecked(-10,TRUE); |
715 | } | 715 | } |
716 | if(iD==-11) {// Red, Black | 716 | if(iD==-11) {// Red, Black |
717 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 | 717 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 |
718 | background.setRgb(0x00,0x00,0x00); | 718 | background.setRgb(0x00,0x00,0x00); |
719 | cfg.writeEntry("Schema","11"); | 719 | cfg.writeEntry("Schema","11"); |
720 | colorMenu->setItemChecked(-11,TRUE); | 720 | colorMenu->setItemChecked(-11,TRUE); |
721 | } | 721 | } |
722 | if(iD==-12) {// Green, Yellow - is ugly | 722 | if(iD==-12) {// Green, Yellow - is ugly |
723 | // foreground.setRgb(0x18,0xB2,0x18); | 723 | // foreground.setRgb(0x18,0xB2,0x18); |
724 | foreground.setRgb(36,139,10); | 724 | foreground.setRgb(36,139,10); |
725 | // background.setRgb(0xB2,0x68,0x18); | 725 | // background.setRgb(0xB2,0x68,0x18); |
726 | background.setRgb(255,255,0); | 726 | background.setRgb(255,255,0); |
727 | cfg.writeEntry("Schema","12"); | 727 | cfg.writeEntry("Schema","12"); |
728 | colorMenu->setItemChecked(-12,TRUE); | 728 | colorMenu->setItemChecked(-12,TRUE); |
729 | } | 729 | } |
730 | if(iD==-13) {// Blue, Magenta | 730 | if(iD==-13) {// Blue, Magenta |
731 | foreground.setRgb(0x18,0xB2,0xB2); | 731 | foreground.setRgb(0x18,0xB2,0xB2); |
732 | background.setRgb(0x18,0x18,0xB2); | 732 | background.setRgb(0x18,0x18,0xB2); |
733 | cfg.writeEntry("Schema","13"); | 733 | cfg.writeEntry("Schema","13"); |
734 | colorMenu->setItemChecked(-13,TRUE); | 734 | colorMenu->setItemChecked(-13,TRUE); |
735 | } | 735 | } |
736 | if(iD==-14) {// Magenta, Blue | 736 | if(iD==-14) {// Magenta, Blue |
737 | foreground.setRgb(0x18,0x18,0xB2); | 737 | foreground.setRgb(0x18,0x18,0xB2); |
738 | background.setRgb(0x18,0xB2,0xB2); | 738 | background.setRgb(0x18,0xB2,0xB2); |
739 | cfg.writeEntry("Schema","14"); | 739 | cfg.writeEntry("Schema","14"); |
740 | colorMenu->setItemChecked(-14,TRUE); | 740 | colorMenu->setItemChecked(-14,TRUE); |
741 | } | 741 | } |
742 | if(iD==-15) {// Cyan, White | 742 | if(iD==-15) {// Cyan, White |
743 | foreground.setRgb(0x18,0xB2,0xB2); | 743 | foreground.setRgb(0x18,0xB2,0xB2); |
744 | background.setRgb(0xFF,0xFF,0xFF); | 744 | background.setRgb(0xFF,0xFF,0xFF); |
745 | cfg.writeEntry("Schema","15"); | 745 | cfg.writeEntry("Schema","15"); |
746 | colorMenu->setItemChecked(-15,TRUE); | 746 | colorMenu->setItemChecked(-15,TRUE); |
747 | } | 747 | } |
748 | if(iD==-16) {// White, Cyan | 748 | if(iD==-16) {// White, Cyan |
749 | background.setRgb(0x18,0xB2,0xB2); | 749 | background.setRgb(0x18,0xB2,0xB2); |
750 | foreground.setRgb(0xFF,0xFF,0xFF); | 750 | foreground.setRgb(0xFF,0xFF,0xFF); |
751 | cfg.writeEntry("Schema","16"); | 751 | cfg.writeEntry("Schema","16"); |
752 | colorMenu->setItemChecked(-16,TRUE); | 752 | colorMenu->setItemChecked(-16,TRUE); |
753 | } | 753 | } |
754 | if(iD==-17) {// Black, Blue | 754 | if(iD==-17) {// Black, Blue |
755 | background.setRgb(0x00,0x00,0x00); | 755 | background.setRgb(0x00,0x00,0x00); |
756 | foreground.setRgb(0x18,0xB2,0xB2); | 756 | foreground.setRgb(0x18,0xB2,0xB2); |
757 | cfg.writeEntry("Schema","17"); | 757 | cfg.writeEntry("Schema","17"); |
758 | colorMenu->setItemChecked(-17,TRUE); | 758 | colorMenu->setItemChecked(-17,TRUE); |
759 | } | 759 | } |
760 | if(iD==-18) {// Black, Gold | 760 | if(iD==-18) {// Black, Gold |
761 | background.setRgb(0x00,0x00,0x00); | 761 | background.setRgb(0x00,0x00,0x00); |
762 | foreground.setRgb(255,215,0); | 762 | foreground.setRgb(255,215,0); |
763 | cfg.writeEntry("Schema","18"); | 763 | cfg.writeEntry("Schema","18"); |
764 | colorMenu->setItemChecked(-18,TRUE); | 764 | colorMenu->setItemChecked(-18,TRUE); |
765 | } | 765 | } |
766 | #ifdef QT_QWS_OPIE | 766 | #ifdef QT_QWS_OPIE |
767 | if(iD==-19) { | 767 | if(iD==-19) { |
768 | // Custom | 768 | // Custom |
769 | qDebug("do custom"); | 769 | qDebug("do custom"); |
770 | if(fromMenu) { | 770 | if(fromMenu) { |
771 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); | 771 | OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, this, "foreground color"); |
772 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 772 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
773 | SLOT(changeForegroundColor(const QColor&))); | 773 | SLOT(changeForegroundColor(const QColor&))); |
774 | penColorPopupMenu->exec(); | 774 | penColorPopupMenu->exec(); |
775 | } | 775 | } |
776 | cfg.writeEntry("Schema","19"); | 776 | cfg.writeEntry("Schema","19"); |
777 | if(!fromMenu) { | 777 | if(!fromMenu) { |
778 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 778 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
779 | background.setNamedColor(cfg.readEntry("background","")); | 779 | background.setNamedColor(cfg.readEntry("background","")); |
780 | } | 780 | } |
781 | fromMenu=FALSE; | 781 | fromMenu=FALSE; |
782 | colorMenu->setItemChecked(-19,TRUE); | 782 | colorMenu->setItemChecked(-19,TRUE); |
783 | } | 783 | } |
784 | #endif | 784 | #endif |
785 | for (i = 0; i < TABLE_COLORS; i++) { | 785 | for (i = 0; i < TABLE_COLORS; i++) { |
786 | if(i==0 || i == 10) { | 786 | if(i==0 || i == 10) { |
787 | m_table[i].color = foreground; | 787 | m_table[i].color = foreground; |
788 | } | 788 | } |
789 | else if(i==1 || i == 11) { | 789 | else if(i==1 || i == 11) { |
790 | m_table[i].color = background; m_table[i].transparent=0; | 790 | m_table[i].color = background; m_table[i].transparent=0; |
791 | } | 791 | } |
792 | else | 792 | else |
793 | m_table[i].color = defaultCt[i].color; | 793 | m_table[i].color = defaultCt[i].color; |
794 | } | 794 | } |
795 | } | 795 | } |
796 | lastSelectedMenu = iD; | 796 | lastSelectedMenu = iD; |
797 | te->setColorTable(m_table); | 797 | te->setColorTable(m_table); |
798 | update(); | 798 | update(); |
799 | 799 | ||
800 | } | 800 | } |
801 | 801 | ||
802 | void Konsole::configMenuSelected(int iD) | 802 | void Konsole::configMenuSelected(int iD) |
803 | { | 803 | { |
804 | // QString temp; | 804 | // QString temp; |
805 | // qDebug( temp.sprintf("configmenu %d",iD)); | 805 | // qDebug( temp.sprintf("configmenu %d",iD)); |
806 | 806 | ||
807 | TEWidget* te = getTe(); | 807 | TEWidget* te = getTe(); |
808 | Config cfg("Konsole"); | 808 | Config cfg("Konsole"); |
809 | cfg.setGroup("Menubar"); | 809 | cfg.setGroup("Menubar"); |
810 | int i,j; | 810 | int i,j; |
811 | #ifdef QT_QWS_OPIE | 811 | #ifdef QT_QWS_OPIE |
812 | i=-29;j=-30; | 812 | i=-29;j=-30; |
813 | #else | 813 | #else |
814 | i=-28;j=-29; | 814 | i=-28;j=-29; |
815 | #endif | 815 | #endif |
816 | 816 | ||
817 | if(iD == -4) { | 817 | if(iD == -4) { |
818 | cfg.setGroup("Tabs"); | 818 | cfg.setGroup("Tabs"); |
819 | QString tmp=cfg.readEntry("Position","Bottom"); | 819 | QString tmp=cfg.readEntry("Position","Bottom"); |
820 | 820 | ||
821 | if(tmp=="Top") { | 821 | if(tmp=="Top") { |
822 | tab->setTabPosition(QTabWidget::Bottom); | 822 | tab->setTabPosition(QTabWidget::Bottom); |
823 | configMenu->changeItem( iD, tr("Tabs on Top")); | 823 | configMenu->changeItem( iD, tr("Tabs on Top")); |
824 | cfg.writeEntry("Position","Bottom"); | 824 | cfg.writeEntry("Position","Bottom"); |
825 | } else { | 825 | } else { |
826 | tab->setTabPosition(QTabWidget::Top); | 826 | tab->setTabPosition(QTabWidget::Top); |
827 | configMenu->changeItem( iD, tr("Tabs on Bottom")); | 827 | configMenu->changeItem( iD, tr("Tabs on Bottom")); |
828 | cfg.writeEntry("Position","Top"); | 828 | cfg.writeEntry("Position","Top"); |
829 | } | 829 | } |
830 | } | 830 | } |
831 | if(iD == i) { | 831 | if(iD == i) { |
832 | cfg.setGroup("ScrollBar"); | 832 | cfg.setGroup("ScrollBar"); |
833 | bool b=cfg.readBoolEntry("HorzScroll",0); | 833 | bool b=cfg.readBoolEntry("HorzScroll",0); |
834 | b=!b; | 834 | b=!b; |
835 | cfg.writeEntry("HorzScroll", b ); | 835 | cfg.writeEntry("HorzScroll", b ); |
836 | cfg.write(); | 836 | cfg.write(); |
837 | doWrap(); | 837 | doWrap(); |
838 | if(cfg.readNumEntry("Position",2) == 0) { | 838 | if(cfg.readNumEntry("Position",2) == 0) { |
839 | te->setScrollbarLocation(1); | 839 | te->setScrollbarLocation(1); |
840 | } else { | 840 | } else { |
841 | te->setScrollbarLocation(0); | 841 | te->setScrollbarLocation(0); |
842 | } | 842 | } |
843 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 843 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
844 | } | 844 | } |
845 | if(iD == j) { | 845 | if(iD == j) { |
846 | cfg.setGroup("Menubar"); | 846 | cfg.setGroup("Menubar"); |
847 | bool b=cfg.readBoolEntry("useBeep",0); | 847 | bool b=cfg.readBoolEntry("useBeep",0); |
848 | b=!b; | 848 | b=!b; |
849 | cfg.writeEntry("useBeep", b ); | 849 | cfg.writeEntry("useBeep", b ); |
850 | cfg.write(); | 850 | cfg.write(); |
851 | configMenu->setItemChecked(j,b); | 851 | configMenu->setItemChecked(j,b); |
852 | te->useBeep=b; | 852 | te->useBeep=b; |
853 | } | 853 | } |
854 | } | 854 | } |
855 | 855 | ||
856 | void Konsole::changeCommand(const QString &text, int c) | 856 | void Konsole::changeCommand(const QString &text, int c) |
857 | { | 857 | { |
858 | Config cfg("Konsole"); | 858 | Config cfg("Konsole"); |
859 | cfg.setGroup("Commands"); | 859 | cfg.setGroup("Commands"); |
860 | if(commonCmds[c] != text) { | 860 | if(commonCmds[c] != text) { |
861 | cfg.writeEntry(QString::number(c),text); | 861 | cfg.writeEntry(QString::number(c),text); |
862 | commonCombo->clearEdit(); | 862 | commonCombo->clearEdit(); |
863 | commonCombo->setCurrentItem(c); | 863 | commonCombo->setCurrentItem(c); |
864 | } | 864 | } |
865 | } | 865 | } |
866 | 866 | ||
867 | void Konsole::setColor() | 867 | void Konsole::setColor() |
868 | { | 868 | { |
869 | Config cfg("Konsole"); | 869 | Config cfg("Konsole"); |
870 | cfg.setGroup("Colors"); | 870 | cfg.setGroup("Colors"); |
871 | int scheme = cfg.readNumEntry("Schema",1); | 871 | int scheme = cfg.readNumEntry("Schema",1); |
872 | if(scheme != 1) colorMenuSelected( -scheme); | 872 | if(scheme != 1) colorMenuSelected( -scheme); |
873 | } | 873 | } |
874 | 874 | ||
875 | void Konsole::scrollMenuSelected(int index) | 875 | void Konsole::scrollMenuSelected(int index) |
876 | { | 876 | { |
877 | // qDebug( "scrollbar menu %d",index); | 877 | // qDebug( "scrollbar menu %d",index); |
878 | 878 | ||
879 | TEWidget* te = getTe(); | 879 | TEWidget* te = getTe(); |
880 | Config cfg("Konsole"); | 880 | Config cfg("Konsole"); |
881 | cfg.setGroup("ScrollBar"); | 881 | cfg.setGroup("ScrollBar"); |
882 | int i,j,k; | 882 | int i,j,k; |
883 | #ifdef QT_QWS_OPIE | 883 | #ifdef QT_QWS_OPIE |
884 | i=-25;j=-26;k=-27; | 884 | i=-25;j=-26;k=-27; |
885 | #else | 885 | #else |
886 | i=-24;j=-25;k=-26; | 886 | i=-24;j=-25;k=-26; |
887 | #endif | 887 | #endif |
888 | if(index == i) { | 888 | if(index == i) { |
889 | 889 | ||
890 | te->setScrollbarLocation(0); | 890 | te->setScrollbarLocation(0); |
891 | cfg.writeEntry("Position",0); | 891 | cfg.writeEntry("Position",0); |
892 | } else if(index == j) { | 892 | } else if(index == j) { |
893 | 893 | ||
894 | te->setScrollbarLocation(1); | 894 | te->setScrollbarLocation(1); |
895 | cfg.writeEntry("Position",1); | 895 | cfg.writeEntry("Position",1); |
896 | } else if(index == k) { | 896 | } else if(index == k) { |
897 | 897 | ||
898 | te->setScrollbarLocation(2); | 898 | te->setScrollbarLocation(2); |
899 | cfg.writeEntry("Position",2); | 899 | cfg.writeEntry("Position",2); |
900 | } | 900 | } |
901 | 901 | ||
902 | // case -29: { | 902 | // case -29: { |
903 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 903 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
904 | // cfg.writeEntry("HorzScroll", !b ); | 904 | // cfg.writeEntry("HorzScroll", !b ); |
905 | // cfg.write(); | 905 | // cfg.write(); |
906 | // if(cfg.readNumEntry("Position",2) == 0) { | 906 | // if(cfg.readNumEntry("Position",2) == 0) { |
907 | // te->setScrollbarLocation(1); | 907 | // te->setScrollbarLocation(1); |
908 | // te->setWrapAt(0); | 908 | // te->setWrapAt(0); |
909 | // } else { | 909 | // } else { |
910 | // te->setScrollbarLocation(0); | 910 | // te->setScrollbarLocation(0); |
911 | // te->setWrapAt(120); | 911 | // te->setWrapAt(120); |
912 | // } | 912 | // } |
913 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 913 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
914 | // } | 914 | // } |
915 | // break; | 915 | // break; |
916 | } | 916 | } |
917 | 917 | ||
918 | void Konsole::editCommandListMenuSelected(int iD) | 918 | void Konsole::editCommandListMenuSelected(int iD) |
919 | { | 919 | { |
920 | // QString temp; | 920 | // QString temp; |
921 | // qDebug( temp.sprintf("edit command list %d",iD)); | 921 | // qDebug( temp.sprintf("edit command list %d",iD)); |
922 | TEWidget* te = getTe(); | 922 | TEWidget* te = getTe(); |
923 | Config cfg("Konsole"); | 923 | Config cfg("Konsole"); |
924 | cfg.setGroup("Menubar"); | 924 | cfg.setGroup("Menubar"); |
925 | if( iD == -3) { | 925 | if( iD == -3) { |
926 | if(!secondToolBar->isHidden()) { | 926 | if(!secondToolBar->isHidden()) { |
927 | secondToolBar->hide(); | 927 | secondToolBar->hide(); |
928 | configMenu->changeItem( iD,tr( "Show Command List" )); | 928 | configMenu->changeItem( iD,tr( "Show Command List" )); |
929 | cfg.writeEntry("Hidden","TRUE"); | 929 | cfg.writeEntry("Hidden","TRUE"); |
930 | configMenu->setItemEnabled(-23 ,FALSE); | 930 | configMenu->setItemEnabled(-23 ,FALSE); |
931 | } else { | 931 | } else { |
932 | secondToolBar->show(); | 932 | secondToolBar->show(); |
933 | configMenu->changeItem( iD,tr( "Hide Command List" )); | 933 | configMenu->changeItem( iD,tr( "Hide Command List" )); |
934 | cfg.writeEntry("Hidden","FALSE"); | 934 | cfg.writeEntry("Hidden","FALSE"); |
935 | configMenu->setItemEnabled(-23 ,TRUE); | 935 | configMenu->setItemEnabled(-23 ,TRUE); |
936 | 936 | ||
937 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { | 937 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { |
938 | configMenu->setItemChecked(-23,TRUE); | 938 | configMenu->setItemChecked(-23,TRUE); |
939 | commonCombo->setEditable( TRUE ); | 939 | commonCombo->setEditable( TRUE ); |
940 | } else { | 940 | } else { |
941 | configMenu->setItemChecked(-23,FALSE); | 941 | configMenu->setItemChecked(-23,FALSE); |
942 | commonCombo->setEditable( FALSE ); | 942 | commonCombo->setEditable( FALSE ); |
943 | } | 943 | } |
944 | } | 944 | } |
945 | } | 945 | } |
946 | if( iD == -23) { | 946 | if( iD == -23) { |
947 | cfg.setGroup("Commands"); | 947 | cfg.setGroup("Commands"); |
948 | // qDebug("enableCommandEdit"); | 948 | // qDebug("enableCommandEdit"); |
949 | if( !configMenu->isItemChecked(iD) ) { | 949 | if( !configMenu->isItemChecked(iD) ) { |
950 | commonCombo->setEditable( TRUE ); | 950 | commonCombo->setEditable( TRUE ); |
951 | configMenu->setItemChecked(iD,TRUE); | 951 | configMenu->setItemChecked(iD,TRUE); |
952 | commonCombo->setCurrentItem(0); | 952 | commonCombo->setCurrentItem(0); |
953 | cfg.writeEntry("EditEnabled","TRUE"); | 953 | cfg.writeEntry("EditEnabled","TRUE"); |
954 | } else { | 954 | } else { |
955 | commonCombo->setEditable( FALSE ); | 955 | commonCombo->setEditable( FALSE ); |
956 | configMenu->setItemChecked(iD,FALSE); | 956 | configMenu->setItemChecked(iD,FALSE); |
957 | cfg.writeEntry("EditEnabled","FALSE"); | 957 | cfg.writeEntry("EditEnabled","FALSE"); |
958 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 958 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
959 | te->setFocus(); | 959 | te->setFocus(); |
960 | } | 960 | } |
961 | } | 961 | } |
962 | if(iD == -24) { | 962 | if(iD == -24) { |
963 | // "edit commands" | 963 | // "edit commands" |
964 | CommandEditDialog *m = new CommandEditDialog(this); | 964 | CommandEditDialog *m = new CommandEditDialog(this); |
965 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); | 965 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); |
966 | m->showMaximized(); | 966 | m->showMaximized(); |
967 | } | 967 | } |
968 | 968 | ||
969 | } | 969 | } |
970 | 970 | ||
971 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' | 971 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' |
972 | void Konsole::setDocument( const QString &cmd) { | 972 | void Konsole::setDocument( const QString &cmd) { |
973 | newSession(); | 973 | newSession(); |
974 | TEWidget* te = getTe(); | 974 | TEWidget* te = getTe(); |
975 | if(cmd.find("-e", 0, TRUE) != -1) { | 975 | if(cmd.find("-e", 0, TRUE) != -1) { |
976 | QString cmd2; | 976 | QString cmd2; |
977 | cmd2=cmd.right(cmd.length()-3)+" &"; | 977 | cmd2=cmd.right(cmd.length()-3)+" &"; |
978 | system(cmd2.latin1()); | 978 | system(cmd2.latin1()); |
979 | if(startUp <= 1 && nsessions < 2) { | 979 | if(startUp <= 1 && nsessions < 2) { |
980 | doneSession(getTe()->currentSession, 0); | 980 | doneSession(getTe()->currentSession, 0); |
981 | exit(0); | 981 | exit(0); |
982 | } else | 982 | } else |
983 | doneSession(getTe()->currentSession, 0); | 983 | doneSession(getTe()->currentSession, 0); |
984 | } else { | 984 | } else { |
985 | if (te != 0) { | 985 | if (te != 0) { |
986 | te->emitText(cmd+"\r"); | 986 | te->emitText(cmd+"\r"); |
987 | } | 987 | } |
988 | } | 988 | } |
989 | startUp++; | 989 | startUp++; |
990 | } | 990 | } |
991 | 991 | ||
992 | void Konsole::parseCommandLine() { | 992 | void Konsole::parseCommandLine() { |
993 | QString cmd; | 993 | QString cmd; |
994 | // newSession(); | 994 | // newSession(); |
995 | for (int i=1;i< qApp->argc();i++) { | 995 | for (int i=1;i< qApp->argc();i++) { |
996 | if( QString(qApp->argv()[i]) == "-e") { | 996 | if( QString(qApp->argv()[i]) == "-e") { |
997 | i++; | 997 | i++; |
998 | for ( int j=i;j< qApp->argc();j++) { | 998 | for ( int j=i;j< qApp->argc();j++) { |
999 | cmd+=QString(qApp->argv()[j])+" "; | 999 | cmd+=QString(qApp->argv()[j])+" "; |
1000 | } | 1000 | } |
1001 | cmd.stripWhiteSpace(); | 1001 | cmd.stripWhiteSpace(); |
1002 | system(cmd.latin1()); | 1002 | system(cmd.latin1()); |
1003 | exit(0);//close(); | 1003 | exit(0);//close(); |
1004 | } // end -e switch | 1004 | } // end -e switch |
1005 | } | 1005 | } |
1006 | startUp++; | 1006 | startUp++; |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | void Konsole::changeForegroundColor(const QColor &color) { | 1009 | void Konsole::changeForegroundColor(const QColor &color) { |
1010 | Config cfg("Konsole"); | 1010 | Config cfg("Konsole"); |
1011 | cfg.setGroup("Colors"); | 1011 | cfg.setGroup("Colors"); |
1012 | int r, g, b; | 1012 | int r, g, b; |
1013 | color.rgb(&r,&g,&b); | 1013 | color.rgb(&r,&g,&b); |
1014 | foreground.setRgb(r,g,b); | 1014 | foreground.setRgb(r,g,b); |
1015 | 1015 | ||
1016 | cfg.writeEntry("foreground",color.name()); | 1016 | cfg.writeEntry("foreground",color.name()); |
1017 | qDebug("foreground "+color.name()); | 1017 | qDebug("foreground "+color.name()); |
1018 | cfg.write(); | 1018 | cfg.write(); |
1019 | 1019 | ||
1020 | qDebug("do other dialog"); | 1020 | qDebug("do other dialog"); |
1021 | #ifdef QT_QWS_OPIE | 1021 | #ifdef QT_QWS_OPIE |
1022 | 1022 | ||
1023 | ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); | 1023 | OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color"); |
1024 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 1024 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
1025 | SLOT(changeBackgroundColor(const QColor&))); | 1025 | SLOT(changeBackgroundColor(const QColor&))); |
1026 | penColorPopupMenu2->exec(); | 1026 | penColorPopupMenu2->exec(); |
1027 | #endif | 1027 | #endif |
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | void Konsole::changeBackgroundColor(const QColor &color) { | 1030 | void Konsole::changeBackgroundColor(const QColor &color) { |
1031 | 1031 | ||
1032 | qDebug("Change background"); | 1032 | qDebug("Change background"); |
1033 | Config cfg("Konsole"); | 1033 | Config cfg("Konsole"); |
1034 | cfg.setGroup("Colors"); | 1034 | cfg.setGroup("Colors"); |
1035 | int r, g, b; | 1035 | int r, g, b; |
1036 | color.rgb(&r,&g,&b); | 1036 | color.rgb(&r,&g,&b); |
1037 | background.setRgb(r,g,b); | 1037 | background.setRgb(r,g,b); |
1038 | cfg.writeEntry("background",color.name()); | 1038 | cfg.writeEntry("background",color.name()); |
1039 | qDebug("background "+color.name()); | 1039 | qDebug("background "+color.name()); |
1040 | cfg.write(); | 1040 | cfg.write(); |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | void Konsole::doWrap() { | 1043 | void Konsole::doWrap() { |
1044 | int i; | 1044 | int i; |
1045 | #ifdef QT_QWS_OPIE | 1045 | #ifdef QT_QWS_OPIE |
1046 | i=-29; | 1046 | i=-29; |
1047 | #else | 1047 | #else |
1048 | i=-28; | 1048 | i=-28; |
1049 | #endif | 1049 | #endif |
1050 | 1050 | ||
1051 | Config cfg("Konsole"); | 1051 | Config cfg("Konsole"); |
1052 | cfg.setGroup("ScrollBar"); | 1052 | cfg.setGroup("ScrollBar"); |
1053 | TEWidget* te = getTe(); | 1053 | TEWidget* te = getTe(); |
1054 | if( !cfg.readBoolEntry("HorzScroll",0)) { | 1054 | if( !cfg.readBoolEntry("HorzScroll",0)) { |
1055 | te->setWrapAt(0); | 1055 | te->setWrapAt(0); |
1056 | configMenu->setItemChecked( i,TRUE); | 1056 | configMenu->setItemChecked( i,TRUE); |
1057 | } else { | 1057 | } else { |
1058 | // te->setWrapAt(90); | 1058 | // te->setWrapAt(90); |
1059 | te->setWrapAt(120); | 1059 | te->setWrapAt(120); |
1060 | configMenu->setItemChecked( i,FALSE); | 1060 | configMenu->setItemChecked( i,FALSE); |
1061 | } | 1061 | } |
1062 | } | 1062 | } |