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