-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 1016885..d54fa1f 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,764 +1,765 @@ | |||
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 | 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 | class EKNumTabBar : public QTabBar { | 55 | class EKNumTabBar : public QTabBar { |
56 | public: | 56 | public: |
57 | void numberTabs() | 57 | void numberTabs() |
58 | { | 58 | { |
59 | // Yes, it really is this messy. QTabWidget needs functions | 59 | // Yes, it really is this messy. QTabWidget needs functions |
60 | // that provide acces to tabs in a sequential way. | 60 | // that provide acces to tabs in a sequential way. |
61 | int m=INT_MIN; | 61 | int m=INT_MIN; |
62 | for (int i=0; i<count(); i++) { | 62 | for (int i=0; i<count(); i++) { |
63 | QTab* left=0; | 63 | QTab* left=0; |
64 | QListIterator<QTab> it(*tabList()); | 64 | QListIterator<QTab> it(*tabList()); |
65 | int x=INT_MAX; | 65 | int x=INT_MAX; |
66 | for( QTab* t; (t=it.current()); ++it ) { | 66 | for( QTab* t; (t=it.current()); ++it ) { |
67 | int tx = t->rect().x(); | 67 | int tx = t->rect().x(); |
68 | if ( tx<x && tx>m ) { | 68 | if ( tx<x && tx>m ) { |
69 | x = tx; | 69 | x = tx; |
70 | left = t; | 70 | left = t; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | if ( left ) { | 73 | if ( left ) { |
74 | left->setText(QString::number(i+1)); | 74 | left->setText(QString::number(i+1)); |
75 | m = left->rect().x(); | 75 | m = left->rect().x(); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |
79 | }; | 79 | }; |
80 | 80 | ||
81 | class EKNumTabWidget : public QTabWidget { | 81 | class EKNumTabWidget : public QTabWidget { |
82 | public: | 82 | public: |
83 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 83 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
84 | { | 84 | { |
85 | } | 85 | } |
86 | 86 | ||
87 | void addTab(QWidget* w) | 87 | void addTab(QWidget* w) |
88 | { | 88 | { |
89 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 89 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
90 | QTabWidget::addTab(w,t); | 90 | QTabWidget::addTab(w,t); |
91 | } | 91 | } |
92 | 92 | ||
93 | void removeTab(QWidget* w) | 93 | void removeTab(QWidget* w) |
94 | { | 94 | { |
95 | removePage(w); | 95 | removePage(w); |
96 | ((EKNumTabBar*)tabBar())->numberTabs(); | 96 | ((EKNumTabBar*)tabBar())->numberTabs(); |
97 | } | 97 | } |
98 | }; | 98 | }; |
99 | 99 | ||
100 | // This could be configurable or dynamicly generated from the bash history | 100 | // This could be configurable or dynamicly generated from the bash history |
101 | // file of the user | 101 | // file of the user |
102 | static const char *commonCmds[] = | 102 | static const char *commonCmds[] = |
103 | { | 103 | { |
104 | "ls ", // I left this here, cause it looks better than the first alpha | 104 | "ls ", // I left this here, cause it looks better than the first alpha |
105 | "cardctl eject", | 105 | "cardctl eject", |
106 | "cat ", | 106 | "cat ", |
107 | "cd ", | 107 | "cd ", |
108 | "chmod ", | 108 | "chmod ", |
109 | "clear", | 109 | "clear", |
110 | "cp ", | 110 | "cp ", |
111 | "dc ", | 111 | "dc ", |
112 | "df ", | 112 | "df ", |
113 | "dmesg", | 113 | "dmesg", |
114 | "echo ", | 114 | "echo ", |
115 | "env", | 115 | "env", |
116 | "find ", | 116 | "find ", |
117 | "free", | 117 | "free", |
118 | "grep ", | 118 | "grep ", |
119 | "ifconfig ", | 119 | "ifconfig ", |
120 | "ipkg ", | 120 | "ipkg ", |
121 | "mkdir ", | 121 | "mkdir ", |
122 | "mv ", | 122 | "mv ", |
123 | "nc localhost 7776", | 123 | "nc localhost 7776", |
124 | "nc localhost 7777", | 124 | "nc localhost 7777", |
125 | "netstat ", | ||
125 | "nslookup ", | 126 | "nslookup ", |
126 | "ping ", | 127 | "ping ", |
127 | "ps aux", | 128 | "ps aux", |
128 | "pwd ", | 129 | "pwd ", |
129 | "rm ", | 130 | "rm ", |
130 | "rmdir ", | 131 | "rmdir ", |
131 | "route ", | 132 | "route ", |
132 | "set ", | 133 | "set ", |
133 | "traceroute", | 134 | "traceroute", |
134 | 135 | ||
135 | /* | 136 | /* |
136 | "gzip", | 137 | "gzip", |
137 | "gunzip", | 138 | "gunzip", |
138 | "chgrp", | 139 | "chgrp", |
139 | "chown", | 140 | "chown", |
140 | "date", | 141 | "date", |
141 | "dd", | 142 | "dd", |
142 | "df", | 143 | "df", |
143 | "dmesg", | 144 | "dmesg", |
144 | "fuser", | 145 | "fuser", |
145 | "hostname", | 146 | "hostname", |
146 | "kill", | 147 | "kill", |
147 | "killall", | 148 | "killall", |
148 | "ln", | 149 | "ln", |
149 | "ping", | 150 | "ping", |
150 | "mount", | 151 | "mount", |
151 | "more", | 152 | "more", |
152 | "sort", | 153 | "sort", |
153 | "touch", | 154 | "touch", |
154 | "umount", | 155 | "umount", |
155 | "mknod", | 156 | "mknod", |
156 | "netstat", | 157 | "netstat", |
157 | */ | 158 | */ |
158 | 159 | ||
159 | "exit", | 160 | "exit", |
160 | NULL | 161 | NULL |
161 | }; | 162 | }; |
162 | 163 | ||
163 | 164 | ||
164 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 165 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
165 | QMainWindow(parent, name, fl) | 166 | QMainWindow(parent, name, fl) |
166 | { | 167 | { |
167 | QStrList args; | 168 | QStrList args; |
168 | init("/bin/sh",args); | 169 | init("/bin/sh",args); |
169 | } | 170 | } |
170 | 171 | ||
171 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 172 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
172 | : QMainWindow(0, name) | 173 | : QMainWindow(0, name) |
173 | { | 174 | { |
174 | init(_pgm,_args); | 175 | init(_pgm,_args); |
175 | } | 176 | } |
176 | 177 | ||
177 | void Konsole::init(const char* _pgm, QStrList & _args) | 178 | void Konsole::init(const char* _pgm, QStrList & _args) |
178 | { | 179 | { |
179 | b_scroll = TRUE; // histon; | 180 | b_scroll = TRUE; // histon; |
180 | n_keytab = 0; | 181 | n_keytab = 0; |
181 | n_render = 0; | 182 | n_render = 0; |
182 | 183 | ||
183 | setCaption( tr("Terminal") ); | 184 | setCaption( tr("Terminal") ); |
184 | setIcon( Resource::loadPixmap( "konsole" ) ); | 185 | setIcon( Resource::loadPixmap( "konsole" ) ); |
185 | 186 | ||
186 | Config cfg("Konsole"); | 187 | Config cfg("Konsole"); |
187 | cfg.setGroup("Konsole"); | 188 | cfg.setGroup("Konsole"); |
188 | QString tmp; | 189 | QString tmp; |
189 | // initialize the list of allowed fonts /////////////////////////////////// | 190 | // initialize the list of allowed fonts /////////////////////////////////// |
190 | cfont = cfg.readNumEntry("FontID", 1); | 191 | cfont = cfg.readNumEntry("FontID", 1); |
191 | QFont f = QFont("Micro", 4, QFont::Normal); | 192 | QFont f = QFont("Micro", 4, QFont::Normal); |
192 | f.setFixedPitch(TRUE); | 193 | f.setFixedPitch(TRUE); |
193 | fonts.append(new VTFont(tr("Micro"), f)); | 194 | fonts.append(new VTFont(tr("Micro"), f)); |
194 | 195 | ||
195 | f = QFont("Fixed", 7, QFont::Normal); | 196 | f = QFont("Fixed", 7, QFont::Normal); |
196 | f.setFixedPitch(TRUE); | 197 | f.setFixedPitch(TRUE); |
197 | fonts.append(new VTFont(tr("Small Fixed"), f)); | 198 | fonts.append(new VTFont(tr("Small Fixed"), f)); |
198 | 199 | ||
199 | f = QFont("Fixed", 12, QFont::Normal); | 200 | f = QFont("Fixed", 12, QFont::Normal); |
200 | f.setFixedPitch(TRUE); | 201 | f.setFixedPitch(TRUE); |
201 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | 202 | fonts.append(new VTFont(tr("Medium Fixed"), f)); |
202 | 203 | ||
203 | // create terminal emulation framework //////////////////////////////////// | 204 | // create terminal emulation framework //////////////////////////////////// |
204 | nsessions = 0; | 205 | nsessions = 0; |
205 | 206 | ||
206 | tab = new EKNumTabWidget(this); | 207 | tab = new EKNumTabWidget(this); |
207 | 208 | ||
208 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 209 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
209 | 210 | ||
210 | // create terminal toolbar //////////////////////////////////////////////// | 211 | // create terminal toolbar //////////////////////////////////////////////// |
211 | setToolBarsMovable( FALSE ); | 212 | setToolBarsMovable( FALSE ); |
212 | QPEToolBar *menuToolBar = new QPEToolBar( this ); | 213 | QPEToolBar *menuToolBar = new QPEToolBar( this ); |
213 | menuToolBar->setHorizontalStretchable( TRUE ); | 214 | menuToolBar->setHorizontalStretchable( TRUE ); |
214 | 215 | ||
215 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); | 216 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); |
216 | 217 | ||
217 | fontList = new QPopupMenu( this ); | 218 | fontList = new QPopupMenu( this ); |
218 | for(uint i = 0; i < fonts.count(); i++) { | 219 | for(uint i = 0; i < fonts.count(); i++) { |
219 | VTFont *fnt = fonts.at(i); | 220 | VTFont *fnt = fonts.at(i); |
220 | fontList->insertItem(fnt->getName(), i); | 221 | fontList->insertItem(fnt->getName(), i); |
221 | } | 222 | } |
222 | fontChanged(cfont); | 223 | fontChanged(cfont); |
223 | 224 | ||
224 | configMenu = new QPopupMenu( this); | 225 | configMenu = new QPopupMenu( this); |
225 | colorMenu = new QPopupMenu( this); | 226 | colorMenu = new QPopupMenu( this); |
226 | 227 | ||
227 | bool listHidden; | 228 | bool listHidden; |
228 | cfg.setGroup("Menubar"); | 229 | cfg.setGroup("Menubar"); |
229 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 230 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
230 | configMenu->insertItem("Show command list"); | 231 | configMenu->insertItem("Show command list"); |
231 | listHidden=TRUE; | 232 | listHidden=TRUE; |
232 | } else { | 233 | } else { |
233 | configMenu->insertItem("Hide command list"); | 234 | configMenu->insertItem("Hide command list"); |
234 | listHidden=FALSE; | 235 | listHidden=FALSE; |
235 | } | 236 | } |
236 | 237 | ||
237 | cfg.setGroup("Tabs"); | 238 | cfg.setGroup("Tabs"); |
238 | tmp=cfg.readEntry("Position","Bottom"); | 239 | tmp=cfg.readEntry("Position","Bottom"); |
239 | if(tmp=="Top") { | 240 | if(tmp=="Top") { |
240 | tab->setTabPosition(QTabWidget::Top); | 241 | tab->setTabPosition(QTabWidget::Top); |
241 | configMenu->insertItem("Tabs on Bottom"); | 242 | configMenu->insertItem("Tabs on Bottom"); |
242 | } else { | 243 | } else { |
243 | tab->setTabPosition(QTabWidget::Bottom); | 244 | tab->setTabPosition(QTabWidget::Bottom); |
244 | configMenu->insertItem("Tabs on Top"); | 245 | configMenu->insertItem("Tabs on Top"); |
245 | } | 246 | } |
246 | configMenu->insertSeparator(2); | 247 | configMenu->insertSeparator(2); |
247 | 248 | ||
248 | colorMenu->insertItem("Green on Black"); | 249 | colorMenu->insertItem("Green on Black"); |
249 | colorMenu->insertItem("Black on White"); | 250 | colorMenu->insertItem("Black on White"); |
250 | colorMenu->insertItem("White on Black"); | 251 | colorMenu->insertItem("White on Black"); |
251 | colorMenu->insertItem("Black on Transparent"); | 252 | colorMenu->insertItem("Black on Transparent"); |
252 | colorMenu->insertItem("Black on Red"); | 253 | colorMenu->insertItem("Black on Red"); |
253 | colorMenu->insertItem("Red on Black"); | 254 | colorMenu->insertItem("Red on Black"); |
254 | colorMenu->insertItem("Green on Yellow"); | 255 | colorMenu->insertItem("Green on Yellow"); |
255 | colorMenu->insertItem("Blue on Magenta"); | 256 | colorMenu->insertItem("Blue on Magenta"); |
256 | colorMenu->insertItem("Magenta on Blue"); | 257 | colorMenu->insertItem("Magenta on Blue"); |
257 | colorMenu->insertItem("Cyan on White"); | 258 | colorMenu->insertItem("Cyan on White"); |
258 | colorMenu->insertItem("White on Cyan"); | 259 | colorMenu->insertItem("White on Cyan"); |
259 | colorMenu->insertItem("Blue on Black"); | 260 | colorMenu->insertItem("Blue on Black"); |
260 | configMenu->insertItem("Colors",colorMenu); | 261 | configMenu->insertItem("Colors",colorMenu); |
261 | 262 | ||
262 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 263 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
263 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 264 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
264 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); | 265 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuSelected(int) )); |
265 | 266 | ||
266 | menuBar->insertItem( tr("Font"), fontList ); | 267 | menuBar->insertItem( tr("Font"), fontList ); |
267 | menuBar->insertItem( tr("Options"), configMenu ); | 268 | menuBar->insertItem( tr("Options"), configMenu ); |
268 | 269 | ||
269 | QPEToolBar *toolbar = new QPEToolBar( this ); | 270 | QPEToolBar *toolbar = new QPEToolBar( this ); |
270 | 271 | ||
271 | QAction *a; | 272 | QAction *a; |
272 | 273 | ||
273 | // Button Commands | 274 | // Button Commands |
274 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 275 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
275 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 276 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
276 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 277 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
277 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 278 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
278 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 279 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
279 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 280 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
280 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 281 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
281 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 282 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
282 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 283 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
283 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 284 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
284 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 285 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
285 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 286 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
286 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 287 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
287 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 288 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
288 | /* | 289 | /* |
289 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 290 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
290 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 291 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
291 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 292 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
292 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 293 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
293 | */ | 294 | */ |
294 | 295 | ||
295 | secondToolBar = new QPEToolBar( this ); | 296 | secondToolBar = new QPEToolBar( this ); |
296 | secondToolBar->setHorizontalStretchable( TRUE ); | 297 | secondToolBar->setHorizontalStretchable( TRUE ); |
297 | 298 | ||
298 | commonCombo = new QComboBox( secondToolBar ); | 299 | commonCombo = new QComboBox( secondToolBar ); |
299 | commonCombo->setMaximumWidth(236); | 300 | commonCombo->setMaximumWidth(236); |
300 | configMenu->insertItem( "Edit Command List"); | 301 | configMenu->insertItem( "Edit Command List"); |
301 | if( listHidden) { | 302 | if( listHidden) { |
302 | secondToolBar->hide(); | 303 | secondToolBar->hide(); |
303 | configMenu->setItemEnabled(-20 ,FALSE); | 304 | configMenu->setItemEnabled(-20 ,FALSE); |
304 | } | 305 | } |
305 | 306 | ||
306 | cfg.setGroup("Commands"); | 307 | cfg.setGroup("Commands"); |
307 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 308 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
308 | 309 | ||
309 | for (int i = 0; commonCmds[i] != NULL; i++) { | 310 | for (int i = 0; commonCmds[i] != NULL; i++) { |
310 | commonCombo->insertItem( commonCmds[i], i ); | 311 | commonCombo->insertItem( commonCmds[i], i ); |
311 | tmp = cfg.readEntry( QString::number(i),""); | 312 | tmp = cfg.readEntry( QString::number(i),""); |
312 | if(tmp != "") | 313 | if(tmp != "") |
313 | commonCombo->changeItem( tmp,i ); | 314 | commonCombo->changeItem( tmp,i ); |
314 | } | 315 | } |
315 | 316 | ||
316 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 317 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
317 | 318 | ||
318 | // create applications ///////////////////////////////////////////////////// | 319 | // create applications ///////////////////////////////////////////////////// |
319 | setCentralWidget(tab); | 320 | setCentralWidget(tab); |
320 | 321 | ||
321 | // load keymaps //////////////////////////////////////////////////////////// | 322 | // load keymaps //////////////////////////////////////////////////////////// |
322 | KeyTrans::loadAll(); | 323 | KeyTrans::loadAll(); |
323 | for (int i = 0; i < KeyTrans::count(); i++) | 324 | for (int i = 0; i < KeyTrans::count(); i++) |
324 | { KeyTrans* s = KeyTrans::find(i); | 325 | { KeyTrans* s = KeyTrans::find(i); |
325 | assert( s ); | 326 | assert( s ); |
326 | } | 327 | } |
327 | 328 | ||
328 | se_pgm = _pgm; | 329 | se_pgm = _pgm; |
329 | se_args = _args; | 330 | se_args = _args; |
330 | 331 | ||
331 | // read and apply default values /////////////////////////////////////////// | 332 | // read and apply default values /////////////////////////////////////////// |
332 | resize(321, 321); // Dummy. | 333 | resize(321, 321); // Dummy. |
333 | QSize currentSize = size(); | 334 | QSize currentSize = size(); |
334 | if (currentSize != size()) | 335 | if (currentSize != size()) |
335 | defaultSize = size(); | 336 | defaultSize = size(); |
336 | 337 | ||
337 | } | 338 | } |
338 | 339 | ||
339 | void Konsole::show() | 340 | void Konsole::show() |
340 | { | 341 | { |
341 | if ( !nsessions ) { | 342 | if ( !nsessions ) { |
342 | newSession(); | 343 | newSession(); |
343 | } | 344 | } |
344 | QMainWindow::show(); | 345 | QMainWindow::show(); |
345 | } | 346 | } |
346 | 347 | ||
347 | void Konsole::initSession(const char*, QStrList &) | 348 | void Konsole::initSession(const char*, QStrList &) |
348 | { | 349 | { |
349 | QMainWindow::show(); | 350 | QMainWindow::show(); |
350 | } | 351 | } |
351 | 352 | ||
352 | Konsole::~Konsole() | 353 | Konsole::~Konsole() |
353 | { | 354 | { |
354 | while (nsessions > 0) { | 355 | while (nsessions > 0) { |
355 | doneSession(getTe()->currentSession, 0); | 356 | doneSession(getTe()->currentSession, 0); |
356 | } | 357 | } |
357 | 358 | ||
358 | Config cfg("Konsole"); | 359 | Config cfg("Konsole"); |
359 | cfg.setGroup("Konsole"); | 360 | cfg.setGroup("Konsole"); |
360 | cfg.writeEntry("FontID", cfont); | 361 | cfg.writeEntry("FontID", cfont); |
361 | } | 362 | } |
362 | 363 | ||
363 | void Konsole::fontChanged(int f) | 364 | void Konsole::fontChanged(int f) |
364 | { | 365 | { |
365 | VTFont* font = fonts.at(f); | 366 | VTFont* font = fonts.at(f); |
366 | if (font != 0) { | 367 | if (font != 0) { |
367 | for(uint i = 0; i < fonts.count(); i++) { | 368 | for(uint i = 0; i < fonts.count(); i++) { |
368 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 369 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
369 | } | 370 | } |
370 | 371 | ||
371 | cfont = f; | 372 | cfont = f; |
372 | 373 | ||
373 | TEWidget* te = getTe(); | 374 | TEWidget* te = getTe(); |
374 | if (te != 0) { | 375 | if (te != 0) { |
375 | te->setVTFont(font->getFont()); | 376 | te->setVTFont(font->getFont()); |
376 | } | 377 | } |
377 | } | 378 | } |
378 | } | 379 | } |
379 | 380 | ||
380 | 381 | ||
381 | void Konsole::enterCommand(int c) | 382 | void Konsole::enterCommand(int c) |
382 | { | 383 | { |
383 | TEWidget* te = getTe(); | 384 | TEWidget* te = getTe(); |
384 | if (te != 0) { | 385 | if (te != 0) { |
385 | if(!commonCombo->editable()) { | 386 | if(!commonCombo->editable()) { |
386 | QString text = commonCombo->text(c); //commonCmds[c]; | 387 | QString text = commonCombo->text(c); //commonCmds[c]; |
387 | te->emitText(text); | 388 | te->emitText(text); |
388 | } else { | 389 | } else { |
389 | changeCommand( commonCombo->text(c), c); | 390 | changeCommand( commonCombo->text(c), c); |
390 | } | 391 | } |
391 | } | 392 | } |
392 | } | 393 | } |
393 | 394 | ||
394 | void Konsole::hitEnter() | 395 | void Konsole::hitEnter() |
395 | { | 396 | { |
396 | TEWidget* te = getTe(); | 397 | TEWidget* te = getTe(); |
397 | if (te != 0) { | 398 | if (te != 0) { |
398 | te->emitText(QString("\r")); | 399 | te->emitText(QString("\r")); |
399 | } | 400 | } |
400 | } | 401 | } |
401 | 402 | ||
402 | void Konsole::hitSpace() | 403 | void Konsole::hitSpace() |
403 | { | 404 | { |
404 | TEWidget* te = getTe(); | 405 | TEWidget* te = getTe(); |
405 | if (te != 0) { | 406 | if (te != 0) { |
406 | te->emitText(QString(" ")); | 407 | te->emitText(QString(" ")); |
407 | } | 408 | } |
408 | } | 409 | } |
409 | 410 | ||
410 | void Konsole::hitTab() | 411 | void Konsole::hitTab() |
411 | { | 412 | { |
412 | TEWidget* te = getTe(); | 413 | TEWidget* te = getTe(); |
413 | if (te != 0) { | 414 | if (te != 0) { |
414 | te->emitText(QString("\t")); | 415 | te->emitText(QString("\t")); |
415 | } | 416 | } |
416 | } | 417 | } |
417 | 418 | ||
418 | void Konsole::hitPaste() | 419 | void Konsole::hitPaste() |
419 | { | 420 | { |
420 | TEWidget* te = getTe(); | 421 | TEWidget* te = getTe(); |
421 | if (te != 0) { | 422 | if (te != 0) { |
422 | te->pasteClipboard(); | 423 | te->pasteClipboard(); |
423 | } | 424 | } |
424 | } | 425 | } |
425 | 426 | ||
426 | void Konsole::hitUp() | 427 | void Konsole::hitUp() |
427 | { | 428 | { |
428 | TEWidget* te = getTe(); | 429 | TEWidget* te = getTe(); |
429 | if (te != 0) { | 430 | if (te != 0) { |
430 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 431 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
431 | QApplication::sendEvent( te, &ke ); | 432 | QApplication::sendEvent( te, &ke ); |
432 | } | 433 | } |
433 | } | 434 | } |
434 | 435 | ||
435 | void Konsole::hitDown() | 436 | void Konsole::hitDown() |
436 | { | 437 | { |
437 | TEWidget* te = getTe(); | 438 | TEWidget* te = getTe(); |
438 | if (te != 0) { | 439 | if (te != 0) { |
439 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 440 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
440 | QApplication::sendEvent( te, &ke ); | 441 | QApplication::sendEvent( te, &ke ); |
441 | } | 442 | } |
442 | } | 443 | } |
443 | 444 | ||
444 | /** | 445 | /** |
445 | This function calculates the size of the external widget | 446 | This function calculates the size of the external widget |
446 | needed for the internal widget to be | 447 | needed for the internal widget to be |
447 | */ | 448 | */ |
448 | QSize Konsole::calcSize(int columns, int lines) { | 449 | QSize Konsole::calcSize(int columns, int lines) { |
449 | TEWidget* te = getTe(); | 450 | TEWidget* te = getTe(); |
450 | if (te != 0) { | 451 | if (te != 0) { |
451 | QSize size = te->calcSize(columns, lines); | 452 | QSize size = te->calcSize(columns, lines); |
452 | return size; | 453 | return size; |
453 | } else { | 454 | } else { |
454 | QSize size; | 455 | QSize size; |
455 | return size; | 456 | return size; |
456 | } | 457 | } |
457 | } | 458 | } |
458 | 459 | ||
459 | /** | 460 | /** |
460 | sets application window to a size based on columns X lines of the te | 461 | sets application window to a size based on columns X lines of the te |
461 | guest widget. Call with (0,0) for setting default size. | 462 | guest widget. Call with (0,0) for setting default size. |
462 | */ | 463 | */ |
463 | 464 | ||
464 | void Konsole::setColLin(int columns, int lines) | 465 | void Konsole::setColLin(int columns, int lines) |
465 | { | 466 | { |
466 | if ((columns==0) || (lines==0)) | 467 | if ((columns==0) || (lines==0)) |
467 | { | 468 | { |
468 | if (defaultSize.isEmpty()) // not in config file : set default value | 469 | if (defaultSize.isEmpty()) // not in config file : set default value |
469 | { | 470 | { |
470 | defaultSize = calcSize(80,24); | 471 | defaultSize = calcSize(80,24); |
471 | // notifySize(24,80); // set menu items (strange arg order !) | 472 | // notifySize(24,80); // set menu items (strange arg order !) |
472 | } | 473 | } |
473 | resize(defaultSize); | 474 | resize(defaultSize); |
474 | } else { | 475 | } else { |
475 | resize(calcSize(columns, lines)); | 476 | resize(calcSize(columns, lines)); |
476 | // notifySize(lines,columns); // set menu items (strange arg order !) | 477 | // notifySize(lines,columns); // set menu items (strange arg order !) |
477 | } | 478 | } |
478 | } | 479 | } |
479 | 480 | ||
480 | /* | 481 | /* |
481 | void Konsole::setFont(int fontno) | 482 | void Konsole::setFont(int fontno) |
482 | { | 483 | { |
483 | QFont f; | 484 | QFont f; |
484 | if (fontno == 0) | 485 | if (fontno == 0) |
485 | f = defaultFont = QFont( "Helvetica", 12 ); | 486 | f = defaultFont = QFont( "Helvetica", 12 ); |
486 | else | 487 | else |
487 | if (fonts[fontno][0] == '-') | 488 | if (fonts[fontno][0] == '-') |
488 | f.setRawName( fonts[fontno] ); | 489 | f.setRawName( fonts[fontno] ); |
489 | else | 490 | else |
490 | { | 491 | { |
491 | f.setFamily(fonts[fontno]); | 492 | f.setFamily(fonts[fontno]); |
492 | f.setRawMode( TRUE ); | 493 | f.setRawMode( TRUE ); |
493 | } | 494 | } |
494 | if ( !f.exactMatch() && fontno != 0) | 495 | if ( !f.exactMatch() && fontno != 0) |
495 | { | 496 | { |
496 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 497 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
497 | QMessageBox(this, msg); | 498 | QMessageBox(this, msg); |
498 | return; | 499 | return; |
499 | } | 500 | } |
500 | if (se) se->setFontNo(fontno); | 501 | if (se) se->setFontNo(fontno); |
501 | te->setVTFont(f); | 502 | te->setVTFont(f); |
502 | n_font = fontno; | 503 | n_font = fontno; |
503 | } | 504 | } |
504 | */ | 505 | */ |
505 | 506 | ||
506 | // --| color selection |------------------------------------------------------- | 507 | // --| color selection |------------------------------------------------------- |
507 | 508 | ||
508 | void Konsole::changeColumns(int columns) | 509 | void Konsole::changeColumns(int columns) |
509 | { | 510 | { |
510 | TEWidget* te = getTe(); | 511 | TEWidget* te = getTe(); |
511 | if (te != 0) { | 512 | if (te != 0) { |
512 | setColLin(columns,te->Lines()); | 513 | setColLin(columns,te->Lines()); |
513 | te->update(); | 514 | te->update(); |
514 | } | 515 | } |
515 | } | 516 | } |
516 | 517 | ||
517 | //FIXME: If a child dies during session swap, | 518 | //FIXME: If a child dies during session swap, |
518 | // this routine might be called before | 519 | // this routine might be called before |
519 | // session swap is completed. | 520 | // session swap is completed. |
520 | 521 | ||
521 | void Konsole::doneSession(TESession*, int ) | 522 | void Konsole::doneSession(TESession*, int ) |
522 | { | 523 | { |
523 | TEWidget *te = getTe(); | 524 | TEWidget *te = getTe(); |
524 | if (te != 0) { | 525 | if (te != 0) { |
525 | te->currentSession->setConnect(FALSE); | 526 | te->currentSession->setConnect(FALSE); |
526 | tab->removeTab(te); | 527 | tab->removeTab(te); |
527 | delete te->currentSession; | 528 | delete te->currentSession; |
528 | delete te; | 529 | delete te; |
529 | nsessions--; | 530 | nsessions--; |
530 | } | 531 | } |
531 | 532 | ||
532 | if (nsessions == 0) { | 533 | if (nsessions == 0) { |
533 | close(); | 534 | close(); |
534 | } | 535 | } |
535 | } | 536 | } |
536 | 537 | ||
537 | void Konsole::newSession() { | 538 | void Konsole::newSession() { |
538 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 539 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
539 | TEWidget* te = new TEWidget(tab); | 540 | TEWidget* te = new TEWidget(tab); |
540 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 541 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
541 | te->setVTFont(fonts.at(cfont)->getFont()); | 542 | te->setVTFont(fonts.at(cfont)->getFont()); |
542 | tab->addTab(te); | 543 | tab->addTab(te); |
543 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 544 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
544 | te->currentSession = se; | 545 | te->currentSession = se; |
545 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); | 546 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); |
546 | se->run(); | 547 | se->run(); |
547 | se->setConnect(TRUE); | 548 | se->setConnect(TRUE); |
548 | se->setHistory(b_scroll); | 549 | se->setHistory(b_scroll); |
549 | tab->setCurrentPage(nsessions); | 550 | tab->setCurrentPage(nsessions); |
550 | nsessions++; | 551 | nsessions++; |
551 | setColor(); | 552 | setColor(); |
552 | } | 553 | } |
553 | } | 554 | } |
554 | 555 | ||
555 | TEWidget* Konsole::getTe() { | 556 | TEWidget* Konsole::getTe() { |
556 | if (nsessions) { | 557 | if (nsessions) { |
557 | return (TEWidget *) tab->currentPage(); | 558 | return (TEWidget *) tab->currentPage(); |
558 | } else { | 559 | } else { |
559 | return 0; | 560 | return 0; |
560 | } | 561 | } |
561 | } | 562 | } |
562 | 563 | ||
563 | void Konsole::switchSession(QWidget* w) { | 564 | void Konsole::switchSession(QWidget* w) { |
564 | TEWidget* te = (TEWidget *) w; | 565 | TEWidget* te = (TEWidget *) w; |
565 | 566 | ||
566 | QFont teFnt = te->getVTFont(); | 567 | QFont teFnt = te->getVTFont(); |
567 | for(uint i = 0; i < fonts.count(); i++) { | 568 | for(uint i = 0; i < fonts.count(); i++) { |
568 | VTFont *fnt = fonts.at(i); | 569 | VTFont *fnt = fonts.at(i); |
569 | bool cf = fnt->getFont() == teFnt; | 570 | bool cf = fnt->getFont() == teFnt; |
570 | fontList->setItemChecked(i, cf); | 571 | fontList->setItemChecked(i, cf); |
571 | if (cf) { | 572 | if (cf) { |
572 | cfont = i; | 573 | cfont = i; |
573 | } | 574 | } |
574 | } | 575 | } |
575 | } | 576 | } |
576 | 577 | ||
577 | /// ------------------------------- some new stuff by L.J. Potter | 578 | /// ------------------------------- some new stuff by L.J. Potter |
578 | void Konsole::colorMenuSelected(int iD) | 579 | void Konsole::colorMenuSelected(int iD) |
579 | { // this is NOT pretty, elegant or anything else besides functional | 580 | { // this is NOT pretty, elegant or anything else besides functional |
580 | // QString temp; | 581 | // QString temp; |
581 | // qDebug( temp.sprintf("%d", iD)); | 582 | // qDebug( temp.sprintf("%d", iD)); |
582 | TEWidget* te = getTe(); | 583 | TEWidget* te = getTe(); |
583 | Config cfg("Konsole"); | 584 | Config cfg("Konsole"); |
584 | cfg.setGroup("Colors"); | 585 | cfg.setGroup("Colors"); |
585 | QColor foreground; | 586 | QColor foreground; |
586 | QColor background; | 587 | QColor background; |
587 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | 588 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); |
588 | ColorEntry m_table[TABLE_COLORS]; | 589 | ColorEntry m_table[TABLE_COLORS]; |
589 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 590 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
590 | /////////// fore back | 591 | /////////// fore back |
591 | int i; | 592 | int i; |
592 | if(iD==-8) { // default default | 593 | if(iD==-8) { // default default |
593 | for (i = 0; i < TABLE_COLORS; i++) { | 594 | for (i = 0; i < TABLE_COLORS; i++) { |
594 | m_table[i].color = defaultCt[i].color; | 595 | m_table[i].color = defaultCt[i].color; |
595 | if(i==1 || i == 11) | 596 | if(i==1 || i == 11) |
596 | m_table[i].transparent=1; | 597 | m_table[i].transparent=1; |
597 | cfg.writeEntry("Schema","8"); | 598 | cfg.writeEntry("Schema","8"); |
598 | colorMenu->setItemChecked(-8,TRUE); | 599 | colorMenu->setItemChecked(-8,TRUE); |
599 | } | 600 | } |
600 | } else { | 601 | } else { |
601 | if(iD==-5) { // green black | 602 | if(iD==-5) { // green black |
602 | foreground.setRgb(0x18,255,0x18); | 603 | foreground.setRgb(0x18,255,0x18); |
603 | background.setRgb(0x00,0x00,0x00); | 604 | background.setRgb(0x00,0x00,0x00); |
604 | cfg.writeEntry("Schema","5"); | 605 | cfg.writeEntry("Schema","5"); |
605 | colorMenu->setItemChecked(-5,TRUE); | 606 | colorMenu->setItemChecked(-5,TRUE); |
606 | } | 607 | } |
607 | if(iD==-6) { // black white | 608 | if(iD==-6) { // black white |
608 | foreground.setRgb(0x00,0x00,0x00); | 609 | foreground.setRgb(0x00,0x00,0x00); |
609 | background.setRgb(0xFF,0xFF,0xFF); | 610 | background.setRgb(0xFF,0xFF,0xFF); |
610 | cfg.writeEntry("Schema","6"); | 611 | cfg.writeEntry("Schema","6"); |
611 | colorMenu->setItemChecked(-6,TRUE); | 612 | colorMenu->setItemChecked(-6,TRUE); |
612 | } | 613 | } |
613 | if(iD==-7) { // white black | 614 | if(iD==-7) { // white black |
614 | foreground.setRgb(0xFF,0xFF,0xFF); | 615 | foreground.setRgb(0xFF,0xFF,0xFF); |
615 | background.setRgb(0x00,0x00,0x00); | 616 | background.setRgb(0x00,0x00,0x00); |
616 | cfg.writeEntry("Schema","7"); | 617 | cfg.writeEntry("Schema","7"); |
617 | colorMenu->setItemChecked(-7,TRUE); | 618 | colorMenu->setItemChecked(-7,TRUE); |
618 | } | 619 | } |
619 | if(iD==-9) {// Black, Red | 620 | if(iD==-9) {// Black, Red |
620 | foreground.setRgb(0x00,0x00,0x00); | 621 | foreground.setRgb(0x00,0x00,0x00); |
621 | background.setRgb(0xB2,0x18,0x18); | 622 | background.setRgb(0xB2,0x18,0x18); |
622 | cfg.writeEntry("Schema","9"); | 623 | cfg.writeEntry("Schema","9"); |
623 | colorMenu->setItemChecked(-9,TRUE); | 624 | colorMenu->setItemChecked(-9,TRUE); |
624 | } | 625 | } |
625 | if(iD==-10) {// Red, Black | 626 | if(iD==-10) {// Red, Black |
626 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 | 627 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 |
627 | background.setRgb(0x00,0x00,0x00); | 628 | background.setRgb(0x00,0x00,0x00); |
628 | cfg.writeEntry("Schema","10"); | 629 | cfg.writeEntry("Schema","10"); |
629 | colorMenu->setItemChecked(-10,TRUE); | 630 | colorMenu->setItemChecked(-10,TRUE); |
630 | } | 631 | } |
631 | if(iD==-11) {// Green, Yellow - is ugly | 632 | if(iD==-11) {// Green, Yellow - is ugly |
632 | // foreground.setRgb(0x18,0xB2,0x18); | 633 | // foreground.setRgb(0x18,0xB2,0x18); |
633 | foreground.setRgb(36,139,10); | 634 | foreground.setRgb(36,139,10); |
634 | // background.setRgb(0xB2,0x68,0x18); | 635 | // background.setRgb(0xB2,0x68,0x18); |
635 | background.setRgb(255,255,0); | 636 | background.setRgb(255,255,0); |
636 | cfg.writeEntry("Schema","11"); | 637 | cfg.writeEntry("Schema","11"); |
637 | colorMenu->setItemChecked(-11,TRUE); | 638 | colorMenu->setItemChecked(-11,TRUE); |
638 | } | 639 | } |
639 | if(iD==-12) {// Blue, Magenta | 640 | if(iD==-12) {// Blue, Magenta |
640 | foreground.setRgb(0x18,0xB2,0xB2); | 641 | foreground.setRgb(0x18,0xB2,0xB2); |
641 | background.setRgb(0x18,0x18,0xB2); | 642 | background.setRgb(0x18,0x18,0xB2); |
642 | cfg.writeEntry("Schema","12"); | 643 | cfg.writeEntry("Schema","12"); |
643 | colorMenu->setItemChecked(-12,TRUE); | 644 | colorMenu->setItemChecked(-12,TRUE); |
644 | } | 645 | } |
645 | if(iD==-13) {// Magenta, Blue | 646 | if(iD==-13) {// Magenta, Blue |
646 | foreground.setRgb(0x18,0x18,0xB2); | 647 | foreground.setRgb(0x18,0x18,0xB2); |
647 | background.setRgb(0x18,0xB2,0xB2); | 648 | background.setRgb(0x18,0xB2,0xB2); |
648 | cfg.writeEntry("Schema","13"); | 649 | cfg.writeEntry("Schema","13"); |
649 | colorMenu->setItemChecked(-13,TRUE); | 650 | colorMenu->setItemChecked(-13,TRUE); |
650 | } | 651 | } |
651 | if(iD==-14) {// Cyan, White | 652 | if(iD==-14) {// Cyan, White |
652 | foreground.setRgb(0x18,0xB2,0xB2); | 653 | foreground.setRgb(0x18,0xB2,0xB2); |
653 | background.setRgb(0xFF,0xFF,0xFF); | 654 | background.setRgb(0xFF,0xFF,0xFF); |
654 | cfg.writeEntry("Schema","14"); | 655 | cfg.writeEntry("Schema","14"); |
655 | colorMenu->setItemChecked(-14,TRUE); | 656 | colorMenu->setItemChecked(-14,TRUE); |
656 | } | 657 | } |
657 | if(iD==-15) {// White, Cyan | 658 | if(iD==-15) {// White, Cyan |
658 | background.setRgb(0x18,0xB2,0xB2); | 659 | background.setRgb(0x18,0xB2,0xB2); |
659 | foreground.setRgb(0xFF,0xFF,0xFF); | 660 | foreground.setRgb(0xFF,0xFF,0xFF); |
660 | cfg.writeEntry("Schema","15"); | 661 | cfg.writeEntry("Schema","15"); |
661 | colorMenu->setItemChecked(-15,TRUE); | 662 | colorMenu->setItemChecked(-15,TRUE); |
662 | } | 663 | } |
663 | if(iD==-16) {// Black, Blue | 664 | if(iD==-16) {// Black, Blue |
664 | background.setRgb(0x00,0x00,0x00); | 665 | background.setRgb(0x00,0x00,0x00); |
665 | foreground.setRgb(0x18,0xB2,0xB2); | 666 | foreground.setRgb(0x18,0xB2,0xB2); |
666 | cfg.writeEntry("Schema","16"); | 667 | cfg.writeEntry("Schema","16"); |
667 | colorMenu->setItemChecked(-16,TRUE); | 668 | colorMenu->setItemChecked(-16,TRUE); |
668 | } | 669 | } |
669 | 670 | ||
670 | for (i = 0; i < TABLE_COLORS; i++) { | 671 | for (i = 0; i < TABLE_COLORS; i++) { |
671 | if(i==0 || i == 10) { | 672 | if(i==0 || i == 10) { |
672 | m_table[i].color = foreground; | 673 | m_table[i].color = foreground; |
673 | } | 674 | } |
674 | else if(i==1 || i == 11) { | 675 | else if(i==1 || i == 11) { |
675 | m_table[i].color = background; m_table[i].transparent=0; | 676 | m_table[i].color = background; m_table[i].transparent=0; |
676 | } | 677 | } |
677 | else | 678 | else |
678 | m_table[i].color = defaultCt[i].color; | 679 | m_table[i].color = defaultCt[i].color; |
679 | } | 680 | } |
680 | } | 681 | } |
681 | lastSelectedMenu = iD; | 682 | lastSelectedMenu = iD; |
682 | te->setColorTable(m_table); | 683 | te->setColorTable(m_table); |
683 | update(); | 684 | update(); |
684 | } | 685 | } |
685 | 686 | ||
686 | void Konsole::configMenuSelected(int iD) | 687 | void Konsole::configMenuSelected(int iD) |
687 | { | 688 | { |
688 | QString temp; | 689 | QString temp; |
689 | qDebug( temp.sprintf("%d",iD)); | 690 | qDebug( temp.sprintf("%d",iD)); |
690 | TEWidget* te = getTe(); | 691 | TEWidget* te = getTe(); |
691 | Config cfg("Konsole"); | 692 | Config cfg("Konsole"); |
692 | cfg.setGroup("Menubar"); | 693 | cfg.setGroup("Menubar"); |
693 | if( iD == -2) { | 694 | if( iD == -2) { |
694 | if(!secondToolBar->isHidden()) { | 695 | if(!secondToolBar->isHidden()) { |
695 | secondToolBar->hide(); | 696 | secondToolBar->hide(); |
696 | configMenu->changeItem( iD,"Show Command List"); | 697 | configMenu->changeItem( iD,"Show Command List"); |
697 | cfg.writeEntry("Hidden","TRUE"); | 698 | cfg.writeEntry("Hidden","TRUE"); |
698 | configMenu->setItemEnabled(-20 ,FALSE); | 699 | configMenu->setItemEnabled(-20 ,FALSE); |
699 | } else { | 700 | } else { |
700 | secondToolBar->show(); | 701 | secondToolBar->show(); |
701 | configMenu->changeItem( iD,"Hide Command List"); | 702 | configMenu->changeItem( iD,"Hide Command List"); |
702 | cfg.writeEntry("Hidden","FALSE"); | 703 | cfg.writeEntry("Hidden","FALSE"); |
703 | configMenu->setItemEnabled(-20 ,TRUE); | 704 | configMenu->setItemEnabled(-20 ,TRUE); |
704 | 705 | ||
705 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { | 706 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { |
706 | configMenu->setItemChecked(-20,TRUE); | 707 | configMenu->setItemChecked(-20,TRUE); |
707 | commonCombo->setEditable( TRUE ); | 708 | commonCombo->setEditable( TRUE ); |
708 | } else { | 709 | } else { |
709 | configMenu->setItemChecked(-20,FALSE); | 710 | configMenu->setItemChecked(-20,FALSE); |
710 | commonCombo->setEditable( FALSE ); | 711 | commonCombo->setEditable( FALSE ); |
711 | } | 712 | } |
712 | } | 713 | } |
713 | } | 714 | } |
714 | if( iD == -3) { | 715 | if( iD == -3) { |
715 | cfg.setGroup("Tabs"); | 716 | cfg.setGroup("Tabs"); |
716 | QString tmp=cfg.readEntry("Position","Top"); | 717 | QString tmp=cfg.readEntry("Position","Top"); |
717 | 718 | ||
718 | if(tmp=="Top") { | 719 | if(tmp=="Top") { |
719 | tab->setTabPosition(QTabWidget::Bottom); | 720 | tab->setTabPosition(QTabWidget::Bottom); |
720 | configMenu->changeItem( iD,"Tabs on Top"); | 721 | configMenu->changeItem( iD,"Tabs on Top"); |
721 | cfg.writeEntry("Position","Bottom"); | 722 | cfg.writeEntry("Position","Bottom"); |
722 | } else { | 723 | } else { |
723 | tab->setTabPosition(QTabWidget::Top); | 724 | tab->setTabPosition(QTabWidget::Top); |
724 | configMenu->changeItem( iD,"Tabs on Bottom"); | 725 | configMenu->changeItem( iD,"Tabs on Bottom"); |
725 | cfg.writeEntry("Position","Top"); | 726 | cfg.writeEntry("Position","Top"); |
726 | } | 727 | } |
727 | } | 728 | } |
728 | if( iD == -20) { | 729 | if( iD == -20) { |
729 | cfg.setGroup("Commands"); | 730 | cfg.setGroup("Commands"); |
730 | // qDebug("enableCommandEdit"); | 731 | // qDebug("enableCommandEdit"); |
731 | if( !configMenu->isItemChecked(iD) ) { | 732 | if( !configMenu->isItemChecked(iD) ) { |
732 | commonCombo->setEditable( TRUE ); | 733 | commonCombo->setEditable( TRUE ); |
733 | configMenu->setItemChecked(iD,TRUE); | 734 | configMenu->setItemChecked(iD,TRUE); |
734 | commonCombo->setCurrentItem(0); | 735 | commonCombo->setCurrentItem(0); |
735 | cfg.writeEntry("EditEnabled","TRUE"); | 736 | cfg.writeEntry("EditEnabled","TRUE"); |
736 | } else { | 737 | } else { |
737 | commonCombo->setEditable( FALSE ); | 738 | commonCombo->setEditable( FALSE ); |
738 | configMenu->setItemChecked(iD,FALSE); | 739 | configMenu->setItemChecked(iD,FALSE); |
739 | cfg.writeEntry("EditEnabled","FALSE"); | 740 | cfg.writeEntry("EditEnabled","FALSE"); |
740 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 741 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
741 | te->setFocus(); | 742 | te->setFocus(); |
742 | } | 743 | } |
743 | } | 744 | } |
744 | } | 745 | } |
745 | 746 | ||
746 | void Konsole::changeCommand(const QString &text, int c) | 747 | void Konsole::changeCommand(const QString &text, int c) |
747 | { | 748 | { |
748 | Config cfg("Konsole"); | 749 | Config cfg("Konsole"); |
749 | cfg.setGroup("Commands"); | 750 | cfg.setGroup("Commands"); |
750 | if(commonCmds[c] != text) { | 751 | if(commonCmds[c] != text) { |
751 | cfg.writeEntry(QString::number(c),text); | 752 | cfg.writeEntry(QString::number(c),text); |
752 | commonCombo->clearEdit(); | 753 | commonCombo->clearEdit(); |
753 | commonCombo->setCurrentItem(c); | 754 | commonCombo->setCurrentItem(c); |
754 | } | 755 | } |
755 | } | 756 | } |
756 | 757 | ||
757 | void Konsole::setColor() | 758 | void Konsole::setColor() |
758 | { | 759 | { |
759 | Config cfg("Konsole"); | 760 | Config cfg("Konsole"); |
760 | cfg.setGroup("Colors"); | 761 | cfg.setGroup("Colors"); |
761 | int scheme = cfg.readNumEntry("Schema",1); | 762 | int scheme = cfg.readNumEntry("Schema",1); |
762 | if(scheme != 1) colorMenuSelected( -scheme); | 763 | if(scheme != 1) colorMenuSelected( -scheme); |
763 | 764 | ||
764 | } | 765 | } |