Bug 225783 - Use tilt wheel over tray area icon for jump to previous/next track
Summary: Use tilt wheel over tray area icon for jump to previous/next track
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-07 02:45 UTC by Frank Steinmetzger
Modified: 2010-02-10 01:57 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Steinmetzger 2010-02-07 02:45:50 UTC
Version:           2.2-GIT (using KDE 4.3.5)
Compiler:          gcc-4.3.4 
OS:                Linux
Installed from:    Gentoo Packages

Wheel up/down information is used for volume up/down. Many mice nowadays can also scroll to the side using a tilt wheel. Laptop users can do this by moving the finger along the bottom edge.
At the moment, scrolling to the left and right over the tray icon cause a volume increase/decrease respectively. It would be cool if that could be used instead to jump to the previous/next track in the playlist.
Comment 1 Kevin Funk 2010-02-08 11:34:19 UTC
commit 5fa73fa2074f0b73f324ba97aba725d815a13737
Author: Kevin Funk <krf@electrostorm.net>
Date:   Mon Feb 8 11:31:16 2010 +0100

    Make it possible to go to next/previous track with horizontal mouse
    wheel button on TrayIcon.
    BUG: 225783

diff --git a/ChangeLog b/ChangeLog
index 882e288..a7343a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@ Amarok ChangeLog
 
 VERSION 2.2.3
   FEATURES:
+    * Make it possible to go to next/previous track with horizontal mouse
+      wheel button on TrayIcon. (BR 225783)
     * New main toolbar with completely redesigned look and new features.
       Contributed by Thomas Luebking <thomas.luebking@web.de>.
     * Podcasts can now be grouped per provider like iPod Podcasts, Local Podcasts,
diff --git a/src/TrayIcon.cpp b/src/TrayIcon.cpp
index dee9847..ed8b0ad 100644
--- a/src/TrayIcon.cpp
+++ b/src/TrayIcon.cpp
@@ -3,7 +3,7 @@
  * Copyright (c) 2003 Max Howell <max.howell@methylblue.com>                            *
  * Copyright (c) 2004 Enrico Ros <eros.kde@email.it>                                    *
  * Copyright (c) 2006 Ian Monroe <ian@monroe.nu>                                        *
- * Copyright (c) 2009 Kevin Funk <krf@electrostorm.net>                                 *
+ * Copyright (c) 2009,2010 Kevin Funk <krf@electrostorm.net>                            *
  * Copyright (c) 2009 Mark Kretschmann <kretschmann@kde.org>                            *
  *                                                                                      *
  * This program is free software; you can redistribute it and/or modify it under        *
@@ -61,6 +61,8 @@ namespace Amarok
     }
 }
 
+QTime Amarok::TrayIcon::lastEventCall = QTime();
+
 Amarok::TrayIcon::TrayIcon( QWidget *playerWidget )
         : KSystemTrayIcon( playerWidget )
         , EngineObserver( The::engineController() )
@@ -72,11 +74,6 @@ Amarok::TrayIcon::TrayIcon( QWidget *playerWidget )
     PERF_LOG( "Beginning TrayIcon Constructor" );
     KActionCollection* const ac = Amarok::actionCollection();
 
-    //seems to be necessary
-    /*QAction *quit = actionCollection()->action( "file_quit" );
-    quit->disconnect();
-    connect( quit, SIGNAL(activated()), kapp, SLOT(quit()) );*/
-
     PERF_LOG( "Before adding actions" );
 
     #ifdef Q_WS_MAC
@@ -233,11 +230,17 @@ Amarok::TrayIcon::event( QEvent *e )
 
     case QEvent::Wheel:
         #define e static_cast<QWheelEvent*>(e)
-        if( e->modifiers() == Qt::ControlModifier )
+        if( e->modifiers() == Qt::ControlModifier || e->orientation() == Qt::Horizontal )
         {
-            const bool up = e->delta() > 0;
-            if( up ) The::playlistActions()->back();
-            else     The::playlistActions()->next();
+            if (lastEventCall.elapsed() < 500) // block event for some ms
+                break;
+
+            lastEventCall.restart();
+
+            if( e->delta() > 0 ) // up
+                The::playlistActions()->back();
+            else
+                The::playlistActions()->next();
             break;
         }
         else if( e->modifiers() == Qt::ShiftModifier )
diff --git a/src/TrayIcon.h b/src/TrayIcon.h
index e7faaa3..6bf5436 100644
--- a/src/TrayIcon.h
+++ b/src/TrayIcon.h
@@ -23,11 +23,12 @@
 #include "meta/Meta.h"
 #include "SmartPointerList.h"
 
-#include <QPointer>
-
 #include <KAction>
 #include <KSystemTrayIcon> //baseclass
 
