diff options
Diffstat (limited to 'konsole/konsole/TEWidget.cpp')
-rw-r--r-- | konsole/konsole/TEWidget.cpp | 130 |
1 files changed, 75 insertions, 55 deletions
diff --git a/konsole/konsole/TEWidget.cpp b/konsole/konsole/TEWidget.cpp index 52cd1236b..33dcf7f79 100644 --- a/konsole/konsole/TEWidget.cpp +++ b/konsole/konsole/TEWidget.cpp @@ -308,6 +308,19 @@ void TEWidget::fontChange(const TQFont &) update(); } +void TEWidget::biggerFont(void) { + TQFont f = getVTFont(); + f.setPointSize( f.pointSize() + 1 ); + setVTFont( f ); +} + +void TEWidget::smallerFont(void) { + TQFont f = getVTFont(); + if ( f.pointSize() < 6 ) return; // A minimum size + f.setPointSize( f.pointSize() - 1 ); + setVTFont( f ); +} + void TEWidget::setVTFont(const TQFont& f) { TQFont font = f; @@ -397,17 +410,17 @@ TEWidget::TEWidget(TQWidget *parent, const char *name) bY = bX = 1; cb = TQApplication::clipboard(); - TQObject::connect( (TQObject*)cb, TQT_SIGNAL(selectionChanged()), - this, TQT_SLOT(onClearSelection()) ); + TQObject::connect( (TQObject*)cb, TQ_SIGNAL(selectionChanged()), + this, TQ_SLOT(onClearSelection()) ); scrollbar = new TQScrollBar(this); - scrollbar->setCursor( tqarrowCursor ); - connect(scrollbar, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(scrollChanged(int))); + scrollbar->setCursor( TQt::arrowCursor ); + connect(scrollbar, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(scrollChanged(int))); blinkT = new TQTimer(this); - connect(blinkT, TQT_SIGNAL(timeout()), this, TQT_SLOT(blinkEvent())); + connect(blinkT, TQ_SIGNAL(timeout()), this, TQ_SLOT(blinkEvent())); blinkCursorT = new TQTimer(this); - connect(blinkCursorT, TQT_SIGNAL(timeout()), this, TQT_SLOT(blinkCursorEvent())); + connect(blinkCursorT, TQ_SIGNAL(timeout()), this, TQ_SLOT(blinkCursorEvent())); setMouseMarks(true); setColorTable(base_color_table); // init color table @@ -419,7 +432,7 @@ TEWidget::TEWidget(TQWidget *parent, const char *name) setAcceptDrops(true); // attempt dragInfo.state = diNone; - setFocusPolicy( TQ_WheelFocus ); + setFocusPolicy( TQWidget::WheelFocus ); // im setInputMethodEnabled(true); @@ -594,7 +607,7 @@ void TEWidget::drawTextFixed(TQPainter &paint, int x, int y, } } - paint.drawText(x,y, w, font_h, Qt::AlignHCenter | TQt::DontClip, drawstr, -1); + paint.drawText(x,y, w, font_h, TQt::AlignHCenter | TQt::DontClip, drawstr, -1); x += w; } } @@ -608,7 +621,7 @@ void TEWidget::drawAttrStr(TQPainter &paint, TQRect rect, TQString& str, const ca *attr, bool pm, bool clear) { int a = font_a + m_lineSpacing / 2; - TQColor fColor = printerFriendly ? Qt::black : attr->f.color(color_table); + TQColor fColor = printerFriendly ? TQt::black : attr->f.color(color_table); TQColor bColor = attr->b.color(color_table); TQString drawstr; @@ -621,13 +634,9 @@ void TEWidget::drawAttrStr(TQPainter &paint, TQRect rect, if (attr->isTransparent(color_table)) { if (pm) - paint.setBackgroundMode( Qt::TransparentMode ); + paint.setBackgroundMode( TQt::TransparentMode ); if (clear || (blinking && (attr->r & RE_BLINK))) { -#ifdef USE_QT4 - paint.eraseRect(rect); -#else // USE_QT4 erase(rect); -#endif // USE_QT4 } } else @@ -638,7 +647,7 @@ void TEWidget::drawAttrStr(TQPainter &paint, TQRect rect, // draw background colors with 75% opacity if ( draw_translucent_background_colors && argb_visual && tqAlpha(blend_color) < 0xff ) { - QRgb col = bColor.rgb(); + TQRgb col = bColor.rgb(); TQ_UINT8 salpha = 192; TQ_UINT8 dalpha = 255 - salpha; @@ -667,7 +676,7 @@ void TEWidget::drawAttrStr(TQPainter &paint, TQRect rect, tmpRect.setWidth( tmpRect.width() + font_w ); } - paint.fillRect( tmpRect, Qt::darkCyan ); // currently use hard code color + paint.fillRect( tmpRect, TQt::darkCyan ); // currently use hard code color } if ( m_isIMSel && !tmpStr.isEmpty() ) { // imput method selection background color @@ -682,13 +691,13 @@ void TEWidget::drawAttrStr(TQPainter &paint, TQRect rect, tmpRect.setWidth( tmpRect.width() + font_w ); } - paint.fillRect( tmpRect, Qt::darkGray ); // currently use hard code color + paint.fillRect( tmpRect, TQt::darkGray ); // currently use hard code color } } // Paint cursor if ((attr->r & RE_CURSOR) && !isPrinting) { - paint.setBackgroundMode( Qt::TransparentMode ); + paint.setBackgroundMode( TQt::TransparentMode ); int h = font_h - m_lineSpacing; TQRect r(rect.x(),rect.y()+m_lineSpacing/2,rect.width(),h); if (hasFocus()) @@ -731,7 +740,7 @@ void TEWidget::drawAttrStr(TQPainter &paint, TQRect rect, int y = rect.y(); // top of rect if ( shadow ) { - paint.setPen( Qt::black ); + paint.setPen( TQt::black ); drawTextFixed(paint, x+1, y+1, str, attr); paint.setPen(fColor); } @@ -744,7 +753,7 @@ void TEWidget::drawAttrStr(TQPainter &paint, TQRect rect, int y = rect.y()+a; // baseline if ( shadow ) { - paint.setPen( Qt::black ); + paint.setPen( TQt::black ); paint.drawText(x+1,y+1, str, -1, bidiEnabled ? TQPainter::Auto : TQPainter::LTR ); paint.setPen(fColor); } @@ -762,7 +771,7 @@ void TEWidget::drawAttrStr(TQPainter &paint, TQRect rect, { paint.setClipRect(rect); // On screen we use overstrike for bold - paint.setBackgroundMode( Qt::TransparentMode ); + paint.setBackgroundMode( TQt::TransparentMode ); int x = rect.x()+1; if(!fixed_font) { @@ -968,7 +977,7 @@ void TEWidget::setImage(const ca* const newimg, int lines, int columns) mResizeWidget->setMinimumWidth(mResizeLabel->fontMetrics().width(i18n("Size: XXX x XXX"))+20); mResizeWidget->setMinimumHeight(mResizeLabel->sizeHint().height()+20); mResizeTimer = new TQTimer(this); - connect(mResizeTimer, TQT_SIGNAL(timeout()), mResizeWidget, TQT_SLOT(hide())); + connect(mResizeTimer, TQ_SIGNAL(timeout()), mResizeWidget, TQ_SLOT(hide())); } TQString sizeStr = i18n("Size: %1 x %2").arg(columns).arg(lines); mResizeLabel->setText(sizeStr); @@ -1007,7 +1016,7 @@ void TEWidget::paintEvent( TQPaintEvent* pe ) TQPainter paint; setUpdatesEnabled(false); paint.begin( this ); - paint.setBackgroundMode( Qt::TransparentMode ); + paint.setBackgroundMode( TQt::TransparentMode ); // Note that the actual widget size can be slightly larger // that the image (the size is truncated towards the smaller @@ -1084,7 +1093,7 @@ void TEWidget::print(TQPainter &paint, bool friendly, bool exact) pm.fill(); TQPainter pm_paint; - pm_paint.begin(&pm, TQT_TQWIDGET(this)); + pm_paint.begin(&pm, this); paintContents(pm_paint, contentsRect(), true); pm_paint.end(); paint.drawPixmap(0, 0, pm); @@ -1245,13 +1254,13 @@ void TEWidget::scrollChanged(int) void TEWidget::setScroll(int cursor, int slines) { //kdDebug(1211)<<"TEWidget::setScroll() disconnect()"<<endl; - disconnect(scrollbar, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(scrollChanged(int))); + disconnect(scrollbar, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(scrollChanged(int))); //kdDebug(1211)<<"TEWidget::setScroll() setRange()"<<endl; scrollbar->setRange(0,slines); //kdDebug(1211)<<"TEWidget::setScroll() setSteps()"<<endl; scrollbar->setSteps(1,lines); scrollbar->setValue(cursor); - connect(scrollbar, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(scrollChanged(int))); + connect(scrollbar, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(scrollChanged(int))); //kdDebug(1211)<<"TEWidget::setScroll() done"<<endl; } @@ -1302,7 +1311,7 @@ void TEWidget::mousePressEvent(TQMouseEvent* ev) { //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); - if ( possibleTripleClick && (ev->button()==Qt::LeftButton) ) { + if ( possibleTripleClick && (ev->button()==TQt::LeftButton) ) { mouseTripleClickEvent(ev); return; } @@ -1315,7 +1324,7 @@ void TEWidget::mousePressEvent(TQMouseEvent* ev) TQPoint pos = TQPoint((ev->x()-tLx-bX+(font_w/2))/font_w,(ev->y()-tLy-bY)/font_h); //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); - if ( ev->button() == Qt::LeftButton) + if ( ev->button() == TQt::LeftButton) { line_selection_mode = false; word_selection_mode = false; @@ -1352,14 +1361,14 @@ void TEWidget::mousePressEvent(TQMouseEvent* ev) } } } - else if ( ev->button() == Qt::MidButton ) + else if ( ev->button() == TQt::MidButton ) { if ( mouse_marks || (!mouse_marks && (ev->state() & ShiftButton)) ) emitSelection(true,ev->state() & ControlButton); else emit mouseSignal( 1, (ev->x()-tLx-bX)/font_w +1, (ev->y()-tLy-bY)/font_h +1 +scrollbar->value() -scrollbar->maxValue() ); } - else if ( ev->button() == Qt::RightButton ) + else if ( ev->button() == TQt::RightButton ) { if (mouse_marks || (ev->state() & ShiftButton)) { configureRequestPoint = TQPoint( ev->x(), ev->y() ); @@ -1373,7 +1382,7 @@ void TEWidget::mousePressEvent(TQMouseEvent* ev) void TEWidget::mouseMoveEvent(TQMouseEvent* ev) { // for auto-hiding the cursor, we need mouseTracking - if (ev->state() == Qt::NoButton ) return; + if (ev->state() == TQt::NoButton ) return; if (dragInfo.state == diPending) { // we had a mouse down, but haven't confirmed a drag yet @@ -1397,7 +1406,7 @@ void TEWidget::mouseMoveEvent(TQMouseEvent* ev) if (actSel == 0) return; // don't extend selection while pasting - if (ev->state() & Qt::MidButton) return; + if (ev->state() & TQt::MidButton) return; extendSelection( ev->pos() ); } @@ -1591,7 +1600,7 @@ void TEWidget::extendSelection( TQPoint pos ) void TEWidget::mouseReleaseEvent(TQMouseEvent* ev) { //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); - if ( ev->button() == Qt::LeftButton) + if ( ev->button() == TQt::LeftButton) { emit isBusySelecting(false); // Ok.. we can breath again. if(dragInfo.state == diPending) @@ -1621,8 +1630,8 @@ void TEWidget::mouseReleaseEvent(TQMouseEvent* ev) } dragInfo.state = diNone; } - if ( !mouse_marks && ((ev->button() == Qt::RightButton && !(ev->state() & ShiftButton)) - || ev->button() == Qt::MidButton) ) { + if ( !mouse_marks && ((ev->button() == TQt::RightButton && !(ev->state() & ShiftButton)) + || ev->button() == TQt::MidButton) ) { TQPoint tL = contentsRect().topLeft(); int tLx = tL.x(); int tLy = tL.y(); @@ -1634,7 +1643,7 @@ void TEWidget::mouseReleaseEvent(TQMouseEvent* ev) void TEWidget::mouseDoubleClickEvent(TQMouseEvent* ev) { - if ( ev->button() != Qt::LeftButton) return; + if ( ev->button() != TQt::LeftButton) return; TQPoint tL = contentsRect().topLeft(); int tLx = tL.x(); @@ -1687,14 +1696,25 @@ void TEWidget::mouseDoubleClickEvent(TQMouseEvent* ev) } possibleTripleClick=true; - TQTimer::singleShot(TQApplication::doubleClickInterval(),this,TQT_SLOT(tripleClickTimeout())); + TQTimer::singleShot(TQApplication::doubleClickInterval(),this,TQ_SLOT(tripleClickTimeout())); } void TEWidget::wheelEvent( TQWheelEvent* ev ) { - if (ev->orientation() != Qt::Vertical) + if (ev->orientation() != TQt::Vertical) return; + if (ev->state() & ControlButton) { + if (ev->delta() > 0) { + biggerFont(); + } + else { + smallerFont(); + } + ev->accept(); + return; + } + if ( mouse_marks ) { if (!screen || screen->hasScroll() || (scrollbar->maxValue() == 0 && screen_num == 0)) @@ -1810,7 +1830,7 @@ void TEWidget::setWordCharacters(TQString wc) void TEWidget::setMouseMarks(bool on) { mouse_marks = on; - setCursor( mouse_marks ? tqibeamCursor : tqarrowCursor ); + setCursor( mouse_marks ? TQt::ibeamCursor : TQt::arrowCursor ); } /* ------------------------------------------------------------------------- */ @@ -1850,15 +1870,15 @@ void TEWidget::setSelection(const TQString& t) { // Disconnect signal while WE set the clipboard TQClipboard *cb = TQApplication::clipboard(); - TQObject::disconnect( cb, TQT_SIGNAL(selectionChanged()), - this, TQT_SLOT(onClearSelection()) ); + TQObject::disconnect( cb, TQ_SIGNAL(selectionChanged()), + this, TQ_SLOT(onClearSelection()) ); cb->setSelectionMode( true ); cb->setText(t); cb->setSelectionMode( false ); - TQObject::connect( cb, TQT_SIGNAL(selectionChanged()), - this, TQT_SLOT(onClearSelection()) ); + TQObject::connect( cb, TQ_SIGNAL(selectionChanged()), + this, TQ_SLOT(onClearSelection()) ); } void TEWidget::copyClipboard() @@ -1911,14 +1931,14 @@ bool TEWidget::eventFilter( TQObject *obj, TQEvent *e ) if ( (e->type() == TQEvent::Accel || e->type() == TQEvent::AccelAvailable ) && tqApp->focusWidget() == this ) { - TQT_TQKEYEVENT( e )->ignore(); + static_cast<TQKeyEvent*>( e )->ignore(); return false; } - if ( TQT_BASE_OBJECT(obj) != TQT_BASE_OBJECT(this) /* when embedded */ && TQT_BASE_OBJECT(obj) != TQT_BASE_OBJECT(parent()) /* when standalone */ ) + if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) return false; // not us if ( e->type() == TQEvent::KeyPress ) { - TQKeyEvent *ke = TQT_TQKEYEVENT(e); + TQKeyEvent *ke = static_cast<TQKeyEvent*>(e); actSel=0; // Key stroke implies a screen update, so TEWidget won't // know where the current selection is. @@ -1936,13 +1956,13 @@ bool TEWidget::eventFilter( TQObject *obj, TQEvent *e ) } if ( e->type() == TQEvent::KeyRelease ) { - TQKeyEvent *ke = TQT_TQKEYEVENT(e); + TQKeyEvent *ke = static_cast<TQKeyEvent*>(e); emit keyReleasedSignal(ke); return true; } if ( e->type() == TQEvent::FocusIn ) { - TQFocusEvent *fe = TQT_TQFOCUSEVENT(e); + TQFocusEvent *fe = static_cast<TQFocusEvent*>(e); if (fe->gotFocus()) { emit focusInSignal(fe); @@ -1952,13 +1972,13 @@ bool TEWidget::eventFilter( TQObject *obj, TQEvent *e ) } if ( e->type() == TQEvent::Enter ) { - TQObject::disconnect( (TQObject*)cb, TQT_SIGNAL(dataChanged()), - this, TQT_SLOT(onClearSelection()) ); + TQObject::disconnect( (TQObject*)cb, TQ_SIGNAL(dataChanged()), + this, TQ_SLOT(onClearSelection()) ); } if ( e->type() == TQEvent::Leave ) { - TQObject::connect( (TQObject*)cb, TQT_SIGNAL(dataChanged()), - this, TQT_SLOT(onClearSelection()) ); + TQObject::connect( (TQObject*)cb, TQ_SIGNAL(dataChanged()), + this, TQ_SLOT(onClearSelection()) ); } return TQFrame::eventFilter( obj, e ); } @@ -2030,7 +2050,7 @@ bool TEWidget::event( TQEvent *e ) { if ( e->type() == TQEvent::AccelOverride ) { - TQKeyEvent *ke = TQT_TQKEYEVENT( e ); + TQKeyEvent *ke = static_cast<TQKeyEvent*>( e ); KKey key( ke ); int keyCodeQt = key.keyCodeQt(); @@ -2104,7 +2124,7 @@ void TEWidget::Bell(bool visibleSession, TQString message) bellTimer.start(BELLVISUAL_DELAY,true); swapColorTable(); - TQTimer::singleShot(200,this,TQT_SLOT(swapColorTable())); + TQTimer::singleShot(200,this,TQ_SLOT(swapColorTable())); } } @@ -2250,7 +2270,7 @@ void TEWidget::dropEvent(TQDropEvent* event) m_drop->insertItem( "cp", cp ); m_drop->insertItem( "ln", ln ); m_drop->insertItem( "mv", mv ); - connect(m_drop, TQT_SIGNAL(activated(int)), TQT_SLOT(drop_menu_activated(int))); + connect(m_drop, TQ_SIGNAL(activated(int)), TQ_SLOT(drop_menu_activated(int))); }; // The current behaviour when url(s) are dropped is // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd/cp/ln/mv |