-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index eafc12e..084c39d 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,1914 +1,1955 @@ | |||
1 | 1 | ||
2 | /* ---------------------------------------------------------------------- */ | 2 | /* ---------------------------------------------------------------------- */ |
3 | /* */ | 3 | /* */ |
4 | /* [main.C] Konsole */ | 4 | /* [main.C] Konsole */ |
5 | /* */ | 5 | /* */ |
6 | /* ---------------------------------------------------------------------- */ | 6 | /* ---------------------------------------------------------------------- */ |
7 | /* */ | 7 | /* */ |
8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
9 | /* */ | 9 | /* */ |
10 | /* This file is part of Konsole, an X terminal. */ | 10 | /* This file is part of Konsole, an X terminal. */ |
11 | /* */ | 11 | /* */ |
12 | /* The material contained in here more or less directly orginates from */ | 12 | /* The material contained in here more or less directly orginates from */ |
13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
14 | /* */ | 14 | /* */ |
15 | /* ---------------------------------------------------------------------- */ | 15 | /* ---------------------------------------------------------------------- */ |
16 | /* */ | 16 | /* */ |
17 | /* Ported Konsole to Qt/Embedded */ | 17 | /* Ported Konsole to Qt/Embedded */ |
18 | /* */ | 18 | /* */ |
19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
20 | /* */ | 20 | /* */ |
21 | /* -------------------------------------------------------------------------- */ | 21 | /* -------------------------------------------------------------------------- */ |
22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
23 | // enhancements added by Phillip Kuhn | 23 | // enhancements added by Phillip Kuhn |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <sys/types.h> | ||
27 | #include <pwd.h> | ||
28 | #include <unistd.h> | ||
26 | 29 | ||
27 | #ifdef QT_QWS_OPIE | 30 | #ifdef QT_QWS_OPIE |
28 | #include <opie2/ocolorpopupmenu.h> | 31 | #include <opie2/ocolorpopupmenu.h> |
29 | #endif | 32 | #endif |
30 | 33 | ||
31 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
32 | 35 | ||
33 | #include <qdir.h> | 36 | #include <qdir.h> |
34 | #include <qevent.h> | 37 | #include <qevent.h> |
35 | #include <qdragobject.h> | 38 | #include <qdragobject.h> |
36 | #include <qobjectlist.h> | 39 | #include <qobjectlist.h> |
37 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
38 | #include <qtoolbar.h> | 41 | #include <qtoolbar.h> |
39 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
40 | #include <qfontdialog.h> | 43 | #include <qfontdialog.h> |
41 | #include <qglobal.h> | 44 | #include <qglobal.h> |
42 | #include <qpainter.h> | 45 | #include <qpainter.h> |
43 | #include <qmenubar.h> | 46 | #include <qmenubar.h> |
44 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
45 | #include <qaction.h> | 48 | #include <qaction.h> |
46 | #include <qapplication.h> | 49 | #include <qapplication.h> |
47 | #include <qfontmetrics.h> | 50 | #include <qfontmetrics.h> |
48 | #include <qcombobox.h> | 51 | #include <qcombobox.h> |
49 | #include <qevent.h> | 52 | #include <qevent.h> |
50 | #include <qtabwidget.h> | 53 | #include <qtabwidget.h> |
51 | #include <qtabbar.h> | 54 | #include <qtabbar.h> |
52 | #include <qpe/config.h> | 55 | #include <qpe/config.h> |
53 | #include <qstringlist.h> | 56 | #include <qstringlist.h> |
54 | #include <qpalette.h> | 57 | #include <qpalette.h> |
55 | #include <qfontdatabase.h> | 58 | #include <qfontdatabase.h> |
56 | #include <qfile.h> | 59 | #include <qfile.h> |
57 | #include <qspinbox.h> | 60 | #include <qspinbox.h> |
58 | #include <qlayout.h> | 61 | #include <qlayout.h> |
59 | #include <qvbox.h> | 62 | #include <qvbox.h> |
60 | 63 | ||
61 | #include <sys/wait.h> | 64 | #include <sys/wait.h> |
62 | #include <stdio.h> | 65 | #include <stdio.h> |
63 | #include <stdlib.h> | 66 | #include <stdlib.h> |
64 | #include <assert.h> | 67 | #include <assert.h> |
65 | 68 | ||
66 | #include "konsole.h" | 69 | #include "konsole.h" |
67 | #include "keytrans.h" | 70 | #include "keytrans.h" |
68 | #include "commandeditdialog.h" | 71 | #include "commandeditdialog.h" |
69 | 72 | ||
70 | class EKNumTabBar : public QTabBar | 73 | class EKNumTabBar : public QTabBar |
71 | { | 74 | { |
72 | public: | 75 | public: |
73 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : | 76 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : |
74 | QTabBar(parent, name) | 77 | QTabBar(parent, name) |
75 | {} | 78 | {} |
76 | 79 | ||
77 | // QList<QTab> *getTabList() { return(tabList()); } | 80 | // QList<QTab> *getTabList() { return(tabList()); } |
78 | 81 | ||
79 | void numberTabs() | 82 | void numberTabs() |
80 | { | 83 | { |
81 | // Yes, it really is this messy. QTabWidget needs functions | 84 | // Yes, it really is this messy. QTabWidget needs functions |
82 | // that provide acces to tabs in a sequential way. | 85 | // that provide acces to tabs in a sequential way. |
83 | int m=INT_MIN; | 86 | int m=INT_MIN; |
84 | for (int i=0; i<count(); i++) | 87 | for (int i=0; i<count(); i++) |
85 | { | 88 | { |
86 | QTab* left=0; | 89 | QTab* left=0; |
87 | QListIterator<QTab> it(*tabList()); | 90 | QListIterator<QTab> it(*tabList()); |
88 | int x=INT_MAX; | 91 | int x=INT_MAX; |
89 | for( QTab* t; (t=it.current()); ++it ) | 92 | for( QTab* t; (t=it.current()); ++it ) |
90 | { | 93 | { |
91 | int tx = t->rect().x(); | 94 | int tx = t->rect().x(); |
92 | if ( tx<x && tx>m ) | 95 | if ( tx<x && tx>m ) |
93 | { | 96 | { |
94 | x = tx; | 97 | x = tx; |
95 | left = t; | 98 | left = t; |
96 | } | 99 | } |
97 | } | 100 | } |
98 | if ( left ) | 101 | if ( left ) |
99 | { | 102 | { |
100 | left->setText(QString::number(i+1)); | 103 | left->setText(QString::number(i+1)); |
101 | m = left->rect().x(); | 104 | m = left->rect().x(); |
102 | } | 105 | } |
103 | } | 106 | } |
104 | } | 107 | } |
105 | 108 | ||
106 | virtual QSize sizeHint() const | 109 | virtual QSize sizeHint() const |
107 | { | 110 | { |
108 | if (isHidden()) | 111 | if (isHidden()) |
109 | { | 112 | { |
110 | return(QSize(0,0)); | 113 | return(QSize(0,0)); |
111 | } | 114 | } |
112 | else | 115 | else |
113 | { | 116 | { |
114 | QSize size = QTabBar::sizeHint(); | 117 | QSize size = QTabBar::sizeHint(); |
115 | int shrink = 5; | 118 | int shrink = 5; |
116 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 119 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
117 | { | 120 | { |
118 | shrink = 10; | 121 | shrink = 10; |
119 | } | 122 | } |
120 | size.setHeight(size.height() - shrink); | 123 | size.setHeight(size.height() - shrink); |
121 | return(size); | 124 | return(size); |
122 | } | 125 | } |
123 | } | 126 | } |
124 | 127 | ||
125 | }; | 128 | }; |
126 | 129 | ||
127 | class EKNumTabWidget : public QTabWidget | 130 | class EKNumTabWidget : public QTabWidget |
128 | { | 131 | { |
129 | public: | 132 | public: |
130 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 133 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
131 | { | 134 | { |
132 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); | 135 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); |
133 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 136 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
134 | } | 137 | } |
135 | 138 | ||
136 | EKNumTabBar *getTabBar() const | 139 | EKNumTabBar *getTabBar() const |
137 | { | 140 | { |
138 | return ((EKNumTabBar*)tabBar()); | 141 | return ((EKNumTabBar*)tabBar()); |
139 | } | 142 | } |
140 | 143 | ||
141 | 144 | ||
142 | void addTab(QWidget* w) | 145 | void addTab(QWidget* w) |
143 | { | 146 | { |
144 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 147 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
145 | QTabWidget::addTab(w,t); | 148 | QTabWidget::addTab(w,t); |
146 | } | 149 | } |
147 | 150 | ||
148 | void removeTab(QWidget* w) | 151 | void removeTab(QWidget* w) |
149 | { | 152 | { |
150 | removePage(w); | 153 | removePage(w); |
151 | ((EKNumTabBar*)tabBar())->numberTabs(); | 154 | ((EKNumTabBar*)tabBar())->numberTabs(); |
152 | } | 155 | } |
153 | }; | 156 | }; |
154 | 157 | ||
155 | // This could be configurable or dynamicly generated from the bash history | 158 | // This could be configurable or dynamicly generated from the bash history |
156 | // file of the user | 159 | // file of the user |
157 | static const char *commonCmds[] = | 160 | static const char *commonCmds[] = |
158 | { | 161 | { |
159 | "ls ", // I left this here, cause it looks better than the first alpha | 162 | "ls ", // I left this here, cause it looks better than the first alpha |
160 | "cardctl eject", | 163 | "cardctl eject", |
161 | "cat ", | 164 | "cat ", |
162 | "cd ", | 165 | "cd ", |
163 | "chmod ", | 166 | "chmod ", |
164 | "clear", | 167 | "clear", |
165 | "cp ", | 168 | "cp ", |
166 | "dc ", | 169 | "dc ", |
167 | "df ", | 170 | "df ", |
168 | "dmesg", | 171 | "dmesg", |
169 | "echo ", | 172 | "echo ", |
170 | "env", | 173 | "env", |
171 | "find ", | 174 | "find ", |
172 | "free", | 175 | "free", |
173 | "grep ", | 176 | "grep ", |
174 | "ifconfig ", | 177 | "ifconfig ", |
175 | "ipkg ", | 178 | "ipkg ", |
176 | "mkdir ", | 179 | "mkdir ", |
177 | "mv ", | 180 | "mv ", |
178 | "nc localhost 7776", | 181 | "nc localhost 7776", |
179 | "nc localhost 7777", | 182 | "nc localhost 7777", |
180 | "netstat ", | 183 | "netstat ", |
181 | "nslookup ", | 184 | "nslookup ", |
182 | "ping ", | 185 | "ping ", |
183 | "ps aux", | 186 | "ps aux", |
184 | "pwd ", | 187 | "pwd ", |
185 | "qcop QPE/System 'linkChanged(QString)' ''", | 188 | "qcop QPE/System 'linkChanged(QString)' ''", |
186 | "qcop QPE/System 'restart()'", | 189 | "qcop QPE/System 'restart()'", |
187 | "qcop QPE/System 'quit()'", | 190 | "qcop QPE/System 'quit()'", |
188 | "rm ", | 191 | "rm ", |
189 | "rmdir ", | 192 | "rmdir ", |
190 | "route ", | 193 | "route ", |
191 | "set ", | 194 | "set ", |
192 | "traceroute", | 195 | "traceroute", |
193 | 196 | ||
194 | /* | 197 | /* |
195 | "gzip", | 198 | "gzip", |
196 | "gunzip", | 199 | "gunzip", |
197 | "chgrp", | 200 | "chgrp", |
198 | "chown", | 201 | "chown", |
199 | "date", | 202 | "date", |
200 | "dd", | 203 | "dd", |
201 | "df", | 204 | "df", |
202 | "dmesg", | 205 | "dmesg", |
203 | "fuser", | 206 | "fuser", |
204 | "hostname", | 207 | "hostname", |
205 | "kill", | 208 | "kill", |
206 | "killall", | 209 | "killall", |
207 | "ln", | 210 | "ln", |
208 | "ping", | 211 | "ping", |
209 | "mount", | 212 | "mount", |
210 | "more", | 213 | "more", |
211 | "sort", | 214 | "sort", |
212 | "touch", | 215 | "touch", |
213 | "umount", | 216 | "umount", |
214 | "mknod", | 217 | "mknod", |
215 | "netstat", | 218 | "netstat", |
216 | */ | 219 | */ |
217 | 220 | ||
218 | "exit", | 221 | "exit", |
219 | NULL | 222 | NULL |
220 | }; | 223 | }; |
221 | 224 | ||
222 | 225 | ||
226 | static void konsoleInit(const char** shell) { | ||
227 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | ||
228 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | ||
229 | |||
230 | |||
231 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | ||
232 | |||
233 | qDebug("keyboard grabbed"); | ||
234 | #ifdef FAKE_CTRL_AND_ALT | ||
235 | qDebug("Fake Ctrl and Alt defined"); | ||
236 | QPEApplication::grabKeyboard(); // for CTRL and ALT | ||
237 | #endif | ||
238 | |||
239 | *shell = getenv("SHELL"); | ||
240 | qWarning("SHell initially is %s", *shell ); | ||
241 | |||
242 | if (shell == NULL || *shell == '\0') { | ||
243 | struct passwd *ent = 0; | ||
244 | uid_t me = getuid(); | ||
245 | *shell = "/bin/sh"; | ||
246 | |||
247 | while ( (ent = getpwent()) != 0 ) { | ||
248 | if (ent->pw_uid == me) { | ||
249 | if (ent->pw_shell != "") | ||
250 | *shell = ent->pw_shell; | ||
251 | break; | ||
252 | } | ||
253 | } | ||
254 | endpwent(); | ||
255 | } | ||
256 | |||
257 | if( putenv((char*)"COLORTERM=") !=0) | ||
258 | qDebug("putenv failed"); // to trigger mc's color detection | ||
259 | } | ||
260 | |||
261 | |||
223 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 262 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
224 | QMainWindow(parent, name, fl) | 263 | QMainWindow(parent, name, fl) |
225 | { | 264 | { |
226 | QStrList args; | 265 | QStrList tmp; const char* shell; |
227 | init("/bin/bash",args); | 266 | |
267 | konsoleInit( &shell); | ||
268 | init(shell,tmp); | ||
228 | } | 269 | } |
229 | 270 | ||
230 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 271 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
231 | : QMainWindow(0, name) | 272 | : QMainWindow(0, name) |
232 | { | 273 | { |
233 | init(_pgm,_args); | 274 | init(_pgm,_args); |
234 | } | 275 | } |
235 | 276 | ||
236 | struct HistoryItem | 277 | struct HistoryItem |
237 | { | 278 | { |
238 | HistoryItem(int c, const QString &l) | 279 | HistoryItem(int c, const QString &l) |
239 | { | 280 | { |
240 | count = c; | 281 | count = c; |
241 | line = l; | 282 | line = l; |
242 | } | 283 | } |
243 | int count; | 284 | int count; |
244 | QString line; | 285 | QString line; |
245 | }; | 286 | }; |
246 | 287 | ||
247 | class HistoryList : public QList<HistoryItem> | 288 | class HistoryList : public QList<HistoryItem> |
248 | { | 289 | { |
249 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 290 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
250 | { | 291 | { |
251 | int c1 = ((HistoryItem*)item1)->count; | 292 | int c1 = ((HistoryItem*)item1)->count; |
252 | int c2 = ((HistoryItem*)item2)->count; | 293 | int c2 = ((HistoryItem*)item2)->count; |
253 | if (c1 > c2) | 294 | if (c1 > c2) |
254 | return(1); | 295 | return(1); |
255 | if (c1 < c2) | 296 | if (c1 < c2) |
256 | return(-1); | 297 | return(-1); |
257 | return(0); | 298 | return(0); |
258 | } | 299 | } |
259 | }; | 300 | }; |
260 | 301 | ||
261 | void Konsole::initCommandList() | 302 | void Konsole::initCommandList() |
262 | { | 303 | { |
263 | // qDebug("Konsole::initCommandList"); | 304 | // qDebug("Konsole::initCommandList"); |
264 | Config cfg( "Konsole" ); | 305 | Config cfg( "Konsole" ); |
265 | cfg.setGroup("Commands"); | 306 | cfg.setGroup("Commands"); |
266 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 307 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
267 | commonCombo->clear(); | 308 | commonCombo->clear(); |
268 | 309 | ||
269 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") | 310 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") |
270 | { | 311 | { |
271 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 312 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
272 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 313 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
273 | QFile histfile(histfilename); | 314 | QFile histfile(histfilename); |
274 | // note: compiler barfed on: | 315 | // note: compiler barfed on: |
275 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 316 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
276 | if (histfile.open( IO_ReadOnly )) | 317 | if (histfile.open( IO_ReadOnly )) |
277 | { | 318 | { |
278 | QString line; | 319 | QString line; |
279 | uint i; | 320 | uint i; |
280 | HistoryList items; | 321 | HistoryList items; |
281 | 322 | ||
282 | int lineno = 0; | 323 | int lineno = 0; |
283 | while(!histfile.atEnd()) | 324 | while(!histfile.atEnd()) |
284 | { | 325 | { |
285 | if (histfile.readLine(line, 200) < 0) | 326 | if (histfile.readLine(line, 200) < 0) |
286 | { | 327 | { |
287 | break; | 328 | break; |
288 | } | 329 | } |
289 | line = line.left(line.length()-1); | 330 | line = line.left(line.length()-1); |
290 | lineno++; | 331 | lineno++; |
291 | 332 | ||
292 | for(i=0; i<items.count(); i++) | 333 | for(i=0; i<items.count(); i++) |
293 | { | 334 | { |
294 | if (line == items.at(i)->line) | 335 | if (line == items.at(i)->line) |
295 | { | 336 | { |
296 | // weight recent commands & repeated commands more | 337 | // weight recent commands & repeated commands more |
297 | // by adding up the index of each command | 338 | // by adding up the index of each command |
298 | items.at(i)->count += lineno; | 339 | items.at(i)->count += lineno; |
299 | break; | 340 | break; |
300 | } | 341 | } |
301 | } | 342 | } |
302 | if (i >= items.count()) | 343 | if (i >= items.count()) |
303 | { | 344 | { |
304 | items.append(new HistoryItem(lineno, line)); | 345 | items.append(new HistoryItem(lineno, line)); |
305 | } | 346 | } |
306 | } | 347 | } |
307 | items.sort(); | 348 | items.sort(); |
308 | int n = items.count(); | 349 | int n = items.count(); |
309 | if (n > 40) | 350 | if (n > 40) |
310 | { | 351 | { |
311 | n = 40; | 352 | n = 40; |
312 | } | 353 | } |
313 | for(int i=0; i<n; i++) | 354 | for(int i=0; i<n; i++) |
314 | { | 355 | { |
315 | // should insert start of command, but keep whole thing | 356 | // should insert start of command, but keep whole thing |
316 | if (items.at(items.count()-i-1)->line.length() < 30) | 357 | if (items.at(items.count()-i-1)->line.length() < 30) |
317 | { | 358 | { |
318 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 359 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
319 | } | 360 | } |
320 | } | 361 | } |
321 | histfile.close(); | 362 | histfile.close(); |
322 | } | 363 | } |
323 | } | 364 | } |
324 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") | 365 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") |
325 | { | 366 | { |
326 | for (int i = 0; commonCmds[i] != NULL; i++) | 367 | for (int i = 0; commonCmds[i] != NULL; i++) |
327 | { | 368 | { |
328 | commonCombo->insertItem(commonCmds[i]); | 369 | commonCombo->insertItem(commonCmds[i]); |
329 | } | 370 | } |
330 | } | 371 | } |
331 | else | 372 | else |
332 | { | 373 | { |
333 | for (int i = 0; i < 100; i++) | 374 | for (int i = 0; i < 100; i++) |
334 | { | 375 | { |
335 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 376 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
336 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 377 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
337 | } | 378 | } |
338 | } | 379 | } |
339 | 380 | ||
340 | 381 | ||
341 | } | 382 | } |
342 | 383 | ||
343 | static void sig_handler(int x) | 384 | static void sig_handler(int x) |
344 | { | 385 | { |
345 | printf("got signal %d\n",x); | 386 | printf("got signal %d\n",x); |
346 | } | 387 | } |
347 | 388 | ||
348 | void Konsole::init(const char* _pgm, QStrList & _args) | 389 | void Konsole::init(const char* _pgm, QStrList & _args) |
349 | { | 390 | { |
350 | 391 | ||
351 | #if 0 | 392 | #if 0 |
352 | for(int i=1; i<=31; i++) | 393 | for(int i=1; i<=31; i++) |
353 | { | 394 | { |
354 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 395 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
355 | && i != SIGINT && i != SIGILL && i != SIGTERM | 396 | && i != SIGINT && i != SIGILL && i != SIGTERM |
356 | && i != SIGBUS) | 397 | && i != SIGBUS) |
357 | signal(i,sig_handler); | 398 | signal(i,sig_handler); |
358 | } | 399 | } |
359 | #endif | 400 | #endif |
360 | signal(SIGSTOP, sig_handler); | 401 | signal(SIGSTOP, sig_handler); |
361 | signal(SIGCONT, sig_handler); | 402 | signal(SIGCONT, sig_handler); |
362 | signal(SIGTSTP, sig_handler); | 403 | signal(SIGTSTP, sig_handler); |
363 | 404 | ||
364 | b_scroll = TRUE; // histon; | 405 | b_scroll = TRUE; // histon; |
365 | n_keytab = 0; | 406 | n_keytab = 0; |
366 | n_render = 0; | 407 | n_render = 0; |
367 | startUp=0; | 408 | startUp=0; |
368 | fromMenu = FALSE; | 409 | fromMenu = FALSE; |
369 | fullscreen = false; | 410 | fullscreen = false; |
370 | 411 | ||
371 | setCaption( tr( "Konsole" ) ); | 412 | setCaption( tr( "Konsole" ) ); |
372 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); | 413 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); |
373 | 414 | ||
374 | Config cfg( "Konsole" ); | 415 | Config cfg( "Konsole" ); |
375 | cfg.setGroup("Font"); | 416 | cfg.setGroup("Font"); |
376 | QString tmp; | 417 | QString tmp; |
377 | 418 | ||
378 | // initialize the list of allowed fonts /////////////////////////////////// | 419 | // initialize the list of allowed fonts /////////////////////////////////// |
379 | 420 | ||
380 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 421 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
381 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 422 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
382 | 423 | ||
383 | cfont = -1; | 424 | cfont = -1; |
384 | 425 | ||
385 | // this code causes repeated access to all the font files | 426 | // this code causes repeated access to all the font files |
386 | // which does slow down startup | 427 | // which does slow down startup |
387 | QFontDatabase fontDB; | 428 | QFontDatabase fontDB; |
388 | QStringList familyNames; | 429 | QStringList familyNames; |
389 | familyNames = fontDB.families( FALSE ); | 430 | familyNames = fontDB.families( FALSE ); |
390 | QString s; | 431 | QString s; |
391 | int fontIndex = 0; | 432 | int fontIndex = 0; |
392 | int familyNum = 0; | 433 | int familyNum = 0; |
393 | fontList = new QPopupMenu( this ); | 434 | fontList = new QPopupMenu( this ); |
394 | 435 | ||
395 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 436 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
396 | { | 437 | { |
397 | s = familyNames[j]; | 438 | s = familyNames[j]; |
398 | if ( s.contains('-') ) | 439 | if ( s.contains('-') ) |
399 | { | 440 | { |
400 | int i = s.find('-'); | 441 | int i = s.find('-'); |
401 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 442 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
402 | } | 443 | } |
403 | s[0] = s[0].upper(); | 444 | s[0] = s[0].upper(); |
404 | 445 | ||
405 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 446 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
406 | 447 | ||
407 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 448 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
408 | sizes.count()); | 449 | sizes.count()); |
409 | 450 | ||
410 | if (sizes.count() > 0) | 451 | if (sizes.count() > 0) |
411 | { | 452 | { |
412 | QPopupMenu *sizeMenu; | 453 | QPopupMenu *sizeMenu; |
413 | QFont f; | 454 | QFont f; |
414 | int last_width = -1; | 455 | int last_width = -1; |
415 | sizeMenu = NULL; | 456 | sizeMenu = NULL; |
416 | 457 | ||
417 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 458 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
418 | { | 459 | { |
419 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 460 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
420 | // need to divide by 10 on the Z, but not otherwise | 461 | // need to divide by 10 on the Z, but not otherwise |
421 | int size; | 462 | int size; |
422 | 463 | ||
423 | if (i >= (uint)sizes.count()) | 464 | if (i >= (uint)sizes.count()) |
424 | { | 465 | { |
425 | // try for expandable fonts | 466 | // try for expandable fonts |
426 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 467 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
427 | } | 468 | } |
428 | else | 469 | else |
429 | { | 470 | { |
430 | printf("sizes[%d] = %d\n", i, sizes[i]); | 471 | printf("sizes[%d] = %d\n", i, sizes[i]); |
431 | size = sizes[i]; | 472 | size = sizes[i]; |
432 | } | 473 | } |
433 | 474 | ||
434 | f = QFont(familyNames[j], size); | 475 | f = QFont(familyNames[j], size); |
435 | f.setFixedPitch(true); | 476 | f.setFixedPitch(true); |
436 | QFontMetrics fm(f); | 477 | QFontMetrics fm(f); |
437 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 478 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
438 | if (fm.width("l") == fm.width("m") | 479 | if (fm.width("l") == fm.width("m") |
439 | && (i < (uint)sizes.count() | 480 | && (i < (uint)sizes.count() |
440 | || fm.width("m") > last_width)) | 481 | || fm.width("m") > last_width)) |
441 | { | 482 | { |
442 | if (i < (uint)sizes.count()) | 483 | if (i < (uint)sizes.count()) |
443 | { | 484 | { |
444 | last_width = fm.width("m"); | 485 | last_width = fm.width("m"); |
445 | } | 486 | } |
446 | if (sizeMenu == NULL) | 487 | if (sizeMenu == NULL) |
447 | { | 488 | { |
448 | sizeMenu = new QPopupMenu(); | 489 | sizeMenu = new QPopupMenu(); |
449 | } | 490 | } |
450 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 491 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
451 | sizeMenu->setItemParameter(id, fontIndex); | 492 | sizeMenu->setItemParameter(id, fontIndex); |
452 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 493 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
453 | QString name = s + " " + QString::number(size); | 494 | QString name = s + " " + QString::number(size); |
454 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 495 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
455 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 496 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
456 | { | 497 | { |
457 | cfont = fontIndex; | 498 | cfont = fontIndex; |
458 | } | 499 | } |
459 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 500 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
460 | fontIndex++; | 501 | fontIndex++; |
461 | } | 502 | } |
462 | } | 503 | } |
463 | if (sizeMenu) | 504 | if (sizeMenu) |
464 | { | 505 | { |
465 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 506 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
466 | 507 | ||
467 | familyNum++; | 508 | familyNum++; |
468 | } | 509 | } |
469 | } | 510 | } |
470 | 511 | ||
471 | } | 512 | } |
472 | 513 | ||
473 | if (cfont < 0 || cfont >= (int)fonts.count()) | 514 | if (cfont < 0 || cfont >= (int)fonts.count()) |
474 | { | 515 | { |
475 | cfont = 0; | 516 | cfont = 0; |
476 | } | 517 | } |
477 | 518 | ||
478 | // create terminal emulation framework //////////////////////////////////// | 519 | // create terminal emulation framework //////////////////////////////////// |
479 | nsessions = 0; | 520 | nsessions = 0; |
480 | 521 | ||
481 | tab = new EKNumTabWidget(this); | 522 | tab = new EKNumTabWidget(this); |
482 | // tab->setMargin(tab->margin()-5); | 523 | // tab->setMargin(tab->margin()-5); |
483 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 524 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
484 | 525 | ||
485 | // create terminal toolbar //////////////////////////////////////////////// | 526 | // create terminal toolbar //////////////////////////////////////////////// |
486 | setToolBarsMovable( FALSE ); | 527 | setToolBarsMovable( FALSE ); |
487 | menuToolBar = new QToolBar( this ); | 528 | menuToolBar = new QToolBar( this ); |
488 | menuToolBar->setHorizontalStretchable( TRUE ); | 529 | menuToolBar->setHorizontalStretchable( TRUE ); |
489 | 530 | ||
490 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 531 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
491 | 532 | ||
492 | bool c7xx = false; | 533 | bool c7xx = false; |
493 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 534 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
494 | { | 535 | { |
495 | c7xx = true; | 536 | c7xx = true; |
496 | } | 537 | } |
497 | QFont menuFont; | 538 | QFont menuFont; |
498 | menuFont.setPointSize(c7xx? 18 : 10); | 539 | menuFont.setPointSize(c7xx? 18 : 10); |
499 | qApp->setFont(menuFont, true); | 540 | qApp->setFont(menuFont, true); |
500 | 541 | ||
501 | setFont(cfont); | 542 | setFont(cfont); |
502 | 543 | ||
503 | configMenu = new QPopupMenu( this); | 544 | configMenu = new QPopupMenu( this); |
504 | colorMenu = new QPopupMenu( this); | 545 | colorMenu = new QPopupMenu( this); |
505 | scrollMenu = new QPopupMenu( this); | 546 | scrollMenu = new QPopupMenu( this); |
506 | editCommandListMenu = new QPopupMenu( this); | 547 | editCommandListMenu = new QPopupMenu( this); |
507 | 548 | ||
508 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 549 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
509 | 550 | ||
510 | bool listHidden; | 551 | bool listHidden; |
511 | cfg.setGroup("Menubar"); | 552 | cfg.setGroup("Menubar"); |
512 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 553 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
513 | { | 554 | { |
514 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 555 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
515 | listHidden=TRUE; | 556 | listHidden=TRUE; |
516 | } | 557 | } |
517 | else | 558 | else |
518 | { | 559 | { |
519 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 560 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
520 | listHidden=FALSE; | 561 | listHidden=FALSE; |
521 | } | 562 | } |
522 | 563 | ||
523 | cfg.setGroup("Tabs"); | 564 | cfg.setGroup("Tabs"); |
524 | 565 | ||
525 | tabMenu = new QPopupMenu(this); | 566 | tabMenu = new QPopupMenu(this); |
526 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 567 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
527 | tm_top = tabMenu->insertItem(tr("Top")); | 568 | tm_top = tabMenu->insertItem(tr("Top")); |
528 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 569 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
529 | 570 | ||
530 | configMenu->insertItem(tr("Tabs"), tabMenu); | 571 | configMenu->insertItem(tr("Tabs"), tabMenu); |
531 | 572 | ||
532 | tmp=cfg.readEntry("Position","Top"); | 573 | tmp=cfg.readEntry("Position","Top"); |
533 | if(tmp=="Top") | 574 | if(tmp=="Top") |
534 | { | 575 | { |
535 | tab->setTabPosition(QTabWidget::Top); | 576 | tab->setTabPosition(QTabWidget::Top); |
536 | tab->getTabBar()->show(); | 577 | tab->getTabBar()->show(); |
537 | tabPos = tm_top; | 578 | tabPos = tm_top; |
538 | } | 579 | } |
539 | else if (tmp=="Bottom") | 580 | else if (tmp=="Bottom") |
540 | { | 581 | { |
541 | tab->setTabPosition(QTabWidget::Bottom); | 582 | tab->setTabPosition(QTabWidget::Bottom); |
542 | tab->getTabBar()->show(); | 583 | tab->getTabBar()->show(); |
543 | tabPos = tm_bottom; | 584 | tabPos = tm_bottom; |
544 | } | 585 | } |
545 | else | 586 | else |
546 | { | 587 | { |
547 | tab->getTabBar()->hide(); | 588 | tab->getTabBar()->hide(); |
548 | tab->setMargin(tab->margin()); | 589 | tab->setMargin(tab->margin()); |
549 | tabPos = tm_hidden; | 590 | tabPos = tm_hidden; |
550 | } | 591 | } |
551 | 592 | ||
552 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 593 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
553 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 594 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
554 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 595 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
555 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 596 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
556 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 597 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
557 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 598 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
558 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 599 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
559 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 600 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
560 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 601 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
561 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 602 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
562 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 603 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
563 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 604 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
564 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 605 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
565 | cm_default = colorMenu->insertItem(tr("default")); | 606 | cm_default = colorMenu->insertItem(tr("default")); |
566 | 607 | ||
567 | #ifdef QT_QWS_OPIE | 608 | #ifdef QT_QWS_OPIE |
568 | 609 | ||
569 | colorMenu->insertItem(tr( "Custom")); | 610 | colorMenu->insertItem(tr( "Custom")); |
570 | #endif | 611 | #endif |
571 | 612 | ||
572 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 613 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
573 | 614 | ||
574 | sessionList = new QPopupMenu(this); | 615 | sessionList = new QPopupMenu(this); |
575 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, | 616 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, |
576 | SLOT(newSession()) ); | 617 | SLOT(newSession()) ); |
577 | 618 | ||
578 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 619 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
579 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 620 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
580 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 621 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
581 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 622 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
582 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 623 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
583 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 624 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
584 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 625 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
585 | 626 | ||
586 | menuBar->insertItem( tr("View"), configMenu ); | 627 | menuBar->insertItem( tr("View"), configMenu ); |
587 | menuBar->insertItem( tr("Fonts"), fontList ); | 628 | menuBar->insertItem( tr("Fonts"), fontList ); |
588 | menuBar->insertItem( tr("Sessions"), sessionList ); | 629 | menuBar->insertItem( tr("Sessions"), sessionList ); |
589 | 630 | ||
590 | toolBar = new QToolBar( this ); | 631 | toolBar = new QToolBar( this ); |
591 | 632 | ||
592 | QAction *a; | 633 | QAction *a; |
593 | 634 | ||
594 | // Button Commands | 635 | // Button Commands |
595 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); | 636 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); |
596 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 637 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
597 | a->addTo( toolBar ); | 638 | a->addTo( toolBar ); |
598 | 639 | ||
599 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 640 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
600 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 641 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
601 | a->addTo( toolBar ); | 642 | a->addTo( toolBar ); |
602 | 643 | ||
603 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 644 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
604 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 645 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
605 | a->addTo( toolBar ); | 646 | a->addTo( toolBar ); |
606 | 647 | ||
607 | 648 | ||
608 | /* | 649 | /* |
609 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 650 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
610 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 651 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
611 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 652 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
612 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 653 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
613 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 654 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
614 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 655 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
615 | */ | 656 | */ |
616 | /* | 657 | /* |
617 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 658 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
618 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 659 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
619 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 660 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
620 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 661 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
621 | */ | 662 | */ |
622 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 663 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
623 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 664 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
624 | a->addTo( toolBar ); | 665 | a->addTo( toolBar ); |
625 | 666 | ||
626 | secondToolBar = new QToolBar( this ); | 667 | secondToolBar = new QToolBar( this ); |
627 | secondToolBar->setHorizontalStretchable( TRUE ); | 668 | secondToolBar->setHorizontalStretchable( TRUE ); |
628 | 669 | ||
629 | commonCombo = new QComboBox( secondToolBar ); | 670 | commonCombo = new QComboBox( secondToolBar ); |
630 | // commonCombo->setMaximumWidth(236); | 671 | // commonCombo->setMaximumWidth(236); |
631 | 672 | ||
632 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 673 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
633 | if( listHidden) | 674 | if( listHidden) |
634 | { | 675 | { |
635 | secondToolBar->hide(); | 676 | secondToolBar->hide(); |
636 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 677 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
637 | } | 678 | } |
638 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 679 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
639 | 680 | ||
640 | cfg.setGroup("Commands"); | 681 | cfg.setGroup("Commands"); |
641 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 682 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
642 | 683 | ||
643 | initCommandList(); | 684 | initCommandList(); |
644 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 685 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
645 | // commonCombo->insertItem( commonCmds[i], i ); | 686 | // commonCombo->insertItem( commonCmds[i], i ); |
646 | // tmp = cfg.readEntry( QString::number(i),""); | 687 | // tmp = cfg.readEntry( QString::number(i),""); |
647 | // if(tmp != "") | 688 | // if(tmp != "") |
648 | // commonCombo->changeItem( tmp,i ); | 689 | // commonCombo->changeItem( tmp,i ); |
649 | // } | 690 | // } |
650 | 691 | ||
651 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 692 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
652 | 693 | ||
653 | sm_none = scrollMenu->insertItem(tr( "None" )); | 694 | sm_none = scrollMenu->insertItem(tr( "None" )); |
654 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 695 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
655 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 696 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
656 | // scrollMenu->insertSeparator(4); | 697 | // scrollMenu->insertSeparator(4); |
657 | // scrollMenu->insertItem(tr( "Horizontal" )); | 698 | // scrollMenu->insertItem(tr( "Horizontal" )); |
658 | 699 | ||
659 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 700 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
660 | 701 | ||
661 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 702 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
662 | 703 | ||
663 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 704 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
664 | cfg.setGroup("ScrollBar"); | 705 | cfg.setGroup("ScrollBar"); |
665 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 706 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
666 | 707 | ||
667 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 708 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
668 | cfg.setGroup("Menubar"); | 709 | cfg.setGroup("Menubar"); |
669 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 710 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
670 | 711 | ||
671 | fullscreen_msg = new QLabel(this); | 712 | fullscreen_msg = new QLabel(this); |
672 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 713 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
673 | fullscreen_msg-> hide(); | 714 | fullscreen_msg-> hide(); |
674 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 715 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
675 | fullscreen_msg-> setAutoResize(true); | 716 | fullscreen_msg-> setAutoResize(true); |
676 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 717 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
677 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 718 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
678 | 719 | ||
679 | fullscreen_timer = new QTimer(this); | 720 | fullscreen_timer = new QTimer(this); |
680 | connect(fullscreen_timer, SIGNAL(timeout()), | 721 | connect(fullscreen_timer, SIGNAL(timeout()), |
681 | this, SLOT(fullscreenTimeout())); | 722 | this, SLOT(fullscreenTimeout())); |
682 | show_fullscreen_msg = true; | 723 | show_fullscreen_msg = true; |
683 | 724 | ||
684 | //scrollMenuSelected(-29); | 725 | //scrollMenuSelected(-29); |
685 | // cfg.setGroup("ScrollBar"); | 726 | // cfg.setGroup("ScrollBar"); |
686 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 727 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
687 | // if(cfg.readNumEntry("Position",2) == 0) | 728 | // if(cfg.readNumEntry("Position",2) == 0) |
688 | // te->setScrollbarLocation(1); | 729 | // te->setScrollbarLocation(1); |
689 | // else | 730 | // else |
690 | // te->setScrollbarLocation(0); | 731 | // te->setScrollbarLocation(0); |
691 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 732 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
692 | // te->setWrapAt(120); | 733 | // te->setWrapAt(120); |
693 | // } | 734 | // } |
694 | // create applications ///////////////////////////////////////////////////// | 735 | // create applications ///////////////////////////////////////////////////// |
695 | setCentralWidget(tab); | 736 | setCentralWidget(tab); |
696 | 737 | ||
697 | // load keymaps //////////////////////////////////////////////////////////// | 738 | // load keymaps //////////////////////////////////////////////////////////// |
698 | KeyTrans::loadAll(); | 739 | KeyTrans::loadAll(); |
699 | for (int i = 0; i < KeyTrans::count(); i++) | 740 | for (int i = 0; i < KeyTrans::count(); i++) |
700 | { | 741 | { |
701 | KeyTrans* s = KeyTrans::find(i); | 742 | KeyTrans* s = KeyTrans::find(i); |
702 | assert( s ); | 743 | assert( s ); |
703 | } | 744 | } |
704 | 745 | ||
705 | se_pgm = _pgm; | 746 | se_pgm = _pgm; |
706 | se_args = _args; | 747 | se_args = _args; |
707 | 748 | ||
708 | cfg.setGroup("CommandLine"); | 749 | cfg.setGroup("CommandLine"); |
709 | 750 | ||
710 | if (cfg.hasKey("shell_args")) | 751 | if (cfg.hasKey("shell_args")) |
711 | { | 752 | { |
712 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 753 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
713 | for(uint i = 0; i < se_args_list.count(); i++) | 754 | for(uint i = 0; i < se_args_list.count(); i++) |
714 | { | 755 | { |
715 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 756 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
716 | } | 757 | } |
717 | } | 758 | } |
718 | else | 759 | else |
719 | { | 760 | { |
720 | se_args.prepend("--login"); | 761 | se_args.prepend("--login"); |
721 | } | 762 | } |
722 | 763 | ||
723 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 764 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
724 | 765 | ||
725 | // this is the "documentation" for those who know to look | 766 | // this is the "documentation" for those who know to look |
726 | if (! cfg.hasKey("shell_args")) | 767 | if (! cfg.hasKey("shell_args")) |
727 | { | 768 | { |
728 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 769 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
729 | } | 770 | } |
730 | if (! cfg.hasKey("shell_bin")) | 771 | if (! cfg.hasKey("shell_bin")) |
731 | { | 772 | { |
732 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 773 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
733 | } | 774 | } |
734 | 775 | ||
735 | parseCommandLine(); | 776 | parseCommandLine(); |
736 | 777 | ||
737 | // read and apply default values /////////////////////////////////////////// | 778 | // read and apply default values /////////////////////////////////////////// |
738 | resize(321, 321); // Dummy. | 779 | resize(321, 321); // Dummy. |
739 | QSize currentSize = size(); | 780 | QSize currentSize = size(); |
740 | if (currentSize != size()) | 781 | if (currentSize != size()) |
741 | defaultSize = size(); | 782 | defaultSize = size(); |
742 | 783 | ||
743 | 784 | ||
744 | /* allows us to catch cancel/escape */ | 785 | /* allows us to catch cancel/escape */ |
745 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 786 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
746 | QPoint ( 0, 0 )); | 787 | QPoint ( 0, 0 )); |
747 | } | 788 | } |
748 | 789 | ||
749 | void Konsole::show() | 790 | void Konsole::show() |
750 | { | 791 | { |
751 | if ( !nsessions ) | 792 | if ( !nsessions ) |
752 | { | 793 | { |
753 | newSession(); | 794 | newSession(); |
754 | } | 795 | } |
755 | QMainWindow::show(); | 796 | QMainWindow::show(); |
756 | 797 | ||
757 | } | 798 | } |
758 | 799 | ||
759 | void Konsole::initSession(const char*, QStrList &) | 800 | void Konsole::initSession(const char*, QStrList &) |
760 | { | 801 | { |
761 | QMainWindow::show(); | 802 | QMainWindow::show(); |
762 | } | 803 | } |
763 | 804 | ||
764 | Konsole::~Konsole() | 805 | Konsole::~Konsole() |
765 | { | 806 | { |
766 | while (nsessions > 0) | 807 | while (nsessions > 0) |
767 | { | 808 | { |
768 | doneSession(getTe(), 0); | 809 | doneSession(getTe(), 0); |
769 | } | 810 | } |
770 | } | 811 | } |
771 | 812 | ||
772 | void | 813 | void |
773 | Konsole::historyDialog() | 814 | Konsole::historyDialog() |
774 | { | 815 | { |
775 | QDialog *d = new QDialog ( this, "histdlg", true ); | 816 | QDialog *d = new QDialog ( this, "histdlg", true ); |
776 | // d-> setCaption ( tr( "History" )); | 817 | // d-> setCaption ( tr( "History" )); |
777 | 818 | ||
778 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 819 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
779 | 820 | ||
780 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 821 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
781 | lay-> addWidget ( l ); | 822 | lay-> addWidget ( l ); |
782 | 823 | ||
783 | Config cfg( "Konsole" ); | 824 | Config cfg( "Konsole" ); |
784 | cfg.setGroup("History"); | 825 | cfg.setGroup("History"); |
785 | int hist = cfg.readNumEntry("history_lines",300); | 826 | int hist = cfg.readNumEntry("history_lines",300); |
786 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 827 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
787 | 828 | ||
788 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 829 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
789 | spin-> setValue ( hist ); | 830 | spin-> setValue ( hist ); |
790 | spin-> setWrapping ( true ); | 831 | spin-> setWrapping ( true ); |
791 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 832 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
792 | lay-> addWidget ( spin ); | 833 | lay-> addWidget ( spin ); |
793 | 834 | ||
794 | if ( d-> exec ( ) == QDialog::Accepted ) | 835 | if ( d-> exec ( ) == QDialog::Accepted ) |
795 | { | 836 | { |
796 | cfg.writeEntry("history_lines", spin->value()); | 837 | cfg.writeEntry("history_lines", spin->value()); |
797 | cfg.writeEntry("avg_line_length", avg_line); | 838 | cfg.writeEntry("avg_line_length", avg_line); |
798 | if (getTe() != NULL) | 839 | if (getTe() != NULL) |
799 | { | 840 | { |
800 | getTe()->currentSession->setHistory(true); | 841 | getTe()->currentSession->setHistory(true); |
801 | } | 842 | } |
802 | } | 843 | } |
803 | 844 | ||
804 | delete d; | 845 | delete d; |
805 | } | 846 | } |
806 | 847 | ||
807 | 848 | ||
808 | void Konsole::cycleZoom() | 849 | void Konsole::cycleZoom() |
809 | { | 850 | { |
810 | TEWidget* te = getTe(); | 851 | TEWidget* te = getTe(); |
811 | QFont font = te->getVTFont(); | 852 | QFont font = te->getVTFont(); |
812 | int size = font.pointSize(); | 853 | int size = font.pointSize(); |
813 | changeFontSize(1); | 854 | changeFontSize(1); |
814 | font = te->getVTFont(); | 855 | font = te->getVTFont(); |
815 | if (font.pointSize() <= size) | 856 | if (font.pointSize() <= size) |
816 | { | 857 | { |
817 | do | 858 | do |
818 | { | 859 | { |
819 | font = te->getVTFont(); | 860 | font = te->getVTFont(); |
820 | size = font.pointSize(); | 861 | size = font.pointSize(); |
821 | changeFontSize(-1); | 862 | changeFontSize(-1); |
822 | font = te->getVTFont(); | 863 | font = te->getVTFont(); |
823 | } | 864 | } |
824 | while (font.pointSize() < size); | 865 | while (font.pointSize() < size); |
825 | } | 866 | } |
826 | } | 867 | } |
827 | 868 | ||
828 | void Konsole::changeFontSize(int delta) | 869 | void Konsole::changeFontSize(int delta) |
829 | { | 870 | { |
830 | // printf("delta font size %d\n", delta); | 871 | // printf("delta font size %d\n", delta); |
831 | TEWidget* te = getTe(); | 872 | TEWidget* te = getTe(); |
832 | QFont font = te->getVTFont(); | 873 | QFont font = te->getVTFont(); |
833 | int size = font.pointSize(); | 874 | int size = font.pointSize(); |
834 | int closest = delta > 0? 10000 : -10000; | 875 | int closest = delta > 0? 10000 : -10000; |
835 | int closest_font = -1; | 876 | int closest_font = -1; |
836 | for(uint i = 0; i < fonts.count(); i++) | 877 | for(uint i = 0; i < fonts.count(); i++) |
837 | { | 878 | { |
838 | if (fonts.at(i)->getFont() == font) | 879 | if (fonts.at(i)->getFont() == font) |
839 | { | 880 | { |
840 | if (delta > 0) | 881 | if (delta > 0) |
841 | { | 882 | { |
842 | if (i+1 < fonts.count() | 883 | if (i+1 < fonts.count() |
843 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 884 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
844 | { | 885 | { |
845 | setFont(i+1); | 886 | setFont(i+1); |
846 | printf("font %d\n", i+1); | 887 | printf("font %d\n", i+1); |
847 | return; | 888 | return; |
848 | } | 889 | } |
849 | } | 890 | } |
850 | else if (delta < 0) | 891 | else if (delta < 0) |
851 | { | 892 | { |
852 | if (i > 0 | 893 | if (i > 0 |
853 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 894 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
854 | { | 895 | { |
855 | setFont(i-1); | 896 | setFont(i-1); |
856 | printf("font %d\n", i-1); | 897 | printf("font %d\n", i-1); |
857 | return; | 898 | return; |
858 | } | 899 | } |
859 | } | 900 | } |
860 | } | 901 | } |
861 | int fsize = fonts.at(i)->getSize(); | 902 | int fsize = fonts.at(i)->getSize(); |
862 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); | 903 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); |
863 | if ((delta > 0 && fsize > size && fsize < closest) | 904 | if ((delta > 0 && fsize > size && fsize < closest) |
864 | || (delta < 0 && fsize < size && fsize > closest)) | 905 | || (delta < 0 && fsize < size && fsize > closest)) |
865 | { | 906 | { |
866 | closest = fsize; | 907 | closest = fsize; |
867 | closest_font = i; | 908 | closest_font = i; |
868 | } | 909 | } |
869 | } | 910 | } |
870 | if (closest_font >= 0) | 911 | if (closest_font >= 0) |
871 | { | 912 | { |
872 | printf("font closest %d (%d)\n", closest_font, closest); | 913 | printf("font closest %d (%d)\n", closest_font, closest); |
873 | setFont(closest_font); | 914 | setFont(closest_font); |
874 | } | 915 | } |
875 | } | 916 | } |
876 | 917 | ||
877 | int Konsole::findFont(const QString& name, int size, bool exactMatch) | 918 | int Konsole::findFont(const QString& name, int size, bool exactMatch) |
878 | { | 919 | { |
879 | for(uint i = 0; i < fonts.count(); i++) | 920 | for(uint i = 0; i < fonts.count(); i++) |
880 | { | 921 | { |
881 | if (fonts.at(i)->getName() == name | 922 | if (fonts.at(i)->getName() == name |
882 | && fonts.at(i)->getSize() == size) | 923 | && fonts.at(i)->getSize() == size) |
883 | { | 924 | { |
884 | return(i); | 925 | return(i); |
885 | } | 926 | } |
886 | } | 927 | } |
887 | if (exactMatch) | 928 | if (exactMatch) |
888 | { | 929 | { |
889 | return(-1); | 930 | return(-1); |
890 | } | 931 | } |
891 | for(uint i = 0; i < fonts.count(); i++) | 932 | for(uint i = 0; i < fonts.count(); i++) |
892 | { | 933 | { |
893 | if (fonts.at(i)->getSize() == size) | 934 | if (fonts.at(i)->getSize() == size) |
894 | { | 935 | { |
895 | return(i); | 936 | return(i); |
896 | } | 937 | } |
897 | } | 938 | } |
898 | return(-1); | 939 | return(-1); |
899 | } | 940 | } |
900 | 941 | ||
901 | void Konsole::setFont(int f) | 942 | void Konsole::setFont(int f) |
902 | { | 943 | { |
903 | VTFont* font = fonts.at(f); | 944 | VTFont* font = fonts.at(f); |
904 | if (font) | 945 | if (font) |
905 | { | 946 | { |
906 | TEWidget* te = getTe(); | 947 | TEWidget* te = getTe(); |
907 | if (te != 0) | 948 | if (te != 0) |
908 | { | 949 | { |
909 | te->setVTFont(font->getFont()); | 950 | te->setVTFont(font->getFont()); |
910 | } | 951 | } |
911 | cfont = f; | 952 | cfont = f; |
912 | 953 | ||
913 | int familyNum = font->getFamilyNum(); | 954 | int familyNum = font->getFamilyNum(); |
914 | int size = font->getSize(); | 955 | int size = font->getSize(); |
915 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, | 956 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, |
916 | fontList->count()); | 957 | fontList->count()); |
917 | for(int i = 0; i < (int)fontList->count(); i++) | 958 | for(int i = 0; i < (int)fontList->count(); i++) |
918 | { | 959 | { |
919 | fontList->setItemChecked(i + 1000, i == familyNum); | 960 | fontList->setItemChecked(i + 1000, i == familyNum); |
920 | } | 961 | } |
921 | for(int i = 0; i < (int)fonts.count(); i++) | 962 | for(int i = 0; i < (int)fonts.count(); i++) |
922 | { | 963 | { |
923 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum | 964 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum |
924 | && fonts.at(i)->getSize() == size); | 965 | && fonts.at(i)->getSize() == size); |
925 | } | 966 | } |
926 | Config cfg( "Konsole" ); | 967 | Config cfg( "Konsole" ); |
927 | cfg.setGroup("Font"); | 968 | cfg.setGroup("Font"); |
928 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); | 969 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); |
929 | if (tab->currentPageIndex() == 0) | 970 | if (tab->currentPageIndex() == 0) |
930 | { | 971 | { |
931 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); | 972 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); |
932 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); | 973 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); |
933 | } | 974 | } |
934 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); | 975 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); |
935 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); | 976 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); |
936 | } | 977 | } |
937 | } | 978 | } |
938 | 979 | ||
939 | #if 0 | 980 | #if 0 |
940 | void Konsole::fontChanged(int f) | 981 | void Konsole::fontChanged(int f) |
941 | { | 982 | { |
942 | VTFont* font = fonts.at(f); | 983 | VTFont* font = fonts.at(f); |
943 | if (font != 0) | 984 | if (font != 0) |
944 | { | 985 | { |
945 | for(uint i = 0; i < fonts.count(); i++) | 986 | for(uint i = 0; i < fonts.count(); i++) |
946 | { | 987 | { |
947 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 988 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
948 | } | 989 | } |
949 | 990 | ||
950 | cfont = f; | 991 | cfont = f; |
951 | 992 | ||
952 | TEWidget* te = getTe(); | 993 | TEWidget* te = getTe(); |
953 | if (te != 0) | 994 | if (te != 0) |
954 | { | 995 | { |
955 | te->setVTFont(font->getFont()); | 996 | te->setVTFont(font->getFont()); |
956 | } | 997 | } |
957 | } | 998 | } |
958 | } | 999 | } |
959 | #endif | 1000 | #endif |
960 | 1001 | ||
961 | 1002 | ||
962 | void Konsole::enterCommand(int c) | 1003 | void Konsole::enterCommand(int c) |
963 | { | 1004 | { |
964 | TEWidget* te = getTe(); | 1005 | TEWidget* te = getTe(); |
965 | if (te != 0) | 1006 | if (te != 0) |
966 | { | 1007 | { |
967 | if(!commonCombo->editable()) | 1008 | if(!commonCombo->editable()) |
968 | { | 1009 | { |
969 | QString text = commonCombo->text(c); //commonCmds[c]; | 1010 | QString text = commonCombo->text(c); //commonCmds[c]; |
970 | te->emitText(text); | 1011 | te->emitText(text); |
971 | } | 1012 | } |
972 | else | 1013 | else |
973 | { | 1014 | { |
974 | changeCommand( commonCombo->text(c), c); | 1015 | changeCommand( commonCombo->text(c), c); |
975 | } | 1016 | } |
976 | } | 1017 | } |
977 | } | 1018 | } |
978 | 1019 | ||
979 | void Konsole::hitEnter() | 1020 | void Konsole::hitEnter() |
980 | { | 1021 | { |
981 | TEWidget* te = getTe(); | 1022 | TEWidget* te = getTe(); |
982 | if (te != 0) | 1023 | if (te != 0) |
983 | { | 1024 | { |
984 | te->emitText(QString("\r")); | 1025 | te->emitText(QString("\r")); |
985 | } | 1026 | } |
986 | } | 1027 | } |
987 | 1028 | ||
988 | void Konsole::hitSpace() | 1029 | void Konsole::hitSpace() |
989 | { | 1030 | { |
990 | TEWidget* te = getTe(); | 1031 | TEWidget* te = getTe(); |
991 | if (te != 0) | 1032 | if (te != 0) |
992 | { | 1033 | { |
993 | te->emitText(QString(" ")); | 1034 | te->emitText(QString(" ")); |
994 | } | 1035 | } |
995 | } | 1036 | } |
996 | 1037 | ||
997 | void Konsole::hitTab() | 1038 | void Konsole::hitTab() |
998 | { | 1039 | { |
999 | TEWidget* te = getTe(); | 1040 | TEWidget* te = getTe(); |
1000 | if (te != 0) | 1041 | if (te != 0) |
1001 | { | 1042 | { |
1002 | te->emitText(QString("\t")); | 1043 | te->emitText(QString("\t")); |
1003 | } | 1044 | } |
1004 | } | 1045 | } |
1005 | 1046 | ||
1006 | void Konsole::hitPaste() | 1047 | void Konsole::hitPaste() |
1007 | { | 1048 | { |
1008 | TEWidget* te = getTe(); | 1049 | TEWidget* te = getTe(); |
1009 | if (te != 0) | 1050 | if (te != 0) |
1010 | { | 1051 | { |
1011 | te->pasteClipboard(); | 1052 | te->pasteClipboard(); |
1012 | } | 1053 | } |
1013 | } | 1054 | } |
1014 | 1055 | ||
1015 | void Konsole::hitUp() | 1056 | void Konsole::hitUp() |
1016 | { | 1057 | { |
1017 | TEWidget* te = getTe(); | 1058 | TEWidget* te = getTe(); |
1018 | if (te != 0) | 1059 | if (te != 0) |
1019 | { | 1060 | { |
1020 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 1061 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
1021 | QApplication::sendEvent( te, &ke ); | 1062 | QApplication::sendEvent( te, &ke ); |
1022 | } | 1063 | } |
1023 | } | 1064 | } |
1024 | 1065 | ||
1025 | void Konsole::hitDown() | 1066 | void Konsole::hitDown() |
1026 | { | 1067 | { |
1027 | TEWidget* te = getTe(); | 1068 | TEWidget* te = getTe(); |
1028 | if (te != 0) | 1069 | if (te != 0) |
1029 | { | 1070 | { |
1030 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 1071 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
1031 | QApplication::sendEvent( te, &ke ); | 1072 | QApplication::sendEvent( te, &ke ); |
1032 | } | 1073 | } |
1033 | } | 1074 | } |
1034 | 1075 | ||
1035 | /** | 1076 | /** |
1036 | This function calculates the size of the external widget | 1077 | This function calculates the size of the external widget |
1037 | needed for the internal widget to be | 1078 | needed for the internal widget to be |
1038 | */ | 1079 | */ |
1039 | QSize Konsole::calcSize(int columns, int lines) | 1080 | QSize Konsole::calcSize(int columns, int lines) |
1040 | { | 1081 | { |
1041 | TEWidget* te = getTe(); | 1082 | TEWidget* te = getTe(); |
1042 | if (te != 0) | 1083 | if (te != 0) |
1043 | { | 1084 | { |
1044 | QSize size = te->calcSize(columns, lines); | 1085 | QSize size = te->calcSize(columns, lines); |
1045 | return size; | 1086 | return size; |
1046 | } | 1087 | } |
1047 | else | 1088 | else |
1048 | { | 1089 | { |
1049 | QSize size; | 1090 | QSize size; |
1050 | return size; | 1091 | return size; |
1051 | } | 1092 | } |
1052 | } | 1093 | } |
1053 | 1094 | ||
1054 | /** | 1095 | /** |
1055 | sets application window to a size based on columns X lines of the te | 1096 | sets application window to a size based on columns X lines of the te |
1056 | guest widget. Call with (0,0) for setting default size. | 1097 | guest widget. Call with (0,0) for setting default size. |
1057 | */ | 1098 | */ |
1058 | 1099 | ||
1059 | void Konsole::setColLin(int columns, int lines) | 1100 | void Konsole::setColLin(int columns, int lines) |
1060 | { | 1101 | { |
1061 | qDebug("konsole::setColLin:: Columns %d", columns); | 1102 | qDebug("konsole::setColLin:: Columns %d", columns); |
1062 | 1103 | ||
1063 | if ((columns==0) || (lines==0)) | 1104 | if ((columns==0) || (lines==0)) |
1064 | { | 1105 | { |
1065 | if (defaultSize.isEmpty()) // not in config file : set default value | 1106 | if (defaultSize.isEmpty()) // not in config file : set default value |
1066 | { | 1107 | { |
1067 | defaultSize = calcSize(80,24); | 1108 | defaultSize = calcSize(80,24); |
1068 | // notifySize(24,80); // set menu items (strange arg order !) | 1109 | // notifySize(24,80); // set menu items (strange arg order !) |
1069 | } | 1110 | } |
1070 | resize(defaultSize); | 1111 | resize(defaultSize); |
1071 | } | 1112 | } |
1072 | else | 1113 | else |
1073 | { | 1114 | { |
1074 | resize(calcSize(columns, lines)); | 1115 | resize(calcSize(columns, lines)); |
1075 | // notifySize(lines,columns); // set menu items (strange arg order !) | 1116 | // notifySize(lines,columns); // set menu items (strange arg order !) |
1076 | } | 1117 | } |
1077 | } | 1118 | } |
1078 | 1119 | ||
1079 | /* | 1120 | /* |
1080 | void Konsole::setFont(int fontno) | 1121 | void Konsole::setFont(int fontno) |
1081 | { | 1122 | { |
1082 | QFont f; | 1123 | QFont f; |
1083 | if (fontno == 0) | 1124 | if (fontno == 0) |
1084 | f = defaultFont = QFont( "Helvetica", 12 ); | 1125 | f = defaultFont = QFont( "Helvetica", 12 ); |
1085 | else | 1126 | else |
1086 | if (fonts[fontno][0] == '-') | 1127 | if (fonts[fontno][0] == '-') |
1087 | f.setRawName( fonts[fontno] ); | 1128 | f.setRawName( fonts[fontno] ); |
1088 | else | 1129 | else |
1089 | { | 1130 | { |
1090 | f.setFamily(fonts[fontno]); | 1131 | f.setFamily(fonts[fontno]); |
1091 | f.setRawMode( TRUE ); | 1132 | f.setRawMode( TRUE ); |
1092 | } | 1133 | } |
1093 | if ( !f.exactMatch() && fontno != 0) | 1134 | if ( !f.exactMatch() && fontno != 0) |
1094 | { | 1135 | { |
1095 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 1136 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
1096 | QMessageBox(this, msg); | 1137 | QMessageBox(this, msg); |
1097 | return; | 1138 | return; |
1098 | } | 1139 | } |
1099 | if (se) se->setFontNo(fontno); | 1140 | if (se) se->setFontNo(fontno); |
1100 | te->setVTFont(f); | 1141 | te->setVTFont(f); |
1101 | n_font = fontno; | 1142 | n_font = fontno; |
1102 | } | 1143 | } |
1103 | */ | 1144 | */ |
1104 | 1145 | ||
1105 | // --| color selection |------------------------------------------------------- | 1146 | // --| color selection |------------------------------------------------------- |
1106 | 1147 | ||
1107 | void Konsole::changeColumns(int /*columns*/) | 1148 | void Konsole::changeColumns(int /*columns*/) |
1108 | { //FIXME this seems to cause silliness when reset command is executed | 1149 | { //FIXME this seems to cause silliness when reset command is executed |
1109 | // qDebug("change columns"); | 1150 | // qDebug("change columns"); |
1110 | // TEWidget* te = getTe(); | 1151 | // TEWidget* te = getTe(); |
1111 | // if (te != 0) { | 1152 | // if (te != 0) { |
1112 | // setColLin(columns,te->Lines()); | 1153 | // setColLin(columns,te->Lines()); |
1113 | // te->update(); | 1154 | // te->update(); |
1114 | // } | 1155 | // } |
1115 | } | 1156 | } |
1116 | 1157 | ||
1117 | //FIXME: If a child dies during session swap, | 1158 | //FIXME: If a child dies during session swap, |
1118 | // this routine might be called before | 1159 | // this routine might be called before |
1119 | // session swap is completed. | 1160 | // session swap is completed. |
1120 | 1161 | ||
1121 | void Konsole::doneSession(TEWidget* te, int ) | 1162 | void Konsole::doneSession(TEWidget* te, int ) |
1122 | { | 1163 | { |
1123 | // TEWidget *te = NULL; | 1164 | // TEWidget *te = NULL; |
1124 | // if (sess->currentSession == tab->currentPage()) { | 1165 | // if (sess->currentSession == tab->currentPage()) { |
1125 | // printf("done current session\n"); | 1166 | // printf("done current session\n"); |
1126 | // te = getTe(); | 1167 | // te = getTe(); |
1127 | // } else { | 1168 | // } else { |
1128 | // int currentPage = tab->currentPageIndex(); | 1169 | // int currentPage = tab->currentPageIndex(); |
1129 | // printf("done not current session\n"); | 1170 | // printf("done not current session\n"); |
1130 | // for(int i = 0; i < nsessions; i++) { | 1171 | // for(int i = 0; i < nsessions; i++) { |
1131 | // tab->setCurrentPage(i); | 1172 | // tab->setCurrentPage(i); |
1132 | // printf("find session %d tab page %x session %x\n", | 1173 | // printf("find session %d tab page %x session %x\n", |
1133 | // i, tab->currentPage(), sess->currentSession); | 1174 | // i, tab->currentPage(), sess->currentSession); |
1134 | // if (tab->currentPage() == sess->currentSession) { | 1175 | // if (tab->currentPage() == sess->currentSession) { |
1135 | // printf("found session %d\n", i); | 1176 | // printf("found session %d\n", i); |
1136 | // te = tab->currentPage(); | 1177 | // te = tab->currentPage(); |
1137 | // break; | 1178 | // break; |
1138 | // } | 1179 | // } |
1139 | // } | 1180 | // } |
1140 | // tab->setCurrentPage(currentPage); | 1181 | // tab->setCurrentPage(currentPage); |
1141 | // } | 1182 | // } |
1142 | if (te != 0) | 1183 | if (te != 0) |
1143 | { | 1184 | { |
1144 | te->currentSession->setConnect(FALSE); | 1185 | te->currentSession->setConnect(FALSE); |
1145 | tab->removeTab(te); | 1186 | tab->removeTab(te); |
1146 | delete te->currentSession; | 1187 | delete te->currentSession; |
1147 | delete te; | 1188 | delete te; |
1148 | sessionList->removeItem(nsessions); | 1189 | sessionList->removeItem(nsessions); |
1149 | nsessions--; | 1190 | nsessions--; |
1150 | } | 1191 | } |
1151 | if (nsessions == 0) | 1192 | if (nsessions == 0) |
1152 | { | 1193 | { |
1153 | close(); | 1194 | close(); |
1154 | } | 1195 | } |
1155 | } | 1196 | } |
1156 | 1197 | ||
1157 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) | 1198 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) |
1158 | { | 1199 | { |
1159 | if (te == getTe()) | 1200 | if (te == getTe()) |
1160 | { | 1201 | { |
1161 | setCaption( newTitle + " - " + tr( "Konsole " ) ); | 1202 | setCaption( newTitle + " - " + tr( "Konsole " ) ); |
1162 | } | 1203 | } |
1163 | } | 1204 | } |
1164 | 1205 | ||
1165 | 1206 | ||
1166 | void Konsole::newSession() | 1207 | void Konsole::newSession() |
1167 | { | 1208 | { |
1168 | if(nsessions < 15) | 1209 | if(nsessions < 15) |
1169 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 1210 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
1170 | TEWidget* te = new TEWidget(tab); | 1211 | TEWidget* te = new TEWidget(tab); |
1171 | Config cfg( "Konsole" ); | 1212 | Config cfg( "Konsole" ); |
1172 | cfg.setGroup("Menubar"); | 1213 | cfg.setGroup("Menubar"); |
1173 | 1214 | ||
1174 | // FIXME use more defaults from config file | 1215 | // FIXME use more defaults from config file |
1175 | te->useBeep=cfg.readBoolEntry("useBeep",0); | 1216 | te->useBeep=cfg.readBoolEntry("useBeep",0); |
1176 | 1217 | ||
1177 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 1218 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
1178 | 1219 | ||
1179 | cfg.setGroup("Font"); | 1220 | cfg.setGroup("Font"); |
1180 | QString sn = "Session" + QString::number(nsessions+1); | 1221 | QString sn = "Session" + QString::number(nsessions+1); |
1181 | printf("read font session %s\n", sn.latin1()); | 1222 | printf("read font session %s\n", sn.latin1()); |
1182 | QString fontName = cfg.readEntry("FontName"+sn, | 1223 | QString fontName = cfg.readEntry("FontName"+sn, |
1183 | cfg.readEntry("FontName", | 1224 | cfg.readEntry("FontName", |
1184 | fonts.at(cfont)->getFamily())); | 1225 | fonts.at(cfont)->getFamily())); |
1185 | int fontSize = cfg.readNumEntry("FontSize"+sn, | 1226 | int fontSize = cfg.readNumEntry("FontSize"+sn, |
1186 | cfg.readNumEntry("FontSize", | 1227 | cfg.readNumEntry("FontSize", |
1187 | fonts.at(cfont)->getSize())); | 1228 | fonts.at(cfont)->getSize())); |
1188 | cfont = findFont(fontName, fontSize, false); | 1229 | cfont = findFont(fontName, fontSize, false); |
1189 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); | 1230 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); |
1190 | if (cfont < 0) | 1231 | if (cfont < 0) |
1191 | cfont = 0; | 1232 | cfont = 0; |
1192 | te->setVTFont(fonts.at(cfont)->getFont()); | 1233 | te->setVTFont(fonts.at(cfont)->getFont()); |
1193 | 1234 | ||
1194 | tab->addTab(te); | 1235 | tab->addTab(te); |
1195 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 1236 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
1196 | te->currentSession = se; | 1237 | te->currentSession = se; |
1197 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); | 1238 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); |
1198 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, | 1239 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, |
1199 | SLOT(changeTitle(TEWidget*,const QString&)) ); | 1240 | SLOT(changeTitle(TEWidget*,const QString&)) ); |
1200 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); | 1241 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); |
1201 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); | 1242 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); |
1202 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); | 1243 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); |
1203 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); | 1244 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); |
1204 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); | 1245 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); |
1205 | se->run(); | 1246 | se->run(); |
1206 | se->setConnect(TRUE); | 1247 | se->setConnect(TRUE); |
1207 | se->setHistory(b_scroll); | 1248 | se->setHistory(b_scroll); |
1208 | nsessions++; | 1249 | nsessions++; |
1209 | sessionList->insertItem(QString::number(nsessions), nsessions); | 1250 | sessionList->insertItem(QString::number(nsessions), nsessions); |
1210 | sessionListSelected(nsessions); | 1251 | sessionListSelected(nsessions); |
1211 | doWrap(); | 1252 | doWrap(); |
1212 | setColor(nsessions-1); | 1253 | setColor(nsessions-1); |
1213 | } | 1254 | } |
1214 | } | 1255 | } |
1215 | 1256 | ||
1216 | TEWidget* Konsole::getTe() | 1257 | TEWidget* Konsole::getTe() |
1217 | { | 1258 | { |
1218 | if (nsessions) | 1259 | if (nsessions) |
1219 | { | 1260 | { |
1220 | return (TEWidget *) tab->currentPage(); | 1261 | return (TEWidget *) tab->currentPage(); |
1221 | } | 1262 | } |
1222 | else | 1263 | else |
1223 | { | 1264 | { |
1224 | return 0; | 1265 | return 0; |
1225 | } | 1266 | } |
1226 | } | 1267 | } |
1227 | 1268 | ||
1228 | void Konsole::sessionListSelected(int id) | 1269 | void Konsole::sessionListSelected(int id) |
1229 | { | 1270 | { |
1230 | if (id < 0) | 1271 | if (id < 0) |
1231 | { | 1272 | { |
1232 | return; | 1273 | return; |
1233 | } | 1274 | } |
1234 | QString selected = sessionList->text(id); | 1275 | QString selected = sessionList->text(id); |
1235 | EKNumTabBar *tabBar = tab->getTabBar(); | 1276 | EKNumTabBar *tabBar = tab->getTabBar(); |
1236 | 1277 | ||
1237 | int n = 0; | 1278 | int n = 0; |
1238 | for(int i = 0; n < tabBar->count(); i++) | 1279 | for(int i = 0; n < tabBar->count(); i++) |
1239 | { | 1280 | { |
1240 | if (tabBar->tab(i)) | 1281 | if (tabBar->tab(i)) |
1241 | { | 1282 | { |
1242 | // printf("selected = %s tab %d = %s\n", selected.latin1(), | 1283 | // printf("selected = %s tab %d = %s\n", selected.latin1(), |
1243 | // i, tabBar->tab(i)->text().latin1()); | 1284 | // i, tabBar->tab(i)->text().latin1()); |
1244 | if (tabBar->tab(i)->text() == selected) | 1285 | if (tabBar->tab(i)->text() == selected) |
1245 | { | 1286 | { |
1246 | tab->setCurrentPage(i); | 1287 | tab->setCurrentPage(i); |
1247 | break; | 1288 | break; |
1248 | } | 1289 | } |
1249 | n++; | 1290 | n++; |
1250 | } | 1291 | } |
1251 | } | 1292 | } |
1252 | } | 1293 | } |
1253 | 1294 | ||
1254 | 1295 | ||
1255 | void Konsole::changeSession(int delta) | 1296 | void Konsole::changeSession(int delta) |
1256 | { | 1297 | { |
1257 | printf("delta session %d\n", delta); | 1298 | printf("delta session %d\n", delta); |
1258 | QTabBar *tabBar = tab->getTabBar(); | 1299 | QTabBar *tabBar = tab->getTabBar(); |
1259 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; | 1300 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; |
1260 | i += delta; | 1301 | i += delta; |
1261 | if (i < 0) | 1302 | if (i < 0) |
1262 | i += tabBar->count(); | 1303 | i += tabBar->count(); |
1263 | if (i >= tabBar->count()) | 1304 | if (i >= tabBar->count()) |
1264 | i -= tabBar->count(); | 1305 | i -= tabBar->count(); |
1265 | 1306 | ||
1266 | QString selected = QString::number(i+1); | 1307 | QString selected = QString::number(i+1); |
1267 | int n = 0; | 1308 | int n = 0; |
1268 | for(int i = 0; n < tabBar->count(); i++) | 1309 | for(int i = 0; n < tabBar->count(); i++) |
1269 | { | 1310 | { |
1270 | if (tabBar->tab(i)) | 1311 | if (tabBar->tab(i)) |
1271 | { | 1312 | { |
1272 | printf("selected = %s tab %d = %s\n", selected.latin1(), | 1313 | printf("selected = %s tab %d = %s\n", selected.latin1(), |
1273 | i, tabBar->tab(i)->text().latin1()); | 1314 | i, tabBar->tab(i)->text().latin1()); |
1274 | if (tabBar->tab(i)->text() == selected) | 1315 | if (tabBar->tab(i)->text() == selected) |
1275 | { | 1316 | { |
1276 | tab->setCurrentPage(i); | 1317 | tab->setCurrentPage(i); |
1277 | break; | 1318 | break; |
1278 | } | 1319 | } |
1279 | n++; | 1320 | n++; |
1280 | } | 1321 | } |
1281 | } | 1322 | } |
1282 | } | 1323 | } |
1283 | 1324 | ||
1284 | void Konsole::switchSession(QWidget* w) | 1325 | void Konsole::switchSession(QWidget* w) |
1285 | { | 1326 | { |
1286 | TEWidget* te = (TEWidget *) w; | 1327 | TEWidget* te = (TEWidget *) w; |
1287 | QFont teFnt = te->getVTFont(); | 1328 | QFont teFnt = te->getVTFont(); |
1288 | int familyNum = -1; | 1329 | int familyNum = -1; |
1289 | 1330 | ||
1290 | for(uint i = 0; i < fonts.count(); i++) | 1331 | for(uint i = 0; i < fonts.count(); i++) |
1291 | { | 1332 | { |
1292 | VTFont *fnt = fonts.at(i); | 1333 | VTFont *fnt = fonts.at(i); |
1293 | bool cf = fnt->getFont() == teFnt; | 1334 | bool cf = fnt->getFont() == teFnt; |
1294 | fontList->setItemChecked(i, cf); | 1335 | fontList->setItemChecked(i, cf); |
1295 | if (cf) | 1336 | if (cf) |
1296 | { | 1337 | { |
1297 | cfont = i; | 1338 | cfont = i; |
1298 | familyNum = fnt->getFamilyNum(); | 1339 | familyNum = fnt->getFamilyNum(); |
1299 | } | 1340 | } |
1300 | } | 1341 | } |
1301 | for(int i = 0; i < (int)fontList->count(); i++) | 1342 | for(int i = 0; i < (int)fontList->count(); i++) |
1302 | { | 1343 | { |
1303 | fontList->setItemChecked(i + 1000, i == familyNum); | 1344 | fontList->setItemChecked(i + 1000, i == familyNum); |
1304 | } | 1345 | } |
1305 | if (! te->currentSession->Title().isEmpty() ) | 1346 | if (! te->currentSession->Title().isEmpty() ) |
1306 | { | 1347 | { |
1307 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); | 1348 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); |
1308 | } | 1349 | } |
1309 | else | 1350 | else |
1310 | { | 1351 | { |
1311 | setCaption( tr( "Konsole" ) ); | 1352 | setCaption( tr( "Konsole" ) ); |
1312 | } | 1353 | } |
1313 | // colorMenuSelected(te->color_menu_item); | 1354 | // colorMenuSelected(te->color_menu_item); |
1314 | } | 1355 | } |
1315 | 1356 | ||
1316 | 1357 | ||
1317 | void Konsole::toggleFullScreen() | 1358 | void Konsole::toggleFullScreen() |
1318 | { | 1359 | { |
1319 | setFullScreen(! fullscreen); | 1360 | setFullScreen(! fullscreen); |
1320 | } | 1361 | } |
1321 | 1362 | ||
1322 | void Konsole::setFullScreen ( bool b ) | 1363 | void Konsole::setFullScreen ( bool b ) |
1323 | { | 1364 | { |
1324 | static QSize normalsize; | 1365 | static QSize normalsize; |
1325 | static bool listHidden; | 1366 | static bool listHidden; |
1326 | 1367 | ||
1327 | if (b == fullscreen) | 1368 | if (b == fullscreen) |
1328 | { | 1369 | { |
1329 | return; | 1370 | return; |
1330 | } | 1371 | } |
1331 | 1372 | ||
1332 | fullscreen = b; | 1373 | fullscreen = b; |
1333 | 1374 | ||
1334 | if ( b ) | 1375 | if ( b ) |
1335 | { | 1376 | { |
1336 | if ( !normalsize. isValid ( )) | 1377 | if ( !normalsize. isValid ( )) |
1337 | { | 1378 | { |
1338 | normalsize = size ( ); | 1379 | normalsize = size ( ); |
1339 | } | 1380 | } |
1340 | 1381 | ||
1341 | setFixedSize ( qApp-> desktop ( )-> size ( )); | 1382 | setFixedSize ( qApp-> desktop ( )-> size ( )); |
1342 | showNormal ( ); | 1383 | showNormal ( ); |
1343 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 1384 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
1344 | QPoint ( 0, 0 )); | 1385 | QPoint ( 0, 0 )); |
1345 | showFullScreen ( ); | 1386 | showFullScreen ( ); |
1346 | 1387 | ||
1347 | menuToolBar->hide(); | 1388 | menuToolBar->hide(); |
1348 | toolBar->hide(); | 1389 | toolBar->hide(); |
1349 | listHidden = secondToolBar->isHidden(); | 1390 | listHidden = secondToolBar->isHidden(); |
1350 | secondToolBar->hide(); | 1391 | secondToolBar->hide(); |
1351 | // commonCombo->hide(); | 1392 | // commonCombo->hide(); |
1352 | tab->getTabBar()->hide(); | 1393 | tab->getTabBar()->hide(); |
1353 | tab->setMargin(tab->margin()); | 1394 | tab->setMargin(tab->margin()); |
1354 | 1395 | ||
1355 | if (show_fullscreen_msg) | 1396 | if (show_fullscreen_msg) |
1356 | { | 1397 | { |
1357 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, | 1398 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, |
1358 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); | 1399 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); |
1359 | fullscreen_msg->show(); | 1400 | fullscreen_msg->show(); |
1360 | fullscreen_timer->start(3000, true); | 1401 | fullscreen_timer->start(3000, true); |
1361 | show_fullscreen_msg = false; | 1402 | show_fullscreen_msg = false; |
1362 | } | 1403 | } |
1363 | } | 1404 | } |
1364 | else | 1405 | else |
1365 | { | 1406 | { |
1366 | showNormal ( ); | 1407 | showNormal ( ); |
1367 | reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); | 1408 | reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); |
1368 | resize ( normalsize ); | 1409 | resize ( normalsize ); |
1369 | showMaximized ( ); | 1410 | showMaximized ( ); |
1370 | normalsize = QSize ( ); | 1411 | normalsize = QSize ( ); |
1371 | 1412 | ||
1372 | menuToolBar->show(); | 1413 | menuToolBar->show(); |
1373 | toolBar->show(); | 1414 | toolBar->show(); |
1374 | if(! listHidden) | 1415 | if(! listHidden) |
1375 | { | 1416 | { |
1376 | secondToolBar->show(); | 1417 | secondToolBar->show(); |
1377 | } | 1418 | } |
1378 | // commonCombo->show(); | 1419 | // commonCombo->show(); |
1379 | menuToolBar->show(); | 1420 | menuToolBar->show(); |
1380 | if (tabPos != tm_hidden) | 1421 | if (tabPos != tm_hidden) |
1381 | { | 1422 | { |
1382 | tab->getTabBar()->show(); | 1423 | tab->getTabBar()->show(); |
1383 | } | 1424 | } |
1384 | } | 1425 | } |
1385 | tab->setMargin(tab->margin()); // cause setup to run | 1426 | tab->setMargin(tab->margin()); // cause setup to run |
1386 | } | 1427 | } |
1387 | 1428 | ||
1388 | 1429 | ||
1389 | void Konsole::fullscreenTimeout() | 1430 | void Konsole::fullscreenTimeout() |
1390 | { | 1431 | { |
1391 | fullscreen_msg->hide(); | 1432 | fullscreen_msg->hide(); |
1392 | } | 1433 | } |
1393 | 1434 | ||
1394 | void Konsole::colorMenuIsSelected(int iD) | 1435 | void Konsole::colorMenuIsSelected(int iD) |
1395 | { | 1436 | { |
1396 | fromMenu = TRUE; | 1437 | fromMenu = TRUE; |
1397 | colorMenuSelected(iD); | 1438 | colorMenuSelected(iD); |
1398 | } | 1439 | } |
1399 | 1440 | ||
1400 | /// ------------------------------- some new stuff by L.J. Potter | 1441 | /// ------------------------------- some new stuff by L.J. Potter |
1401 | 1442 | ||
1402 | 1443 | ||
1403 | void Konsole::colorMenuSelected(int iD) | 1444 | void Konsole::colorMenuSelected(int iD) |
1404 | { | 1445 | { |
1405 | // this is NOT pretty, elegant or anything else besides functional | 1446 | // this is NOT pretty, elegant or anything else besides functional |
1406 | // QString temp; | 1447 | // QString temp; |
1407 | // qDebug( temp.sprintf("colormenu %d", iD)); | 1448 | // qDebug( temp.sprintf("colormenu %d", iD)); |
1408 | 1449 | ||
1409 | TEWidget* te = getTe(); | 1450 | TEWidget* te = getTe(); |
1410 | Config cfg( "Konsole" ); | 1451 | Config cfg( "Konsole" ); |
1411 | cfg.setGroup("Colors"); | 1452 | cfg.setGroup("Colors"); |
1412 | 1453 | ||
1413 | ColorEntry m_table[TABLE_COLORS]; | 1454 | ColorEntry m_table[TABLE_COLORS]; |
1414 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1455 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
1415 | 1456 | ||
1416 | int i; | 1457 | int i; |
1417 | 1458 | ||
1418 | // te->color_menu_item = iD; | 1459 | // te->color_menu_item = iD; |
1419 | 1460 | ||
1420 | colorMenu->setItemChecked(cm_ab,FALSE); | 1461 | colorMenu->setItemChecked(cm_ab,FALSE); |
1421 | colorMenu->setItemChecked(cm_bb,FALSE); | 1462 | colorMenu->setItemChecked(cm_bb,FALSE); |
1422 | colorMenu->setItemChecked(cm_wc,FALSE); | 1463 | colorMenu->setItemChecked(cm_wc,FALSE); |
1423 | colorMenu->setItemChecked(cm_cw,FALSE); | 1464 | colorMenu->setItemChecked(cm_cw,FALSE); |
1424 | colorMenu->setItemChecked(cm_mb,FALSE); | 1465 | colorMenu->setItemChecked(cm_mb,FALSE); |
1425 | colorMenu->setItemChecked(cm_bm,FALSE); | 1466 | colorMenu->setItemChecked(cm_bm,FALSE); |
1426 | colorMenu->setItemChecked(cm_gy,FALSE); | 1467 | colorMenu->setItemChecked(cm_gy,FALSE); |
1427 | colorMenu->setItemChecked(cm_rb,FALSE); | 1468 | colorMenu->setItemChecked(cm_rb,FALSE); |
1428 | colorMenu->setItemChecked(cm_br,FALSE); | 1469 | colorMenu->setItemChecked(cm_br,FALSE); |
1429 | colorMenu->setItemChecked(cm_wb,FALSE); | 1470 | colorMenu->setItemChecked(cm_wb,FALSE); |
1430 | colorMenu->setItemChecked(cm_bw,FALSE); | 1471 | colorMenu->setItemChecked(cm_bw,FALSE); |
1431 | colorMenu->setItemChecked(cm_gb,FALSE); | 1472 | colorMenu->setItemChecked(cm_gb,FALSE); |
1432 | 1473 | ||
1433 | if(iD==cm_default) | 1474 | if(iD==cm_default) |
1434 | { // default default | 1475 | { // default default |
1435 | printf("default colors\n"); | 1476 | printf("default colors\n"); |
1436 | for (i = 0; i < TABLE_COLORS; i++) | 1477 | for (i = 0; i < TABLE_COLORS; i++) |
1437 | { | 1478 | { |
1438 | m_table[i].color = defaultCt[i].color; | 1479 | m_table[i].color = defaultCt[i].color; |
1439 | if(i==1 || i == 11) | 1480 | if(i==1 || i == 11) |
1440 | m_table[i].transparent=1; | 1481 | m_table[i].transparent=1; |
1441 | colorMenu->setItemChecked(cm_default,TRUE); | 1482 | colorMenu->setItemChecked(cm_default,TRUE); |
1442 | } | 1483 | } |
1443 | te->setColorTable(m_table); | 1484 | te->setColorTable(m_table); |
1444 | } | 1485 | } |
1445 | if(iD==cm_gb) | 1486 | if(iD==cm_gb) |
1446 | { // green black | 1487 | { // green black |
1447 | foreground.setRgb(100,255,100); // (0x18,255,0x18); | 1488 | foreground.setRgb(100,255,100); // (0x18,255,0x18); |
1448 | background.setRgb(0x00,0x00,0x00); | 1489 | background.setRgb(0x00,0x00,0x00); |
1449 | colorMenu->setItemChecked(cm_gb,TRUE); | 1490 | colorMenu->setItemChecked(cm_gb,TRUE); |
1450 | } | 1491 | } |
1451 | if(iD==cm_bw) | 1492 | if(iD==cm_bw) |
1452 | { // black white | 1493 | { // black white |
1453 | foreground.setRgb(0x00,0x00,0x00); | 1494 | foreground.setRgb(0x00,0x00,0x00); |
1454 | background.setRgb(0xFF,0xFF,0xFF); | 1495 | background.setRgb(0xFF,0xFF,0xFF); |
1455 | colorMenu->setItemChecked(cm_bw,TRUE); | 1496 | colorMenu->setItemChecked(cm_bw,TRUE); |
1456 | } | 1497 | } |
1457 | if(iD==cm_wb) | 1498 | if(iD==cm_wb) |
1458 | { // white black | 1499 | { // white black |
1459 | foreground.setRgb(0xFF,0xFF,0xFF); | 1500 | foreground.setRgb(0xFF,0xFF,0xFF); |
1460 | background.setRgb(0x00,0x00,0x00); | 1501 | background.setRgb(0x00,0x00,0x00); |
1461 | colorMenu->setItemChecked(cm_wb,TRUE); | 1502 | colorMenu->setItemChecked(cm_wb,TRUE); |
1462 | } | 1503 | } |
1463 | if(iD==cm_br) | 1504 | if(iD==cm_br) |
1464 | {// Black, Red | 1505 | {// Black, Red |
1465 | foreground.setRgb(0x00,0x00,0x00); | 1506 | foreground.setRgb(0x00,0x00,0x00); |
1466 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); | 1507 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); |
1467 | colorMenu->setItemChecked(cm_br,TRUE); | 1508 | colorMenu->setItemChecked(cm_br,TRUE); |
1468 | } | 1509 | } |
1469 | if(iD==cm_rb) | 1510 | if(iD==cm_rb) |
1470 | {// Red, Black | 1511 | {// Red, Black |
1471 | foreground.setRgb(255,85,85); | 1512 | foreground.setRgb(255,85,85); |
1472 | background.setRgb(0x00,0x00,0x00); | 1513 | background.setRgb(0x00,0x00,0x00); |
1473 | colorMenu->setItemChecked(cm_rb,TRUE); | 1514 | colorMenu->setItemChecked(cm_rb,TRUE); |
1474 | } | 1515 | } |
1475 | if(iD==cm_gy) | 1516 | if(iD==cm_gy) |
1476 | {// Green, Yellow - is ugly | 1517 | {// Green, Yellow - is ugly |
1477 | // foreground.setRgb(0x18,0xB2,0x18); | 1518 | // foreground.setRgb(0x18,0xB2,0x18); |
1478 | foreground.setRgb(15,115,0); | 1519 | foreground.setRgb(15,115,0); |
1479 | // background.setRgb(0xB2,0x68,0x18); | 1520 | // background.setRgb(0xB2,0x68,0x18); |
1480 | background.setRgb(255,255,0); | 1521 | background.setRgb(255,255,0); |
1481 | colorMenu->setItemChecked(cm_gy,TRUE); | 1522 | colorMenu->setItemChecked(cm_gy,TRUE); |
1482 | } | 1523 | } |
1483 | if(iD==cm_bm) | 1524 | if(iD==cm_bm) |
1484 | {// Blue, Magenta | 1525 | {// Blue, Magenta |
1485 | foreground.setRgb(3,24,132); | 1526 | foreground.setRgb(3,24,132); |
1486 | background.setRgb(225,2,255); | 1527 | background.setRgb(225,2,255); |
1487 | colorMenu->setItemChecked(cm_bm,TRUE); | 1528 | colorMenu->setItemChecked(cm_bm,TRUE); |
1488 | } | 1529 | } |
1489 | if(iD==cm_mb) | 1530 | if(iD==cm_mb) |
1490 | {// Magenta, Blue | 1531 | {// Magenta, Blue |
1491 | foreground.setRgb(225,2,255); | 1532 | foreground.setRgb(225,2,255); |
1492 | background.setRgb(3,24,132); | 1533 | background.setRgb(3,24,132); |
1493 | colorMenu->setItemChecked(cm_mb,TRUE); | 1534 | colorMenu->setItemChecked(cm_mb,TRUE); |
1494 | } | 1535 | } |
1495 | if(iD==cm_cw) | 1536 | if(iD==cm_cw) |
1496 | {// Cyan, White | 1537 | {// Cyan, White |
1497 | foreground.setRgb(8,91,129); | 1538 | foreground.setRgb(8,91,129); |
1498 | background.setRgb(0xFF,0xFF,0xFF); | 1539 | background.setRgb(0xFF,0xFF,0xFF); |
1499 | colorMenu->setItemChecked(cm_cw,TRUE); | 1540 | colorMenu->setItemChecked(cm_cw,TRUE); |
1500 | } | 1541 | } |
1501 | if(iD==cm_wc) | 1542 | if(iD==cm_wc) |
1502 | {// White, Cyan | 1543 | {// White, Cyan |
1503 | background.setRgb(8,91,129); | 1544 | background.setRgb(8,91,129); |
1504 | foreground.setRgb(0xFF,0xFF,0xFF); | 1545 | foreground.setRgb(0xFF,0xFF,0xFF); |
1505 | colorMenu->setItemChecked(cm_wc,TRUE); | 1546 | colorMenu->setItemChecked(cm_wc,TRUE); |
1506 | } | 1547 | } |
1507 | if(iD==cm_bb) | 1548 | if(iD==cm_bb) |
1508 | {// Black, Blue | 1549 | {// Black, Blue |
1509 | background.setRgb(0x00,0x00,0x00); | 1550 | background.setRgb(0x00,0x00,0x00); |
1510 | foreground.setRgb(127,147,225); | 1551 | foreground.setRgb(127,147,225); |
1511 | colorMenu->setItemChecked(cm_bb,TRUE); | 1552 | colorMenu->setItemChecked(cm_bb,TRUE); |
1512 | } | 1553 | } |
1513 | if(iD==cm_ab) | 1554 | if(iD==cm_ab) |
1514 | {// Black, Gold | 1555 | {// Black, Gold |
1515 | background.setRgb(0x00,0x00,0x00); | 1556 | background.setRgb(0x00,0x00,0x00); |
1516 | foreground.setRgb(255,215,105); | 1557 | foreground.setRgb(255,215,105); |
1517 | colorMenu->setItemChecked(cm_ab,TRUE); | 1558 | colorMenu->setItemChecked(cm_ab,TRUE); |
1518 | } | 1559 | } |
1519 | #ifdef QT_QWS_OPIE | 1560 | #ifdef QT_QWS_OPIE |
1520 | if(iD==-19) | 1561 | if(iD==-19) |
1521 | { | 1562 | { |
1522 | // Custom | 1563 | // Custom |
1523 | qDebug("do custom"); | 1564 | qDebug("do custom"); |
1524 | if(fromMenu) | 1565 | if(fromMenu) |
1525 | { | 1566 | { |
1526 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); | 1567 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); |
1527 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 1568 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
1528 | SLOT(changeForegroundColor(const QColor&))); | 1569 | SLOT(changeForegroundColor(const QColor&))); |
1529 | penColorPopupMenu->exec(); | 1570 | penColorPopupMenu->exec(); |
1530 | } | 1571 | } |
1531 | if(!fromMenu) | 1572 | if(!fromMenu) |
1532 | { | 1573 | { |
1533 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 1574 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
1534 | background.setNamedColor(cfg.readEntry("background","")); | 1575 | background.setNamedColor(cfg.readEntry("background","")); |
1535 | } | 1576 | } |
1536 | fromMenu=FALSE; | 1577 | fromMenu=FALSE; |
1537 | colorMenu->setItemChecked(-19,TRUE); | 1578 | colorMenu->setItemChecked(-19,TRUE); |
1538 | } | 1579 | } |
1539 | #endif | 1580 | #endif |
1540 | 1581 | ||
1541 | lastSelectedMenu = iD; | 1582 | lastSelectedMenu = iD; |
1542 | 1583 | ||
1543 | setColors(foreground, background); | 1584 | setColors(foreground, background); |
1544 | 1585 | ||
1545 | QTabBar *tabBar = tab->getTabBar(); | 1586 | QTabBar *tabBar = tab->getTabBar(); |
1546 | QString ss = QString("Session%1").arg(tabBar->currentTab()); | 1587 | QString ss = QString("Session%1").arg(tabBar->currentTab()); |
1547 | // printf("current tab = %d\n", tabBar->currentTab()); | 1588 | // printf("current tab = %d\n", tabBar->currentTab()); |
1548 | 1589 | ||
1549 | if (tabBar->currentTab() == 0) | 1590 | if (tabBar->currentTab() == 0) |
1550 | { | 1591 | { |
1551 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); | 1592 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); |
1552 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); | 1593 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); |
1553 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); | 1594 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); |
1554 | cfg.writeEntry("backgroundRed",QString::number(background.red())); | 1595 | cfg.writeEntry("backgroundRed",QString::number(background.red())); |
1555 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); | 1596 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); |
1556 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); | 1597 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); |
1557 | } | 1598 | } |
1558 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); | 1599 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); |
1559 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); | 1600 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); |
1560 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); | 1601 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); |
1561 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); | 1602 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); |
1562 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); | 1603 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); |
1563 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); | 1604 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); |
1564 | 1605 | ||
1565 | update(); | 1606 | update(); |
1566 | } | 1607 | } |
1567 | 1608 | ||
1568 | void Konsole::setColors(QColor foreground, QColor background) | 1609 | void Konsole::setColors(QColor foreground, QColor background) |
1569 | { | 1610 | { |
1570 | int i; | 1611 | int i; |
1571 | ColorEntry m_table[TABLE_COLORS]; | 1612 | ColorEntry m_table[TABLE_COLORS]; |
1572 | TEWidget* te = getTe(); | 1613 | TEWidget* te = getTe(); |
1573 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1614 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
1574 | 1615 | ||
1575 | for (i = 0; i < TABLE_COLORS; i++) | 1616 | for (i = 0; i < TABLE_COLORS; i++) |
1576 | { | 1617 | { |
1577 | if(i==0 || i == 10) | 1618 | if(i==0 || i == 10) |
1578 | { | 1619 | { |
1579 | m_table[i].color = foreground; | 1620 | m_table[i].color = foreground; |
1580 | } | 1621 | } |
1581 | else if(i==1 || i == 11) | 1622 | else if(i==1 || i == 11) |
1582 | { | 1623 | { |
1583 | m_table[i].color = background; | 1624 | m_table[i].color = background; |
1584 | m_table[i].transparent=0; | 1625 | m_table[i].transparent=0; |
1585 | } | 1626 | } |
1586 | else | 1627 | else |
1587 | m_table[i].color = defaultCt[i].color; | 1628 | m_table[i].color = defaultCt[i].color; |
1588 | } | 1629 | } |
1589 | te->setColorTable(m_table); | 1630 | te->setColorTable(m_table); |
1590 | } | 1631 | } |
1591 | 1632 | ||
1592 | void Konsole::tabMenuSelected(int id) | 1633 | void Konsole::tabMenuSelected(int id) |
1593 | { | 1634 | { |
1594 | Config cfg( "Konsole" ); | 1635 | Config cfg( "Konsole" ); |
1595 | cfg.setGroup("Tabs"); | 1636 | cfg.setGroup("Tabs"); |
1596 | tabMenu->setItemChecked(tabPos, false); | 1637 | tabMenu->setItemChecked(tabPos, false); |
1597 | if (id == tm_bottom) | 1638 | if (id == tm_bottom) |
1598 | { | 1639 | { |
1599 | printf("set bottom tab\n"); | 1640 | printf("set bottom tab\n"); |
1600 | tab->getTabBar()->show(); | 1641 | tab->getTabBar()->show(); |
1601 | tab->setTabPosition(QTabWidget::Bottom); | 1642 | tab->setTabPosition(QTabWidget::Bottom); |
1602 | tab->getTabBar()->show(); | 1643 | tab->getTabBar()->show(); |
1603 | cfg.writeEntry("Position","Bottom"); | 1644 | cfg.writeEntry("Position","Bottom"); |
1604 | } | 1645 | } |
1605 | else if (id == tm_top) | 1646 | else if (id == tm_top) |
1606 | { | 1647 | { |
1607 | printf("set top tab\n"); | 1648 | printf("set top tab\n"); |
1608 | tab->getTabBar()->show(); | 1649 | tab->getTabBar()->show(); |
1609 | tab->setTabPosition(QTabWidget::Bottom); | 1650 | tab->setTabPosition(QTabWidget::Bottom); |
1610 | tab->setTabPosition(QTabWidget::Top); | 1651 | tab->setTabPosition(QTabWidget::Top); |
1611 | tab->getTabBar()->show(); | 1652 | tab->getTabBar()->show(); |
1612 | cfg.writeEntry("Position","Top"); | 1653 | cfg.writeEntry("Position","Top"); |
1613 | } | 1654 | } |
1614 | else if (id == tm_hidden) | 1655 | else if (id == tm_hidden) |
1615 | { | 1656 | { |
1616 | tab->getTabBar()->hide(); | 1657 | tab->getTabBar()->hide(); |
1617 | tab->setMargin(tab->margin()); | 1658 | tab->setMargin(tab->margin()); |
1618 | cfg.writeEntry("Position","Hidden"); | 1659 | cfg.writeEntry("Position","Hidden"); |
1619 | } | 1660 | } |
1620 | tabMenu->setItemChecked(id, true); | 1661 | tabMenu->setItemChecked(id, true); |
1621 | tabPos = id; | 1662 | tabPos = id; |
1622 | } | 1663 | } |
1623 | 1664 | ||
1624 | 1665 | ||
1625 | void Konsole::configMenuSelected(int iD) | 1666 | void Konsole::configMenuSelected(int iD) |
1626 | { | 1667 | { |
1627 | // QString temp; | 1668 | // QString temp; |
1628 | // qDebug( temp.sprintf("configmenu %d",iD)); | 1669 | // qDebug( temp.sprintf("configmenu %d",iD)); |
1629 | 1670 | ||
1630 | TEWidget* te = getTe(); | 1671 | TEWidget* te = getTe(); |
1631 | Config cfg( "Konsole" ); | 1672 | Config cfg( "Konsole" ); |
1632 | cfg.setGroup("Menubar"); | 1673 | cfg.setGroup("Menubar"); |
1633 | if(iD == cm_wrap) | 1674 | if(iD == cm_wrap) |
1634 | { | 1675 | { |
1635 | cfg.setGroup("ScrollBar"); | 1676 | cfg.setGroup("ScrollBar"); |
1636 | bool b=cfg.readBoolEntry("HorzScroll",0); | 1677 | bool b=cfg.readBoolEntry("HorzScroll",0); |
1637 | b=!b; | 1678 | b=!b; |
1638 | cfg.writeEntry("HorzScroll", b ); | 1679 | cfg.writeEntry("HorzScroll", b ); |
1639 | cfg.write(); | 1680 | cfg.write(); |
1640 | doWrap(); | 1681 | doWrap(); |
1641 | if(cfg.readNumEntry("Position",2) == 0) | 1682 | if(cfg.readNumEntry("Position",2) == 0) |
1642 | { | 1683 | { |
1643 | te->setScrollbarLocation(1); | 1684 | te->setScrollbarLocation(1); |
1644 | } | 1685 | } |
1645 | else | 1686 | else |
1646 | { | 1687 | { |
1647 | te->setScrollbarLocation(0); | 1688 | te->setScrollbarLocation(0); |
1648 | } | 1689 | } |
1649 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1690 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1650 | } | 1691 | } |
1651 | if(iD == cm_beep) | 1692 | if(iD == cm_beep) |
1652 | { | 1693 | { |
1653 | cfg.setGroup("Menubar"); | 1694 | cfg.setGroup("Menubar"); |
1654 | bool b=cfg.readBoolEntry("useBeep",0); | 1695 | bool b=cfg.readBoolEntry("useBeep",0); |
1655 | b=!b; | 1696 | b=!b; |
1656 | cfg.writeEntry("useBeep", b ); | 1697 | cfg.writeEntry("useBeep", b ); |
1657 | cfg.write(); | 1698 | cfg.write(); |
1658 | configMenu->setItemChecked(cm_beep,b); | 1699 | configMenu->setItemChecked(cm_beep,b); |
1659 | te->useBeep=b; | 1700 | te->useBeep=b; |
1660 | } | 1701 | } |
1661 | } | 1702 | } |
1662 | 1703 | ||
1663 | void Konsole::changeCommand(const QString &text, int c) | 1704 | void Konsole::changeCommand(const QString &text, int c) |
1664 | { | 1705 | { |
1665 | Config cfg( "Konsole" ); | 1706 | Config cfg( "Konsole" ); |
1666 | cfg.setGroup("Commands"); | 1707 | cfg.setGroup("Commands"); |
1667 | if(commonCmds[c] != text) | 1708 | if(commonCmds[c] != text) |
1668 | { | 1709 | { |
1669 | cfg.writeEntry(QString::number(c),text); | 1710 | cfg.writeEntry(QString::number(c),text); |
1670 | commonCombo->clearEdit(); | 1711 | commonCombo->clearEdit(); |
1671 | commonCombo->setCurrentItem(c); | 1712 | commonCombo->setCurrentItem(c); |
1672 | } | 1713 | } |
1673 | } | 1714 | } |
1674 | 1715 | ||
1675 | void Konsole::setColor(int sess) | 1716 | void Konsole::setColor(int sess) |
1676 | { | 1717 | { |
1677 | Config cfg( "Konsole" ); | 1718 | Config cfg( "Konsole" ); |
1678 | cfg.setGroup("Colors"); | 1719 | cfg.setGroup("Colors"); |
1679 | QColor foreground, background; | 1720 | QColor foreground, background; |
1680 | QString ss = QString("Session") + QString::number(sess); | 1721 | QString ss = QString("Session") + QString::number(sess); |
1681 | foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, | 1722 | foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, |
1682 | cfg.readNumEntry("foregroundRed",0xff)), | 1723 | cfg.readNumEntry("foregroundRed",0xff)), |
1683 | cfg.readNumEntry("foregroundGreen"+ss, | 1724 | cfg.readNumEntry("foregroundGreen"+ss, |
1684 | cfg.readNumEntry("foregroundGreen",0xff)), | 1725 | cfg.readNumEntry("foregroundGreen",0xff)), |
1685 | cfg.readNumEntry("foregroundBlue"+ss, | 1726 | cfg.readNumEntry("foregroundBlue"+ss, |
1686 | cfg.readNumEntry("foregroundBlue",0xff))); | 1727 | cfg.readNumEntry("foregroundBlue",0xff))); |
1687 | background.setRgb(cfg.readNumEntry("backgroundRed"+ss, | 1728 | background.setRgb(cfg.readNumEntry("backgroundRed"+ss, |
1688 | cfg.readNumEntry("backgroundRed",0)), | 1729 | cfg.readNumEntry("backgroundRed",0)), |
1689 | cfg.readNumEntry("backgroundGreen"+ss, | 1730 | cfg.readNumEntry("backgroundGreen"+ss, |
1690 | cfg.readNumEntry("backgroundGreen",0)), | 1731 | cfg.readNumEntry("backgroundGreen",0)), |
1691 | cfg.readNumEntry("backgroundBlue"+ss, | 1732 | cfg.readNumEntry("backgroundBlue"+ss, |
1692 | cfg.readNumEntry("backgroundBlue",0))); | 1733 | cfg.readNumEntry("backgroundBlue",0))); |
1693 | setColors(foreground, background); | 1734 | setColors(foreground, background); |
1694 | } | 1735 | } |
1695 | 1736 | ||
1696 | void Konsole::scrollMenuSelected(int index) | 1737 | void Konsole::scrollMenuSelected(int index) |
1697 | { | 1738 | { |
1698 | // qDebug( "scrollbar menu %d",index); | 1739 | // qDebug( "scrollbar menu %d",index); |
1699 | 1740 | ||
1700 | TEWidget* te = getTe(); | 1741 | TEWidget* te = getTe(); |
1701 | Config cfg( "Konsole" ); | 1742 | Config cfg( "Konsole" ); |
1702 | cfg.setGroup("ScrollBar"); | 1743 | cfg.setGroup("ScrollBar"); |
1703 | 1744 | ||
1704 | if(index == sm_none) | 1745 | if(index == sm_none) |
1705 | { | 1746 | { |
1706 | te->setScrollbarLocation(0); | 1747 | te->setScrollbarLocation(0); |
1707 | cfg.writeEntry("Position",0); | 1748 | cfg.writeEntry("Position",0); |
1708 | } | 1749 | } |
1709 | else if(index == sm_left) | 1750 | else if(index == sm_left) |
1710 | { | 1751 | { |
1711 | te->setScrollbarLocation(1); | 1752 | te->setScrollbarLocation(1); |
1712 | cfg.writeEntry("Position",1); | 1753 | cfg.writeEntry("Position",1); |
1713 | } | 1754 | } |
1714 | else if(index == sm_right) | 1755 | else if(index == sm_right) |
1715 | { | 1756 | { |
1716 | te->setScrollbarLocation(2); | 1757 | te->setScrollbarLocation(2); |
1717 | cfg.writeEntry("Position",2); | 1758 | cfg.writeEntry("Position",2); |
1718 | } | 1759 | } |
1719 | scrollMenu->setItemChecked(sm_none, index == sm_none); | 1760 | scrollMenu->setItemChecked(sm_none, index == sm_none); |
1720 | scrollMenu->setItemChecked(sm_left, index == sm_left); | 1761 | scrollMenu->setItemChecked(sm_left, index == sm_left); |
1721 | scrollMenu->setItemChecked(sm_right, index == sm_right); | 1762 | scrollMenu->setItemChecked(sm_right, index == sm_right); |
1722 | } | 1763 | } |
1723 | 1764 | ||
1724 | // case -29: { | 1765 | // case -29: { |
1725 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 1766 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
1726 | // cfg.writeEntry("HorzScroll", !b ); | 1767 | // cfg.writeEntry("HorzScroll", !b ); |
1727 | // cfg.write(); | 1768 | // cfg.write(); |
1728 | // if(cfg.readNumEntry("Position",2) == 0) { | 1769 | // if(cfg.readNumEntry("Position",2) == 0) { |
1729 | // te->setScrollbarLocation(1); | 1770 | // te->setScrollbarLocation(1); |
1730 | // te->setWrapAt(0); | 1771 | // te->setWrapAt(0); |
1731 | // } else { | 1772 | // } else { |
1732 | // te->setScrollbarLocation(0); | 1773 | // te->setScrollbarLocation(0); |
1733 | // te->setWrapAt(120); | 1774 | // te->setWrapAt(120); |
1734 | // } | 1775 | // } |
1735 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1776 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1736 | // } | 1777 | // } |
1737 | // break; | 1778 | // break; |
1738 | 1779 | ||
1739 | void Konsole::editCommandListMenuSelected(int iD) | 1780 | void Konsole::editCommandListMenuSelected(int iD) |
1740 | { | 1781 | { |
1741 | // QString temp; | 1782 | // QString temp; |
1742 | // qDebug( temp.sprintf("edit command list %d",iD)); | 1783 | // qDebug( temp.sprintf("edit command list %d",iD)); |
1743 | 1784 | ||
1744 | // FIXME: more cleanup needed here | 1785 | // FIXME: more cleanup needed here |
1745 | 1786 | ||
1746 | 1787 | ||
1747 | TEWidget* te = getTe(); | 1788 | TEWidget* te = getTe(); |
1748 | Config cfg( "Konsole" ); | 1789 | Config cfg( "Konsole" ); |
1749 | cfg.setGroup("Menubar"); | 1790 | cfg.setGroup("Menubar"); |
1750 | if( iD == ec_cmdlist) | 1791 | if( iD == ec_cmdlist) |
1751 | { | 1792 | { |
1752 | if(!secondToolBar->isHidden()) | 1793 | if(!secondToolBar->isHidden()) |
1753 | { | 1794 | { |
1754 | secondToolBar->hide(); | 1795 | secondToolBar->hide(); |
1755 | configMenu->changeItem( iD,tr( "Show Command List" )); | 1796 | configMenu->changeItem( iD,tr( "Show Command List" )); |
1756 | cfg.writeEntry("Hidden","TRUE"); | 1797 | cfg.writeEntry("Hidden","TRUE"); |
1757 | configMenu->setItemEnabled(ec_edit ,FALSE); | 1798 | configMenu->setItemEnabled(ec_edit ,FALSE); |
1758 | configMenu->setItemEnabled(ec_quick ,FALSE); | 1799 | configMenu->setItemEnabled(ec_quick ,FALSE); |
1759 | } | 1800 | } |
1760 | else | 1801 | else |
1761 | { | 1802 | { |
1762 | secondToolBar->show(); | 1803 | secondToolBar->show(); |
1763 | configMenu->changeItem( iD,tr( "Hide Command List" )); | 1804 | configMenu->changeItem( iD,tr( "Hide Command List" )); |
1764 | cfg.writeEntry("Hidden","FALSE"); | 1805 | cfg.writeEntry("Hidden","FALSE"); |
1765 | configMenu->setItemEnabled(ec_edit ,TRUE); | 1806 | configMenu->setItemEnabled(ec_edit ,TRUE); |
1766 | configMenu->setItemEnabled(ec_quick ,TRUE); | 1807 | configMenu->setItemEnabled(ec_quick ,TRUE); |
1767 | 1808 | ||
1768 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") | 1809 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") |
1769 | { | 1810 | { |
1770 | configMenu->setItemChecked(ec_edit,TRUE); | 1811 | configMenu->setItemChecked(ec_edit,TRUE); |
1771 | commonCombo->setEditable( TRUE ); | 1812 | commonCombo->setEditable( TRUE ); |
1772 | } | 1813 | } |
1773 | else | 1814 | else |
1774 | { | 1815 | { |
1775 | configMenu->setItemChecked(ec_edit,FALSE); | 1816 | configMenu->setItemChecked(ec_edit,FALSE); |
1776 | commonCombo->setEditable( FALSE ); | 1817 | commonCombo->setEditable( FALSE ); |
1777 | } | 1818 | } |
1778 | } | 1819 | } |
1779 | } | 1820 | } |
1780 | if( iD == ec_quick) | 1821 | if( iD == ec_quick) |
1781 | { | 1822 | { |
1782 | cfg.setGroup("Commands"); | 1823 | cfg.setGroup("Commands"); |
1783 | // qDebug("enableCommandEdit"); | 1824 | // qDebug("enableCommandEdit"); |
1784 | if( !configMenu->isItemChecked(iD) ) | 1825 | if( !configMenu->isItemChecked(iD) ) |
1785 | { | 1826 | { |
1786 | commonCombo->setEditable( TRUE ); | 1827 | commonCombo->setEditable( TRUE ); |
1787 | configMenu->setItemChecked(iD,TRUE); | 1828 | configMenu->setItemChecked(iD,TRUE); |
1788 | commonCombo->setCurrentItem(0); | 1829 | commonCombo->setCurrentItem(0); |
1789 | cfg.writeEntry("EditEnabled","TRUE"); | 1830 | cfg.writeEntry("EditEnabled","TRUE"); |
1790 | } | 1831 | } |
1791 | else | 1832 | else |
1792 | { | 1833 | { |
1793 | commonCombo->setEditable( FALSE ); | 1834 | commonCombo->setEditable( FALSE ); |
1794 | configMenu->setItemChecked(iD,FALSE); | 1835 | configMenu->setItemChecked(iD,FALSE); |
1795 | cfg.writeEntry("EditEnabled","FALSE"); | 1836 | cfg.writeEntry("EditEnabled","FALSE"); |
1796 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 1837 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
1797 | te->setFocus(); | 1838 | te->setFocus(); |
1798 | } | 1839 | } |
1799 | } | 1840 | } |
1800 | if(iD == ec_edit) | 1841 | if(iD == ec_edit) |
1801 | { | 1842 | { |
1802 | // "edit commands" | 1843 | // "edit commands" |
1803 | CommandEditDialog *m = new CommandEditDialog(this); | 1844 | CommandEditDialog *m = new CommandEditDialog(this); |
1804 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); | 1845 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); |
1805 | m->showMaximized(); | 1846 | m->showMaximized(); |
1806 | } | 1847 | } |
1807 | 1848 | ||
1808 | } | 1849 | } |
1809 | 1850 | ||
1810 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' | 1851 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' |
1811 | void Konsole::setDocument( const QString &cmd) | 1852 | void Konsole::setDocument( const QString &cmd) |
1812 | { | 1853 | { |
1813 | newSession(); | 1854 | newSession(); |
1814 | TEWidget* te = getTe(); | 1855 | TEWidget* te = getTe(); |
1815 | if(cmd.find("-e", 0, TRUE) != -1) | 1856 | if(cmd.find("-e", 0, TRUE) != -1) |
1816 | { | 1857 | { |
1817 | QString cmd2; | 1858 | QString cmd2; |
1818 | cmd2=cmd.right(cmd.length()-3)+" &"; | 1859 | cmd2=cmd.right(cmd.length()-3)+" &"; |
1819 | system(cmd2.latin1()); | 1860 | system(cmd2.latin1()); |
1820 | if(startUp <= 1 && nsessions < 2) | 1861 | if(startUp <= 1 && nsessions < 2) |
1821 | { | 1862 | { |
1822 | doneSession(getTe(), 0); | 1863 | doneSession(getTe(), 0); |
1823 | exit(0); | 1864 | exit(0); |
1824 | } | 1865 | } |
1825 | else | 1866 | else |
1826 | doneSession(getTe(), 0); | 1867 | doneSession(getTe(), 0); |
1827 | } | 1868 | } |
1828 | else | 1869 | else |
1829 | { | 1870 | { |
1830 | if (te != 0) | 1871 | if (te != 0) |
1831 | { | 1872 | { |
1832 | te->emitText(cmd+"\r"); | 1873 | te->emitText(cmd+"\r"); |
1833 | } | 1874 | } |
1834 | } | 1875 | } |
1835 | startUp++; | 1876 | startUp++; |
1836 | } | 1877 | } |
1837 | 1878 | ||
1838 | 1879 | ||
1839 | // what is the point of this when you can just | 1880 | // what is the point of this when you can just |
1840 | // run commands by using the shell directly?? | 1881 | // run commands by using the shell directly?? |
1841 | void Konsole::parseCommandLine() | 1882 | void Konsole::parseCommandLine() |
1842 | { | 1883 | { |
1843 | QString cmd; | 1884 | QString cmd; |
1844 | // newSession(); | 1885 | // newSession(); |
1845 | for (int i=1;i< qApp->argc();i++) | 1886 | for (int i=1;i< qApp->argc();i++) |
1846 | { | 1887 | { |
1847 | if( QString(qApp->argv()[i]) == "-e") | 1888 | if( QString(qApp->argv()[i]) == "-e") |
1848 | { | 1889 | { |
1849 | i++; | 1890 | i++; |
1850 | for ( int j=i;j< qApp->argc();j++) | 1891 | for ( int j=i;j< qApp->argc();j++) |
1851 | { | 1892 | { |
1852 | cmd+=QString(qApp->argv()[j])+" "; | 1893 | cmd+=QString(qApp->argv()[j])+" "; |
1853 | } | 1894 | } |
1854 | cmd.stripWhiteSpace(); | 1895 | cmd.stripWhiteSpace(); |
1855 | system(cmd.latin1()); | 1896 | system(cmd.latin1()); |
1856 | exit(0);//close(); | 1897 | exit(0);//close(); |
1857 | } // end -e switch | 1898 | } // end -e switch |
1858 | } | 1899 | } |
1859 | startUp++; | 1900 | startUp++; |
1860 | } | 1901 | } |
1861 | 1902 | ||
1862 | void Konsole::changeForegroundColor(const QColor &color) | 1903 | void Konsole::changeForegroundColor(const QColor &color) |
1863 | { | 1904 | { |
1864 | Config cfg( "Konsole" ); | 1905 | Config cfg( "Konsole" ); |
1865 | cfg.setGroup("Colors"); | 1906 | cfg.setGroup("Colors"); |
1866 | int r, g, b; | 1907 | int r, g, b; |
1867 | color.rgb(&r,&g,&b); | 1908 | color.rgb(&r,&g,&b); |
1868 | foreground.setRgb(r,g,b); | 1909 | foreground.setRgb(r,g,b); |
1869 | 1910 | ||
1870 | cfg.writeEntry("foreground",color.name()); | 1911 | cfg.writeEntry("foreground",color.name()); |
1871 | qDebug("foreground "+color.name()); | 1912 | qDebug("foreground "+color.name()); |
1872 | cfg.write(); | 1913 | cfg.write(); |
1873 | 1914 | ||
1874 | qDebug("do other dialog"); | 1915 | qDebug("do other dialog"); |
1875 | #ifdef QT_QWS_OPIE | 1916 | #ifdef QT_QWS_OPIE |
1876 | 1917 | ||
1877 | Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); | 1918 | Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); |
1878 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 1919 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
1879 | SLOT(changeBackgroundColor(const QColor&))); | 1920 | SLOT(changeBackgroundColor(const QColor&))); |
1880 | penColorPopupMenu2->exec(); | 1921 | penColorPopupMenu2->exec(); |
1881 | #endif | 1922 | #endif |
1882 | } | 1923 | } |
1883 | 1924 | ||
1884 | void Konsole::changeBackgroundColor(const QColor &color) | 1925 | void Konsole::changeBackgroundColor(const QColor &color) |
1885 | { | 1926 | { |
1886 | 1927 | ||
1887 | qDebug("Change background"); | 1928 | qDebug("Change background"); |
1888 | Config cfg( "Konsole" ); | 1929 | Config cfg( "Konsole" ); |
1889 | cfg.setGroup("Colors"); | 1930 | cfg.setGroup("Colors"); |
1890 | int r, g, b; | 1931 | int r, g, b; |
1891 | color.rgb(&r,&g,&b); | 1932 | color.rgb(&r,&g,&b); |
1892 | background.setRgb(r,g,b); | 1933 | background.setRgb(r,g,b); |
1893 | cfg.writeEntry("background",color.name()); | 1934 | cfg.writeEntry("background",color.name()); |
1894 | qDebug("background "+color.name()); | 1935 | qDebug("background "+color.name()); |
1895 | cfg.write(); | 1936 | cfg.write(); |
1896 | } | 1937 | } |
1897 | 1938 | ||
1898 | void Konsole::doWrap() | 1939 | void Konsole::doWrap() |
1899 | { | 1940 | { |
1900 | Config cfg( "Konsole" ); | 1941 | Config cfg( "Konsole" ); |
1901 | cfg.setGroup("ScrollBar"); | 1942 | cfg.setGroup("ScrollBar"); |
1902 | TEWidget* te = getTe(); | 1943 | TEWidget* te = getTe(); |
1903 | if( !cfg.readBoolEntry("HorzScroll",0)) | 1944 | if( !cfg.readBoolEntry("HorzScroll",0)) |
1904 | { | 1945 | { |
1905 | te->setWrapAt(0); | 1946 | te->setWrapAt(0); |
1906 | configMenu->setItemChecked( cm_wrap,TRUE); | 1947 | configMenu->setItemChecked( cm_wrap,TRUE); |
1907 | } | 1948 | } |
1908 | else | 1949 | else |
1909 | { | 1950 | { |
1910 | // te->setWrapAt(90); | 1951 | // te->setWrapAt(90); |
1911 | te->setWrapAt(120); | 1952 | te->setWrapAt(120); |
1912 | configMenu->setItemChecked( cm_wrap,FALSE); | 1953 | configMenu->setItemChecked( cm_wrap,FALSE); |
1913 | } | 1954 | } |
1914 | } | 1955 | } |