1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2025-02-22 12:58:39 +00:00

Fix mouse wheel behavior.

This commit is contained in:
Filippo Scognamiglio 2014-08-27 23:42:45 +02:00
parent 95dce399b5
commit 8313b2a2fd
3 changed files with 13 additions and 15 deletions

View File

@ -134,8 +134,8 @@ Item{
anchors.fill: parent anchors.fill: parent
onWheel:{ onWheel:{
var coord = correctDistortion(wheel.x, wheel.y); var coord = correctDistortion(wheel.x, wheel.y);
var lines = wheel.angleDelta.y > 0 ? -2 : 2; var lines = wheel.angleDelta.y > 0 ? -1 : 1;
kterminal.scrollWheel(coord.width, coord.height, lines); kterminal.scrollWheelEvent(coord, lines);
} }
//onClicked: { //onClicked: {
// if (mouse.button == Qt.RightButton){ // if (mouse.button == Qt.RightButton){

View File

@ -447,28 +447,27 @@ QStringList KTerminalDisplay::availableColorSchemes()
return ret; return ret;
} }
void KTerminalDisplay::scrollWheel(qreal x, qreal y, int lines){ void KTerminalDisplay::scrollWheelEvent(QPoint position, int lines){
if(_mouseMarks){ if(_mouseMarks){
int charLine;
int charColumn;
getCharacterPosition(QPoint(x,y) , charLine , charColumn);
emit mouseSignal(lines > 0 ? 5 : 4,
charColumn + 1,
charLine + 1,
0);
} else {
if(_screenWindow->lineCount() == _screenWindow->windowLines()){ if(_screenWindow->lineCount() == _screenWindow->windowLines()){
const int keyCode = lines > 0 ? Qt::Key_Down : Qt::Key_Up; const int keyCode = lines > 0 ? Qt::Key_Down : Qt::Key_Up;
QKeyEvent keyEvent(QEvent::KeyPress, keyCode, Qt::NoModifier); QKeyEvent keyEvent(QEvent::KeyPress, keyCode, Qt::NoModifier);
emit keyPressedSignal(&keyEvent); emit keyPressedSignal(&keyEvent);
emit keyPressedSignal(&keyEvent);
} else { } else {
_screenWindow->scrollBy( ScreenWindow::ScrollLines, lines ); _screenWindow->scrollBy( ScreenWindow::ScrollLines, lines );
_screenWindow->scrollCount(); _screenWindow->scrollCount();
updateImage(); updateImage();
} }
} else {
int charLine;
int charColumn;
getCharacterPosition(position, charLine, charColumn);
emit mouseSignal(lines > 0 ? 5 : 4,
charColumn + 1,
charLine + 1,
0);
} }
} }

View File

@ -312,8 +312,6 @@ public slots:
void setColorScheme(const QString &name); void setColorScheme(const QString &name);
QStringList availableColorSchemes(); QStringList availableColorSchemes();
void scrollWheel(qreal x, qreal y, int lines);
void scrollScreenWindow(enum ScreenWindow::RelativeScrollMode mode, int amount); void scrollScreenWindow(enum ScreenWindow::RelativeScrollMode mode, int amount);
void setUsesMouse(bool usesMouse); void setUsesMouse(bool usesMouse);
@ -481,6 +479,7 @@ protected:
Q_INVOKABLE void mouseReleaseEvent(QPoint position, int but, int mod); Q_INVOKABLE void mouseReleaseEvent(QPoint position, int but, int mod);
Q_INVOKABLE void mouseDoubleClickEvent(QPoint position, int but, int mod); Q_INVOKABLE void mouseDoubleClickEvent(QPoint position, int but, int mod);
Q_INVOKABLE void mouseMoveEvent(QPoint position, int but, int buts, int mod); Q_INVOKABLE void mouseMoveEvent(QPoint position, int but, int buts, int mod);
Q_INVOKABLE void scrollWheelEvent(QPoint position, int lines);
//void mouseReleaseEvent( QMouseEvent* ); //void mouseReleaseEvent( QMouseEvent* );
//void mouseMoveEvent( QMouseEvent* ); //void mouseMoveEvent( QMouseEvent* );