From a09f7ea6f41f0744e9d34361aa146652e94cf74a Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Fri, 18 Sep 2009 18:33:23 +0000 Subject: text scroller: added scrolling with mouse (patch by Erik Ölsar) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1233 90c681e8-e032-0410-971d-27865f9a5e38 --- src/ui/textscroller.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/ui/textscroller.cpp') 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); +} -- cgit v1.2.3-13-gbd6f