diff options
| -rw-r--r-- | src/ui/textscroller.cpp | 29 | ||||
| -rw-r--r-- | src/ui/textscroller.h | 4 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/ui/textscroller.cpp b/src/ui/textscroller.cpp index 577403ba7..6e7687c7e 100644 --- a/src/ui/textscroller.cpp +++ b/src/ui/textscroller.cpp @@ -181,7 +181,34 @@ void TextScroller::mousePressEvent (QMouseEvent *e) { if (e->button() == Qt::RightButton) m_menu->exec(e->globalPos()); - else + else if (e->button() == Qt::LeftButton && m_autoscroll) { + m_timer->stop(); + press_pos = e->x() - (x + 154); + m_pressing = TRUE; + } else QWidget::mousePressEvent(e); } +void TextScroller::mouseReleaseEvent (QMouseEvent *e) +{ + if (e->button() == Qt::RightButton) + m_menu->exec(e->globalPos()); + else if (e->button() == Qt::LeftButton && m_autoscroll) { + m_timer->start(); + m_pressing = FALSE; + } else + QWidget::mouseReleaseEvent(e); +} + +void TextScroller::mouseMoveEvent (QMouseEvent *e) +{ + if (m_pressing) { + int bound = m_metrics->width (m_scrollText) + 15 - 1; + x = (e->x() - press_pos) % bound; + if (x < 0) + x += bound; + x = x - bound - 154; + update(); + } else + QWidget::mouseMoveEvent(e); +} diff --git a/src/ui/textscroller.h b/src/ui/textscroller.h index bab7b5998..895796ca1 100644 --- a/src/ui/textscroller.h +++ b/src/ui/textscroller.h @@ -57,8 +57,12 @@ protected: void showEvent (QShowEvent *); void paintEvent (QPaintEvent *); void mousePressEvent (QMouseEvent *); + void mouseReleaseEvent (QMouseEvent *); + void mouseMoveEvent (QMouseEvent *); private: + bool m_pressing; + int press_pos; bool m_update; static TextScroller *pointer; QPixmap m_pixmap; |
