-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 | |||
@@ -134,256 +134,257 @@ static const char *commonCmds[] = | |||
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) |
@@ -549,246 +550,251 @@ void Konsole::newSession() { | |||
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 | } |