]> git.sesse.net Git - vlc/commitdiff
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 5073fe115ba8ad6a977b74ebc7b5e9cb6a6c6d77..7aa960c5464879f8fb52460e9b6a68e4ed82f579 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;
     }