-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 7 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.h | 11 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 68 |
3 files changed, 47 insertions, 39 deletions
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index 4c6ea2a..c220e11 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -239,193 +239,194 @@ static QChar identicalMap(QChar c) | |||
239 | { | 239 | { |
240 | return c; | 240 | return c; |
241 | } | 241 | } |
242 | 242 | ||
243 | void TEWidget::fontChange(const QFont &) | 243 | void TEWidget::fontChange(const QFont &) |
244 | { | 244 | { |
245 | QFontMetrics fm(font()); | 245 | QFontMetrics fm(font()); |
246 | font_h = fm.height(); | 246 | font_h = fm.height(); |
247 | font_w = fm.maxWidth(); | 247 | font_w = fm.maxWidth(); |
248 | font_a = fm.ascent(); | 248 | font_a = fm.ascent(); |
249 | //printf("font_h: %d\n",font_h); | 249 | //printf("font_h: %d\n",font_h); |
250 | //printf("font_w: %d\n",font_w); | 250 | //printf("font_w: %d\n",font_w); |
251 | //printf("font_a: %d\n",font_a); | 251 | //printf("font_a: %d\n",font_a); |
252 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 252 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
253 | //printf("rawname: %s\n",font().rawName().ascii()); | 253 | //printf("rawname: %s\n",font().rawName().ascii()); |
254 | fontMap = | 254 | fontMap = |
255 | #if QT_VERSION < 300 | 255 | #if QT_VERSION < 300 |
256 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 256 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
257 | ? vt100extended | 257 | ? vt100extended |
258 | : | 258 | : |
259 | #endif | 259 | #endif |
260 | identicalMap; | 260 | identicalMap; |
261 | propagateSize(); | 261 | propagateSize(); |
262 | update(); | 262 | update(); |
263 | } | 263 | } |
264 | 264 | ||
265 | void TEWidget::setVTFont(const QFont& f) | 265 | void TEWidget::setVTFont(const QFont& f) |
266 | { | 266 | { |
267 | QFrame::setFont(f); | 267 | QFrame::setFont(f); |
268 | } | 268 | } |
269 | 269 | ||
270 | QFont TEWidget::getVTFont() { | 270 | QFont TEWidget::getVTFont() { |
271 | return font(); | 271 | return font(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void TEWidget::setFont(const QFont &) | 274 | void TEWidget::setFont(const QFont &) |
275 | { | 275 | { |
276 | // ignore font change request if not coming from konsole itself | 276 | // ignore font change request if not coming from konsole itself |
277 | } | 277 | } |
278 | 278 | ||
279 | /* ------------------------------------------------------------------------- */ | 279 | /* ------------------------------------------------------------------------- */ |
280 | /* */ | 280 | /* */ |
281 | /* Constructor / Destructor */ | 281 | /* Constructor / Destructor */ |
282 | /* */ | 282 | /* */ |
283 | /* ------------------------------------------------------------------------- */ | 283 | /* ------------------------------------------------------------------------- */ |
284 | 284 | ||
285 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | 285 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) |
286 | { | 286 | { |
287 | #ifndef QT_NO_CLIPBOARD | 287 | #ifndef QT_NO_CLIPBOARD |
288 | cb = QApplication::clipboard(); | 288 | cb = QApplication::clipboard(); |
289 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 289 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
290 | this, SLOT(onClearSelection()) ); | 290 | this, SLOT(onClearSelection()) ); |
291 | #endif | 291 | #endif |
292 | 292 | ||
293 | scrollbar = new QScrollBar(this); | 293 | scrollbar = new QScrollBar(this); |
294 | scrollbar->setCursor( arrowCursor ); | 294 | scrollbar->setCursor( arrowCursor ); |
295 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 295 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
296 | 296 | ||
297 | hScrollbar = new QScrollBar(this); | 297 | hScrollbar = new QScrollBar(this); |
298 | hScrollbar->setCursor( arrowCursor ); | 298 | hScrollbar->setCursor( arrowCursor ); |
299 | hScrollbar->setOrientation(QScrollBar::Horizontal); | 299 | hScrollbar->setOrientation(QScrollBar::Horizontal); |
300 | hScrollbar->setMaximumHeight(16); | 300 | hScrollbar->setMaximumHeight(16); |
301 | 301 | ||
302 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); | 302 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); |
303 | 303 | ||
304 | Config cfg("Konsole"); | 304 | Config cfg("Konsole"); |
305 | cfg.setGroup("ScrollBar"); | 305 | cfg.setGroup("ScrollBar"); |
306 | switch( cfg.readNumEntry("Position",2)){ | 306 | switch( cfg.readNumEntry("Position",2)){ |
307 | case 0: | 307 | case 0: |
308 | scrollLoc = SCRNONE; | 308 | scrollLoc = SCRNONE; |
309 | break; | 309 | break; |
310 | case 1: | 310 | case 1: |
311 | scrollLoc = SCRLEFT; | 311 | scrollLoc = SCRLEFT; |
312 | break; | 312 | break; |
313 | case 2: | 313 | case 2: |
314 | scrollLoc = SCRRIGHT; | 314 | scrollLoc = SCRRIGHT; |
315 | break; | 315 | break; |
316 | }; | 316 | }; |
317 | 317 | ||
318 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 318 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
319 | 319 | ||
320 | blinkT = new QTimer(this); | 320 | blinkT = new QTimer(this); |
321 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | 321 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
322 | // blinking = FALSE; | 322 | // blinking = FALSE; |
323 | blinking = TRUE; | 323 | blinking = TRUE; |
324 | 324 | ||
325 | resizing = FALSE; | 325 | resizing = FALSE; |
326 | actSel = 0; | 326 | actSel = 0; |
327 | image = 0; | 327 | image = 0; |
328 | lines = 1; | 328 | lines = 1; |
329 | columns = 1; | 329 | columns = 1; |
330 | font_w = 1; | 330 | font_w = 1; |
331 | font_h = 1; | 331 | font_h = 1; |
332 | font_a = 1; | 332 | font_a = 1; |
333 | word_selection_mode = FALSE; | 333 | word_selection_mode = FALSE; |
334 | hposition = 0; | 334 | hposition = 0; |
335 | vcolumns = 0; | 335 | vcolumns = 0; |
336 | useBeep = true; | ||
336 | 337 | ||
337 | setMouseMarks(TRUE); | 338 | setMouseMarks(TRUE); |
338 | setVTFont( QFont("fixed") ); | 339 | setVTFont( QFont("fixed") ); |
339 | setColorTable(base_color_table); // init color table | 340 | setColorTable(base_color_table); // init color table |
340 | 341 | ||
341 | qApp->installEventFilter( this ); //FIXME: see below | 342 | qApp->installEventFilter( this ); //FIXME: see below |
342 | // KCursor::setAutoHideCursor( this, true ); | 343 | // KCursor::setAutoHideCursor( this, true ); |
343 | 344 | ||
344 | // Init DnD //////////////////////////////////////////////////////////////// | 345 | // Init DnD //////////////////////////////////////////////////////////////// |
345 | currentSession = NULL; | 346 | currentSession = NULL; |
346 | // setAcceptDrops(true); // attempt | 347 | // setAcceptDrops(true); // attempt |
347 | // m_drop = new QPopupMenu(this); | 348 | // m_drop = new QPopupMenu(this); |
348 | // m_drop->insertItem( QString("Paste"), 0); | 349 | // m_drop->insertItem( QString("Paste"), 0); |
349 | // m_drop->insertItem( QString("cd"), 1); | 350 | // m_drop->insertItem( QString("cd"), 1); |
350 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | 351 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); |
351 | 352 | ||
352 | // we need focus so that the auto-hide cursor feature works | 353 | // we need focus so that the auto-hide cursor feature works |
353 | setFocus(); | 354 | setFocus(); |
354 | setFocusPolicy( WheelFocus ); | 355 | setFocusPolicy( WheelFocus ); |
355 | } | 356 | } |
356 | 357 | ||
357 | //FIXME: make proper destructor | 358 | //FIXME: make proper destructor |
358 | // Here's a start (David) | 359 | // Here's a start (David) |
359 | TEWidget::~TEWidget() | 360 | TEWidget::~TEWidget() |
360 | { | 361 | { |
361 | qApp->removeEventFilter( this ); | 362 | qApp->removeEventFilter( this ); |
362 | if (image) free(image); | 363 | if (image) free(image); |
363 | } | 364 | } |
364 | 365 | ||
365 | /* ------------------------------------------------------------------------- */ | 366 | /* ------------------------------------------------------------------------- */ |
366 | /* */ | 367 | /* */ |
367 | /* Display Operations */ | 368 | /* Display Operations */ |
368 | /* */ | 369 | /* */ |
369 | /* ------------------------------------------------------------------------- */ | 370 | /* ------------------------------------------------------------------------- */ |
370 | 371 | ||
371 | /*! | 372 | /*! |
372 | attributed string draw primitive | 373 | attributed string draw primitive |
373 | */ | 374 | */ |
374 | 375 | ||
375 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, | 376 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, |
376 | QString& str, ca attr, BOOL pm, BOOL clear) | 377 | QString& str, ca attr, BOOL pm, BOOL clear) |
377 | { | 378 | { |
378 | if (pm && color_table[attr.b].transparent) | 379 | if (pm && color_table[attr.b].transparent) |
379 | { | 380 | { |
380 | paint.setBackgroundMode( TransparentMode ); | 381 | paint.setBackgroundMode( TransparentMode ); |
381 | if (clear) erase(rect); | 382 | if (clear) erase(rect); |
382 | } | 383 | } |
383 | else | 384 | else |
384 | { | 385 | { |
385 | if (blinking) | 386 | if (blinking) |
386 | paint.fillRect(rect, color_table[attr.b].color); | 387 | paint.fillRect(rect, color_table[attr.b].color); |
387 | else | 388 | else |
388 | { | 389 | { |
389 | paint.setBackgroundMode( OpaqueMode ); | 390 | paint.setBackgroundMode( OpaqueMode ); |
390 | paint.setBackgroundColor( color_table[attr.b].color ); | 391 | paint.setBackgroundColor( color_table[attr.b].color ); |
391 | } | 392 | } |
392 | } | 393 | } |
393 | 394 | ||
394 | if (color_table[attr.f].bold) | 395 | if (color_table[attr.f].bold) |
395 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | 396 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); |
396 | else | 397 | else |
397 | paint.setPen(color_table[attr.f].color); | 398 | paint.setPen(color_table[attr.f].color); |
398 | 399 | ||
399 | paint.drawText(rect.x(),rect.y()+font_a, str); | 400 | paint.drawText(rect.x(),rect.y()+font_a, str); |
400 | 401 | ||
401 | if (attr.r & RE_UNDERLINE) | 402 | if (attr.r & RE_UNDERLINE) |
402 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); | 403 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); |
403 | } | 404 | } |
404 | 405 | ||
405 | /*! | 406 | /*! |
406 | The image can only be set completely. | 407 | The image can only be set completely. |
407 | 408 | ||
408 | The size of the new image may or may not match the size of the widget. | 409 | The size of the new image may or may not match the size of the widget. |
409 | */ | 410 | */ |
410 | 411 | ||
411 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) | 412 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) |
412 | { int y,x,len; | 413 | { int y,x,len; |
413 | const QPixmap* pm = backgroundPixmap(); | 414 | const QPixmap* pm = backgroundPixmap(); |
414 | QPainter paint; | 415 | QPainter paint; |
415 | setUpdatesEnabled(FALSE); | 416 | setUpdatesEnabled(FALSE); |
416 | paint.begin( this ); | 417 | paint.begin( this ); |
417 | HCNT("setImage"); | 418 | HCNT("setImage"); |
418 | 419 | ||
419 | QPoint tL = contentsRect().topLeft(); | 420 | QPoint tL = contentsRect().topLeft(); |
420 | int tLx = tL.x(); | 421 | int tLx = tL.x(); |
421 | int tLy = tL.y(); | 422 | int tLy = tL.y(); |
422 | hasBlinker = FALSE; | 423 | hasBlinker = FALSE; |
423 | 424 | ||
424 | int cf = -1; // undefined | 425 | int cf = -1; // undefined |
425 | int cb = -1; // undefined | 426 | int cb = -1; // undefined |
426 | int cr = -1; // undefined | 427 | int cr = -1; // undefined |
427 | 428 | ||
428 | int lins = QMIN(this->lines, QMAX(0,lines )); | 429 | int lins = QMIN(this->lines, QMAX(0,lines )); |
429 | int cols = QMIN(this->columns,QMAX(0,columns)); | 430 | int cols = QMIN(this->columns,QMAX(0,columns)); |
430 | QChar *disstrU = new QChar[cols]; | 431 | QChar *disstrU = new QChar[cols]; |
431 | for (y = 0; y < lins; y++) { | 432 | for (y = 0; y < lins; y++) { |
@@ -1014,193 +1015,195 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1014 | } | 1015 | } |
1015 | 1016 | ||
1016 | #ifdef FAKE_CTRL_AND_ALT | 1017 | #ifdef FAKE_CTRL_AND_ALT |
1017 | static bool control = FALSE; | 1018 | static bool control = FALSE; |
1018 | static bool alt = FALSE; | 1019 | static bool alt = FALSE; |
1019 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 1020 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
1020 | bool dele=FALSE; | 1021 | bool dele=FALSE; |
1021 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1022 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1022 | QKeyEvent* ke = (QKeyEvent*)e; | 1023 | QKeyEvent* ke = (QKeyEvent*)e; |
1023 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1024 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1024 | switch (ke->key()) { | 1025 | switch (ke->key()) { |
1025 | case Key_F9: // let this be "Control" | 1026 | case Key_F9: // let this be "Control" |
1026 | control = keydown; | 1027 | control = keydown; |
1027 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1028 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1028 | dele=TRUE; | 1029 | dele=TRUE; |
1029 | break; | 1030 | break; |
1030 | case Key_F13: // let this be "Alt" | 1031 | case Key_F13: // let this be "Alt" |
1031 | alt = keydown; | 1032 | alt = keydown; |
1032 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1033 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1033 | dele=TRUE; | 1034 | dele=TRUE; |
1034 | break; | 1035 | break; |
1035 | default: | 1036 | default: |
1036 | if ( control ) { | 1037 | if ( control ) { |
1037 | int a = toupper(ke->ascii())-64; | 1038 | int a = toupper(ke->ascii())-64; |
1038 | if ( a >= 0 && a < ' ' ) { | 1039 | if ( a >= 0 && a < ' ' ) { |
1039 | e = new QKeyEvent(e->type(), ke->key(), | 1040 | e = new QKeyEvent(e->type(), ke->key(), |
1040 | a, ke->state()|ControlButton, QChar(a,0)); | 1041 | a, ke->state()|ControlButton, QChar(a,0)); |
1041 | dele=TRUE; | 1042 | dele=TRUE; |
1042 | } | 1043 | } |
1043 | } | 1044 | } |
1044 | if ( alt ) { | 1045 | if ( alt ) { |
1045 | e = new QKeyEvent(e->type(), ke->key(), | 1046 | e = new QKeyEvent(e->type(), ke->key(), |
1046 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1047 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1047 | dele=TRUE; | 1048 | dele=TRUE; |
1048 | } | 1049 | } |
1049 | } | 1050 | } |
1050 | } | 1051 | } |
1051 | #endif | 1052 | #endif |
1052 | 1053 | ||
1053 | if ( e->type() == QEvent::KeyPress ) { | 1054 | if ( e->type() == QEvent::KeyPress ) { |
1054 | QKeyEvent* ke = (QKeyEvent*)e; | 1055 | QKeyEvent* ke = (QKeyEvent*)e; |
1055 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1056 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1056 | // know where the current selection is. | 1057 | // know where the current selection is. |
1057 | 1058 | ||
1058 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); | 1059 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); |
1059 | 1060 | ||
1060 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { | 1061 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { |
1061 | //lets hardcode this sucker | 1062 | //lets hardcode this sucker |
1062 | 1063 | ||
1063 | // qDebug("key pressed 2 is 0x%x", ke->key()); | 1064 | // qDebug("key pressed 2 is 0x%x", ke->key()); |
1064 | emitText("\\"); // expose | 1065 | emitText("\\"); // expose |
1065 | } | 1066 | } |
1066 | else if( ke->state() == ControlButton && ke->key() == Key_V) { | 1067 | else if( ke->state() == ControlButton && ke->key() == Key_V) { |
1067 | pasteClipboard(); | 1068 | pasteClipboard(); |
1068 | } | 1069 | } |
1069 | else | 1070 | else |
1070 | emit keyPressedSignal(ke); // expose | 1071 | emit keyPressedSignal(ke); // expose |
1071 | ke->accept(); | 1072 | ke->accept(); |
1072 | #ifdef FAKE_CTRL_AND_ALT | 1073 | #ifdef FAKE_CTRL_AND_ALT |
1073 | if ( dele ) delete e; | 1074 | if ( dele ) delete e; |
1074 | #endif | 1075 | #endif |
1075 | return true; // stop the event | 1076 | return true; // stop the event |
1076 | } | 1077 | } |
1077 | if ( e->type() == QEvent::Enter ) { | 1078 | if ( e->type() == QEvent::Enter ) { |
1078 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1079 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1079 | this, SLOT(onClearSelection()) ); | 1080 | this, SLOT(onClearSelection()) ); |
1080 | } | 1081 | } |
1081 | if ( e->type() == QEvent::Leave ) { | 1082 | if ( e->type() == QEvent::Leave ) { |
1082 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1083 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1083 | this, SLOT(onClearSelection()) ); | 1084 | this, SLOT(onClearSelection()) ); |
1084 | } | 1085 | } |
1085 | return QFrame::eventFilter( obj, e ); | 1086 | return QFrame::eventFilter( obj, e ); |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | /* ------------------------------------------------------------------------- */ | 1089 | /* ------------------------------------------------------------------------- */ |
1089 | /* */ | 1090 | /* */ |
1090 | /* Frame */ | 1091 | /* Frame */ |
1091 | /* */ | 1092 | /* */ |
1092 | /* ------------------------------------------------------------------------- */ | 1093 | /* ------------------------------------------------------------------------- */ |
1093 | 1094 | ||
1094 | void TEWidget::frameChanged() | 1095 | void TEWidget::frameChanged() |
1095 | { | 1096 | { |
1096 | propagateSize(); | 1097 | propagateSize(); |
1097 | update(); | 1098 | update(); |
1098 | } | 1099 | } |
1099 | 1100 | ||
1100 | /* ------------------------------------------------------------------------- */ | 1101 | /* ------------------------------------------------------------------------- */ |
1101 | /* */ | 1102 | /* */ |
1102 | /* Sound */ | 1103 | /* Sound */ |
1103 | /* */ | 1104 | /* */ |
1104 | /* ------------------------------------------------------------------------- */ | 1105 | /* ------------------------------------------------------------------------- */ |
1105 | 1106 | ||
1106 | void TEWidget::Bell() | 1107 | void TEWidget::Bell() |
1107 | { | 1108 | { |
1108 | //#ifdef QT_QWS_SHARP | 1109 | //#ifdef QT_QWS_SHARP |
1109 | //# ifndef QT_NO_COP | 1110 | //# ifndef QT_NO_COP |
1110 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); | 1111 | if(useBeep) |
1112 | QCopEnvelope( "QPE/TaskBar", "soundAlarm()" ); | ||
1113 | |||
1111 | //# endif | 1114 | //# endif |
1112 | //#else | 1115 | //#else |
1113 | //# ifndef QT_NO_SOUND | 1116 | //# ifndef QT_NO_SOUND |
1114 | // QSound::play(Resource::findSound("alarm")); | 1117 | // QSound::play(Resource::findSound("alarm")); |
1115 | //# endif | 1118 | //# endif |
1116 | //#endif | 1119 | //#endif |
1117 | 1120 | ||
1118 | // QApplication::beep(); | 1121 | // QApplication::beep(); |
1119 | } | 1122 | } |
1120 | 1123 | ||
1121 | /* ------------------------------------------------------------------------- */ | 1124 | /* ------------------------------------------------------------------------- */ |
1122 | /* */ | 1125 | /* */ |
1123 | /* Auxiluary */ | 1126 | /* Auxiluary */ |
1124 | /* */ | 1127 | /* */ |
1125 | /* ------------------------------------------------------------------------- */ | 1128 | /* ------------------------------------------------------------------------- */ |
1126 | 1129 | ||
1127 | void TEWidget::clearImage() | 1130 | void TEWidget::clearImage() |
1128 | // initialize the image | 1131 | // initialize the image |
1129 | // for internal use only | 1132 | // for internal use only |
1130 | { | 1133 | { |
1131 | for (int y = 0; y < lines; y++) | 1134 | for (int y = 0; y < lines; y++) |
1132 | for (int x = 0; x < columns; x++) | 1135 | for (int x = 0; x < columns; x++) |
1133 | { | 1136 | { |
1134 | image[loc(x,y)].c = 0xff; //' '; | 1137 | image[loc(x,y)].c = 0xff; //' '; |
1135 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1138 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1136 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1139 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1137 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1140 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1138 | } | 1141 | } |
1139 | } | 1142 | } |
1140 | 1143 | ||
1141 | // Create Image /////////////////////////////////////////////////////// | 1144 | // Create Image /////////////////////////////////////////////////////// |
1142 | 1145 | ||
1143 | void TEWidget::calcGeometry() | 1146 | void TEWidget::calcGeometry() |
1144 | { | 1147 | { |
1145 | int showhscrollbar = 1; | 1148 | int showhscrollbar = 1; |
1146 | int hwidth = 0; | 1149 | int hwidth = 0; |
1147 | int dcolumns; | 1150 | int dcolumns; |
1148 | Config cfg("Konsole"); | 1151 | Config cfg("Konsole"); |
1149 | cfg.setGroup("ScrollBar"); | 1152 | cfg.setGroup("ScrollBar"); |
1150 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 1153 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
1151 | 1154 | ||
1152 | if(vcolumns == 0) showhscrollbar = 0; | 1155 | if(vcolumns == 0) showhscrollbar = 0; |
1153 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1156 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1154 | 1157 | ||
1155 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1158 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1156 | contentsRect().height() - hwidth); | 1159 | contentsRect().height() - hwidth); |
1157 | 1160 | ||
1158 | switch(scrollLoc) { | 1161 | switch(scrollLoc) { |
1159 | case SCRNONE : | 1162 | case SCRNONE : |
1160 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1163 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1161 | dcolumns = columns; | 1164 | dcolumns = columns; |
1162 | if(vcolumns) columns = vcolumns; | 1165 | if(vcolumns) columns = vcolumns; |
1163 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1166 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1164 | if(showhscrollbar) | 1167 | if(showhscrollbar) |
1165 | blX = -hposition * font_w; | 1168 | blX = -hposition * font_w; |
1166 | brX = blX; | 1169 | brX = blX; |
1167 | scrollbar->hide(); | 1170 | scrollbar->hide(); |
1168 | break; | 1171 | break; |
1169 | case SCRLEFT : | 1172 | case SCRLEFT : |
1170 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1173 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1171 | dcolumns = columns; | 1174 | dcolumns = columns; |
1172 | if(vcolumns) columns = vcolumns; | 1175 | if(vcolumns) columns = vcolumns; |
1173 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1176 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1174 | if(showhscrollbar) | 1177 | if(showhscrollbar) |
1175 | brX = -hposition * font_w; | 1178 | brX = -hposition * font_w; |
1176 | blX = brX + scrollbar->width(); | 1179 | blX = brX + scrollbar->width(); |
1177 | scrollbar->move(contentsRect().topLeft()); | 1180 | scrollbar->move(contentsRect().topLeft()); |
1178 | scrollbar->show(); | 1181 | scrollbar->show(); |
1179 | break; | 1182 | break; |
1180 | case SCRRIGHT: | 1183 | case SCRRIGHT: |
1181 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1184 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1182 | dcolumns = columns; | 1185 | dcolumns = columns; |
1183 | if(vcolumns) columns = vcolumns; | 1186 | if(vcolumns) columns = vcolumns; |
1184 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1187 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1185 | if(showhscrollbar) | 1188 | if(showhscrollbar) |
1186 | blX = -hposition * font_w; | 1189 | blX = -hposition * font_w; |
1187 | brX = blX; | 1190 | brX = blX; |
1188 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1191 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1189 | scrollbar->show(); | 1192 | scrollbar->show(); |
1190 | break; | 1193 | break; |
1191 | } | 1194 | } |
1192 | //FIXME: support 'rounding' styles | 1195 | //FIXME: support 'rounding' styles |
1193 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1196 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1194 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1197 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1195 | 1198 | ||
1196 | if(showhscrollbar == 1) { | 1199 | if(showhscrollbar == 1) { |
1197 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); | 1200 | hScrollbar->resize(contentsRect().width() - hwidth, hwidth); |
1198 | hScrollbar->setRange(0, vcolumns - dcolumns); | 1201 | hScrollbar->setRange(0, vcolumns - dcolumns); |
1199 | 1202 | ||
1200 | QPoint p = contentsRect().bottomLeft(); | 1203 | QPoint p = contentsRect().bottomLeft(); |
1201 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); | 1204 | hScrollbar->move(QPoint(p.x(), p.y() - hwidth)); |
1202 | hScrollbar->show(); | 1205 | hScrollbar->show(); |
1203 | } | 1206 | } |
1204 | else hScrollbar->hide(); | 1207 | else hScrollbar->hide(); |
1205 | 1208 | ||
1206 | if(showhscrollbar == 1) { | 1209 | if(showhscrollbar == 1) { |
diff --git a/core/apps/embeddedkonsole/TEWidget.h b/core/apps/embeddedkonsole/TEWidget.h index a480d45..5597f27 100644 --- a/core/apps/embeddedkonsole/TEWidget.h +++ b/core/apps/embeddedkonsole/TEWidget.h | |||
@@ -1,179 +1,172 @@ | |||
1 | /* ----------------------------------------------------------------------- */ | 1 | /* ----------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [te_widget.h] Terminal Emulation Widget */ | 3 | /* [te_widget.h] Terminal Emulation Widget */ |
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 for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* ----------------------------------------------------------------------- */ | 11 | /* ----------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | #ifndef TE_WIDGET_H | 18 | #ifndef TE_WIDGET_H |
19 | #define TE_WIDGET_H | 19 | #define TE_WIDGET_H |
20 | 20 | ||
21 | #include <qwidget.h> | 21 | #include <qwidget.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qcolor.h> | 24 | #include <qcolor.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qscrollbar.h> | 26 | #include <qscrollbar.h> |
27 | 27 | ||
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | 29 | ||
30 | #include "TECommon.h" | 30 | #include "TECommon.h" |
31 | 31 | ||
32 | extern unsigned short vt100_graphics[32]; | 32 | extern unsigned short vt100_graphics[32]; |
33 | 33 | ||
34 | class TESession; | 34 | class TESession; |
35 | 35 | ||
36 | // class Konsole; | 36 | // class Konsole; |
37 | 37 | ||
38 | class TEWidget : public QFrame | 38 | class TEWidget : public QFrame |
39 | // a widget representing attributed text | 39 | // a widget representing attributed text |
40 | { Q_OBJECT | 40 | { Q_OBJECT |
41 | 41 | ||
42 | // friend class Konsole; | 42 | // friend class Konsole; |
43 | 43 | ||
44 | public: | 44 | public: |
45 | 45 | ||
46 | TEWidget(QWidget *parent=0, const char *name=0); | 46 | TEWidget(QWidget *parent=0, const char *name=0); |
47 | virtual ~TEWidget(); | 47 | virtual ~TEWidget(); |
48 | 48 | ||
49 | public: | 49 | public: |
50 | 50 | ||
51 | QColor getDefaultBackColor(); | 51 | QColor getDefaultBackColor(); |
52 | 52 | ||
53 | const ColorEntry* getColorTable() const; | 53 | const ColorEntry* getColorTable() const; |
54 | const ColorEntry* getdefaultColorTable() const; | 54 | const ColorEntry* getdefaultColorTable() const; |
55 | void setColorTable(const ColorEntry table[]); | 55 | void setColorTable(const ColorEntry table[]); |
56 | |||
57 | void setScrollbarLocation(int loc); | 56 | void setScrollbarLocation(int loc); |
58 | enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; | 57 | enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; |
59 | |||
60 | void setScroll(int cursor, int lines); | 58 | void setScroll(int cursor, int lines); |
61 | void doScroll(int lines); | 59 | void doScroll(int lines); |
62 | |||
63 | void doHScroll(int lines); | 60 | void doHScroll(int lines); |
64 | |||
65 | |||
66 | void emitSelection(); | 61 | void emitSelection(); |
67 | void setWrapAt(int columns); | 62 | void setWrapAt(int columns); |
68 | |||
69 | public: | ||
70 | 63 | ||
71 | void setImage(const ca* const newimg, int lines, int columns); | 64 | void setImage(const ca* const newimg, int lines, int columns); |
72 | 65 | ||
73 | int Lines() { return lines; } | 66 | int Lines() { return lines; } |
74 | int Columns() { return columns; } | 67 | int Columns() { return columns; } |
75 | 68 | ||
76 | void calcGeometry(); | 69 | void calcGeometry(); |
77 | void propagateSize(); | 70 | void propagateSize(); |
78 | QSize calcSize(int cols, int lins) const; | 71 | QSize calcSize(int cols, int lins) const; |
79 | 72 | ||
80 | QSize sizeHint() const; | 73 | QSize sizeHint() const; |
81 | 74 | ||
82 | public: | ||
83 | bool useHorzScroll; | 75 | bool useHorzScroll; |
76 | bool useBeep; | ||
84 | 77 | ||
85 | void Bell(); | 78 | void Bell(); |
86 | void emitText(QString text); | 79 | void emitText(QString text); |
87 | void pasteClipboard(); | 80 | void pasteClipboard(); |
88 | 81 | ||
89 | signals: | 82 | signals: |
90 | 83 | ||
91 | void keyPressedSignal(QKeyEvent *e); | 84 | void keyPressedSignal(QKeyEvent *e); |
92 | void mouseSignal(int cb, int cx, int cy); | 85 | void mouseSignal(int cb, int cx, int cy); |
93 | void changedImageSizeSignal(int lines, int columns); | 86 | void changedImageSizeSignal(int lines, int columns); |
94 | void changedHistoryCursor(int value); | 87 | void changedHistoryCursor(int value); |
95 | void changedHorzCursor(int value); | 88 | void changedHorzCursor(int value); |
96 | void configureRequest( TEWidget*, int state, int x, int y ); | 89 | void configureRequest( TEWidget*, int state, int x, int y ); |
97 | 90 | ||
98 | void clearSelectionSignal(); | 91 | void clearSelectionSignal(); |
99 | void beginSelectionSignal( const int x, const int y ); | 92 | void beginSelectionSignal( const int x, const int y ); |
100 | void extendSelectionSignal( const int x, const int y ); | 93 | void extendSelectionSignal( const int x, const int y ); |
101 | void endSelectionSignal(const BOOL preserve_line_breaks); | 94 | void endSelectionSignal(const BOOL preserve_line_breaks); |
102 | 95 | ||
103 | 96 | ||
104 | protected: | 97 | protected: |
105 | virtual void styleChange( QStyle& ); | 98 | virtual void styleChange( QStyle& ); |
106 | 99 | ||
107 | bool eventFilter( QObject *, QEvent * ); | 100 | bool eventFilter( QObject *, QEvent * ); |
108 | 101 | ||
109 | void drawAttrStr(QPainter &paint, QRect rect, | 102 | void drawAttrStr(QPainter &paint, QRect rect, |
110 | QString& str, ca attr, BOOL pm, BOOL clear); | 103 | QString& str, ca attr, BOOL pm, BOOL clear); |
111 | void paintEvent( QPaintEvent * ); | 104 | void paintEvent( QPaintEvent * ); |
112 | 105 | ||
113 | void resizeEvent(QResizeEvent*); | 106 | void resizeEvent(QResizeEvent*); |
114 | 107 | ||
115 | void fontChange(const QFont &font); | 108 | void fontChange(const QFont &font); |
116 | void frameChanged(); | 109 | void frameChanged(); |
117 | 110 | ||
118 | void mouseDoubleClickEvent(QMouseEvent* ev); | 111 | void mouseDoubleClickEvent(QMouseEvent* ev); |
119 | void mousePressEvent( QMouseEvent* ); | 112 | void mousePressEvent( QMouseEvent* ); |
120 | void mouseReleaseEvent( QMouseEvent* ); | 113 | void mouseReleaseEvent( QMouseEvent* ); |
121 | void mouseMoveEvent( QMouseEvent* ); | 114 | void mouseMoveEvent( QMouseEvent* ); |
122 | 115 | ||
123 | void focusInEvent( QFocusEvent * ); | 116 | void focusInEvent( QFocusEvent * ); |
124 | void focusOutEvent( QFocusEvent * ); | 117 | void focusOutEvent( QFocusEvent * ); |
125 | bool focusNextPrevChild( bool next ); | 118 | bool focusNextPrevChild( bool next ); |
126 | 119 | ||
127 | #ifndef QT_NO_DRAGANDDROP | 120 | #ifndef QT_NO_DRAGANDDROP |
128 | // Dnd | 121 | // Dnd |
129 | void dragEnterEvent(QDragEnterEvent* event); | 122 | void dragEnterEvent(QDragEnterEvent* event); |
130 | void dropEvent(QDropEvent* event); | 123 | void dropEvent(QDropEvent* event); |
131 | #endif | 124 | #endif |
132 | 125 | ||
133 | virtual int charClass(char) const; | 126 | virtual int charClass(char) const; |
134 | 127 | ||
135 | void clearImage(); | 128 | void clearImage(); |
136 | 129 | ||
137 | public: | 130 | public: |
138 | const QPixmap *backgroundPixmap(); | 131 | const QPixmap *backgroundPixmap(); |
139 | 132 | ||
140 | void setSelection(const QString &t); | 133 | void setSelection(const QString &t); |
141 | 134 | ||
142 | virtual void setFont(const QFont &); | 135 | virtual void setFont(const QFont &); |
143 | void setVTFont(const QFont &); | 136 | void setVTFont(const QFont &); |
144 | QFont getVTFont(); | 137 | QFont getVTFont(); |
145 | 138 | ||
146 | void setMouseMarks(bool on); | 139 | void setMouseMarks(bool on); |
147 | 140 | ||
148 | public slots: | 141 | public slots: |
149 | 142 | ||
150 | void onClearSelection(); | 143 | void onClearSelection(); |
151 | 144 | ||
152 | protected slots: | 145 | protected slots: |
153 | 146 | ||
154 | void scrollChanged(int value); | 147 | void scrollChanged(int value); |
155 | void hScrollChanged(int value); | 148 | void hScrollChanged(int value); |
156 | void blinkEvent(); | 149 | void blinkEvent(); |
157 | 150 | ||
158 | private: | 151 | private: |
159 | 152 | ||
160 | QChar (*fontMap)(QChar); // possible vt100 font extention | 153 | QChar (*fontMap)(QChar); // possible vt100 font extention |
161 | 154 | ||
162 | bool fixed_font; // has fixed pitch | 155 | bool fixed_font; // has fixed pitch |
163 | int font_h; // height | 156 | int font_h; // height |
164 | int font_w; // width | 157 | int font_w; // width |
165 | int font_a; // ascend | 158 | int font_a; // ascend |
166 | 159 | ||
167 | int blX; // actual offset (left) | 160 | int blX; // actual offset (left) |
168 | int brX; // actual offset (right) | 161 | int brX; // actual offset (right) |
169 | int bY; // actual offset | 162 | int bY; // actual offset |
170 | 163 | ||
171 | int lines; | 164 | int lines; |
172 | int columns; | 165 | int columns; |
173 | ca *image; // [lines][columns] | 166 | ca *image; // [lines][columns] |
174 | 167 | ||
175 | ColorEntry color_table[TABLE_COLORS]; | 168 | ColorEntry color_table[TABLE_COLORS]; |
176 | 169 | ||
177 | BOOL resizing; | 170 | BOOL resizing; |
178 | bool mouse_marks; | 171 | bool mouse_marks; |
179 | 172 | ||
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 5a68c81..ebff05e 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -278,192 +278,196 @@ void Konsole::init(const char* _pgm, QStrList & _args) | |||
278 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); | 278 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); |
279 | } else { | 279 | } else { |
280 | tab->setTabPosition(QTabWidget::Bottom); | 280 | tab->setTabPosition(QTabWidget::Bottom); |
281 | configMenu->insertItem("Tabs on Top"); | 281 | configMenu->insertItem("Tabs on Top"); |
282 | } | 282 | } |
283 | configMenu->insertSeparator(2); | 283 | configMenu->insertSeparator(2); |
284 | 284 | ||
285 | colorMenu->insertItem(tr( "Green on Black")); | 285 | colorMenu->insertItem(tr( "Green on Black")); |
286 | colorMenu->insertItem(tr( "Black on White")); | 286 | colorMenu->insertItem(tr( "Black on White")); |
287 | colorMenu->insertItem(tr( "White on Black")); | 287 | colorMenu->insertItem(tr( "White on Black")); |
288 | colorMenu->insertItem(tr( "Black on Transparent")); | 288 | colorMenu->insertItem(tr( "Black on Transparent")); |
289 | colorMenu->insertItem(tr( "Black on Red")); | 289 | colorMenu->insertItem(tr( "Black on Red")); |
290 | colorMenu->insertItem(tr( "Red on Black")); | 290 | colorMenu->insertItem(tr( "Red on Black")); |
291 | colorMenu->insertItem(tr( "Green on Yellow")); | 291 | colorMenu->insertItem(tr( "Green on Yellow")); |
292 | colorMenu->insertItem(tr( "Blue on Magenta")); | 292 | colorMenu->insertItem(tr( "Blue on Magenta")); |
293 | colorMenu->insertItem(tr( "Magenta on Blue")); | 293 | colorMenu->insertItem(tr( "Magenta on Blue")); |
294 | colorMenu->insertItem(tr( "Cyan on White")); | 294 | colorMenu->insertItem(tr( "Cyan on White")); |
295 | colorMenu->insertItem(tr( "White on Cyan")); | 295 | colorMenu->insertItem(tr( "White on Cyan")); |
296 | colorMenu->insertItem(tr( "Blue on Black")); | 296 | colorMenu->insertItem(tr( "Blue on Black")); |
297 | colorMenu->insertItem(tr( "Amber on Black")); | 297 | colorMenu->insertItem(tr( "Amber on Black")); |
298 | 298 | ||
299 | #ifdef QWS_QT_OPIE | 299 | #ifdef QWS_QT_OPIE |
300 | colorMenu->insertItem(tr( "Custom")); | 300 | colorMenu->insertItem(tr( "Custom")); |
301 | #endif | 301 | #endif |
302 | 302 | ||
303 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 303 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
304 | 304 | ||
305 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 305 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
306 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 306 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
307 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 307 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
308 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 308 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
309 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 309 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
310 | menuBar->insertItem( tr("Font"), fontList ); | 310 | menuBar->insertItem( tr("Font"), fontList ); |
311 | menuBar->insertItem( tr("Options"), configMenu ); | 311 | menuBar->insertItem( tr("Options"), configMenu ); |
312 | 312 | ||
313 | QPEToolBar *toolbar = new QPEToolBar( this ); | 313 | QPEToolBar *toolbar = new QPEToolBar( this ); |
314 | 314 | ||
315 | QAction *a; | 315 | QAction *a; |
316 | 316 | ||
317 | // Button Commands | 317 | // Button Commands |
318 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 318 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
319 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 319 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
320 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 320 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
321 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 321 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
322 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 322 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
323 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 323 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
324 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 324 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
325 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 325 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
326 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 326 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
328 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 328 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
330 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 330 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
331 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 331 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
332 | /* | 332 | /* |
333 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 333 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
334 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 334 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
335 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 335 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
336 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 336 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
337 | */ | 337 | */ |
338 | 338 | ||
339 | secondToolBar = new QPEToolBar( this ); | 339 | secondToolBar = new QPEToolBar( this ); |
340 | secondToolBar->setHorizontalStretchable( TRUE ); | 340 | secondToolBar->setHorizontalStretchable( TRUE ); |
341 | 341 | ||
342 | commonCombo = new QComboBox( secondToolBar ); | 342 | commonCombo = new QComboBox( secondToolBar ); |
343 | commonCombo->setMaximumWidth(236); | 343 | commonCombo->setMaximumWidth(236); |
344 | 344 | ||
345 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 345 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
346 | if( listHidden) { | 346 | if( listHidden) { |
347 | secondToolBar->hide(); | 347 | secondToolBar->hide(); |
348 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 348 | editCommandListMenu->setItemEnabled(-23 ,FALSE); |
349 | } | 349 | } |
350 | editCommandListMenu->insertItem(tr( "Edit" ) ); | 350 | editCommandListMenu->insertItem(tr( "Edit" ) ); |
351 | 351 | ||
352 | cfg.setGroup("Commands"); | 352 | cfg.setGroup("Commands"); |
353 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 353 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
354 | 354 | ||
355 | initCommandList(); | 355 | initCommandList(); |
356 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 356 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
357 | // commonCombo->insertItem( commonCmds[i], i ); | 357 | // commonCombo->insertItem( commonCmds[i], i ); |
358 | // tmp = cfg.readEntry( QString::number(i),""); | 358 | // tmp = cfg.readEntry( QString::number(i),""); |
359 | // if(tmp != "") | 359 | // if(tmp != "") |
360 | // commonCombo->changeItem( tmp,i ); | 360 | // commonCombo->changeItem( tmp,i ); |
361 | // } | 361 | // } |
362 | 362 | ||
363 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 363 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
364 | 364 | ||
365 | scrollMenu->insertItem(tr( "None" )); | 365 | scrollMenu->insertItem(tr( "None" )); |
366 | scrollMenu->insertItem(tr( "Left" )); | 366 | scrollMenu->insertItem(tr( "Left" )); |
367 | scrollMenu->insertItem(tr( "Right" )); | 367 | scrollMenu->insertItem(tr( "Right" )); |
368 | // scrollMenu->insertSeparator(4); | 368 | // scrollMenu->insertSeparator(4); |
369 | // scrollMenu->insertItem(tr( "Horizontal" )); | 369 | // scrollMenu->insertItem(tr( "Horizontal" )); |
370 | 370 | ||
371 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 371 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
372 | 372 | ||
373 | configMenu->insertItem(tr( "Wrap" )); | 373 | configMenu->insertItem(tr( "Wrap" )); |
374 | int jut = configMenu->insertItem(tr( "Use Beep" )); | ||
375 | cfg.setGroup("Menubar"); | ||
376 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | ||
377 | |||
374 | 378 | ||
375 | //scrollMenuSelected(-29); | 379 | //scrollMenuSelected(-29); |
376 | // cfg.setGroup("ScrollBar"); | 380 | // cfg.setGroup("ScrollBar"); |
377 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 381 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
378 | // if(cfg.readNumEntry("Position",2) == 0) | 382 | // if(cfg.readNumEntry("Position",2) == 0) |
379 | // te->setScrollbarLocation(1); | 383 | // te->setScrollbarLocation(1); |
380 | // else | 384 | // else |
381 | // te->setScrollbarLocation(0); | 385 | // te->setScrollbarLocation(0); |
382 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 386 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
383 | // te->setWrapAt(120); | 387 | // te->setWrapAt(120); |
384 | // } | 388 | // } |
385 | // create applications ///////////////////////////////////////////////////// | 389 | // create applications ///////////////////////////////////////////////////// |
386 | setCentralWidget(tab); | 390 | setCentralWidget(tab); |
387 | 391 | ||
388 | // load keymaps //////////////////////////////////////////////////////////// | 392 | // load keymaps //////////////////////////////////////////////////////////// |
389 | KeyTrans::loadAll(); | 393 | KeyTrans::loadAll(); |
390 | for (int i = 0; i < KeyTrans::count(); i++) | 394 | for (int i = 0; i < KeyTrans::count(); i++) |
391 | { KeyTrans* s = KeyTrans::find(i); | 395 | { KeyTrans* s = KeyTrans::find(i); |
392 | assert( s ); | 396 | assert( s ); |
393 | } | 397 | } |
394 | 398 | ||
395 | se_pgm = _pgm; | 399 | se_pgm = _pgm; |
396 | se_args = _args; | 400 | se_args = _args; |
397 | se_args.prepend("--login"); | 401 | se_args.prepend("--login"); |
398 | parseCommandLine(); | 402 | parseCommandLine(); |
399 | // read and apply default values /////////////////////////////////////////// | 403 | // read and apply default values /////////////////////////////////////////// |
400 | resize(321, 321); // Dummy. | 404 | resize(321, 321); // Dummy. |
401 | QSize currentSize = size(); | 405 | QSize currentSize = size(); |
402 | if (currentSize != size()) | 406 | if (currentSize != size()) |
403 | defaultSize = size(); | 407 | defaultSize = size(); |
404 | } | 408 | } |
405 | 409 | ||
406 | void Konsole::show() | 410 | void Konsole::show() |
407 | { | 411 | { |
408 | if ( !nsessions ) { | 412 | if ( !nsessions ) { |
409 | newSession(); | 413 | newSession(); |
410 | } | 414 | } |
411 | QMainWindow::show(); | 415 | QMainWindow::show(); |
412 | 416 | ||
413 | } | 417 | } |
414 | 418 | ||
415 | void Konsole::initSession(const char*, QStrList &) | 419 | void Konsole::initSession(const char*, QStrList &) |
416 | { | 420 | { |
417 | QMainWindow::show(); | 421 | QMainWindow::show(); |
418 | } | 422 | } |
419 | 423 | ||
420 | Konsole::~Konsole() | 424 | Konsole::~Konsole() |
421 | { | 425 | { |
422 | while (nsessions > 0) { | 426 | while (nsessions > 0) { |
423 | doneSession(getTe()->currentSession, 0); | 427 | doneSession(getTe()->currentSession, 0); |
424 | } | 428 | } |
425 | 429 | ||
426 | Config cfg("Konsole"); | 430 | Config cfg("Konsole"); |
427 | cfg.setGroup("Konsole"); | 431 | cfg.setGroup("Konsole"); |
428 | cfg.writeEntry("FontID", cfont); | 432 | cfg.writeEntry("FontID", cfont); |
429 | } | 433 | } |
430 | 434 | ||
431 | void Konsole::fontChanged(int f) | 435 | void Konsole::fontChanged(int f) |
432 | { | 436 | { |
433 | VTFont* font = fonts.at(f); | 437 | VTFont* font = fonts.at(f); |
434 | if (font != 0) { | 438 | if (font != 0) { |
435 | for(uint i = 0; i < fonts.count(); i++) { | 439 | for(uint i = 0; i < fonts.count(); i++) { |
436 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 440 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
437 | } | 441 | } |
438 | 442 | ||
439 | cfont = f; | 443 | cfont = f; |
440 | 444 | ||
441 | TEWidget* te = getTe(); | 445 | TEWidget* te = getTe(); |
442 | if (te != 0) { | 446 | if (te != 0) { |
443 | te->setVTFont(font->getFont()); | 447 | te->setVTFont(font->getFont()); |
444 | } | 448 | } |
445 | } | 449 | } |
446 | } | 450 | } |
447 | 451 | ||
448 | 452 | ||
449 | void Konsole::enterCommand(int c) | 453 | void Konsole::enterCommand(int c) |
450 | { | 454 | { |
451 | TEWidget* te = getTe(); | 455 | TEWidget* te = getTe(); |
452 | if (te != 0) { | 456 | if (te != 0) { |
453 | if(!commonCombo->editable()) { | 457 | if(!commonCombo->editable()) { |
454 | QString text = commonCombo->text(c); //commonCmds[c]; | 458 | QString text = commonCombo->text(c); //commonCmds[c]; |
455 | te->emitText(text); | 459 | te->emitText(text); |
456 | } else { | 460 | } else { |
457 | changeCommand( commonCombo->text(c), c); | 461 | changeCommand( commonCombo->text(c), c); |
458 | } | 462 | } |
459 | } | 463 | } |
460 | } | 464 | } |
461 | 465 | ||
462 | void Konsole::hitEnter() | 466 | void Konsole::hitEnter() |
463 | { | 467 | { |
464 | TEWidget* te = getTe(); | 468 | TEWidget* te = getTe(); |
465 | if (te != 0) { | 469 | if (te != 0) { |
466 | te->emitText(QString("\r")); | 470 | te->emitText(QString("\r")); |
467 | } | 471 | } |
468 | } | 472 | } |
469 | 473 | ||
@@ -694,339 +698,347 @@ void Konsole::colorMenuSelected(int iD) | |||
694 | colorMenu->setItemChecked(-8,TRUE); | 698 | colorMenu->setItemChecked(-8,TRUE); |
695 | } | 699 | } |
696 | if(iD==-10) {// Black, Red | 700 | if(iD==-10) {// Black, Red |
697 | foreground.setRgb(0x00,0x00,0x00); | 701 | foreground.setRgb(0x00,0x00,0x00); |
698 | background.setRgb(0xB2,0x18,0x18); | 702 | background.setRgb(0xB2,0x18,0x18); |
699 | cfg.writeEntry("Schema","10"); | 703 | cfg.writeEntry("Schema","10"); |
700 | colorMenu->setItemChecked(-10,TRUE); | 704 | colorMenu->setItemChecked(-10,TRUE); |
701 | } | 705 | } |
702 | if(iD==-11) {// Red, Black | 706 | if(iD==-11) {// Red, Black |
703 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 | 707 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 |
704 | background.setRgb(0x00,0x00,0x00); | 708 | background.setRgb(0x00,0x00,0x00); |
705 | cfg.writeEntry("Schema","11"); | 709 | cfg.writeEntry("Schema","11"); |
706 | colorMenu->setItemChecked(-11,TRUE); | 710 | colorMenu->setItemChecked(-11,TRUE); |
707 | } | 711 | } |
708 | if(iD==-12) {// Green, Yellow - is ugly | 712 | if(iD==-12) {// Green, Yellow - is ugly |
709 | // foreground.setRgb(0x18,0xB2,0x18); | 713 | // foreground.setRgb(0x18,0xB2,0x18); |
710 | foreground.setRgb(36,139,10); | 714 | foreground.setRgb(36,139,10); |
711 | // background.setRgb(0xB2,0x68,0x18); | 715 | // background.setRgb(0xB2,0x68,0x18); |
712 | background.setRgb(255,255,0); | 716 | background.setRgb(255,255,0); |
713 | cfg.writeEntry("Schema","12"); | 717 | cfg.writeEntry("Schema","12"); |
714 | colorMenu->setItemChecked(-12,TRUE); | 718 | colorMenu->setItemChecked(-12,TRUE); |
715 | } | 719 | } |
716 | if(iD==-13) {// Blue, Magenta | 720 | if(iD==-13) {// Blue, Magenta |
717 | foreground.setRgb(0x18,0xB2,0xB2); | 721 | foreground.setRgb(0x18,0xB2,0xB2); |
718 | background.setRgb(0x18,0x18,0xB2); | 722 | background.setRgb(0x18,0x18,0xB2); |
719 | cfg.writeEntry("Schema","13"); | 723 | cfg.writeEntry("Schema","13"); |
720 | colorMenu->setItemChecked(-13,TRUE); | 724 | colorMenu->setItemChecked(-13,TRUE); |
721 | } | 725 | } |
722 | if(iD==-14) {// Magenta, Blue | 726 | if(iD==-14) {// Magenta, Blue |
723 | foreground.setRgb(0x18,0x18,0xB2); | 727 | foreground.setRgb(0x18,0x18,0xB2); |
724 | background.setRgb(0x18,0xB2,0xB2); | 728 | background.setRgb(0x18,0xB2,0xB2); |
725 | cfg.writeEntry("Schema","14"); | 729 | cfg.writeEntry("Schema","14"); |
726 | colorMenu->setItemChecked(-14,TRUE); | 730 | colorMenu->setItemChecked(-14,TRUE); |
727 | } | 731 | } |
728 | if(iD==-15) {// Cyan, White | 732 | if(iD==-15) {// Cyan, White |
729 | foreground.setRgb(0x18,0xB2,0xB2); | 733 | foreground.setRgb(0x18,0xB2,0xB2); |
730 | background.setRgb(0xFF,0xFF,0xFF); | 734 | background.setRgb(0xFF,0xFF,0xFF); |
731 | cfg.writeEntry("Schema","15"); | 735 | cfg.writeEntry("Schema","15"); |
732 | colorMenu->setItemChecked(-15,TRUE); | 736 | colorMenu->setItemChecked(-15,TRUE); |
733 | } | 737 | } |
734 | if(iD==-16) {// White, Cyan | 738 | if(iD==-16) {// White, Cyan |
735 | background.setRgb(0x18,0xB2,0xB2); | 739 | background.setRgb(0x18,0xB2,0xB2); |
736 | foreground.setRgb(0xFF,0xFF,0xFF); | 740 | foreground.setRgb(0xFF,0xFF,0xFF); |
737 | cfg.writeEntry("Schema","16"); | 741 | cfg.writeEntry("Schema","16"); |
738 | colorMenu->setItemChecked(-16,TRUE); | 742 | colorMenu->setItemChecked(-16,TRUE); |
739 | } | 743 | } |
740 | if(iD==-17) {// Black, Blue | 744 | if(iD==-17) {// Black, Blue |
741 | background.setRgb(0x00,0x00,0x00); | 745 | background.setRgb(0x00,0x00,0x00); |
742 | foreground.setRgb(0x18,0xB2,0xB2); | 746 | foreground.setRgb(0x18,0xB2,0xB2); |
743 | cfg.writeEntry("Schema","17"); | 747 | cfg.writeEntry("Schema","17"); |
744 | colorMenu->setItemChecked(-17,TRUE); | 748 | colorMenu->setItemChecked(-17,TRUE); |
745 | } | 749 | } |
746 | if(iD==-18) {// Black, Gold | 750 | if(iD==-18) {// Black, Gold |
747 | background.setRgb(0x00,0x00,0x00); | 751 | background.setRgb(0x00,0x00,0x00); |
748 | foreground.setRgb(255,215,0); | 752 | foreground.setRgb(255,215,0); |
749 | cfg.writeEntry("Schema","18"); | 753 | cfg.writeEntry("Schema","18"); |
750 | colorMenu->setItemChecked(-18,TRUE); | 754 | colorMenu->setItemChecked(-18,TRUE); |
751 | } | 755 | } |
752 | #ifdef QWS_QT_OPIE | 756 | #ifdef QWS_QT_OPIE |
753 | if(iD==-19) { | 757 | if(iD==-19) { |
754 | // Custom | 758 | // Custom |
755 | qDebug("do custom"); | 759 | qDebug("do custom"); |
756 | if(fromMenu) { | 760 | if(fromMenu) { |
757 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); | 761 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); |
758 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 762 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
759 | SLOT(changeForegroundColor(const QColor&))); | 763 | SLOT(changeForegroundColor(const QColor&))); |
760 | penColorPopupMenu->exec(); | 764 | penColorPopupMenu->exec(); |
761 | } | 765 | } |
762 | cfg.writeEntry("Schema","19"); | 766 | cfg.writeEntry("Schema","19"); |
763 | if(!fromMenu) { | 767 | if(!fromMenu) { |
764 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 768 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
765 | background.setNamedColor(cfg.readEntry("background","")); | 769 | background.setNamedColor(cfg.readEntry("background","")); |
766 | } | 770 | } |
767 | fromMenu=FALSE; | 771 | fromMenu=FALSE; |
768 | colorMenu->setItemChecked(-19,TRUE); | 772 | colorMenu->setItemChecked(-19,TRUE); |
769 | } | 773 | } |
770 | #endif | 774 | #endif |
771 | for (i = 0; i < TABLE_COLORS; i++) { | 775 | for (i = 0; i < TABLE_COLORS; i++) { |
772 | if(i==0 || i == 10) { | 776 | if(i==0 || i == 10) { |
773 | m_table[i].color = foreground; | 777 | m_table[i].color = foreground; |
774 | } | 778 | } |
775 | else if(i==1 || i == 11) { | 779 | else if(i==1 || i == 11) { |
776 | m_table[i].color = background; m_table[i].transparent=0; | 780 | m_table[i].color = background; m_table[i].transparent=0; |
777 | } | 781 | } |
778 | else | 782 | else |
779 | m_table[i].color = defaultCt[i].color; | 783 | m_table[i].color = defaultCt[i].color; |
780 | } | 784 | } |
781 | } | 785 | } |
782 | lastSelectedMenu = iD; | 786 | lastSelectedMenu = iD; |
783 | te->setColorTable(m_table); | 787 | te->setColorTable(m_table); |
784 | update(); | 788 | update(); |
785 | 789 | ||
786 | } | 790 | } |
787 | 791 | ||
788 | void Konsole::configMenuSelected(int iD) | 792 | void Konsole::configMenuSelected(int iD) |
789 | { | 793 | { |
790 | // QString temp; | 794 | // QString temp; |
791 | // qDebug( temp.sprintf("configmenu %d",iD)); | 795 | // qDebug( temp.sprintf("configmenu %d",iD)); |
792 | TEWidget* te = getTe(); | 796 | TEWidget* te = getTe(); |
793 | Config cfg("Konsole"); | 797 | Config cfg("Konsole"); |
794 | cfg.setGroup("Menubar"); | 798 | cfg.setGroup("Menubar"); |
795 | if( iD == -4) { | 799 | int i,j; |
796 | cfg.setGroup("Tabs"); | ||
797 | QString tmp=cfg.readEntry("Position","Bottom"); | ||
798 | |||
799 | if(tmp=="Top") { | ||
800 | tab->setTabPosition(QTabWidget::Bottom); | ||
801 | configMenu->changeItem( iD,"Tabs on Top"); | ||
802 | cfg.writeEntry("Position","Bottom"); | ||
803 | } else { | ||
804 | tab->setTabPosition(QTabWidget::Top); | ||
805 | configMenu->changeItem( iD,"Tabs on Bottom"); | ||
806 | cfg.writeEntry("Position","Top"); | ||
807 | } | ||
808 | } | ||
809 | int i; | ||
810 | #ifdef QWS_QT_OPIE | 800 | #ifdef QWS_QT_OPIE |
811 | i=-29; | 801 | i=-29;j=-30; |
812 | #else | 802 | #else |
813 | i=-28; | 803 | i=-28;j=-29; |
814 | #endif | 804 | #endif |
815 | 805 | ||
816 | if( iD == i) { | 806 | if(iD == -4) { |
817 | cfg.setGroup("ScrollBar"); | 807 | cfg.setGroup("Tabs"); |
808 | QString tmp=cfg.readEntry("Position","Bottom"); | ||
809 | |||
810 | if(tmp=="Top") { | ||
811 | tab->setTabPosition(QTabWidget::Bottom); | ||
812 | configMenu->changeItem( iD,"Tabs on Top"); | ||
813 | cfg.writeEntry("Position","Bottom"); | ||
814 | } else { | ||
815 | tab->setTabPosition(QTabWidget::Top); | ||
816 | configMenu->changeItem( iD,"Tabs on Bottom"); | ||
817 | cfg.writeEntry("Position","Top"); | ||
818 | } | ||
819 | } | ||
820 | if(iD == i) { | ||
821 | cfg.setGroup("ScrollBar"); | ||
818 | bool b=cfg.readBoolEntry("HorzScroll",0); | 822 | bool b=cfg.readBoolEntry("HorzScroll",0); |
819 | b=!b; | 823 | b=!b; |
820 | cfg.writeEntry("HorzScroll", b ); | 824 | cfg.writeEntry("HorzScroll", b ); |
821 | cfg.write(); | 825 | cfg.write(); |
822 | doWrap(); | 826 | doWrap(); |
823 | if(cfg.readNumEntry("Position",2) == 0) { | 827 | if(cfg.readNumEntry("Position",2) == 0) { |
824 | te->setScrollbarLocation(1); | 828 | te->setScrollbarLocation(1); |
825 | } else { | 829 | } else { |
826 | te->setScrollbarLocation(0); | 830 | te->setScrollbarLocation(0); |
827 | } | 831 | } |
828 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 832 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
829 | } | 833 | } |
834 | if(iD == j) { | ||
835 | cfg.setGroup("Menubar"); | ||
836 | bool b=cfg.readBoolEntry("useBeep",0); | ||
837 | b=!b; | ||
838 | cfg.writeEntry("useBeep", b ); | ||
839 | cfg.write(); | ||
840 | configMenu->setItemChecked(j,b); | ||
841 | te->useBeep=b; | ||
842 | } | ||
830 | } | 843 | } |
831 | 844 | ||
832 | void Konsole::changeCommand(const QString &text, int c) | 845 | void Konsole::changeCommand(const QString &text, int c) |
833 | { | 846 | { |
834 | Config cfg("Konsole"); | 847 | Config cfg("Konsole"); |
835 | cfg.setGroup("Commands"); | 848 | cfg.setGroup("Commands"); |
836 | if(commonCmds[c] != text) { | 849 | if(commonCmds[c] != text) { |
837 | cfg.writeEntry(QString::number(c),text); | 850 | cfg.writeEntry(QString::number(c),text); |
838 | commonCombo->clearEdit(); | 851 | commonCombo->clearEdit(); |
839 | commonCombo->setCurrentItem(c); | 852 | commonCombo->setCurrentItem(c); |
840 | } | 853 | } |
841 | } | 854 | } |
842 | 855 | ||
843 | void Konsole::setColor() | 856 | void Konsole::setColor() |
844 | { | 857 | { |
845 | Config cfg("Konsole"); | 858 | Config cfg("Konsole"); |
846 | cfg.setGroup("Colors"); | 859 | cfg.setGroup("Colors"); |
847 | int scheme = cfg.readNumEntry("Schema",1); | 860 | int scheme = cfg.readNumEntry("Schema",1); |
848 | if(scheme != 1) colorMenuSelected( -scheme); | 861 | if(scheme != 1) colorMenuSelected( -scheme); |
849 | } | 862 | } |
850 | 863 | ||
851 | void Konsole::scrollMenuSelected(int index) | 864 | void Konsole::scrollMenuSelected(int index) |
852 | { | 865 | { |
853 | qDebug( "scrollbar menu %d",index); | 866 | qDebug( "scrollbar menu %d",index); |
854 | TEWidget* te = getTe(); | 867 | TEWidget* te = getTe(); |
855 | Config cfg("Konsole"); | 868 | Config cfg("Konsole"); |
856 | cfg.setGroup("ScrollBar"); | 869 | cfg.setGroup("ScrollBar"); |
857 | switch( index){ | 870 | switch( index){ |
858 | case -25: | 871 | case -25: |
859 | te->setScrollbarLocation(0); | 872 | te->setScrollbarLocation(0); |
860 | cfg.writeEntry("Position",0); | 873 | cfg.writeEntry("Position",0); |
861 | break; | 874 | break; |
862 | case -26: | 875 | case -26: |
863 | te->setScrollbarLocation(1); | 876 | te->setScrollbarLocation(1); |
864 | cfg.writeEntry("Position",1); | 877 | cfg.writeEntry("Position",1); |
865 | break; | 878 | break; |
866 | case -27: | 879 | case -27: |
867 | te->setScrollbarLocation(2); | 880 | te->setScrollbarLocation(2); |
868 | cfg.writeEntry("Position",2); | 881 | cfg.writeEntry("Position",2); |
869 | break; | 882 | break; |
870 | // case -29: { | 883 | // case -29: { |
871 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 884 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
872 | // cfg.writeEntry("HorzScroll", !b ); | 885 | // cfg.writeEntry("HorzScroll", !b ); |
873 | // cfg.write(); | 886 | // cfg.write(); |
874 | // if(cfg.readNumEntry("Position",2) == 0) { | 887 | // if(cfg.readNumEntry("Position",2) == 0) { |
875 | // te->setScrollbarLocation(1); | 888 | // te->setScrollbarLocation(1); |
876 | // te->setWrapAt(0); | 889 | // te->setWrapAt(0); |
877 | // } else { | 890 | // } else { |
878 | // te->setScrollbarLocation(0); | 891 | // te->setScrollbarLocation(0); |
879 | // te->setWrapAt(120); | 892 | // te->setWrapAt(120); |
880 | // } | 893 | // } |
881 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 894 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
882 | // } | 895 | // } |
883 | // break; | 896 | // break; |
884 | }; | 897 | }; |
885 | } | 898 | } |
886 | 899 | ||
887 | void Konsole::editCommandListMenuSelected(int iD) | 900 | void Konsole::editCommandListMenuSelected(int iD) |
888 | { | 901 | { |
889 | // QString temp; | 902 | // QString temp; |
890 | // qDebug( temp.sprintf("edit command list %d",iD)); | 903 | // qDebug( temp.sprintf("edit command list %d",iD)); |
891 | TEWidget* te = getTe(); | 904 | TEWidget* te = getTe(); |
892 | Config cfg("Konsole"); | 905 | Config cfg("Konsole"); |
893 | cfg.setGroup("Menubar"); | 906 | cfg.setGroup("Menubar"); |
894 | if( iD == -3) { | 907 | if( iD == -3) { |
895 | if(!secondToolBar->isHidden()) { | 908 | if(!secondToolBar->isHidden()) { |
896 | secondToolBar->hide(); | 909 | secondToolBar->hide(); |
897 | configMenu->changeItem( iD,tr( "Show Command List" )); | 910 | configMenu->changeItem( iD,tr( "Show Command List" )); |
898 | cfg.writeEntry("Hidden","TRUE"); | 911 | cfg.writeEntry("Hidden","TRUE"); |
899 | configMenu->setItemEnabled(-23 ,FALSE); | 912 | configMenu->setItemEnabled(-23 ,FALSE); |
900 | } else { | 913 | } else { |
901 | secondToolBar->show(); | 914 | secondToolBar->show(); |
902 | configMenu->changeItem( iD,tr( "Hide Command List" )); | 915 | configMenu->changeItem( iD,tr( "Hide Command List" )); |
903 | cfg.writeEntry("Hidden","FALSE"); | 916 | cfg.writeEntry("Hidden","FALSE"); |
904 | configMenu->setItemEnabled(-23 ,TRUE); | 917 | configMenu->setItemEnabled(-23 ,TRUE); |
905 | 918 | ||
906 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { | 919 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { |
907 | configMenu->setItemChecked(-23,TRUE); | 920 | configMenu->setItemChecked(-23,TRUE); |
908 | commonCombo->setEditable( TRUE ); | 921 | commonCombo->setEditable( TRUE ); |
909 | } else { | 922 | } else { |
910 | configMenu->setItemChecked(-23,FALSE); | 923 | configMenu->setItemChecked(-23,FALSE); |
911 | commonCombo->setEditable( FALSE ); | 924 | commonCombo->setEditable( FALSE ); |
912 | } | 925 | } |
913 | } | 926 | } |
914 | } | 927 | } |
915 | if( iD == -23) { | 928 | if( iD == -23) { |
916 | cfg.setGroup("Commands"); | 929 | cfg.setGroup("Commands"); |
917 | // qDebug("enableCommandEdit"); | 930 | // qDebug("enableCommandEdit"); |
918 | if( !configMenu->isItemChecked(iD) ) { | 931 | if( !configMenu->isItemChecked(iD) ) { |
919 | commonCombo->setEditable( TRUE ); | 932 | commonCombo->setEditable( TRUE ); |
920 | configMenu->setItemChecked(iD,TRUE); | 933 | configMenu->setItemChecked(iD,TRUE); |
921 | commonCombo->setCurrentItem(0); | 934 | commonCombo->setCurrentItem(0); |
922 | cfg.writeEntry("EditEnabled","TRUE"); | 935 | cfg.writeEntry("EditEnabled","TRUE"); |
923 | } else { | 936 | } else { |
924 | commonCombo->setEditable( FALSE ); | 937 | commonCombo->setEditable( FALSE ); |
925 | configMenu->setItemChecked(iD,FALSE); | 938 | configMenu->setItemChecked(iD,FALSE); |
926 | cfg.writeEntry("EditEnabled","FALSE"); | 939 | cfg.writeEntry("EditEnabled","FALSE"); |
927 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 940 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
928 | te->setFocus(); | 941 | te->setFocus(); |
929 | } | 942 | } |
930 | } | 943 | } |
931 | if(iD == -24) { | 944 | if(iD == -24) { |
932 | // "edit commands" | 945 | // "edit commands" |
933 | CommandEditDialog *m = new CommandEditDialog(this); | 946 | CommandEditDialog *m = new CommandEditDialog(this); |
934 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); | 947 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); |
935 | m->showMaximized(); | 948 | m->showMaximized(); |
936 | } | 949 | } |
937 | 950 | ||
938 | } | 951 | } |
939 | 952 | ||
940 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' | 953 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' |
941 | void Konsole::setDocument( const QString &cmd) { | 954 | void Konsole::setDocument( const QString &cmd) { |
942 | newSession(); | 955 | newSession(); |
943 | TEWidget* te = getTe(); | 956 | TEWidget* te = getTe(); |
944 | if(cmd.find("-e", 0, TRUE) != -1) { | 957 | if(cmd.find("-e", 0, TRUE) != -1) { |
945 | QString cmd2; | 958 | QString cmd2; |
946 | cmd2=cmd.right(cmd.length()-3)+" &"; | 959 | cmd2=cmd.right(cmd.length()-3)+" &"; |
947 | system(cmd2.latin1()); | 960 | system(cmd2.latin1()); |
948 | if(startUp <= 1 && nsessions < 2) { | 961 | if(startUp <= 1 && nsessions < 2) { |
949 | doneSession(getTe()->currentSession, 0); | 962 | doneSession(getTe()->currentSession, 0); |
950 | exit(0); | 963 | exit(0); |
951 | } else | 964 | } else |
952 | doneSession(getTe()->currentSession, 0); | 965 | doneSession(getTe()->currentSession, 0); |
953 | } else { | 966 | } else { |
954 | if (te != 0) { | 967 | if (te != 0) { |
955 | te->emitText(cmd+"\r"); | 968 | te->emitText(cmd+"\r"); |
956 | } | 969 | } |
957 | } | 970 | } |
958 | startUp++; | 971 | startUp++; |
959 | } | 972 | } |
960 | 973 | ||
961 | void Konsole::parseCommandLine() { | 974 | void Konsole::parseCommandLine() { |
962 | QString cmd; | 975 | QString cmd; |
963 | // newSession(); | 976 | // newSession(); |
964 | for (int i=1;i< qApp->argc();i++) { | 977 | for (int i=1;i< qApp->argc();i++) { |
965 | if( QString(qApp->argv()[i]) == "-e") { | 978 | if( QString(qApp->argv()[i]) == "-e") { |
966 | i++; | 979 | i++; |
967 | for ( int j=i;j< qApp->argc();j++) { | 980 | for ( int j=i;j< qApp->argc();j++) { |
968 | cmd+=QString(qApp->argv()[j])+" "; | 981 | cmd+=QString(qApp->argv()[j])+" "; |
969 | } | 982 | } |
970 | cmd.stripWhiteSpace(); | 983 | cmd.stripWhiteSpace(); |
971 | system(cmd.latin1()); | 984 | system(cmd.latin1()); |
972 | exit(0);//close(); | 985 | exit(0);//close(); |
973 | } // end -e switch | 986 | } // end -e switch |
974 | } | 987 | } |
975 | startUp++; | 988 | startUp++; |
976 | } | 989 | } |
977 | 990 | ||
978 | void Konsole::changeForegroundColor(const QColor &color) { | 991 | void Konsole::changeForegroundColor(const QColor &color) { |
979 | Config cfg("Konsole"); | 992 | Config cfg("Konsole"); |
980 | cfg.setGroup("Colors"); | 993 | cfg.setGroup("Colors"); |
981 | int r, g, b; | 994 | int r, g, b; |
982 | color.rgb(&r,&g,&b); | 995 | color.rgb(&r,&g,&b); |
983 | foreground.setRgb(r,g,b); | 996 | foreground.setRgb(r,g,b); |
984 | // QString colors; | 997 | |
985 | // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); | ||
986 | cfg.writeEntry("foreground",color.name()); | 998 | cfg.writeEntry("foreground",color.name()); |
999 | qDebug("foreground "+color.name()); | ||
987 | cfg.write(); | 1000 | cfg.write(); |
988 | 1001 | ||
989 | qDebug("do other dialog"); | 1002 | qDebug("do other dialog"); |
990 | #ifdef QWS_QT_OPIE | 1003 | #ifdef QWS_QT_OPIE |
991 | 1004 | ||
992 | ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); | 1005 | ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); |
993 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 1006 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
994 | SLOT(changeBackgroundColor(const QColor&))); | 1007 | SLOT(changeBackgroundColor(const QColor&))); |
995 | penColorPopupMenu2->exec(); | 1008 | penColorPopupMenu2->exec(); |
996 | #endif | 1009 | #endif |
997 | } | 1010 | } |
998 | 1011 | ||
999 | void Konsole::changeBackgroundColor(const QColor &color) { | 1012 | void Konsole::changeBackgroundColor(const QColor &color) { |
1000 | 1013 | ||
1001 | qDebug("Change background"); | 1014 | qDebug("Change background"); |
1002 | Config cfg("Konsole"); | 1015 | Config cfg("Konsole"); |
1003 | cfg.setGroup("Colors"); | 1016 | cfg.setGroup("Colors"); |
1004 | int r, g, b; | 1017 | int r, g, b; |
1005 | color.rgb(&r,&g,&b); | 1018 | color.rgb(&r,&g,&b); |
1006 | background.setRgb(r,g,b); | 1019 | background.setRgb(r,g,b); |
1007 | // QString colors; | ||
1008 | // colors.sprintf("%d,%d,%d"color.red,color.green,color.blue); | ||
1009 | cfg.writeEntry("background",color.name()); | 1020 | cfg.writeEntry("background",color.name()); |
1021 | qDebug("background "+color.name()); | ||
1010 | cfg.write(); | 1022 | cfg.write(); |
1011 | } | 1023 | } |
1012 | 1024 | ||
1013 | void Konsole::doWrap() { | 1025 | void Konsole::doWrap() { |
1014 | int i; | 1026 | int i; |
1015 | #ifdef QWS_QT_OPIE | 1027 | #ifdef QWS_QT_OPIE |
1016 | i=-29; | 1028 | i=-29; |
1017 | #else | 1029 | #else |
1018 | i=-28; | 1030 | i=-28; |
1019 | #endif | 1031 | #endif |
1020 | 1032 | ||
1021 | Config cfg("Konsole"); | 1033 | Config cfg("Konsole"); |
1022 | cfg.setGroup("ScrollBar"); | 1034 | cfg.setGroup("ScrollBar"); |
1023 | TEWidget* te = getTe(); | 1035 | TEWidget* te = getTe(); |
1024 | if( !cfg.readBoolEntry("HorzScroll",0)) { | 1036 | if( !cfg.readBoolEntry("HorzScroll",0)) { |
1025 | te->setWrapAt(0); | 1037 | te->setWrapAt(0); |
1026 | configMenu->setItemChecked( i,TRUE); | 1038 | configMenu->setItemChecked( i,TRUE); |
1027 | } else { | 1039 | } else { |
1028 | te->setWrapAt(90); | 1040 | // te->setWrapAt(90); |
1029 | // te->setWrapAt(120); | 1041 | te->setWrapAt(120); |
1030 | configMenu->setItemChecked( i,FALSE); | 1042 | configMenu->setItemChecked( i,FALSE); |
1031 | } | 1043 | } |
1032 | } | 1044 | } |