]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/controller_widget.cpp
Qt: lower a bit the default sound slider.
[vlc] / modules / gui / qt4 / components / controller_widget.cpp
index 5073fe115ba8ad6a977b74ebc7b5e9cb6a6c6d77..f9761a78808a7a817090805d97a9e6761799eab5 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 #include "controller_widget.hpp"
+#include "controller.hpp"
 
 #include "input_manager.hpp"         /* Get notification of Volume Change */
 #include "util/input_slider.hpp"     /* SoundSlider */
@@ -37,6 +38,7 @@
 #include <QSpinBox>
 #include <QMenu>
 #include <QWidgetAction>
+#include <QMouseEvent>
 
 SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
                           bool b_shiny, bool b_special )
@@ -54,20 +56,18 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
     /* We might need a subLayout too */
     QVBoxLayout *subLayout;
 
+    volMuteLabel->installEventFilter( this );
+
     /* Normal View, click on icon mutes */
     if( !b_special )
     {
-        volMuteLabel->installEventFilter( this );
-        volumeMenu = NULL;
-        subLayout = NULL;
+        volumeMenu = NULL; subLayout = NULL;
     }
     else
     {
         /* Special view, click on button shows the slider */
         b_shiny = false;
 
-        setContextMenuPolicy ( Qt::CustomContextMenu );
-
         QFrame *volumeControlWidget = new QFrame;
         subLayout = new QVBoxLayout( volumeControlWidget );
         subLayout->setLayoutMargins( 4, 4, 4, 4, 4 );
@@ -76,12 +76,6 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
         QWidgetAction *widgetAction = new QWidgetAction( volumeControlWidget );
         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 */
@@ -113,7 +107,7 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
     if( b_special )
         subLayout->addWidget( volumeSlider );
     else
-        layout->addWidget( volumeSlider );
+        layout->addWidget( volumeSlider, 0, Qt::AlignBottom  );
 
     /* Set the volume from the config */
     volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
@@ -127,30 +121,6 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
     CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
 }
 
-void SoundWidget::showVolumeMenu( QPoint pos )
-{
-    volumeMenu->exec( QCursor::pos() - pos - QPoint( 0, volumeMenu->height()/2 )
-                          + QPoint( width(), height() /2) );
-}
-
-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 );
-        e->accept();
-        return true;
-    }
-    else
-    {
-        e->ignore();
-        return false;
-    }
-}
-
 void SoundWidget::updateVolume( int i_sliderVolume )
 {
     if( !b_my_volume )
@@ -178,7 +148,7 @@ void SoundWidget::updateVolume()
     /* Audio part */
     audio_volume_t i_volume;
     aout_VolumeGet( p_intf, &i_volume );
-    i_volume = ( i_volume *  VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
+    i_volume = ( ( i_volume + 1 ) *  VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
     int i_gauge = volumeSlider->value();
     b_my_volume = false;
     if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
@@ -189,13 +159,39 @@ void SoundWidget::updateVolume()
     }
 }
 
-void TeletextController::enableTeletextButtons( bool b_enabled )
+void SoundWidget::showVolumeMenu( QPoint pos )
 {
-    telexOn->setChecked( b_enabled );
-    telexTransparent->setEnabled( b_enabled );
-    telexPage->setEnabled( b_enabled );
+    volumeMenu->exec( QCursor::pos() - pos - QPoint( 0, volumeMenu->height()/2 )
+                          + QPoint( width(), height() /2) );
+}
+
+bool SoundWidget::eventFilter( QObject *obj, QEvent *e )
+{
+    VLC_UNUSED( obj );
+    if (e->type() == QEvent::MouseButtonPress  )
+    {
+        if( volumeSlider->orientation() ==  Qt::Vertical )
+        {
+            QMouseEvent *event = static_cast<QMouseEvent*>(e);
+            showVolumeMenu( event->pos() );
+        }
+        else
+        {
+            aout_VolumeMute( p_intf, NULL );
+        }
+        e->accept();
+        return true;
+    }
+    else
+    {
+        e->ignore();
+        return false;
+    }
 }
 
+/**
+ * Play Button
+ **/
 void PlayButton::updateButton( bool b_playing )
 {
     setIcon( b_playing ? QIcon( ":/pause_b" ) : QIcon( ":/play_b" ) );