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