[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [PATCH] Makes mouse wheel scrolls QTabBar/KTabBar
From:       "=?UTF-8?Q?Ho=C3=A0ng_=C4=90=E1=BB=A9c_Hi=E1=BA=BFu?=" <hieu.d.hoang () gmail ! com>
Date:       2007-09-24 2:16:36
Message-ID: 4f12b0dd0709231916m4579ad61k4866f8a4c86860d8 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (text/plain)]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 9/24/07, Hoà ng Äức Hiếu <hieu.d.hoang@gmail.com> wrote:
>
>   robertknight pointed out one problem with the KTabBar patch. This
> scrolling might intefere with slots listening to the wheelDelta(
> event->delta() ) signal.
>

  I have just realized that my patches scroll in the different way
from what Konsole 3 and other GTK+ apps are doing.

  I have also improved the wording in the documentation of QTabBar::wheelEvent.

  Sorry for the mess.

   Hiếu
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFG9x31h4dScvxKz04RAlXxAKDSr55sZGbtxHILQec2wEobTi03RQCgkGf9
d/7xoqF0UflvpDDr4c4Vjzo=
=vY43
-----END PGP SIGNATURE-----

["KTabBar-mouse-wheel-scroll.patch" (text/x-patch)]

Index: KDE/kdelibs/kdeui/widgets/ktabbar.cpp
===================================================================
--- KDE/kdelibs/kdeui/widgets/ktabbar.cpp	(revision 715948)
+++ KDE/kdelibs/kdeui/widgets/ktabbar.cpp	(working copy)
@@ -302,6 +302,25 @@
 {
   if ( event->orientation() == Qt::Horizontal )
     return;
+  if ( event->delta() < 0 ) {
+    if ( currentIndex() == count() - 1 ) {
+      setCurrentIndex( 0 );
+    }
+    else {
+      setCurrentIndex( currentIndex() + 1 );
+    }
+  }
+  else if ( event->delta() > 0 ) {
+    if ( currentIndex() == 0 ) {
+      setCurrentIndex( count() - 1 );
+    }
+    else {
+      setCurrentIndex( currentIndex() - 1 );
+    }
+  }
+  else {
+      QTabBar::wheelEvent( event );
+  }
 
   emit( wheelDelta( event->delta() ) );
 }

["QTabBar-mouse-wheel-scroll.patch" (text/x-patch)]

Index: qt-copy/src/gui/widgets/qtabbar.cpp
===================================================================
--- qt-copy/src/gui/widgets/qtabbar.cpp	(revision 716039)
+++ qt-copy/src/gui/widgets/qtabbar.cpp	(working copy)
@@ -1347,6 +1347,38 @@
         setCurrentIndex(i);
 }
 
+/*!
+    \fn void QTabBar::wheelEvent(QWheelEvent *e)
+
+    Scroll to tab with lower index when mouse wheel is scrolled forward.
+    Scroll to tab with higher index when mouse wheel is scrolled backward.
+    Wrap around currently doesn't work, no idea why
+*/
+void QTabBar::wheelEvent(QWheelEvent *e)
+{
+    Q_D(QTabBar);
+    if (e->delta() < 0) {
+        if (currentIndex() == count() - 1) {
+            setCurrentIndex(0);
+        }
+        else {
+     	    setCurrentIndex(currentIndex() + 1);
+        }
+    }
+    else if (e->delta() > 0) {
+        if (currentIndex() == 0) {
+            setCurrentIndex(count() - 1);
+        }
+        else {
+            setCurrentIndex(currentIndex() - 1);
+        }
+    }
+    else {
+        QWidget::wheelEvent(e);
+    }
+}
+
+
 /*!\reimp
  */
 void QTabBar::keyPressEvent(QKeyEvent *e)
Index: qt-copy/src/gui/widgets/qtabbar.h
===================================================================
--- qt-copy/src/gui/widgets/qtabbar.h	(revision 716039)
+++ qt-copy/src/gui/widgets/qtabbar.h	(working copy)
@@ -153,6 +153,7 @@
     void mousePressEvent (QMouseEvent *);
     void mouseMoveEvent (QMouseEvent *);
     void mouseReleaseEvent (QMouseEvent *);
+    void wheelEvent(QWheelEvent *);
     void keyPressEvent(QKeyEvent *);
     void changeEvent(QEvent *);
     void initStyleOption(QStyleOptionTab *option, int tabIndex) const;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic