author | zecke <zecke> | 2004-02-25 20:55:24 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-25 20:55:24 (UTC) |
commit | ad8cbdb693ecccd2a67a8294014360b70ad4253a (patch) (unidiff) | |
tree | c0d3bdc8d3b3d143d195170fee2cc54045840fa6 | |
parent | ddab47e21543e806a7de978985f77ea2b9e8c214 (diff) | |
download | opie-ad8cbdb693ecccd2a67a8294014360b70ad4253a.zip opie-ad8cbdb693ecccd2a67a8294014360b70ad4253a.tar.gz opie-ad8cbdb693ecccd2a67a8294014360b70ad4253a.tar.bz2 |
remove the stupid #ifdef __i386__
We're on Opie and don't need to mess with Qtopia..
we fix up broken Qt usage of legacy via a __weak__ symbol hack
-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 1c613a9..2c0001f 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -49,772 +49,770 @@ | |||
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 | #ifndef __i386__ | ||
434 | // a hack, sizes on Z seem to be points*10 | 433 | // a hack, sizes on Z seem to be points*10 |
435 | size /= 10; | 434 | size /= 10; |
436 | #endif | ||
437 | 435 | ||
438 | f = QFont(familyNames[j], size); | 436 | f = QFont(familyNames[j], size); |
439 | f.setFixedPitch(true); | 437 | f.setFixedPitch(true); |
440 | QFontMetrics fm(f); | 438 | QFontMetrics fm(f); |
441 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 439 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
442 | if (fm.width("l") == fm.width("m") | 440 | if (fm.width("l") == fm.width("m") |
443 | && (i < (uint)sizes.count() | 441 | && (i < (uint)sizes.count() |
444 | || fm.width("m") > last_width)) | 442 | || fm.width("m") > last_width)) |
445 | { | 443 | { |
446 | if (i < (uint)sizes.count()) | 444 | if (i < (uint)sizes.count()) |
447 | { | 445 | { |
448 | last_width = fm.width("m"); | 446 | last_width = fm.width("m"); |
449 | } | 447 | } |
450 | if (sizeMenu == NULL) | 448 | if (sizeMenu == NULL) |
451 | { | 449 | { |
452 | sizeMenu = new QPopupMenu(); | 450 | sizeMenu = new QPopupMenu(); |
453 | } | 451 | } |
454 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 452 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
455 | sizeMenu->setItemParameter(id, fontIndex); | 453 | sizeMenu->setItemParameter(id, fontIndex); |
456 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 454 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
457 | QString name = s + " " + QString::number(size); | 455 | QString name = s + " " + QString::number(size); |
458 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 456 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
459 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 457 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
460 | { | 458 | { |
461 | cfont = fontIndex; | 459 | cfont = fontIndex; |
462 | } | 460 | } |
463 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 461 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
464 | fontIndex++; | 462 | fontIndex++; |
465 | } | 463 | } |
466 | } | 464 | } |
467 | if (sizeMenu) | 465 | if (sizeMenu) |
468 | { | 466 | { |
469 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 467 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
470 | 468 | ||
471 | familyNum++; | 469 | familyNum++; |
472 | } | 470 | } |
473 | } | 471 | } |
474 | 472 | ||
475 | } | 473 | } |
476 | 474 | ||
477 | if (cfont < 0 || cfont >= (int)fonts.count()) | 475 | if (cfont < 0 || cfont >= (int)fonts.count()) |
478 | { | 476 | { |
479 | cfont = 0; | 477 | cfont = 0; |
480 | } | 478 | } |
481 | 479 | ||
482 | // create terminal emulation framework //////////////////////////////////// | 480 | // create terminal emulation framework //////////////////////////////////// |
483 | nsessions = 0; | 481 | nsessions = 0; |
484 | 482 | ||
485 | tab = new EKNumTabWidget(this); | 483 | tab = new EKNumTabWidget(this); |
486 | // tab->setMargin(tab->margin()-5); | 484 | // tab->setMargin(tab->margin()-5); |
487 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 485 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
488 | 486 | ||
489 | // create terminal toolbar //////////////////////////////////////////////// | 487 | // create terminal toolbar //////////////////////////////////////////////// |
490 | setToolBarsMovable( FALSE ); | 488 | setToolBarsMovable( FALSE ); |
491 | menuToolBar = new QToolBar( this ); | 489 | menuToolBar = new QToolBar( this ); |
492 | menuToolBar->setHorizontalStretchable( TRUE ); | 490 | menuToolBar->setHorizontalStretchable( TRUE ); |
493 | 491 | ||
494 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 492 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
495 | 493 | ||
496 | bool c7xx = false; | 494 | bool c7xx = false; |
497 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 495 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
498 | { | 496 | { |
499 | c7xx = true; | 497 | c7xx = true; |
500 | } | 498 | } |
501 | QFont menuFont; | 499 | QFont menuFont; |
502 | menuFont.setPointSize(c7xx? 18 : 10); | 500 | menuFont.setPointSize(c7xx? 18 : 10); |
503 | qApp->setFont(menuFont, true); | 501 | qApp->setFont(menuFont, true); |
504 | 502 | ||
505 | setFont(cfont); | 503 | setFont(cfont); |
506 | 504 | ||
507 | configMenu = new QPopupMenu( this); | 505 | configMenu = new QPopupMenu( this); |
508 | colorMenu = new QPopupMenu( this); | 506 | colorMenu = new QPopupMenu( this); |
509 | scrollMenu = new QPopupMenu( this); | 507 | scrollMenu = new QPopupMenu( this); |
510 | editCommandListMenu = new QPopupMenu( this); | 508 | editCommandListMenu = new QPopupMenu( this); |
511 | 509 | ||
512 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 510 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
513 | 511 | ||
514 | bool listHidden; | 512 | bool listHidden; |
515 | cfg.setGroup("Menubar"); | 513 | cfg.setGroup("Menubar"); |
516 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 514 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
517 | { | 515 | { |
518 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 516 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
519 | listHidden=TRUE; | 517 | listHidden=TRUE; |
520 | } | 518 | } |
521 | else | 519 | else |
522 | { | 520 | { |
523 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 521 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
524 | listHidden=FALSE; | 522 | listHidden=FALSE; |
525 | } | 523 | } |
526 | 524 | ||
527 | cfg.setGroup("Tabs"); | 525 | cfg.setGroup("Tabs"); |
528 | 526 | ||
529 | tabMenu = new QPopupMenu(this); | 527 | tabMenu = new QPopupMenu(this); |
530 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 528 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
531 | tm_top = tabMenu->insertItem(tr("Top")); | 529 | tm_top = tabMenu->insertItem(tr("Top")); |
532 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 530 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
533 | 531 | ||
534 | configMenu->insertItem(tr("Tabs"), tabMenu); | 532 | configMenu->insertItem(tr("Tabs"), tabMenu); |
535 | 533 | ||
536 | tmp=cfg.readEntry("Position","Top"); | 534 | tmp=cfg.readEntry("Position","Top"); |
537 | if(tmp=="Top") | 535 | if(tmp=="Top") |
538 | { | 536 | { |
539 | tab->setTabPosition(QTabWidget::Top); | 537 | tab->setTabPosition(QTabWidget::Top); |
540 | tab->getTabBar()->show(); | 538 | tab->getTabBar()->show(); |
541 | tabPos = tm_top; | 539 | tabPos = tm_top; |
542 | } | 540 | } |
543 | else if (tmp=="Bottom") | 541 | else if (tmp=="Bottom") |
544 | { | 542 | { |
545 | tab->setTabPosition(QTabWidget::Bottom); | 543 | tab->setTabPosition(QTabWidget::Bottom); |
546 | tab->getTabBar()->show(); | 544 | tab->getTabBar()->show(); |
547 | tabPos = tm_bottom; | 545 | tabPos = tm_bottom; |
548 | } | 546 | } |
549 | else | 547 | else |
550 | { | 548 | { |
551 | tab->getTabBar()->hide(); | 549 | tab->getTabBar()->hide(); |
552 | tab->setMargin(tab->margin()); | 550 | tab->setMargin(tab->margin()); |
553 | tabPos = tm_hidden; | 551 | tabPos = tm_hidden; |
554 | } | 552 | } |
555 | 553 | ||
556 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 554 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
557 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 555 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
558 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 556 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
559 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 557 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
560 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 558 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
561 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 559 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
562 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 560 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
563 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 561 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
564 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 562 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
565 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 563 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
566 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 564 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
567 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 565 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
568 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 566 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
569 | cm_default = colorMenu->insertItem(tr("default")); | 567 | cm_default = colorMenu->insertItem(tr("default")); |
570 | 568 | ||
571 | #ifdef QT_QWS_OPIE | 569 | #ifdef QT_QWS_OPIE |
572 | 570 | ||
573 | colorMenu->insertItem(tr( "Custom")); | 571 | colorMenu->insertItem(tr( "Custom")); |
574 | #endif | 572 | #endif |
575 | 573 | ||
576 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 574 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
577 | 575 | ||
578 | sessionList = new QPopupMenu(this); | 576 | sessionList = new QPopupMenu(this); |
579 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, | 577 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, |
580 | SLOT(newSession()) ); | 578 | SLOT(newSession()) ); |
581 | 579 | ||
582 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 580 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
583 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 581 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
584 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 582 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
585 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 583 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
586 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 584 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
587 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 585 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
588 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 586 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
589 | 587 | ||
590 | menuBar->insertItem( tr("View"), configMenu ); | 588 | menuBar->insertItem( tr("View"), configMenu ); |
591 | menuBar->insertItem( tr("Fonts"), fontList ); | 589 | menuBar->insertItem( tr("Fonts"), fontList ); |
592 | menuBar->insertItem( tr("Sessions"), sessionList ); | 590 | menuBar->insertItem( tr("Sessions"), sessionList ); |
593 | 591 | ||
594 | toolBar = new QToolBar( this ); | 592 | toolBar = new QToolBar( this ); |
595 | 593 | ||
596 | QAction *a; | 594 | QAction *a; |
597 | 595 | ||
598 | // Button Commands | 596 | // Button Commands |
599 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); | 597 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); |
600 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 598 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
601 | a->addTo( toolBar ); | 599 | a->addTo( toolBar ); |
602 | 600 | ||
603 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 601 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
604 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 602 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
605 | a->addTo( toolBar ); | 603 | a->addTo( toolBar ); |
606 | 604 | ||
607 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 605 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
608 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 606 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
609 | a->addTo( toolBar ); | 607 | a->addTo( toolBar ); |
610 | 608 | ||
611 | 609 | ||
612 | /* | 610 | /* |
613 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 611 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
614 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 612 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
615 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 613 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
616 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 614 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
617 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 615 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
618 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 616 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
619 | */ | 617 | */ |
620 | /* | 618 | /* |
621 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 619 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
622 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 620 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
623 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 621 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
624 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 622 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
625 | */ | 623 | */ |
626 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 624 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
627 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 625 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
628 | a->addTo( toolBar ); | 626 | a->addTo( toolBar ); |
629 | 627 | ||
630 | secondToolBar = new QToolBar( this ); | 628 | secondToolBar = new QToolBar( this ); |
631 | secondToolBar->setHorizontalStretchable( TRUE ); | 629 | secondToolBar->setHorizontalStretchable( TRUE ); |
632 | 630 | ||
633 | commonCombo = new QComboBox( secondToolBar ); | 631 | commonCombo = new QComboBox( secondToolBar ); |
634 | // commonCombo->setMaximumWidth(236); | 632 | // commonCombo->setMaximumWidth(236); |
635 | 633 | ||
636 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 634 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
637 | if( listHidden) | 635 | if( listHidden) |
638 | { | 636 | { |
639 | secondToolBar->hide(); | 637 | secondToolBar->hide(); |
640 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 638 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
641 | } | 639 | } |
642 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 640 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
643 | 641 | ||
644 | cfg.setGroup("Commands"); | 642 | cfg.setGroup("Commands"); |
645 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 643 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
646 | 644 | ||
647 | initCommandList(); | 645 | initCommandList(); |
648 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 646 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
649 | // commonCombo->insertItem( commonCmds[i], i ); | 647 | // commonCombo->insertItem( commonCmds[i], i ); |
650 | // tmp = cfg.readEntry( QString::number(i),""); | 648 | // tmp = cfg.readEntry( QString::number(i),""); |
651 | // if(tmp != "") | 649 | // if(tmp != "") |
652 | // commonCombo->changeItem( tmp,i ); | 650 | // commonCombo->changeItem( tmp,i ); |
653 | // } | 651 | // } |
654 | 652 | ||
655 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 653 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
656 | 654 | ||
657 | sm_none = scrollMenu->insertItem(tr( "None" )); | 655 | sm_none = scrollMenu->insertItem(tr( "None" )); |
658 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 656 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
659 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 657 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
660 | // scrollMenu->insertSeparator(4); | 658 | // scrollMenu->insertSeparator(4); |
661 | // scrollMenu->insertItem(tr( "Horizontal" )); | 659 | // scrollMenu->insertItem(tr( "Horizontal" )); |
662 | 660 | ||
663 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 661 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
664 | 662 | ||
665 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 663 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
666 | 664 | ||
667 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 665 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
668 | cfg.setGroup("ScrollBar"); | 666 | cfg.setGroup("ScrollBar"); |
669 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 667 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
670 | 668 | ||
671 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 669 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
672 | cfg.setGroup("Menubar"); | 670 | cfg.setGroup("Menubar"); |
673 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 671 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
674 | 672 | ||
675 | fullscreen_msg = new QLabel(this); | 673 | fullscreen_msg = new QLabel(this); |
676 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 674 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
677 | fullscreen_msg-> hide(); | 675 | fullscreen_msg-> hide(); |
678 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 676 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
679 | fullscreen_msg-> setAutoResize(true); | 677 | fullscreen_msg-> setAutoResize(true); |
680 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 678 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
681 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 679 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
682 | 680 | ||
683 | fullscreen_timer = new QTimer(this); | 681 | fullscreen_timer = new QTimer(this); |
684 | connect(fullscreen_timer, SIGNAL(timeout()), | 682 | connect(fullscreen_timer, SIGNAL(timeout()), |
685 | this, SLOT(fullscreenTimeout())); | 683 | this, SLOT(fullscreenTimeout())); |
686 | show_fullscreen_msg = true; | 684 | show_fullscreen_msg = true; |
687 | 685 | ||
688 | //scrollMenuSelected(-29); | 686 | //scrollMenuSelected(-29); |
689 | // cfg.setGroup("ScrollBar"); | 687 | // cfg.setGroup("ScrollBar"); |
690 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 688 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
691 | // if(cfg.readNumEntry("Position",2) == 0) | 689 | // if(cfg.readNumEntry("Position",2) == 0) |
692 | // te->setScrollbarLocation(1); | 690 | // te->setScrollbarLocation(1); |
693 | // else | 691 | // else |
694 | // te->setScrollbarLocation(0); | 692 | // te->setScrollbarLocation(0); |
695 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 693 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
696 | // te->setWrapAt(120); | 694 | // te->setWrapAt(120); |
697 | // } | 695 | // } |
698 | // create applications ///////////////////////////////////////////////////// | 696 | // create applications ///////////////////////////////////////////////////// |
699 | setCentralWidget(tab); | 697 | setCentralWidget(tab); |
700 | 698 | ||
701 | // load keymaps //////////////////////////////////////////////////////////// | 699 | // load keymaps //////////////////////////////////////////////////////////// |
702 | KeyTrans::loadAll(); | 700 | KeyTrans::loadAll(); |
703 | for (int i = 0; i < KeyTrans::count(); i++) | 701 | for (int i = 0; i < KeyTrans::count(); i++) |
704 | { | 702 | { |
705 | KeyTrans* s = KeyTrans::find(i); | 703 | KeyTrans* s = KeyTrans::find(i); |
706 | assert( s ); | 704 | assert( s ); |
707 | } | 705 | } |
708 | 706 | ||
709 | se_pgm = _pgm; | 707 | se_pgm = _pgm; |
710 | se_args = _args; | 708 | se_args = _args; |
711 | 709 | ||
712 | cfg.setGroup("CommandLine"); | 710 | cfg.setGroup("CommandLine"); |
713 | 711 | ||
714 | if (cfg.hasKey("shell_args")) | 712 | if (cfg.hasKey("shell_args")) |
715 | { | 713 | { |
716 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 714 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
717 | for(uint i = 0; i < se_args_list.count(); i++) | 715 | for(uint i = 0; i < se_args_list.count(); i++) |
718 | { | 716 | { |
719 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 717 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
720 | } | 718 | } |
721 | } | 719 | } |
722 | else | 720 | else |
723 | { | 721 | { |
724 | se_args.prepend("--login"); | 722 | se_args.prepend("--login"); |
725 | } | 723 | } |
726 | 724 | ||
727 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 725 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
728 | 726 | ||
729 | // this is the "documentation" for those who know to look | 727 | // this is the "documentation" for those who know to look |
730 | if (! cfg.hasKey("shell_args")) | 728 | if (! cfg.hasKey("shell_args")) |
731 | { | 729 | { |
732 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 730 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
733 | } | 731 | } |
734 | if (! cfg.hasKey("shell_bin")) | 732 | if (! cfg.hasKey("shell_bin")) |
735 | { | 733 | { |
736 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 734 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
737 | } | 735 | } |
738 | 736 | ||
739 | parseCommandLine(); | 737 | parseCommandLine(); |
740 | 738 | ||
741 | // read and apply default values /////////////////////////////////////////// | 739 | // read and apply default values /////////////////////////////////////////// |
742 | resize(321, 321); // Dummy. | 740 | resize(321, 321); // Dummy. |
743 | QSize currentSize = size(); | 741 | QSize currentSize = size(); |
744 | if (currentSize != size()) | 742 | if (currentSize != size()) |
745 | defaultSize = size(); | 743 | defaultSize = size(); |
746 | 744 | ||
747 | 745 | ||
748 | /* allows us to catch cancel/escape */ | 746 | /* allows us to catch cancel/escape */ |
749 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 747 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
750 | QPoint ( 0, 0 )); | 748 | QPoint ( 0, 0 )); |
751 | } | 749 | } |
752 | 750 | ||
753 | void Konsole::show() | 751 | void Konsole::show() |
754 | { | 752 | { |
755 | if ( !nsessions ) | 753 | if ( !nsessions ) |
756 | { | 754 | { |
757 | newSession(); | 755 | newSession(); |
758 | } | 756 | } |
759 | QMainWindow::show(); | 757 | QMainWindow::show(); |
760 | 758 | ||
761 | } | 759 | } |
762 | 760 | ||
763 | void Konsole::initSession(const char*, QStrList &) | 761 | void Konsole::initSession(const char*, QStrList &) |
764 | { | 762 | { |
765 | QMainWindow::show(); | 763 | QMainWindow::show(); |
766 | } | 764 | } |
767 | 765 | ||
768 | Konsole::~Konsole() | 766 | Konsole::~Konsole() |
769 | { | 767 | { |
770 | while (nsessions > 0) | 768 | while (nsessions > 0) |
771 | { | 769 | { |
772 | doneSession(getTe(), 0); | 770 | doneSession(getTe(), 0); |
773 | } | 771 | } |
774 | } | 772 | } |
775 | 773 | ||
776 | void | 774 | void |
777 | Konsole::historyDialog() | 775 | Konsole::historyDialog() |
778 | { | 776 | { |
779 | QDialog *d = new QDialog ( this, "histdlg", true ); | 777 | QDialog *d = new QDialog ( this, "histdlg", true ); |
780 | // d-> setCaption ( tr( "History" )); | 778 | // d-> setCaption ( tr( "History" )); |
781 | 779 | ||
782 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 780 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
783 | 781 | ||
784 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 782 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
785 | lay-> addWidget ( l ); | 783 | lay-> addWidget ( l ); |
786 | 784 | ||
787 | Config cfg( "Konsole" ); | 785 | Config cfg( "Konsole" ); |
788 | cfg.setGroup("History"); | 786 | cfg.setGroup("History"); |
789 | int hist = cfg.readNumEntry("history_lines",300); | 787 | int hist = cfg.readNumEntry("history_lines",300); |
790 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 788 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
791 | 789 | ||
792 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 790 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
793 | spin-> setValue ( hist ); | 791 | spin-> setValue ( hist ); |
794 | spin-> setWrapping ( true ); | 792 | spin-> setWrapping ( true ); |
795 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 793 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
796 | lay-> addWidget ( spin ); | 794 | lay-> addWidget ( spin ); |
797 | 795 | ||
798 | if ( d-> exec ( ) == QDialog::Accepted ) | 796 | if ( d-> exec ( ) == QDialog::Accepted ) |
799 | { | 797 | { |
800 | cfg.writeEntry("history_lines", spin->value()); | 798 | cfg.writeEntry("history_lines", spin->value()); |
801 | cfg.writeEntry("avg_line_length", avg_line); | 799 | cfg.writeEntry("avg_line_length", avg_line); |
802 | if (getTe() != NULL) | 800 | if (getTe() != NULL) |
803 | { | 801 | { |
804 | getTe()->currentSession->setHistory(true); | 802 | getTe()->currentSession->setHistory(true); |
805 | } | 803 | } |
806 | } | 804 | } |
807 | 805 | ||
808 | delete d; | 806 | delete d; |
809 | } | 807 | } |
810 | 808 | ||
811 | 809 | ||
812 | void Konsole::cycleZoom() | 810 | void Konsole::cycleZoom() |
813 | { | 811 | { |
814 | TEWidget* te = getTe(); | 812 | TEWidget* te = getTe(); |
815 | QFont font = te->getVTFont(); | 813 | QFont font = te->getVTFont(); |
816 | int size = font.pointSize(); | 814 | int size = font.pointSize(); |
817 | changeFontSize(1); | 815 | changeFontSize(1); |
818 | font = te->getVTFont(); | 816 | font = te->getVTFont(); |
819 | if (font.pointSize() <= size) | 817 | if (font.pointSize() <= size) |
820 | { | 818 | { |