Qt: simplification of the special volume slider. Any click will show it.
authorJean-Baptiste Kempf <jb@videolan.org>
Sat, 7 Feb 2009 19:56:15 +0000 (20:56 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 7 Feb 2009 19:57:54 +0000 (20:57 +0100)
modules/gui/qt4/components/controller_widget.cpp

index 5073fe1..7aa960c 100644 (file)
@@ -37,6 +37,7 @@
 #include <QSpinBox>
 #include <QMenu>
 #include <QWidgetAction>
+#include <QMouseEvent>
 
 SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
                           bool b_shiny, bool b_special )
@@ -66,7 +67,7 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
         /* Special view, click on button shows the slider */
         b_shiny = false;
 
-        setContextMenuPolicy ( Qt::CustomContextMenu );
+        volMuteLabel->installEventFilter( this );
 
         QFrame *volumeControlWidget = new QFrame;
         subLayout = new QVBoxLayout( volumeControlWidget );
@@ -77,11 +78,6 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
         widgetAction->setDefaultWidget( volumeControlWidget );
         volumeMenu->addAction( widgetAction );
 
-        /* Speed Label behaviour:
-           - right click gives the vertical speed slider */
-        CONNECT( this, customContextMenuRequested( QPoint ),
-                this, showVolumeMenu( QPoint ) );
-
     }
 
     /* And add the label */
@@ -138,9 +134,17 @@ bool SoundWidget::eventFilter( QObject *obj, QEvent *e )
     VLC_UNUSED( obj );
     if (e->type() == QEvent::MouseButtonPress  )
     {
-        aout_VolumeMute( p_intf, NULL );
-        audio_volume_t i_volume;
-        aout_VolumeGet( p_intf, &i_volume );
+        if( volumeSlider->orientation() ==  Qt::Vertical )
+        {
+            QMouseEvent *event = static_cast<QMouseEvent*>(e);
+            showVolumeMenu( event->pos() );
+        }
+        else
+        {
+            aout_VolumeMute( p_intf, NULL );
+            audio_volume_t i_volume;
+            aout_VolumeGet( p_intf, &i_volume );
+        }
         e->accept();
         return true;
     }