diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-09-18 18:33:23 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-09-18 18:33:23 +0000 |
| commit | a09f7ea6f41f0744e9d34361aa146652e94cf74a (patch) | |
| tree | e3e14fc23d1ee7035fd08353bea1daecea0669f1 | |
| parent | 136f634c6c334fe1f1b77c9640fe49c8204d011f (diff) | |
| download | qmmp-a09f7ea6f41f0744e9d34361aa146652e94cf74a.tar.gz qmmp-a09f7ea6f41f0744e9d34361aa146652e94cf74a.tar.bz2 qmmp-a09f7ea6f41f0744e9d34361aa146652e94cf74a.zip | |
text scroller: added scrolling with mouse (patch by Erik Ölsar)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1233 90c681e8-e032-0410-971d-27865f9a5e38
| -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; |
