author | llornkcor <llornkcor> | 2002-02-01 18:27:20 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-01 18:27:20 (UTC) |
commit | 96f799b935cda52dfed323cadb9025ba1ae737df (patch) (unidiff) | |
tree | a171ad37eed9bfb8619e8c524f4311a9abc3f4f1 | |
parent | 4ffeffe4e91867dca42c02ddc5521d4182cabbb6 (diff) | |
download | opie-96f799b935cda52dfed323cadb9025ba1ae737df.zip opie-96f799b935cda52dfed323cadb9025ba1ae737df.tar.gz opie-96f799b935cda52dfed323cadb9025ba1ae737df.tar.bz2 |
enabled fix
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index f3f0c29..efcb1f2 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -7,164 +7,166 @@ | |||
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 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | 23 | ||
24 | #include <qdir.h> | 24 | #include <qdir.h> |
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qobjectlist.h> | 27 | #include <qobjectlist.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qpe/qpetoolbar.h> | 29 | #include <qpe/qpetoolbar.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qfontdialog.h> | 31 | #include <qfontdialog.h> |
32 | #include <qglobal.h> | 32 | #include <qglobal.h> |
33 | #include <qpainter.h> | 33 | #include <qpainter.h> |
34 | #include <qpe/qpemenubar.h> | 34 | #include <qpe/qpemenubar.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <qaction.h> | 36 | #include <qaction.h> |
37 | #include <qapplication.h> | 37 | #include <qapplication.h> |
38 | #include <qfontmetrics.h> | 38 | #include <qfontmetrics.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qevent.h> | 40 | #include <qevent.h> |
41 | #include <qtabwidget.h> | 41 | #include <qtabwidget.h> |
42 | #include <qtabbar.h> | 42 | #include <qtabbar.h> |
43 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
44 | #include <qstringlist.h> | 44 | #include <qstringlist.h> |
45 | #include <qpalette.h> | 45 | #include <qpalette.h> |
46 | 46 | ||
47 | #include <sys/wait.h> | 47 | #include <sys/wait.h> |
48 | #include <stdio.h> | 48 | #include <stdio.h> |
49 | #include <stdlib.h> | 49 | #include <stdlib.h> |
50 | #include <assert.h> | 50 | #include <assert.h> |
51 | 51 | ||
52 | #include "konsole.h" | 52 | #include "konsole.h" |
53 | #include "keytrans.h" | 53 | #include "keytrans.h" |
54 | 54 | ||
55 | |||
55 | class EKNumTabBar : public QTabBar { | 56 | class EKNumTabBar : public QTabBar { |
56 | public: | 57 | public: |
57 | void numberTabs() | 58 | void numberTabs() |
58 | { | 59 | { |
59 | // Yes, it really is this messy. QTabWidget needs functions | 60 | // Yes, it really is this messy. QTabWidget needs functions |
60 | // that provide acces to tabs in a sequential way. | 61 | // that provide acces to tabs in a sequential way. |
61 | int m=INT_MIN; | 62 | int m=INT_MIN; |
62 | for (int i=0; i<count(); i++) { | 63 | for (int i=0; i<count(); i++) { |
63 | QTab* left=0; | 64 | QTab* left=0; |
64 | QListIterator<QTab> it(*tabList()); | 65 | QListIterator<QTab> it(*tabList()); |
65 | int x=INT_MAX; | 66 | int x=INT_MAX; |
66 | for( QTab* t; (t=it.current()); ++it ) { | 67 | for( QTab* t; (t=it.current()); ++it ) { |
67 | int tx = t->rect().x(); | 68 | int tx = t->rect().x(); |
68 | if ( tx<x && tx>m ) { | 69 | if ( tx<x && tx>m ) { |
69 | x = tx; | 70 | x = tx; |
70 | left = t; | 71 | left = t; |
71 | } | 72 | } |
72 | } | 73 | } |
73 | if ( left ) { | 74 | if ( left ) { |
74 | left->setText(QString::number(i+1)); | 75 | left->setText(QString::number(i+1)); |
75 | m = left->rect().x(); | 76 | m = left->rect().x(); |
76 | } | 77 | } |
77 | } | 78 | } |
78 | } | 79 | } |
79 | }; | 80 | }; |
80 | 81 | ||
81 | class EKNumTabWidget : public QTabWidget { | 82 | class EKNumTabWidget : public QTabWidget { |
82 | public: | 83 | public: |
83 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 84 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
84 | { | 85 | { |
85 | } | 86 | } |
86 | 87 | ||
87 | void addTab(QWidget* w) | 88 | void addTab(QWidget* w) |
88 | { | 89 | { |
89 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 90 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
90 | QTabWidget::addTab(w,t); | 91 | QTabWidget::addTab(w,t); |
91 | } | 92 | } |
92 | 93 | ||
93 | void removeTab(QWidget* w) | 94 | void removeTab(QWidget* w) |
94 | { | 95 | { |
95 | removePage(w); | 96 | removePage(w); |
96 | ((EKNumTabBar*)tabBar())->numberTabs(); | 97 | ((EKNumTabBar*)tabBar())->numberTabs(); |
97 | } | 98 | } |
98 | }; | 99 | }; |
99 | 100 | ||
100 | // This could be configurable or dynamicly generated from the bash history | 101 | // This could be configurable or dynamicly generated from the bash history |
101 | // file of the user | 102 | // file of the user |
102 | static const char *commonCmds[] = | 103 | static const char *commonCmds[] = |
103 | { | 104 | { |
104 | "ls ", // I left this here, cause it looks better than the first alpha | 105 | "ls ", // I left this here, cause it looks better than the first alpha |
105 | "cardctl eject", | 106 | "cardctl eject", |
106 | "cat ", | 107 | "cat ", |
107 | "cd ", | 108 | "cd ", |
108 | "chmod ", | 109 | "chmod ", |
109 | "cp ", | 110 | "cp ", |
110 | "dc ", | 111 | "dc ", |
111 | "df ", | 112 | "df ", |
112 | "dmesg", | 113 | "dmesg", |
113 | "echo ", | 114 | "echo ", |
114 | "find ", | 115 | "find ", |
115 | "free", | 116 | "free", |
116 | "grep ", | 117 | "grep ", |
117 | "ifconfig ", | 118 | "ifconfig ", |
118 | "ipkg ", | 119 | "ipkg ", |
119 | "mkdir ", | 120 | "mkdir ", |
120 | "mv ", | 121 | "mv ", |
121 | "nc localhost 7776", | 122 | "nc localhost 7776", |
122 | "nc localhost 7777", | 123 | "nc localhost 7777", |
124 | "netstat ", | ||
123 | "nslookup ", | 125 | "nslookup ", |
124 | "ping ", | 126 | "ping ", |
125 | "ps aux", | 127 | "ps aux", |
126 | "pwd ", | 128 | "pwd ", |
127 | "rm ", | 129 | "rm ", |
128 | "rmdir ", | 130 | "rmdir ", |
129 | "route ", | 131 | "route ", |
130 | "set ", | 132 | "set ", |
131 | "traceroute", | 133 | "traceroute", |
132 | 134 | ||
133 | /* | 135 | /* |
134 | "gzip", | 136 | "gzip", |
135 | "gunzip", | 137 | "gunzip", |
136 | "chgrp", | 138 | "chgrp", |
137 | "chown", | 139 | "chown", |
138 | "date", | 140 | "date", |
139 | "dd", | 141 | "dd", |
140 | "df", | 142 | "df", |
141 | "dmesg", | 143 | "dmesg", |
142 | "fuser", | 144 | "fuser", |
143 | "hostname", | 145 | "hostname", |
144 | "kill", | 146 | "kill", |
145 | "killall", | 147 | "killall", |
146 | "ln", | 148 | "ln", |
147 | "ping", | 149 | "ping", |
148 | "mount", | 150 | "mount", |
149 | "more", | 151 | "more", |
150 | "sort", | 152 | "sort", |
151 | "touch", | 153 | "touch", |
152 | "umount", | 154 | "umount", |
153 | "mknod", | 155 | "mknod", |
154 | "netstat", | 156 | "netstat", |
155 | */ | 157 | */ |
156 | 158 | ||
157 | "exit", | 159 | "exit", |
158 | NULL | 160 | NULL |
159 | }; | 161 | }; |
160 | 162 | ||
161 | 163 | ||
162 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 164 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
163 | QMainWindow(parent, name, fl) | 165 | QMainWindow(parent, name, fl) |
164 | { | 166 | { |
165 | QStrList args; | 167 | QStrList args; |
166 | init("/bin/sh",args); | 168 | init("/bin/sh",args); |
167 | } | 169 | } |
168 | 170 | ||
169 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 171 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
170 | : QMainWindow(0, name) | 172 | : QMainWindow(0, name) |
@@ -656,97 +658,97 @@ void Konsole::colorMenuSelected(int iD) | |||
656 | foreground.setRgb(0xFF,0xFF,0xFF); | 658 | foreground.setRgb(0xFF,0xFF,0xFF); |
657 | cfg.writeEntry("Schema","15"); | 659 | cfg.writeEntry("Schema","15"); |
658 | colorMenu->setItemChecked(-15,TRUE); | 660 | colorMenu->setItemChecked(-15,TRUE); |
659 | } | 661 | } |
660 | if(iD==-16) {// Black, Blue | 662 | if(iD==-16) {// Black, Blue |
661 | background.setRgb(0x00,0x00,0x00); | 663 | background.setRgb(0x00,0x00,0x00); |
662 | foreground.setRgb(0x18,0xB2,0xB2); | 664 | foreground.setRgb(0x18,0xB2,0xB2); |
663 | cfg.writeEntry("Schema","16"); | 665 | cfg.writeEntry("Schema","16"); |
664 | colorMenu->setItemChecked(-16,TRUE); | 666 | colorMenu->setItemChecked(-16,TRUE); |
665 | } | 667 | } |
666 | 668 | ||
667 | for (i = 0; i < TABLE_COLORS; i++) { | 669 | for (i = 0; i < TABLE_COLORS; i++) { |
668 | if(i==0 || i == 10) { | 670 | if(i==0 || i == 10) { |
669 | m_table[i].color = foreground; | 671 | m_table[i].color = foreground; |
670 | } | 672 | } |
671 | else if(i==1 || i == 11) { | 673 | else if(i==1 || i == 11) { |
672 | m_table[i].color = background; m_table[i].transparent=0; | 674 | m_table[i].color = background; m_table[i].transparent=0; |
673 | } | 675 | } |
674 | else | 676 | else |
675 | m_table[i].color = defaultCt[i].color; | 677 | m_table[i].color = defaultCt[i].color; |
676 | } | 678 | } |
677 | } | 679 | } |
678 | lastSelectedMenu = iD; | 680 | lastSelectedMenu = iD; |
679 | te->setColorTable(m_table); | 681 | te->setColorTable(m_table); |
680 | update(); | 682 | update(); |
681 | } | 683 | } |
682 | 684 | ||
683 | void Konsole::configMenuSelected(int iD) | 685 | void Konsole::configMenuSelected(int iD) |
684 | { | 686 | { |
685 | // QString temp; | 687 | // QString temp; |
686 | // temp.sprintf("%d",iD); | 688 | // temp.sprintf("%d",iD); |
687 | // qDebug(temp); | 689 | // qDebug(temp); |
688 | TEWidget* te = getTe(); | 690 | TEWidget* te = getTe(); |
689 | Config cfg("Konsole"); | 691 | Config cfg("Konsole"); |
690 | cfg.setGroup("Menubar"); | 692 | cfg.setGroup("Menubar"); |
691 | if( iD == -2) { | 693 | if( iD == -2) { |
692 | if(!secondToolBar->isHidden()) { | 694 | if(!secondToolBar->isHidden()) { |
693 | secondToolBar->hide(); | 695 | secondToolBar->hide(); |
694 | configMenu->changeItem( iD,"Show Command List"); | 696 | configMenu->changeItem( iD,"Show Command List"); |
695 | cfg.writeEntry("Hidden","TRUE"); | 697 | cfg.writeEntry("Hidden","TRUE"); |
696 | configMenu->setItemEnabled(-20 ,FALSE); | 698 | configMenu->setItemEnabled(-20 ,FALSE); |
697 | } else { | 699 | } else { |
698 | secondToolBar->show(); | 700 | secondToolBar->show(); |
699 | configMenu->changeItem( iD,"Hide Command List"); | 701 | configMenu->changeItem( iD,"Hide Command List"); |
700 | cfg.writeEntry("Hidden","FALSE"); | 702 | cfg.writeEntry("Hidden","FALSE"); |
701 | configMenu->setItemEnabled(-20 ,TRUE); | 703 | configMenu->setItemEnabled(-20 ,TRUE); |
702 | 704 | ||
703 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { | 705 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { |
704 | configMenu->setItemChecked(-16,TRUE); | 706 | configMenu->setItemChecked(-20,TRUE); |
705 | commonCombo->setEditable( TRUE ); | 707 | commonCombo->setEditable( TRUE ); |
706 | } else { | 708 | } else { |
707 | configMenu->setItemChecked(-20,FALSE); | 709 | configMenu->setItemChecked(-20,FALSE); |
708 | commonCombo->setEditable( FALSE ); | 710 | commonCombo->setEditable( FALSE ); |
709 | } | 711 | } |
710 | } | 712 | } |
711 | } | 713 | } |
712 | if( iD == -3) { | 714 | if( iD == -3) { |
713 | cfg.setGroup("Tabs"); | 715 | cfg.setGroup("Tabs"); |
714 | QString tmp=cfg.readEntry("Position","Top"); | 716 | QString tmp=cfg.readEntry("Position","Top"); |
715 | 717 | ||
716 | if(tmp=="Top") { | 718 | if(tmp=="Top") { |
717 | tab->setTabPosition(QTabWidget::Bottom); | 719 | tab->setTabPosition(QTabWidget::Bottom); |
718 | configMenu->changeItem( iD,"Tabs on Top"); | 720 | configMenu->changeItem( iD,"Tabs on Top"); |
719 | cfg.writeEntry("Position","Bottom"); | 721 | cfg.writeEntry("Position","Bottom"); |
720 | } else { | 722 | } else { |
721 | tab->setTabPosition(QTabWidget::Top); | 723 | tab->setTabPosition(QTabWidget::Top); |
722 | configMenu->changeItem( iD,"Tabs on Bottom"); | 724 | configMenu->changeItem( iD,"Tabs on Bottom"); |
723 | cfg.writeEntry("Position","Top"); | 725 | cfg.writeEntry("Position","Top"); |
724 | } | 726 | } |
725 | } | 727 | } |
726 | if( iD == -20) { | 728 | if( iD == -20) { |
727 | cfg.setGroup("Commands"); | 729 | cfg.setGroup("Commands"); |
728 | // qDebug("enableCommandEdit"); | 730 | // qDebug("enableCommandEdit"); |
729 | if( !configMenu->isItemChecked(iD) ) { | 731 | if( !configMenu->isItemChecked(iD) ) { |
730 | commonCombo->setEditable( TRUE ); | 732 | commonCombo->setEditable( TRUE ); |
731 | configMenu->setItemChecked(iD,TRUE); | 733 | configMenu->setItemChecked(iD,TRUE); |
732 | commonCombo->setCurrentItem(0); | 734 | commonCombo->setCurrentItem(0); |
733 | cfg.writeEntry("EditEnabled","TRUE"); | 735 | cfg.writeEntry("EditEnabled","TRUE"); |
734 | } else { | 736 | } else { |
735 | commonCombo->setEditable( FALSE ); | 737 | commonCombo->setEditable( FALSE ); |
736 | configMenu->setItemChecked(iD,FALSE); | 738 | configMenu->setItemChecked(iD,FALSE); |
737 | cfg.writeEntry("EditEnabled","FALSE"); | 739 | cfg.writeEntry("EditEnabled","FALSE"); |
738 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 740 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
739 | te->setFocus(); | 741 | te->setFocus(); |
740 | } | 742 | } |
741 | } | 743 | } |
742 | } | 744 | } |
743 | 745 | ||
744 | void Konsole::changeCommand(const QString &text, int c) | 746 | void Konsole::changeCommand(const QString &text, int c) |
745 | { | 747 | { |
746 | Config cfg("Konsole"); | 748 | Config cfg("Konsole"); |
747 | cfg.setGroup("Commands"); | 749 | cfg.setGroup("Commands"); |
748 | if(commonCmds[c] != text) { | 750 | if(commonCmds[c] != text) { |
749 | cfg.writeEntry(QString::number(c),text); | 751 | cfg.writeEntry(QString::number(c),text); |
750 | commonCombo->clearEdit(); | 752 | commonCombo->clearEdit(); |
751 | commonCombo->setCurrentItem(c); | 753 | commonCombo->setCurrentItem(c); |
752 | } | 754 | } |