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