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