Commit 760d8635 authored by Robert Knight's avatar Robert Knight

Remove a few unused methods and member variables, more Qt-ish API and naming. ...

Remove a few unused methods and member variables, more Qt-ish API and naming.  Prepend 'virtual' to declarations of re-implementations of virtual methods.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=691162
parent de8e6ee6
......@@ -97,8 +97,8 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
SLOT(sessionResizeRequest(const QSize&)) );
// listen for popup menu requests
connect( _view , SIGNAL(configureRequest(TerminalDisplay*,int,int,int)) , this,
SLOT(showDisplayContextMenu(TerminalDisplay*,int,int,int)) );
connect( _view , SIGNAL(configureRequest(TerminalDisplay*,int,const QPoint&)) , this,
SLOT(showDisplayContextMenu(TerminalDisplay*,int,const QPoint&)) );
// move view to newest output when keystrokes occur
connect( _view , SIGNAL(keyPressedSignal(QKeyEvent*)) , this ,
......@@ -859,7 +859,7 @@ void SessionController::sessionTitleChanged()
setTitle( title );
}
void SessionController::showDisplayContextMenu(TerminalDisplay* /*display*/ , int /*state*/, int x, int y)
void SessionController::showDisplayContextMenu(TerminalDisplay* /*display*/ , int /*state*/, const QPoint& position)
{
if ( factory() )
{
......@@ -868,7 +868,7 @@ void SessionController::showDisplayContextMenu(TerminalDisplay* /*display*/ , in
Q_ASSERT( popup );
popup->exec( _view->mapToGlobal(QPoint(x,y)) );
popup->exec( _view->mapToGlobal(position) );
}
else
{
......
......@@ -175,7 +175,7 @@ private slots:
// other
void prepareChangeProfileMenu();
void updateCodecAction();
void showDisplayContextMenu(TerminalDisplay* display , int state , int x , int y);
void showDisplayContextMenu(TerminalDisplay* display , int state , const QPoint& position);
void sessionStateChanged(int state);
void sessionTitleChanged();
void searchTextChanged(const QString& text);
......
......@@ -72,8 +72,7 @@ using namespace Konsole;
// scroll increment used when dragging selection at top/bottom of window.
// static
bool TerminalDisplay::s_antialias = true;
bool TerminalDisplay::s_standalone = false;
bool TerminalDisplay::_antialiasText = true;
bool TerminalDisplay::HAVE_TRANSPARENCY = false;
/* ------------------------------------------------------------------------- */
......@@ -126,7 +125,7 @@ void TerminalDisplay::setColorTable(const ColorEntry table[])
p.setColor( backgroundRole(), _colorTable[DEFAULT_BACK_COLOR].color );
setPalette( p );
// We don't want the palette change to propagate to the scrollbar
// Avoid propagating the palette change to the scroll bar
_scrollBar->setPalette( QApplication::palette() );
update();
......@@ -167,7 +166,7 @@ unsigned short Konsole::vt100_graphics[32] =
0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7
};
void TerminalDisplay::fontChange(const QFont &)
void TerminalDisplay::fontChange(const QFont&)
{
QFontMetrics fm(font());
_fontHeight = fm.height() + _lineSpacing;
......@@ -179,17 +178,18 @@ void TerminalDisplay::fontChange(const QFont &)
_fontWidth = qRound((double)fm.width(REPCHAR)/(double)strlen(REPCHAR));
_fixedFont = true;
int fw = fm.width(REPCHAR[0]);
for(unsigned int i=1; i< strlen(REPCHAR); i++){
if (fw != fm.width(REPCHAR[i])){
for(unsigned int i=1; i< strlen(REPCHAR); i++)
{
if (fw != fm.width(REPCHAR[i]))
{
_fixedFont = false;
break;
}
}
}
if (_fontWidth>200) // don't trust unrealistic value, fallback to QFontMetrics::maxWidth()
_fontWidth=fm.maxWidth();
if (_fontWidth<1)
if (_fontWidth < 1)
_fontWidth=1;
_fontAscent = fm.ascent();
......@@ -207,7 +207,9 @@ void TerminalDisplay::setVTFont(const QFont& f)
if ( metrics.height() < height() && metrics.maxWidth() < width() )
{
if (!s_antialias)
// hint that text should be drawn without anti-aliasing.
// depending on the user's font configuration, this may not be respected
if (!_antialiasText)
font.setStyleStrategy( QFont::NoAntialias );
// experimental optimization. Konsole assumes that the terminal is using a
......@@ -256,7 +258,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
,_lineSelectionMode(false)
,_preserveLineBreaks(true)
,_columnSelectionMode(false)
,_scrollbarLocation(SCROLLBAR_NONE)
,_scrollbarLocation(NoScrollBar)
,_wordCharacters(":@-./_~")
,_bellMode(BELL_SYSTEM)
,_blinking(false)
......@@ -303,7 +305,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent)
_scrollBar = new QScrollBar(this);
setScroll(0,0);
_scrollBar->setCursor( Qt::ArrowCursor );
connect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
connect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarPositionChanged(int)));
_blinkTimer = new QTimer(this);
connect(_blinkTimer, SIGNAL(timeout()), this, SLOT(blinkEvent()));
......@@ -1439,7 +1441,7 @@ void TerminalDisplay::hideEvent(QHideEvent*)
/* */
/* ------------------------------------------------------------------------- */
void TerminalDisplay::scrollChanged(int)
void TerminalDisplay::scrollBarPositionChanged(int)
{
if ( !_screenWindow )
return;
......@@ -1471,19 +1473,22 @@ void TerminalDisplay::setScroll(int cursor, int slines)
return;
}
disconnect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
disconnect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarPositionChanged(int)));
_scrollBar->setRange(0,slines - _lines);
_scrollBar->setSingleStep(1);
_scrollBar->setPageStep(_lines);
_scrollBar->setValue(cursor);
connect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int)));
connect(_scrollBar, SIGNAL(valueChanged(int)), this, SLOT(scrollBarPositionChanged(int)));
}
void TerminalDisplay::setScrollBarLocation(ScrollBarLocation loc)
void TerminalDisplay::setScrollBarPosition(ScrollBarPosition position)
{
if (_scrollbarLocation == loc) return; // quickly
if (_scrollbarLocation == position)
return;
_bY = _bX = 1;
_scrollbarLocation = loc;
_scrollbarLocation = position;
calcGeometry();
propagateSize();
update();
......@@ -1567,11 +1572,9 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev)
}
else
{
_configureRequestPoint = QPoint( ev->x(), ev->y() );
emit configureRequest( this,
ev->modifiers() & (Qt::ShiftModifier|Qt::ControlModifier),
ev->x(),
ev->y()
ev->pos()
);
}
}
......@@ -1681,10 +1684,12 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev)
extendSelection( ev->pos() );
}
#if 0
void TerminalDisplay::setSelectionEnd()
{
extendSelection( _configureRequestPoint );
}
#endif
void TerminalDisplay::extendSelection( const QPoint& position )
{
......@@ -2185,6 +2190,10 @@ void TerminalDisplay::setUsesMouse(bool on)
_mouseMarks = on;
setCursor( _mouseMarks ? Qt::IBeamCursor : Qt::ArrowCursor );
}
bool TerminalDisplay::usesMouse() const
{
return _mouseMarks;
}
/* ------------------------------------------------------------------------- */
/* */
......@@ -2238,14 +2247,6 @@ void TerminalDisplay::pasteSelection()
emitSelection(true,false);
}
void TerminalDisplay::onClearSelection()
{
if ( !_screenWindow ) return;
_screenWindow->clearSelection();
//emit clearSelectionSignal();
}
/* ------------------------------------------------------------------------- */
/* */
/* Keyboard */
......@@ -2396,8 +2397,7 @@ bool TerminalDisplay::event( QEvent *e )
// this is important as it allows a press and release of the Alt key
// on its own to focus the menu bar, making it possible to
// work with the menu without using the mouse
if ( !standalone() &&
( (keyEvent->modifiers() == Qt::ControlModifier) ||
if ( ( (keyEvent->modifiers() == Qt::ControlModifier) ||
(keyEvent->modifiers() == Qt::AltModifier) ) &&
!keyEvent->text().isEmpty() )
{
......@@ -2493,18 +2493,18 @@ void TerminalDisplay::calcGeometry()
contentsRect().height());
switch(_scrollbarLocation)
{
case SCROLLBAR_NONE :
case NoScrollBar :
_bX = _rimX;
_contentWidth = contentsRect().width() - 2 * _rimX;
_scrollBar->hide();
break;
case SCROLLBAR_LEFT :
case ScrollBarLeft :
_bX = _rimX+_scrollBar->width();
_contentWidth = contentsRect().width() - 2 * _rimX - _scrollBar->width();
_scrollBar->move(contentsRect().topLeft());
_scrollBar->show();
break;
case SCROLLBAR_RIGHT:
case ScrollBarRight:
_bX = _rimX;
_contentWidth = contentsRect().width() - 2 * _rimX - _scrollBar->width();
_scrollBar->move(contentsRect().topRight() - QPoint(_scrollBar->width()-1,0));
......@@ -2590,11 +2590,6 @@ QSize TerminalDisplay::sizeHint() const
return _size;
}
void TerminalDisplay::styleChange(QStyle &)
{
propagateSize();
}
/* --------------------------------------------------------------------- */
/* */
......
......@@ -86,20 +86,20 @@ public:
/**
* This enum describes the location where the scroll bar is positioned in the display widget.
*/
enum ScrollBarLocation
enum ScrollBarPosition
{
/** Do not show the scroll bar. */
SCROLLBAR_NONE=0,
NoScrollBar=0,
/** Show the scroll bar on the left side of the display. */
SCROLLBAR_LEFT=1,
ScrollBarLeft=1,
/** Show the scroll bar on the right side of the display. */
SCROLLBAR_RIGHT=2
ScrollBarRight=2
};
/**
* Specifies whether the terminal display has a vertical scroll bar, and if so whether it
* is shown on the left or right side of the display.
*/
void setScrollBarLocation(ScrollBarLocation loc);
void setScrollBarPosition(ScrollBarPosition position);
/**
* Sets the current position and range of the display's scroll bar.
......@@ -322,15 +322,12 @@ public:
* Specified whether anti-aliasing of text in the terminal display
* is enabled or not. Defaults to enabled.
*/
static void setAntialias( bool enable ) { s_antialias = enable; }
static void setAntialias( bool antialias ) { _antialiasText = antialias; }
/**
* Returns true if anti-aliasing of text in the terminal is enabled.
*/
static bool antialias() { return s_antialias; }
static bool antialias() { return _antialiasText; }
static void setStandalone( bool standalone ) { s_standalone = standalone; }
static bool standalone() { return s_standalone; }
/**
* Sets whether or not the current height and width of the
* terminal in lines and columns is displayed whilst the widget
......@@ -374,7 +371,7 @@ public:
/** Returns the terminal screen section which is displayed in this widget. See setScreenWindow() */
ScreenWindow* screenWindow() const;
public Q_SLOTS:
public slots:
/**
* Causes the terminal display to fetch the latest character image from the associated
......@@ -387,8 +384,6 @@ public Q_SLOTS:
*/
void updateLineProperties();
void setSelectionEnd();
/** Copies the selected text to the clipboard. */
void copyClipboard();
/**
......@@ -401,8 +396,8 @@ public Q_SLOTS:
* display.
*/
void pasteSelection();
void onClearSelection();
/**
/**
* Causes the widget to display or hide a message informing the user that terminal
* output has been suspended (by using the flow control key combination Ctrl+S)
*
......@@ -427,14 +422,17 @@ public Q_SLOTS:
* or false otherwise.
*/
void setUsesMouse(bool usesMouse);
/** See setUsesMouse() */
bool usesMouse() const;
/**
* Shows a notification that a bell event has occurred in the terminal.
* TODO: More documentation here
*/
void bell(const QString& message);
Q_SIGNALS:
signals:
/**
* Emitted when the user presses a key whilst the terminal widget has focus.
......@@ -451,49 +449,50 @@ Q_SIGNALS:
/**
* A mouse event occurred.
* @param cb The mouse button (0 for left button, 1 for middle button, 2 for right button, 3 for release)
* @param cx The character column where the event occurred
* @param cy The character row where the event occurred
* @param button The mouse button (0 for left button, 1 for middle button, 2 for right button, 3 for release)
* @param column The character column where the event occurred
* @param line The character row where the event occurred
* @param eventType The type of event. 0 for a mouse press / release or 1 for mouse motion
*/
void mouseSignal(int cb, int cx, int cy, int eventType);
void mouseSignal(int button, int column, int line, int eventType);
void changedFontMetricSignal(int height, int width);
void changedContentSizeSignal(int height, int width);
void changedHistoryCursor( int value);
void configureRequest( TerminalDisplay*, int state, int x, int y );
/**
* Emitted when the user right clicks on the display, or right-clicks with the Shift
* key held down if usesMouse() is true.
*
* This can be used to display a context menu.
*/
void configureRequest( TerminalDisplay*, int state, const QPoint& position );
void isBusySelecting(bool);
void sendStringToEmu(const char*);
protected:
virtual bool event( QEvent * );
virtual void styleChange( QStyle& );
virtual void paintEvent( QPaintEvent * );
bool event( QEvent * );
virtual void showEvent(QShowEvent*);
virtual void hideEvent(QHideEvent*);
virtual void resizeEvent(QResizeEvent*);
virtual void fontChange(const QFont &font);
void paintEvent( QPaintEvent * );
void paintFilters(QPainter& painter);
void showEvent(QShowEvent*);
void hideEvent(QHideEvent*);
void resizeEvent(QResizeEvent*);
void fontChange(const QFont &font);
virtual void keyPressEvent(QKeyEvent* event);
virtual void mouseDoubleClickEvent(QMouseEvent* ev);
virtual void mousePressEvent( QMouseEvent* );
virtual void mouseReleaseEvent( QMouseEvent* );
virtual void mouseMoveEvent( QMouseEvent* );
virtual void extendSelection( const QPoint& pos );
virtual void wheelEvent( QWheelEvent* );
void keyPressEvent(QKeyEvent* event);
void mouseDoubleClickEvent(QMouseEvent* ev);
void mousePressEvent( QMouseEvent* );
void mouseReleaseEvent( QMouseEvent* );
void mouseMoveEvent( QMouseEvent* );
void extendSelection( const QPoint& pos );
void wheelEvent( QWheelEvent* );
bool focusNextPrevChild( bool next );
// Dnd
void dragEnterEvent(QDragEnterEvent* event);
void dropEvent(QDropEvent* event);
virtual bool focusNextPrevChild( bool next );
// drag and drop
virtual void dragEnterEvent(QDragEnterEvent* event);
virtual void dropEvent(QDropEvent* event);
void doDrag();
enum DragState { diNone, diPending, diDragging };
......@@ -509,18 +508,20 @@ protected:
void mouseTripleClickEvent(QMouseEvent* ev);
void inputMethodEvent ( QInputMethodEvent * e );
virtual void inputMethodEvent ( QInputMethodEvent * e );
protected Q_SLOTS:
protected slots:
void scrollChanged(int value);
void scrollBarPositionChanged(int value);
void blinkEvent();
void blinkCursorEvent();
//Renables bell noises and visuals. Used to disable further bells for a short period of time
//after emitting the first in a sequence of bell events.
void enableBell();
private Q_SLOTS:
private slots:
void drop_menu_activated(QAction*);
void swapColorTable();
void tripleClickTimeout(); // resets possibleTripleClick
......@@ -578,6 +579,8 @@ private:
void updateImageSize();
void makeImage();
void paintFilters(QPainter& painter);
// the window onto the terminal screen which this display
// is currently showing.
QPointer<ScreenWindow> _screenWindow;
......@@ -633,7 +636,7 @@ private:
QClipboard* _clipboard;
QScrollBar* _scrollBar;
ScrollBarLocation _scrollbarLocation;
ScrollBarPosition _scrollbarLocation;
QString _wordCharacters;
int _bellMode;
......@@ -657,8 +660,6 @@ private:
bool _possibleTripleClick; // is set in mouseDoubleClickEvent and deleted
// after QApplication::doubleClickInterval() delay
static bool s_antialias; // do we antialias or not
static bool s_standalone; // are we part of a standalone konsole?
QFrame* _resizeWidget;
QLabel* _resizeLabel;
......@@ -670,7 +671,6 @@ private:
uint _lineSpacing;
QPoint _configureRequestPoint; // remember right mouse button click position
bool _colorsInverted; // true during visual bell
// the rim should normally be 1, 0 only when running in full screen mode.
......@@ -708,6 +708,8 @@ private:
static const int BLINK_DELAY = 500;
static bool HAVE_TRANSPARENCY;
static bool _antialiasText; // do we antialias or not
public:
static void setTransparencyEnabled(bool enable)
{
......
......@@ -557,7 +557,7 @@ TerminalDisplay* ViewManager::createTerminalDisplay(Session* session)
display->setTerminalSizeHint(false);
display->setCutToBeginningOfLine(true);
display->setTerminalSizeStartup(false);
display->setScrollBarLocation(TerminalDisplay::SCROLLBAR_RIGHT);
display->setScrollBarPosition(TerminalDisplay::ScrollBarRight);
display->setRandomSeed(session->sessionId() * 31);
return display;
......@@ -618,11 +618,11 @@ void ViewManager::applyProfile(TerminalDisplay* view , const QString& profileKey
int scrollBarPosition = info->property(Profile::ScrollBarPosition).value<int>();
if ( scrollBarPosition == Profile::ScrollBarHidden )
view->setScrollBarLocation(TerminalDisplay::SCROLLBAR_NONE);
view->setScrollBarPosition(TerminalDisplay::NoScrollBar);
else if ( scrollBarPosition == Profile::ScrollBarLeft )
view->setScrollBarLocation(TerminalDisplay::SCROLLBAR_LEFT);
view->setScrollBarPosition(TerminalDisplay::ScrollBarLeft);
else if ( scrollBarPosition == Profile::ScrollBarRight )
view->setScrollBarLocation(TerminalDisplay::SCROLLBAR_RIGHT);
view->setScrollBarPosition(TerminalDisplay::ScrollBarRight);
// terminal features
bool blinkingCursor = info->property(Profile::BlinkingCursorEnabled).value<bool>();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment