]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/util/directslider.hpp
don't poll volume-change, change volumecontrol to use signal from
[vlc] / modules / gui / qt4 / util / directslider.hpp
index 9bc7c12a1922542888b46c688e8226ae1e731b99..ec713ebd72f49c2784d857a8c01cbb7d7da1750e 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * directslider.hpp : A slider that goes where you click
  ****************************************************************************
- * Copyright (C) 2000-2005 the VideoLAN team
- * $Id: wxwidgets.cpp 15731 2006-05-25 14:43:53Z zorglub $
+ * Copyright (C) 2006 the VideoLAN team
+ * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
  *          with precious help from ahigerd on #qt@freenode
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
 
 #ifndef _DIRECTSLIDER_H_
 #define _DIRECTSLIDER_H_
 
 #include <QSlider>
 #include <QMouseEvent>
+#include <QLayout>
 
 class DirectSlider : public QSlider
 {
@@ -37,13 +39,17 @@ public:
 
     void mousePressEvent(QMouseEvent* event)
     {
-        if(event->button() == Qt::LeftButton)
+        if( event->button() != Qt::LeftButton && event->button() != Qt::MidButton )
         {
-            int pos = (int)(minimum() + 
-                          (double)(event->x())/width()*(maximum()-minimum()) );
-            setSliderPosition( pos );
-            QSlider::mousePressEvent(event);
+            QSlider::mousePressEvent( event );
+            return;
         }
+
+        QMouseEvent newEvent( event->type(), event->pos(), event->globalPos(),
+                Qt::MouseButton( event->button() ^ Qt::LeftButton ^ Qt::MidButton ),
+                Qt::MouseButtons( event->buttons() ^ Qt::LeftButton ^ Qt::MidButton ),
+                event->modifiers() );
+        QSlider::mousePressEvent( &newEvent );
     }
 };
 #endif