]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/controller_widget.cpp
Kill stupid VOUT_SNAPSHOT control.
[vlc] / modules / gui / qt4 / components / controller_widget.cpp
index 21f95609b515ebc145f6ccfb5e29d5b0ec088edd..4b957847b020767700f5efb036d350cd81b0811b 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * Controller_widget.cpp : Controller Widget for the controllers
  ****************************************************************************
- * Copyright ( C ) 2006-2008 the VideoLAN team
+ * Copyright (C) 2006-2008 the VideoLAN team
  * $Id$
  *
  * Authors: Jean-Baptiste Kempf <jb@videolan.org>
 #include <QLabel>
 #include <QHBoxLayout>
 #include <QSpinBox>
+#include <QMenu>
+#include <QWidgetAction>
+#include <QMouseEvent>
 
 SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
-                          bool b_shiny )
-                         : b_my_volume( false ), QWidget( _parent )
+                          bool b_shiny, bool b_special )
+                         : QWidget( _parent ), b_my_volume( false ),
+                           p_intf( _p_intf)
 {
-    p_intf = _p_intf;
+    /* We need a layout for this widget */
     QHBoxLayout *layout = new QHBoxLayout( this );
     layout->setSpacing( 0 ); layout->setMargin( 0 );
-    hVolLabel = new VolumeClickHandler( p_intf, this );
 
+    /* We need a Label for the pix */
     volMuteLabel = new QLabel;
     volMuteLabel->setPixmap( QPixmap( ":/volume-medium" ) );
-    volMuteLabel->installEventFilter( hVolLabel );
+
+    /* We might need a subLayout too */
+    QVBoxLayout *subLayout;
+
+    volMuteLabel->installEventFilter( this );
+
+    /* Normal View, click on icon mutes */
+    if( !b_special )
+    {
+        volumeMenu = NULL; subLayout = NULL;
+    }
+    else
+    {
+        /* Special view, click on button shows the slider */
+        b_shiny = false;
+
+        QFrame *volumeControlWidget = new QFrame;
+        subLayout = new QVBoxLayout( volumeControlWidget );
+        subLayout->setLayoutMargins( 4, 4, 4, 4, 4 );
+        volumeMenu = new QMenu( this );
+
+        QWidgetAction *widgetAction = new QWidgetAction( volumeControlWidget );
+        widgetAction->setDefaultWidget( volumeControlWidget );
+        volumeMenu->addAction( widgetAction );
+    }
+
+    /* And add the label */
     layout->addWidget( volMuteLabel );
 
+    /* Slider creation: shiny or clean */
     if( b_shiny )
     {
         volumeSlider = new SoundSlider( this,
@@ -59,13 +90,23 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
     }
     else
     {
-        volumeSlider = new QSlider( this );
-        volumeSlider->setOrientation( Qt::Horizontal );
+        volumeSlider = new QSlider( NULL );
+        volumeSlider->setOrientation( b_special ? Qt::Vertical
+                                                : Qt::Horizontal );
+        volumeSlider->setMaximum( config_GetInt( p_intf, "qt-volume-complete" )
+                                  ? 400 : 200 );
+    }
+    if( volumeSlider->orientation() ==  Qt::Horizontal )
+    {
+        volumeSlider->setMaximumSize( QSize( 200, 40 ) );
+        volumeSlider->setMinimumSize( QSize( 85, 30 ) );
     }
-    volumeSlider->setMaximumSize( QSize( 200, 40 ) );
-    volumeSlider->setMinimumSize( QSize( 85, 30 ) );
+
     volumeSlider->setFocusPolicy( Qt::NoFocus );
-    layout->addWidget( volumeSlider );
+    if( b_special )
+        subLayout->addWidget( volumeSlider );
+    else
+        layout->addWidget( volumeSlider );
 
     /* Set the volume from the config */
     volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
@@ -79,6 +120,36 @@ 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  )
+    {
+        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;
+    }
+}
+
 void SoundWidget::updateVolume( int i_sliderVolume )
 {
     if( !b_my_volume )
@@ -117,19 +188,6 @@ void SoundWidget::updateVolume()
     }
 }
 
-void TeletextController::toggleTeletextTransparency( bool b_transparent )
-{
-    telexTransparent->setIcon( b_transparent ? QIcon( ":/tvtelx" )
-                                             : QIcon( ":/tvtelx-trans" ) );
-}
-
-void TeletextController::enableTeletextButtons( bool b_enabled )
-{
-    telexOn->setChecked( b_enabled );
-    telexTransparent->setEnabled( b_enabled );
-    telexPage->setEnabled( b_enabled );
-}
-
 void PlayButton::updateButton( bool b_playing )
 {
     setIcon( b_playing ? QIcon( ":/pause_b" ) : QIcon( ":/play_b" ) );
@@ -157,16 +215,4 @@ void AtoB_Button::setIcons( bool timeA, bool timeB )
     }
 }
 
-bool VolumeClickHandler::eventFilter( QObject *obj, QEvent *e )
-{
-    if (e->type() == QEvent::MouseButtonPress  )
-    {
-        aout_VolumeMute( p_intf, NULL );
-        audio_volume_t i_volume;
-        aout_VolumeGet( p_intf, &i_volume );
-//        m->updateVolume( i_volume *  VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
-        return true;
-    }
-    return false;
-}