+#include <QPointer>
+#include <QTime>
+
 class QEvent;
 class App;
 
@@ -77,6 +78,8 @@ private:
     QPixmap m_playOverlay, m_pauseOverlay;
     SmartPointerList<QAction> m_extraActions;
     QPointer<QAction> m_separator;
+
+    static QTime lastEventCall;
 };
 
 }
Comment 2 Kevin Funk 2010-02-10 01:57:26 UTC
commit 5fa73fa2074f0b73f324ba97aba725d815a13737
Author: Kevin Funk <krf@electrostorm.net>
Date:   Mon Feb 8 11:31:16 2010 +0100

    Make it possible to go to next/previous track with horizontal mouse
    wheel button on TrayIcon.
    BUG: 225783

diff --git a/ChangeLog b/ChangeLog
index 882e288..a7343a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@ Amarok ChangeLog
 
 VERSION 2.2.3
   FEATURES:
+    * Make it possible to go to next/previous track with horizontal mouse
+      wheel button on TrayIcon. (BR 225783)
     * New main toolbar with completely redesigned look and new features.
       Contributed by Thomas Luebking <thomas.luebking@web.de>.
     * Podcasts can now be grouped per provider like iPod Podcasts, Local Podcasts,
diff --git a/src/TrayIcon.cpp b/src/TrayIcon.cpp
index dee9847..ed8b0ad 100644
--- a/src/TrayIcon.cpp
+++ b/src/TrayIcon.cpp
@@ -3,7 +3,7 @@
  * Copyright (c) 2003 Max Howell <max.howell@methylblue.com>                            *
  * Copyright (c) 2004 Enrico Ros <eros.kde@email.it>                                    *
  * Copyright (c) 2006 Ian Monroe <ian@monroe.nu>                                        *
- * Copyright (c) 2009 Kevin Funk <krf@electrostorm.net>                                 *
+ * Copyright (c) 2009,2010 Kevin Funk <krf@electrostorm.net>                            *
  * Copyright (c) 2009 Mark Kretschmann <kretschmann@kde.org>                            *
  *                                                                                      *
  * This program is free software; you can redistribute it and/or modify it under        *
@@ -61,6 +61,8 @@ namespace Amarok
     }
 }
 
+QTime Amarok::TrayIcon::lastEventCall = QTime();
+
 Amarok::TrayIcon::TrayIcon( QWidget *playerWidget )
         : KSystemTrayIcon( playerWidget )
         , EngineObserver( The::engineController() )
@@ -72,11 +74,6 @@ Amarok::TrayIcon::TrayIcon( QWidget *playerWidget )
     PERF_LOG( "Beginning TrayIcon Constructor" );
     KActionCollection* const ac = Amarok::actionCollection();
 
-    //seems to be necessary
-    /*QAction *quit = actionCollection()->action( "file_quit" );
-    quit->disconnect();
-    connect( quit, SIGNAL(activated()), kapp, SLOT(quit()) );*/
-
     PERF_LOG( "Before adding actions" );
 
     #ifdef Q_WS_MAC
@@ -233,11 +230,17 @@ Amarok::TrayIcon::event( QEvent *e )
 
     case QEvent::Wheel:
         #define e static_cast<QWheelEvent*>(e)
-        if( e->modifiers() == Qt::ControlModifier )
+        if( e->modifiers() == Qt::ControlModifier || e->orientation() == Qt::Horizontal )
         {
-            const bool up = e->delta() > 0;
-            if( up ) The::playlistActions()->back();
-            else     The::playlistActions()->next();
+            if (lastEventCall.elapsed() < 500) // block event for some ms
+                break;
+
+            lastEventCall.restart();
+
+            if( e->delta() > 0 ) // up
+                The::playlistActions()->back();
+            else
+                The::playlistActions()->next();
             break;
         }
         else if( e->modifiers() == Qt::ShiftModifier )
diff --git a/src/TrayIcon.h b/src/TrayIcon.h
index e7faaa3..6bf5436 100644
--- a/src/TrayIcon.h
+++ b/src/TrayIcon.h
@@ -23,11 +23,12 @@
 #include "meta/Meta.h"
 #include "SmartPointerList.h"
 
-#include <QPointer>
-
 #include <KAction>
 #include <KSystemTrayIcon> //baseclass
 
+#include <QPointer>
+#include <QTime>
+
 class QEvent;
 class App;
 
@@ -77,6 +78,8 @@ private:
     QPixmap m_playOverlay, m_pauseOverlay;
     SmartPointerList<QAction> m_extraActions;
     QPointer<QAction> m_separator;
+
+    static QTime lastEventCall;
 };
 
 }