Fix event catching (checking for destination object)

Implemented openURL by simulating "cd /blah/" - this makes Up work at least:)

svn path=/trunk/kdebase/konsole/; revision=45438
wilder-portage
David Faure 26 years ago
parent 33d31c07a4
commit 8e450d8c4a
  1. 2
      include/konsole_part.h
  2. 68
      src/TEWidget.C
  3. 17
      src/konsole_part.C

@ -58,7 +58,7 @@ class konsolePart: public KParts::ReadOnlyPart
protected:
virtual bool openURL( const KURL & url );
virtual bool openFile() {}
virtual bool openFile() {return false;} // never used
virtual bool closeURL();
protected slots:

@ -13,7 +13,7 @@
/*! \class TEWidget
\brief Visible screen contents
This class is responsible to map the `image' of a terminal emulation to the
display. All the dependency of the emulation to a specific GUI or toolkit is
localized here. Further, this widget has no knowledge about being part of an
@ -95,14 +95,14 @@ static const ColorEntry base_color_table[TABLE_COLORS] =
ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White
// intensiv
ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ),
ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ),
ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ),
ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0xFF), 0, 0 ),
ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 )
};
/* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb)
Code 0 1 2 3 4 5 6 7
----------- ------- ------- ------- ------- ------- ------- ------- -------
ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White
@ -135,7 +135,7 @@ void TEWidget::setColorTable(const ColorEntry table[])
/* */
/* ------------------------------------------------------------------------- */
/*
/*
The VT100 has 32 special graphical characters. The usual vt100 extended
xterm fonts have these at 0x00..0x1f.
@ -237,8 +237,8 @@ void TEWidget::setFont(const QFont &)
TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name)
{
cb = QApplication::clipboard();
QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
cb = QApplication::clipboard();
QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
scrollbar = new QScrollBar(this);
@ -304,7 +304,7 @@ void TEWidget::drawAttrStr(QPainter &paint, QRect rect,
}
if (!(blinking && (attr.r & RE_BLINK)))
{
paint.setPen(color_table[attr.f].color);
paint.setPen(color_table[attr.f].color);
paint.drawText(rect.x(),rect.y()+font_a, str);
if ((attr.r & RE_UNDERLINE) || color_table[attr.f].bold)
{
@ -344,7 +344,7 @@ HCNT("setImage");
int cf = -1; // undefined
int cb = -1; // undefined
int cr = -1; // undefined
int lins = QMIN(this->lines, QMAX(0,lines ));
int cols = QMIN(this->columns,QMAX(0,columns));
QChar *disstrU = new QChar[cols];
@ -361,7 +361,7 @@ HCNT("setImage");
if (ext[x] != lcl[x])
{
cr = ext[x].r;
cb = ext[x].b;
cb = ext[x].b;
if (ext[x].f != cf) cf = ext[x].f;
int lln = cols - x;
disstrU[0] = fontMap(ext[x+0].c);
@ -373,7 +373,7 @@ HCNT("setImage");
disstrU[len] = fontMap(ext[x+len].c);
}
QString unistr(disstrU,len);
drawAttrStr(paint,
drawAttrStr(paint,
QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
unistr, ext[x], pm != NULL, true);
x += len - 1;
@ -421,7 +421,7 @@ HCNT("paintEvent");
QPoint tL = contentsRect().topLeft();
int tLx = tL.x();
int tLy = tL.y();
int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w));
int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h));
int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w));
@ -438,14 +438,14 @@ HCNT("paintEvent");
for (int y = luy; y <= rly; y++)
for (int x = lux; x <= rlx; x++)
{
{
QChar *disstrU = new QChar[columns];
int len = 1;
disstrU[0] = fontMap(image[loc(x,y)].c);
disstrU[0] = fontMap(image[loc(x,y)].c);
int cf = image[loc(x,y)].f;
int cb = image[loc(x,y)].b;
int cr = image[loc(x,y)].r;
while (x+len <= rlx &&
while (x+len <= rlx &&
image[loc(x+len,y)].f == cf &&
image[loc(x+len,y)].b == cb &&
image[loc(x+len,y)].r == cr )
@ -454,7 +454,7 @@ HCNT("paintEvent");
len += 1;
}
QString unistr(disstrU,len);
drawAttrStr(paint,
drawAttrStr(paint,
QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
unistr, image[loc(x,y)], pm != NULL, false);
x += len - 1;
@ -554,7 +554,7 @@ void TEWidget::setScrollbarLocation(int loc)
/* */
/* ------------------------------------------------------------------------- */
/*!
/*!
Three different operations can be performed using the mouse, and the
routines in this section serve all of them:
@ -751,8 +751,8 @@ void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
return;
}
emit clearSelectionSignal();
QPoint bgnSel = pos;
QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
@ -815,7 +815,7 @@ void TEWidget::setMouseMarks(bool on)
void TEWidget::emitSelection()
// Paste Clipboard by simulating keypress events
{
{
QString text = QApplication::clipboard()->text();
if ( ! text.isNull() )
{
@ -829,18 +829,18 @@ void TEWidget::emitSelection()
void TEWidget::setSelection(const QString& t)
{
// Disconnect signal while WE set the clipboard
QObject *cb = QApplication::clipboard();
QObject::disconnect( cb, SIGNAL(dataChanged()),
QObject *cb = QApplication::clipboard();
QObject::disconnect( cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
QApplication::clipboard()->setText(t);
QObject::connect( cb, SIGNAL(dataChanged()),
QObject::connect( cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
}
void TEWidget::onClearSelection()
{
{
emit clearSelectionSignal();
}
@ -864,14 +864,16 @@ void TEWidget::doScroll(int lines)
scrollbar->setValue(scrollbar->value()+lines);
}
bool TEWidget::eventFilter( QObject *, QEvent *e )
bool TEWidget::eventFilter( QObject *obj, QEvent *e )
{
if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ )
return FALSE; // not us
if ( e->type() == QEvent::Wheel)
{
QApplication::sendEvent(scrollbar, e);
}
if ( e->type() == QEvent::KeyPress )
{
{
QKeyEvent* ke = (QKeyEvent*)e;
actSel=0; // Key stroke implies a screen update, so TEWidget won't
@ -879,15 +881,15 @@ bool TEWidget::eventFilter( QObject *, QEvent *e )
emit keyPressedSignal(ke); // expose
return TRUE; // accept event
}
}
if ( e->type() == QEvent::Enter )
{
QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
}
if ( e->type() == QEvent::Leave )
{
QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
QObject::connect( (QObject*)cb, SIGNAL(dataChanged()),
this, SLOT(onClearSelection()) );
}
return FALSE; // standard event processing
@ -939,20 +941,20 @@ void TEWidget::clearImage()
// Create Image ///////////////////////////////////////////////////////
void TEWidget::calcGeometry()
{
{
//FIXME: set rimX == rimY == 0 when running in full screen mode.
scrollbar->resize(QApplication::style().scrollBarExtent().width(),
contentsRect().height());
switch(scrollLoc)
{
case SCRNONE :
case SCRNONE :
columns = ( contentsRect().width() - 2 * rimX ) / font_w;
blX = (contentsRect().width() - (columns*font_w) ) / 2;
brX = blX;
scrollbar->hide();
break;
case SCRLEFT :
case SCRLEFT :
columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w;
brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2;
blX = brX + scrollbar->width();
@ -982,7 +984,7 @@ void TEWidget::makeImage()
// calculate the needed size
QSize TEWidget::calcSize(int cols, int lins) const
{
{
int frw = width() - contentsRect().width();
int frh = height() - contentsRect().height();
int scw = (scrollLoc==SCRNONE?0:scrollbar->width());

@ -96,8 +96,8 @@ konsolePart::konsolePart(QWidget *parent, const char *name)
//bool login_shell = false;
//bool welcome = true;
bool histon = true;
const char* wname = PACKAGE;
//bool histon = true;
//const char* wname = PACKAGE;
// QCString sz = "";
//sz = args->getOption("vt_sz");
@ -154,7 +154,20 @@ konsolePart::~konsolePart()
bool konsolePart::openURL( const KURL & url )
{
m_url = url;
emit setWindowCaption( url.decodedURL() );
emit started( 0 );
if ( url.isLocalFile() )
{
QString text = url.path();
text.replace(QRegExp(" "), "\\ "); // escape spaces
text = QString::fromLatin1("cd ") + text + '\n';
QKeyEvent e(QEvent::KeyPress, 0,-1,0, text);
initial->getEmulation()->onKeyPress(&e);
}
emit completed();
return true;
// TODO: follow directory m_file

Loading…
Cancel
Save