-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 16db0ea..06bee33 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,105 +1,108 @@ | |||
1 | /* ---------------------------------------------------------------------- */ | 1 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [main.C] Konsole */ | 3 | /* [main.C] Konsole */ |
4 | /* */ | 4 | /* */ |
5 | /* ---------------------------------------------------------------------- */ | 5 | /* ---------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole, an X terminal. */ | 9 | /* This file is part of Konsole, an X terminal. */ |
10 | /* */ | 10 | /* */ |
11 | /* The material contained in here more or less directly orginates from */ | 11 | /* The material contained in here more or less directly orginates from */ |
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* ---------------------------------------------------------------------- */ | 14 | /* ---------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
22 | #define QWS_QT_OPIE | ||
22 | 23 | ||
23 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
24 | 25 | ||
25 | #include <qdir.h> | 26 | #include <qdir.h> |
26 | #include <qevent.h> | 27 | #include <qevent.h> |
27 | #include <qdragobject.h> | 28 | #include <qdragobject.h> |
28 | #include <qobjectlist.h> | 29 | #include <qobjectlist.h> |
29 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
30 | #include <qpe/qpetoolbar.h> | 31 | #include <qpe/qpetoolbar.h> |
31 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
32 | #include <qfontdialog.h> | 33 | #include <qfontdialog.h> |
33 | #include <qglobal.h> | 34 | #include <qglobal.h> |
34 | #include <qpainter.h> | 35 | #include <qpainter.h> |
35 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
36 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
37 | #include <qaction.h> | 38 | #include <qaction.h> |
38 | #include <qapplication.h> | 39 | #include <qapplication.h> |
39 | #include <qfontmetrics.h> | 40 | #include <qfontmetrics.h> |
40 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
41 | #include <qevent.h> | 42 | #include <qevent.h> |
42 | #include <qtabwidget.h> | 43 | #include <qtabwidget.h> |
43 | #include <qtabbar.h> | 44 | #include <qtabbar.h> |
44 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
45 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
46 | #include <qpalette.h> | 47 | #include <qpalette.h> |
47 | 48 | ||
48 | #include <sys/wait.h> | 49 | #include <sys/wait.h> |
49 | #include <stdio.h> | 50 | #include <stdio.h> |
50 | #include <stdlib.h> | 51 | #include <stdlib.h> |
51 | #include <assert.h> | 52 | #include <assert.h> |
52 | 53 | ||
53 | #include "konsole.h" | 54 | #include "konsole.h" |
54 | #include "keytrans.h" | 55 | #include "keytrans.h" |
55 | #include "commandeditdialog.h" | 56 | #include "commandeditdialog.h" |
56 | 57 | ||
58 | #ifdef QWS_QT_OPIE | ||
57 | #include <opie/colorpopupmenu.h> | 59 | #include <opie/colorpopupmenu.h> |
60 | #endif | ||
58 | 61 | ||
59 | class EKNumTabBar : public QTabBar { | 62 | class EKNumTabBar : public QTabBar { |
60 | public: | 63 | public: |
61 | void numberTabs() | 64 | void numberTabs() |
62 | { | 65 | { |
63 | // Yes, it really is this messy. QTabWidget needs functions | 66 | // Yes, it really is this messy. QTabWidget needs functions |
64 | // that provide acces to tabs in a sequential way. | 67 | // that provide acces to tabs in a sequential way. |
65 | int m=INT_MIN; | 68 | int m=INT_MIN; |
66 | for (int i=0; i<count(); i++) { | 69 | for (int i=0; i<count(); i++) { |
67 | QTab* left=0; | 70 | QTab* left=0; |
68 | QListIterator<QTab> it(*tabList()); | 71 | QListIterator<QTab> it(*tabList()); |
69 | int x=INT_MAX; | 72 | int x=INT_MAX; |
70 | for( QTab* t; (t=it.current()); ++it ) { | 73 | for( QTab* t; (t=it.current()); ++it ) { |
71 | int tx = t->rect().x(); | 74 | int tx = t->rect().x(); |
72 | if ( tx<x && tx>m ) { | 75 | if ( tx<x && tx>m ) { |
73 | x = tx; | 76 | x = tx; |
74 | left = t; | 77 | left = t; |
75 | } | 78 | } |
76 | } | 79 | } |
77 | if ( left ) { | 80 | if ( left ) { |
78 | left->setText(QString::number(i+1)); | 81 | left->setText(QString::number(i+1)); |
79 | m = left->rect().x(); | 82 | m = left->rect().x(); |
80 | } | 83 | } |
81 | } | 84 | } |
82 | } | 85 | } |
83 | }; | 86 | }; |
84 | 87 | ||
85 | class EKNumTabWidget : public QTabWidget { | 88 | class EKNumTabWidget : public QTabWidget { |
86 | public: | 89 | public: |
87 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 90 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
88 | { | 91 | { |
89 | } | 92 | } |
90 | 93 | ||
91 | void addTab(QWidget* w) | 94 | void addTab(QWidget* w) |
92 | { | 95 | { |
93 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 96 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
94 | QTabWidget::addTab(w,t); | 97 | QTabWidget::addTab(w,t); |
95 | } | 98 | } |
96 | 99 | ||
97 | void removeTab(QWidget* w) | 100 | void removeTab(QWidget* w) |
98 | { | 101 | { |
99 | removePage(w); | 102 | removePage(w); |
100 | ((EKNumTabBar*)tabBar())->numberTabs(); | 103 | ((EKNumTabBar*)tabBar())->numberTabs(); |
101 | } | 104 | } |
102 | }; | 105 | }; |
103 | 106 | ||
104 | // This could be configurable or dynamicly generated from the bash history | 107 | // This could be configurable or dynamicly generated from the bash history |
105 | // file of the user | 108 | // file of the user |
@@ -247,97 +250,101 @@ void Konsole::init(const char* _pgm, QStrList & _args) | |||
247 | fontList = new QPopupMenu( this ); | 250 | fontList = new QPopupMenu( this ); |
248 | for(uint i = 0; i < fonts.count(); i++) { | 251 | for(uint i = 0; i < fonts.count(); i++) { |
249 | VTFont *fnt = fonts.at(i); | 252 | VTFont *fnt = fonts.at(i); |
250 | fontList->insertItem(fnt->getName(), i); | 253 | fontList->insertItem(fnt->getName(), i); |
251 | } | 254 | } |
252 | fontChanged(cfont); | 255 | fontChanged(cfont); |
253 | 256 | ||
254 | configMenu = new QPopupMenu( this); | 257 | configMenu = new QPopupMenu( this); |
255 | colorMenu = new QPopupMenu( this); | 258 | colorMenu = new QPopupMenu( this); |
256 | scrollMenu = new QPopupMenu( this); | 259 | scrollMenu = new QPopupMenu( this); |
257 | editCommandListMenu = new QPopupMenu( this); | 260 | editCommandListMenu = new QPopupMenu( this); |
258 | 261 | ||
259 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 262 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
260 | 263 | ||
261 | bool listHidden; | 264 | bool listHidden; |
262 | cfg.setGroup("Menubar"); | 265 | cfg.setGroup("Menubar"); |
263 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 266 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
264 | editCommandListMenu->insertItem( tr( "Show command list" )); | 267 | editCommandListMenu->insertItem( tr( "Show command list" )); |
265 | listHidden=TRUE; | 268 | listHidden=TRUE; |
266 | } else { | 269 | } else { |
267 | editCommandListMenu->insertItem( tr( "Hide command list" )); | 270 | editCommandListMenu->insertItem( tr( "Hide command list" )); |
268 | listHidden=FALSE; | 271 | listHidden=FALSE; |
269 | } | 272 | } |
270 | 273 | ||
271 | cfg.setGroup("Tabs"); | 274 | cfg.setGroup("Tabs"); |
272 | tmp=cfg.readEntry("Position","Bottom"); | 275 | tmp=cfg.readEntry("Position","Bottom"); |
273 | if(tmp=="Top") { | 276 | if(tmp=="Top") { |
274 | tab->setTabPosition(QTabWidget::Top); | 277 | tab->setTabPosition(QTabWidget::Top); |
275 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); | 278 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); |
276 | } else { | 279 | } else { |
277 | tab->setTabPosition(QTabWidget::Bottom); | 280 | tab->setTabPosition(QTabWidget::Bottom); |
278 | configMenu->insertItem("Tabs on Top"); | 281 | configMenu->insertItem("Tabs on Top"); |
279 | } | 282 | } |
280 | configMenu->insertSeparator(2); | 283 | configMenu->insertSeparator(2); |
281 | 284 | ||
282 | colorMenu->insertItem(tr( "Green on Black")); | 285 | colorMenu->insertItem(tr( "Green on Black")); |
283 | colorMenu->insertItem(tr( "Black on White")); | 286 | colorMenu->insertItem(tr( "Black on White")); |
284 | colorMenu->insertItem(tr( "White on Black")); | 287 | colorMenu->insertItem(tr( "White on Black")); |
285 | colorMenu->insertItem(tr( "Black on Transparent")); | 288 | colorMenu->insertItem(tr( "Black on Transparent")); |
286 | colorMenu->insertItem(tr( "Black on Red")); | 289 | colorMenu->insertItem(tr( "Black on Red")); |
287 | colorMenu->insertItem(tr( "Red on Black")); | 290 | colorMenu->insertItem(tr( "Red on Black")); |
288 | colorMenu->insertItem(tr( "Green on Yellow")); | 291 | colorMenu->insertItem(tr( "Green on Yellow")); |
289 | colorMenu->insertItem(tr( "Blue on Magenta")); | 292 | colorMenu->insertItem(tr( "Blue on Magenta")); |
290 | colorMenu->insertItem(tr( "Magenta on Blue")); | 293 | colorMenu->insertItem(tr( "Magenta on Blue")); |
291 | colorMenu->insertItem(tr( "Cyan on White")); | 294 | colorMenu->insertItem(tr( "Cyan on White")); |
292 | colorMenu->insertItem(tr( "White on Cyan")); | 295 | colorMenu->insertItem(tr( "White on Cyan")); |
293 | colorMenu->insertItem(tr( "Blue on Black")); | 296 | colorMenu->insertItem(tr( "Blue on Black")); |
294 | colorMenu->insertItem(tr( "Amber on Black")); | 297 | colorMenu->insertItem(tr( "Amber on Black")); |
298 | |||
299 | #ifdef QWS_QT_OPIE | ||
295 | colorMenu->insertItem(tr( "Custom")); | 300 | colorMenu->insertItem(tr( "Custom")); |
301 | #endif | ||
302 | |||
296 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 303 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
297 | 304 | ||
298 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 305 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
299 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 306 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
300 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 307 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
301 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 308 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
302 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 309 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
303 | menuBar->insertItem( tr("Font"), fontList ); | 310 | menuBar->insertItem( tr("Font"), fontList ); |
304 | menuBar->insertItem( tr("Options"), configMenu ); | 311 | menuBar->insertItem( tr("Options"), configMenu ); |
305 | 312 | ||
306 | QPEToolBar *toolbar = new QPEToolBar( this ); | 313 | QPEToolBar *toolbar = new QPEToolBar( this ); |
307 | 314 | ||
308 | QAction *a; | 315 | QAction *a; |
309 | 316 | ||
310 | // Button Commands | 317 | // Button Commands |
311 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 318 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
312 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 319 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
313 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 320 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
314 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 321 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
315 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 322 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
316 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 323 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
317 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 324 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
318 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 325 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
319 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 326 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
320 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
321 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 328 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
322 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
323 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 330 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
324 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 331 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
325 | /* | 332 | /* |
326 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 333 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 334 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
328 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 335 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 336 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
330 | */ | 337 | */ |
331 | 338 | ||
332 | secondToolBar = new QPEToolBar( this ); | 339 | secondToolBar = new QPEToolBar( this ); |
333 | secondToolBar->setHorizontalStretchable( TRUE ); | 340 | secondToolBar->setHorizontalStretchable( TRUE ); |
334 | 341 | ||
335 | commonCombo = new QComboBox( secondToolBar ); | 342 | commonCombo = new QComboBox( secondToolBar ); |
336 | commonCombo->setMaximumWidth(236); | 343 | commonCombo->setMaximumWidth(236); |
337 | 344 | ||
338 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 345 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
339 | if( listHidden) { | 346 | if( listHidden) { |
340 | secondToolBar->hide(); | 347 | secondToolBar->hide(); |
341 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 348 | editCommandListMenu->setItemEnabled(-23 ,FALSE); |
342 | } | 349 | } |
343 | editCommandListMenu->insertItem(tr( "Edit" ) ); | 350 | editCommandListMenu->insertItem(tr( "Edit" ) ); |
@@ -697,152 +704,161 @@ void Konsole::colorMenuSelected(int iD) | |||
697 | background.setRgb(0x00,0x00,0x00); | 704 | background.setRgb(0x00,0x00,0x00); |
698 | cfg.writeEntry("Schema","11"); | 705 | cfg.writeEntry("Schema","11"); |
699 | colorMenu->setItemChecked(-11,TRUE); | 706 | colorMenu->setItemChecked(-11,TRUE); |
700 | } | 707 | } |
701 | if(iD==-12) {// Green, Yellow - is ugly | 708 | if(iD==-12) {// Green, Yellow - is ugly |
702 | // foreground.setRgb(0x18,0xB2,0x18); | 709 | // foreground.setRgb(0x18,0xB2,0x18); |
703 | foreground.setRgb(36,139,10); | 710 | foreground.setRgb(36,139,10); |
704 | // background.setRgb(0xB2,0x68,0x18); | 711 | // background.setRgb(0xB2,0x68,0x18); |
705 | background.setRgb(255,255,0); | 712 | background.setRgb(255,255,0); |
706 | cfg.writeEntry("Schema","12"); | 713 | cfg.writeEntry("Schema","12"); |
707 | colorMenu->setItemChecked(-12,TRUE); | 714 | colorMenu->setItemChecked(-12,TRUE); |
708 | } | 715 | } |
709 | if(iD==-13) {// Blue, Magenta | 716 | if(iD==-13) {// Blue, Magenta |
710 | foreground.setRgb(0x18,0xB2,0xB2); | 717 | foreground.setRgb(0x18,0xB2,0xB2); |
711 | background.setRgb(0x18,0x18,0xB2); | 718 | background.setRgb(0x18,0x18,0xB2); |
712 | cfg.writeEntry("Schema","13"); | 719 | cfg.writeEntry("Schema","13"); |
713 | colorMenu->setItemChecked(-13,TRUE); | 720 | colorMenu->setItemChecked(-13,TRUE); |
714 | } | 721 | } |
715 | if(iD==-14) {// Magenta, Blue | 722 | if(iD==-14) {// Magenta, Blue |
716 | foreground.setRgb(0x18,0x18,0xB2); | 723 | foreground.setRgb(0x18,0x18,0xB2); |
717 | background.setRgb(0x18,0xB2,0xB2); | 724 | background.setRgb(0x18,0xB2,0xB2); |
718 | cfg.writeEntry("Schema","14"); | 725 | cfg.writeEntry("Schema","14"); |
719 | colorMenu->setItemChecked(-14,TRUE); | 726 | colorMenu->setItemChecked(-14,TRUE); |
720 | } | 727 | } |
721 | if(iD==-15) {// Cyan, White | 728 | if(iD==-15) {// Cyan, White |
722 | foreground.setRgb(0x18,0xB2,0xB2); | 729 | foreground.setRgb(0x18,0xB2,0xB2); |
723 | background.setRgb(0xFF,0xFF,0xFF); | 730 | background.setRgb(0xFF,0xFF,0xFF); |
724 | cfg.writeEntry("Schema","15"); | 731 | cfg.writeEntry("Schema","15"); |
725 | colorMenu->setItemChecked(-15,TRUE); | 732 | colorMenu->setItemChecked(-15,TRUE); |
726 | } | 733 | } |
727 | if(iD==-16) {// White, Cyan | 734 | if(iD==-16) {// White, Cyan |
728 | background.setRgb(0x18,0xB2,0xB2); | 735 | background.setRgb(0x18,0xB2,0xB2); |
729 | foreground.setRgb(0xFF,0xFF,0xFF); | 736 | foreground.setRgb(0xFF,0xFF,0xFF); |
730 | cfg.writeEntry("Schema","16"); | 737 | cfg.writeEntry("Schema","16"); |
731 | colorMenu->setItemChecked(-16,TRUE); | 738 | colorMenu->setItemChecked(-16,TRUE); |
732 | } | 739 | } |
733 | if(iD==-17) {// Black, Blue | 740 | if(iD==-17) {// Black, Blue |
734 | background.setRgb(0x00,0x00,0x00); | 741 | background.setRgb(0x00,0x00,0x00); |
735 | foreground.setRgb(0x18,0xB2,0xB2); | 742 | foreground.setRgb(0x18,0xB2,0xB2); |
736 | cfg.writeEntry("Schema","17"); | 743 | cfg.writeEntry("Schema","17"); |
737 | colorMenu->setItemChecked(-17,TRUE); | 744 | colorMenu->setItemChecked(-17,TRUE); |
738 | } | 745 | } |
739 | if(iD==-18) {// Black, Gold | 746 | if(iD==-18) {// Black, Gold |
740 | background.setRgb(0x00,0x00,0x00); | 747 | background.setRgb(0x00,0x00,0x00); |
741 | foreground.setRgb(255,215,0); | 748 | foreground.setRgb(255,215,0); |
742 | cfg.writeEntry("Schema","18"); | 749 | cfg.writeEntry("Schema","18"); |
743 | colorMenu->setItemChecked(-18,TRUE); | 750 | colorMenu->setItemChecked(-18,TRUE); |
744 | } | 751 | } |
745 | if(iD==-19) {// Custom | 752 | #ifdef QWS_QT_OPIE |
753 | if(iD==-19) { | ||
754 | // Custom | ||
746 | qDebug("do custom"); | 755 | qDebug("do custom"); |
747 | if(fromMenu) { | 756 | if(fromMenu) { |
748 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); | 757 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); |
749 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 758 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
750 | SLOT(changeForegroundColor(const QColor&))); | 759 | SLOT(changeForegroundColor(const QColor&))); |
751 | penColorPopupMenu->exec(); | 760 | penColorPopupMenu->exec(); |
752 | } | 761 | } |
753 | cfg.writeEntry("Schema","19"); | 762 | cfg.writeEntry("Schema","19"); |
754 | if(!fromMenu) { | 763 | if(!fromMenu) { |
755 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 764 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
756 | background.setNamedColor(cfg.readEntry("background","")); | 765 | background.setNamedColor(cfg.readEntry("background","")); |
757 | } | 766 | } |
758 | fromMenu=FALSE; | 767 | fromMenu=FALSE; |
759 | colorMenu->setItemChecked(-19,TRUE); | 768 | colorMenu->setItemChecked(-19,TRUE); |
760 | } | 769 | } |
761 | 770 | #endif | |
762 | for (i = 0; i < TABLE_COLORS; i++) { | 771 | for (i = 0; i < TABLE_COLORS; i++) { |
763 | if(i==0 || i == 10) { | 772 | if(i==0 || i == 10) { |
764 | m_table[i].color = foreground; | 773 | m_table[i].color = foreground; |
765 | } | 774 | } |
766 | else if(i==1 || i == 11) { | 775 | else if(i==1 || i == 11) { |
767 | m_table[i].color = background; m_table[i].transparent=0; | 776 | m_table[i].color = background; m_table[i].transparent=0; |
768 | } | 777 | } |
769 | else | 778 | else |
770 | m_table[i].color = defaultCt[i].color; | 779 | m_table[i].color = defaultCt[i].color; |
771 | } | 780 | } |
772 | } | 781 | } |
773 | lastSelectedMenu = iD; | 782 | lastSelectedMenu = iD; |
774 | te->setColorTable(m_table); | 783 | te->setColorTable(m_table); |
775 | update(); | 784 | update(); |
776 | 785 | ||
777 | } | 786 | } |
778 | 787 | ||
779 | void Konsole::configMenuSelected(int iD) | 788 | void Konsole::configMenuSelected(int iD) |
780 | { | 789 | { |
781 | QString temp; | 790 | // QString temp; |
782 | qDebug( temp.sprintf("configmenu %d",iD)); | 791 | // qDebug( temp.sprintf("configmenu %d",iD)); |
783 | TEWidget* te = getTe(); | 792 | TEWidget* te = getTe(); |
784 | Config cfg("Konsole"); | 793 | Config cfg("Konsole"); |
785 | cfg.setGroup("Menubar"); | 794 | cfg.setGroup("Menubar"); |
786 | if( iD == -4) { | 795 | if( iD == -4) { |
787 | cfg.setGroup("Tabs"); | 796 | cfg.setGroup("Tabs"); |
788 | QString tmp=cfg.readEntry("Position","Bottom"); | 797 | QString tmp=cfg.readEntry("Position","Bottom"); |
789 | 798 | ||
790 | if(tmp=="Top") { | 799 | if(tmp=="Top") { |
791 | tab->setTabPosition(QTabWidget::Bottom); | 800 | tab->setTabPosition(QTabWidget::Bottom); |
792 | configMenu->changeItem( iD,"Tabs on Top"); | 801 | configMenu->changeItem( iD,"Tabs on Top"); |
793 | cfg.writeEntry("Position","Bottom"); | 802 | cfg.writeEntry("Position","Bottom"); |
794 | } else { | 803 | } else { |
795 | tab->setTabPosition(QTabWidget::Top); | 804 | tab->setTabPosition(QTabWidget::Top); |
796 | configMenu->changeItem( iD,"Tabs on Bottom"); | 805 | configMenu->changeItem( iD,"Tabs on Bottom"); |
797 | cfg.writeEntry("Position","Top"); | 806 | cfg.writeEntry("Position","Top"); |
798 | } | 807 | } |
799 | } | 808 | } |
800 | if( iD == -29) { | 809 | int i; |
810 | #ifdef QWS_QT_OPIE | ||
811 | i=-29; | ||
812 | #else | ||
813 | i=-28; | ||
814 | #endif | ||
815 | |||
816 | if( iD == i) { | ||
801 | cfg.setGroup("ScrollBar"); | 817 | cfg.setGroup("ScrollBar"); |
802 | bool b=cfg.readBoolEntry("HorzScroll",0); | 818 | bool b=cfg.readBoolEntry("HorzScroll",0); |
803 | b=!b; | 819 | b=!b; |
804 | cfg.writeEntry("HorzScroll", b ); | 820 | cfg.writeEntry("HorzScroll", b ); |
805 | cfg.write(); | 821 | cfg.write(); |
806 | doWrap(); | 822 | doWrap(); |
807 | if(cfg.readNumEntry("Position",2) == 0) { | 823 | if(cfg.readNumEntry("Position",2) == 0) { |
808 | te->setScrollbarLocation(1); | 824 | te->setScrollbarLocation(1); |
809 | } else { | 825 | } else { |
810 | te->setScrollbarLocation(0); | 826 | te->setScrollbarLocation(0); |
811 | } | 827 | } |
812 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 828 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
813 | } | 829 | } |
814 | } | 830 | } |
815 | 831 | ||
816 | void Konsole::changeCommand(const QString &text, int c) | 832 | void Konsole::changeCommand(const QString &text, int c) |
817 | { | 833 | { |
818 | Config cfg("Konsole"); | 834 | Config cfg("Konsole"); |
819 | cfg.setGroup("Commands"); | 835 | cfg.setGroup("Commands"); |
820 | if(commonCmds[c] != text) { | 836 | if(commonCmds[c] != text) { |
821 | cfg.writeEntry(QString::number(c),text); | 837 | cfg.writeEntry(QString::number(c),text); |
822 | commonCombo->clearEdit(); | 838 | commonCombo->clearEdit(); |
823 | commonCombo->setCurrentItem(c); | 839 | commonCombo->setCurrentItem(c); |
824 | } | 840 | } |
825 | } | 841 | } |
826 | 842 | ||
827 | void Konsole::setColor() | 843 | void Konsole::setColor() |
828 | { | 844 | { |
829 | Config cfg("Konsole"); | 845 | Config cfg("Konsole"); |
830 | cfg.setGroup("Colors"); | 846 | cfg.setGroup("Colors"); |
831 | int scheme = cfg.readNumEntry("Schema",1); | 847 | int scheme = cfg.readNumEntry("Schema",1); |
832 | if(scheme != 1) colorMenuSelected( -scheme); | 848 | if(scheme != 1) colorMenuSelected( -scheme); |
833 | } | 849 | } |
834 | 850 | ||
835 | void Konsole::scrollMenuSelected(int index) | 851 | void Konsole::scrollMenuSelected(int index) |
836 | { | 852 | { |
837 | qDebug( "scrollbar menu %d",index); | 853 | qDebug( "scrollbar menu %d",index); |
838 | TEWidget* te = getTe(); | 854 | TEWidget* te = getTe(); |
839 | Config cfg("Konsole"); | 855 | Config cfg("Konsole"); |
840 | cfg.setGroup("ScrollBar"); | 856 | cfg.setGroup("ScrollBar"); |
841 | switch( index){ | 857 | switch( index){ |
842 | case -25: | 858 | case -25: |
843 | te->setScrollbarLocation(0); | 859 | te->setScrollbarLocation(0); |
844 | cfg.writeEntry("Position",0); | 860 | cfg.writeEntry("Position",0); |
845 | break; | 861 | break; |
846 | case -26: | 862 | case -26: |
847 | te->setScrollbarLocation(1); | 863 | te->setScrollbarLocation(1); |
848 | cfg.writeEntry("Position",1); | 864 | cfg.writeEntry("Position",1); |
@@ -926,82 +942,91 @@ void Konsole::setDocument( const QString &cmd) { | |||
926 | newSession(); | 942 | newSession(); |
927 | TEWidget* te = getTe(); | 943 | TEWidget* te = getTe(); |
928 | if(cmd.find("-e", 0, TRUE) != -1) { | 944 | if(cmd.find("-e", 0, TRUE) != -1) { |
929 | QString cmd2; | 945 | QString cmd2; |
930 | cmd2=cmd.right(cmd.length()-3)+" &"; | 946 | cmd2=cmd.right(cmd.length()-3)+" &"; |
931 | system(cmd2.latin1()); | 947 | system(cmd2.latin1()); |
932 | if(startUp <= 1 && nsessions < 2) { | 948 | if(startUp <= 1 && nsessions < 2) { |
933 | doneSession(getTe()->currentSession, 0); | 949 | doneSession(getTe()->currentSession, 0); |
934 | exit(0); | 950 | exit(0); |
935 | } else | 951 | } else |
936 | doneSession(getTe()->currentSession, 0); | 952 | doneSession(getTe()->currentSession, 0); |
937 | } else { | 953 | } else { |
938 | if (te != 0) { | 954 | if (te != 0) { |
939 | te->emitText(cmd+"\r"); | 955 | te->emitText(cmd+"\r"); |
940 | } | 956 | } |
941 | } | 957 | } |
942 | startUp++; | 958 | startUp++; |
943 | } | 959 | } |
944 | 960 | ||
945 | void Konsole::parseCommandLine() { | 961 | void Konsole::parseCommandLine() { |
946 | QString cmd; | 962 | QString cmd; |
947 | // newSession(); | 963 | // newSession(); |
948 | for (int i=1;i< qApp->argc();i++) { | 964 | for (int i=1;i< qApp->argc();i++) { |
949 | if( QString(qApp->argv()[i]) == "-e") { | 965 | if( QString(qApp->argv()[i]) == "-e") { |
950 | i++; | 966 | i++; |
951 | for ( int j=i;j< qApp->argc();j++) { | 967 | for ( int j=i;j< qApp->argc();j++) { |
952 | cmd+=QString(qApp->argv()[j])+" "; | 968 | cmd+=QString(qApp->argv()[j])+" "; |
953 | } | 969 | } |
954 | cmd.stripWhiteSpace(); | 970 | cmd.stripWhiteSpace(); |
955 | system(cmd.latin1()); | 971 | system(cmd.latin1()); |
956 | exit(0);//close(); | 972 | exit(0);//close(); |
957 | } // end -e switch | 973 | } // end -e switch |
958 | } | 974 | } |
959 | startUp++; | 975 | startUp++; |
960 | } | 976 | } |
961 | 977 | ||
962 | void Konsole::changeForegroundColor(const QColor &color) { | 978 | void Konsole::changeForegroundColor(const QColor &color) { |
963 | Config cfg("Konsole"); | 979 | Config cfg("Konsole"); |
964 | cfg.setGroup("Colors"); | 980 | cfg.setGroup("Colors"); |
965 | int r, g, b; | 981 | int r, g, b; |
966 | color.rgb(&r,&g,&b); | 982 | color.rgb(&r,&g,&b); |
967 | foreground.setRgb(r,g,b); | 983 | foreground.setRgb(r,g,b); |
968 | // QString colors; | 984 | // QString colors; |
969 | // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); | 985 | // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); |
970 | cfg.writeEntry("foreground",color.name()); | 986 | cfg.writeEntry("foreground",color.name()); |
971 | cfg.write(); | 987 | cfg.write(); |
972 | 988 | ||
973 | qDebug("do other dialog"); | 989 | qDebug("do other dialog"); |
990 | #ifdef QWS_QT_OPIE | ||
991 | |||
974 | ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); | 992 | ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); |
975 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 993 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
976 | SLOT(changeBackgroundColor(const QColor&))); | 994 | SLOT(changeBackgroundColor(const QColor&))); |
977 | penColorPopupMenu2->exec(); | 995 | penColorPopupMenu2->exec(); |
978 | 996 | #endif | |
979 | } | 997 | } |
980 | 998 | ||
981 | void Konsole::changeBackgroundColor(const QColor &color) { | 999 | void Konsole::changeBackgroundColor(const QColor &color) { |
982 | 1000 | ||
983 | qDebug("Change background"); | 1001 | qDebug("Change background"); |
984 | Config cfg("Konsole"); | 1002 | Config cfg("Konsole"); |
985 | cfg.setGroup("Colors"); | 1003 | cfg.setGroup("Colors"); |
986 | int r, g, b; | 1004 | int r, g, b; |
987 | color.rgb(&r,&g,&b); | 1005 | color.rgb(&r,&g,&b); |
988 | background.setRgb(r,g,b); | 1006 | background.setRgb(r,g,b); |
989 | // QString colors; | 1007 | // QString colors; |
990 | // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); | 1008 | // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); |
991 | cfg.writeEntry("background",color.name()); | 1009 | cfg.writeEntry("background",color.name()); |
992 | cfg.write(); | 1010 | cfg.write(); |
993 | } | 1011 | } |
994 | 1012 | ||
995 | void Konsole::doWrap() { | 1013 | void Konsole::doWrap() { |
996 | Config cfg("Konsole"); | 1014 | int i; |
1015 | #ifdef QWS_QT_OPIE | ||
1016 | i=-29; | ||
1017 | #else | ||
1018 | i=-28; | ||
1019 | #endif | ||
1020 | |||
1021 | Config cfg("Konsole"); | ||
997 | cfg.setGroup("ScrollBar"); | 1022 | cfg.setGroup("ScrollBar"); |
998 | TEWidget* te = getTe(); | 1023 | TEWidget* te = getTe(); |
999 | if( !cfg.readBoolEntry("HorzScroll",0)) { | 1024 | if( !cfg.readBoolEntry("HorzScroll",0)) { |
1000 | te->setWrapAt(0); | 1025 | te->setWrapAt(0); |
1001 | configMenu->setItemChecked(-29,FALSE); | 1026 | configMenu->setItemChecked( i,FALSE); |
1002 | } else { | 1027 | } else { |
1003 | te->setWrapAt(90); | 1028 | te->setWrapAt(90); |
1004 | // te->setWrapAt(120); | 1029 | // te->setWrapAt(120); |
1005 | configMenu->setItemChecked(-29,TRUE); | 1030 | configMenu->setItemChecked( i,TRUE); |
1006 | } | 1031 | } |
1007 | } | 1032 | } |