]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/extended_panels.cpp
Replace vlc_bool_t by bool, VLC_TRUE by true and VLC_FALSE by false.
[vlc] / modules / gui / qt4 / components / extended_panels.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 02909de..0061ee7
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * extended_panels.cpp : Extended controls panels
  ****************************************************************************
- * Copyright ( C ) 2006-2007 the VideoLAN team
+ * Copyright (C) 2006-2007 the VideoLAN team
  * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
@@ -37,6 +37,7 @@
 #include "dialogs/preferences.hpp"
 #include "dialogs_provider.hpp"
 #include "qt4.hpp"
+#include "input_manager.hpp"
 
 #include "../../audio_filter/equalizer_presets.h"
 #include <vlc_aout.h>
@@ -44,8 +45,6 @@
 #include <vlc_vout.h>
 #include <vlc_osd.h>
 
-#include <iostream>
-#include <string.h>
 
 #if 0
 class ConfClickHandler : public QObject
@@ -92,10 +91,10 @@ QString OptionFromWidgetName( QObject *obj )
     return option;
 }
 
-ExtVideo::ExtVideo( intf_thread_t *_p_intf, QWidget *_parent ) :
-                           QWidget( _parent ) , p_intf( _p_intf )
+ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
+                           p_intf( _p_intf )
 {
-    ui.setupUi( this );
+    ui.setupUi( _parent );
 
 #define SETUP_VFILTER( widget ) \
     { \
@@ -184,6 +183,11 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QWidget *_parent ) :
     SETUP_VFILTER_OPTION( wallRowsSpin, valueChanged( int ) )
     SETUP_VFILTER_OPTION( wallColsSpin, valueChanged( int ) )
 
+    SETUP_VFILTER( panoramix )
+    SETUP_VFILTER_OPTION( panoramixRowsSpin, valueChanged( int ) )
+    SETUP_VFILTER_OPTION( panoramixColsSpin, valueChanged( int ) )
+
+
     SETUP_VFILTER( erase )
     SETUP_VFILTER_OPTION( eraseMaskText, editingFinished() )
     SETUP_VFILTER_OPTION( eraseYSpin, valueChanged( int ) )
@@ -201,15 +205,36 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QWidget *_parent ) :
 
 #undef SETUP_VFILTER
 #undef SETUP_VFILTER_OPTION
+
+    CONNECT( ui.cropTopPx, valueChanged( int ), this, cropChange() );
+    CONNECT( ui.cropBotPx, valueChanged( int ), this, cropChange() );
+    CONNECT( ui.cropLeftPx, valueChanged( int ), this, cropChange() );
+    CONNECT( ui.cropRightPx, valueChanged( int ), this, cropChange() );
+    CONNECT( ui.topBotCropSync, toggled( bool ),
+             ui.cropBotPx, setDisabled( bool ) );
+    CONNECT( ui.leftRightCropSync, toggled( bool ),
+             ui.cropRightPx, setDisabled( bool ) );
 }
 
 ExtVideo::~ExtVideo()
 {
 }
 
-void ExtVideo::ChangeVFiltersString( char *psz_name, vlc_bool_t b_add )
+void ExtVideo::cropChange()
+{
+    p_vout = ( vout_thread_t * )vlc_object_find( p_intf,
+                                VLC_OBJECT_VOUT, FIND_CHILD );
+    if( p_vout )
+    {
+        var_SetInteger( p_vout, "crop-top", ui.cropTopPx->value() );
+        var_SetInteger( p_vout, "crop-bottom", ui.cropBotPx->value() );
+        var_SetInteger( p_vout, "crop-left", ui.cropLeftPx->value() );
+        var_SetInteger( p_vout, "crop-right", ui.cropRightPx->value() );
+    }
+}
+
+void ExtVideo::ChangeVFiltersString( char *psz_name, bool b_add )
 {
-    vout_thread_t *p_vout;
     char *psz_parser, *psz_string;
     const char *psz_filter_type;
 
@@ -253,8 +278,9 @@ void ExtVideo::ChangeVFiltersString( char *psz_name, vlc_bool_t b_add )
         if( !psz_parser )
         {
             psz_parser = psz_string;
-            asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s",
-                            psz_string, psz_name );
+            if( asprintf( &psz_string, ( *psz_string ) ? "%s:%s" : "%s%s",
+                            psz_string, psz_name ) == -1 )
+                return;
             free( psz_parser );
         }
         else
@@ -332,7 +358,7 @@ void ExtVideo::initComboBoxItems( QObject *widget )
     if( !combobox ) return;
     QString option = OptionFromWidgetName( widget );
     module_config_t *p_item = config_FindConfig( VLC_OBJECT( p_intf ),
-                                                 option.toStdString().c_str() );
+                                                 qtu( option ) );
     if( p_item )
     {
         int i_type = p_item->i_type & CONFIG_ITEM;
@@ -350,7 +376,7 @@ void ExtVideo::initComboBoxItems( QObject *widget )
     else
     {
         msg_Err( p_intf, "Couldn't find option \"%s\".",
-                 option.toStdString().c_str() );
+                 qtu( option ) );
     }
 }
 
@@ -363,7 +389,7 @@ void ExtVideo::setWidgetValue( QObject *widget )
 
     vlc_object_t *p_obj = ( vlc_object_t * )
         vlc_object_find_name( p_intf->p_libvlc,
-                              module.toStdString().c_str(),
+                              qtu( module ),
                               FIND_CHILD );
     int i_type;
     vlc_value_t val;
@@ -373,27 +399,27 @@ void ExtVideo::setWidgetValue( QObject *widget )
 #if 0
         msg_Dbg( p_intf,
                  "Module instance %s not found, looking in config values.",
-                 module.toStdString().c_str() );
+                 qtu( module ) );
 #endif
-        i_type = config_GetType( p_intf, option.toStdString().c_str() ) & 0xf0;
+        i_type = config_GetType( p_intf, qtu( option ) ) & 0xf0;
         switch( i_type )
         {
             case VLC_VAR_INTEGER:
             case VLC_VAR_BOOL:
-                val.i_int = config_GetInt( p_intf, option.toStdString().c_str() );
+                val.i_int = config_GetInt( p_intf, qtu( option ) );
                 break;
             case VLC_VAR_FLOAT:
-                val.f_float = config_GetFloat( p_intf, option.toStdString().c_str() );
+                val.f_float = config_GetFloat( p_intf, qtu( option ) );
                 break;
             case VLC_VAR_STRING:
-                val.psz_string = config_GetPsz( p_intf, option.toStdString().c_str() );
+                val.psz_string = config_GetPsz( p_intf, qtu( option ) );
                 break;
         }
     }
     else
     {
-        i_type = var_Type( p_obj, option.toStdString().c_str() ) & 0xf0;
-        var_Get( p_obj, option.toStdString().c_str(), &val );
+        i_type = var_Type( p_obj, qtu( option ) ) & 0xf0;
+        var_Get( p_obj, qtu( option ), &val );
         vlc_object_release( p_obj );
     }
 
@@ -443,8 +469,8 @@ void ExtVideo::setWidgetValue( QObject *widget )
     else
         msg_Err( p_intf,
                  "Module %s's %s variable is of an unsupported type ( %d )",
-                 module.toStdString().c_str(),
-                 option.toStdString().c_str(),
+                 qtu( module ),
+                 qtu( option ),
                  i_type );
 }
 
@@ -457,21 +483,21 @@ void ExtVideo::updateFilterOptions()
 
     vlc_object_t *p_obj = ( vlc_object_t * )
         vlc_object_find_name( p_intf->p_libvlc,
-                              module.toStdString().c_str(),
+                              qtu( module ),
                               FIND_CHILD );
     if( !p_obj )
     {
-        msg_Err( p_intf, "Module %s not found.", module.toStdString().c_str() );
+        msg_Err( p_intf, "Module %s not found.", qtu( module ) );
         return;
     }
 
-    int i_type = var_Type( p_obj, option.toStdString().c_str() );
+    int i_type = var_Type( p_obj, qtu( option ) );
     bool b_is_command = ( i_type & VLC_VAR_ISCOMMAND );
     if( !b_is_command )
     {
         msg_Warn( p_intf, "Module %s's %s variable isn't a command. You'll need to restart the filter to take change into account.",
-                 module.toStdString().c_str(),
-                 option.toStdString().c_str() );
+                 qtu( module ),
+                 qtu( option ) );
         /* FIXME: restart automatically somewhere near the end of this function */
     }
 
@@ -496,13 +522,13 @@ void ExtVideo::updateFilterOptions()
         else if( lineedit ) i_int = lineedit->text().toInt( NULL,16 );
         else if( combobox ) i_int = combobox->itemData( combobox->currentIndex() ).toInt();
         else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
-        config_PutInt( p_intf, option.toStdString().c_str(), i_int );
+        config_PutInt( p_intf, qtu( option ), i_int );
         if( b_is_command )
         {
             if( i_type == VLC_VAR_INTEGER )
-                var_SetInteger( p_obj, option.toStdString().c_str(), i_int );
+                var_SetInteger( p_obj, qtu( option ), i_int );
             else
-                var_SetBool( p_obj, option.toStdString().c_str(), i_int );
+                var_SetBool( p_obj, qtu( option ), i_int );
         }
     }
     else if( i_type == VLC_VAR_FLOAT )
@@ -513,27 +539,27 @@ void ExtVideo::updateFilterOptions()
         else if( doublespinbox ) f_float = doublespinbox->value();
         else if( lineedit ) f_float = lineedit->text().toDouble();
         else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
-        config_PutFloat( p_intf, option.toStdString().c_str(), f_float );
+        config_PutFloat( p_intf, qtu( option ), f_float );
         if( b_is_command )
-            var_SetFloat( p_obj, option.toStdString().c_str(), f_float );
+            var_SetFloat( p_obj, qtu( option ), f_float );
     }
     else if( i_type == VLC_VAR_STRING )
     {
         char *psz_string = NULL;
         if( lineedit ) psz_string = strdup( qtu( lineedit->text() ) );
         else if( combobox ) psz_string = strdup( qtu( combobox->itemData(
-                                         combobox->currentIndex() ).toString() ) );
+                                       combobox->currentIndex() ).toString() ) );
         else msg_Warn( p_intf, "Oops %s %s %d", __FILE__, __func__, __LINE__ );
-        config_PutPsz( p_intf, option.toStdString().c_str(), psz_string );
+        config_PutPsz( p_intf, qtu( option ), psz_string );
         if( b_is_command )
-            var_SetString( p_obj, option.toStdString().c_str(), psz_string );
+            var_SetString( p_obj, qtu( option ), psz_string );
         free( psz_string );
     }
     else
         msg_Err( p_intf,
                  "Module %s's %s variable is of an unsupported type ( %d )",
-                 module.toStdString().c_str(),
-                 option.toStdString().c_str(),
+                 qtu( module ),
+                 qtu( option ),
                  i_type );
 
     vlc_object_release( p_obj );
@@ -598,7 +624,6 @@ void ExtV4l2::Refresh( void )
     }
     if( p_obj )
     {
-        msg_Dbg( p_intf, "Found v4l2 instance" );
         vlc_value_t val, text, name;
         int i_ret = var_Change( p_obj, "controls", VLC_VAR_GETCHOICES,
                                 &val, &text );
@@ -722,7 +747,6 @@ void ExtV4l2::Refresh( void )
         msg_Dbg( p_intf, "Couldn't find v4l2 instance" );
         ui.help->show();
     }
-
 }
 
 void ExtV4l2::ValueChange( bool value )
@@ -736,7 +760,7 @@ void ExtV4l2::ValueChange( int value )
     vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( p_intf, "v4l2", FIND_ANYWHERE );
     if( p_obj )
     {
-        char *psz_var = strdup( s->objectName().toStdString().c_str() );
+        char *psz_var = strdup( qtu( s->objectName() ) );
         int i_type = var_Type( p_obj, psz_var );
         switch( i_type & VLC_VAR_TYPE )
         {
@@ -851,11 +875,11 @@ void Equalizer::enable()
 {
     bool en = ui.enableCheck->isChecked();
     aout_EnableFilter( VLC_OBJECT( p_intf ), "equalizer",
-                       en ? VLC_TRUE : VLC_FALSE );
+                       en ? true : false );
 //    aout_EnableFilter( VLC_OBJECT( p_intf ), "upmixer",
-//                       en ? VLC_TRUE : VLC_FALSE );
+//                       en ? true : false );
 //     aout_EnableFilter( VLC_OBJECT( p_intf ), "vsurround",
-//                       en ? VLC_TRUE : VLC_FALSE );
+//                       en ? true : false );
      enable( en );
 }
 
@@ -874,7 +898,7 @@ void Equalizer::set2Pass()
 {
     aout_instance_t *p_aout= ( aout_instance_t * )vlc_object_find( p_intf,
                                  VLC_OBJECT_AOUT, FIND_ANYWHERE );
-    vlc_bool_t b_2p = ui.eq2PassCheck->isChecked();
+    bool b_2p = ui.eq2PassCheck->isChecked();
 
     if( p_aout == NULL )
         config_PutInt( p_intf, "equalizer-2pass", b_2p );
@@ -884,7 +908,7 @@ void Equalizer::set2Pass()
         config_PutInt( p_intf, "equalizer-2pass", b_2p );
         for( int i = 0; i < p_aout->i_nb_inputs; i++ )
         {
-            p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
+            p_aout->pp_inputs[i]->b_restart = true;
         }
         vlc_object_release( p_aout );
     }
@@ -1075,7 +1099,7 @@ Spatializer::Spatializer( intf_thread_t *_p_intf, QWidget *_parent ) :
     }
     else
     {
-        psz_af = config_GetPsz( p_aout, "audio-filter" );
+        psz_af = config_GetPsz( p_intf, "audio-filter" );
         for( int i = 0; i < NUM_SP_CTRL ; i++ )
         {
             controlVars[i] = config_GetFloat( p_intf, psz_control_names[i] );
@@ -1096,7 +1120,7 @@ void Spatializer::enable()
 {
     bool en = enableCheck->isChecked();
     aout_EnableFilter( VLC_OBJECT( p_intf ), "spatializer",
-            en ? VLC_TRUE : VLC_FALSE );
+            en ? true : false );
     enable( en );
 }
 
@@ -1156,6 +1180,180 @@ void Spatializer::addCallbacks( aout_instance_t *p_aout )
     //    var_AddCallback( p_aout, "Spatializer-preamp", EqzCallback, this );
 }
 
+#include <QToolButton>
+#include <QGridLayout>
+
+SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent ) :
+                            QWidget( _parent ) , p_intf( _p_intf )
+{
+    QGroupBox *AVBox, *subsBox;
+
+    QToolButton *moinsAV, *plusAV;
+    QToolButton *moinssubs, *plussubs;
+    QToolButton *moinssubSpeed, *plussubSpeed;
+
+    QToolButton *updateButton;
+
+    QGridLayout *mainLayout = new QGridLayout( this );
+
+    /* AV sync */
+    AVBox = new QGroupBox( qtr( "Audio/Video" ) );
+    QGridLayout *AVLayout = new QGridLayout( AVBox );
+
+    moinsAV = new QToolButton;
+    moinsAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
+    moinsAV->setAutoRaise( true );
+    moinsAV->setText( "-" );
+    AVLayout->addWidget( moinsAV, 0, 1, 1, 1 );
+
+    plusAV = new QToolButton;
+    plusAV->setToolButtonStyle( Qt::ToolButtonTextOnly );
+    plusAV->setAutoRaise( true );
+    plusAV->setText( "+" );
+    AVLayout->addWidget( plusAV, 0, 3, 1, 1 );
+
+    QLabel *AVLabel = new QLabel;
+    AVLabel->setText( qtr( "Advance of audio over video:" ) );
+    AVLayout->addWidget( AVLabel, 0, 0, 1, 1 );
+
+    AVSpin = new QDoubleSpinBox;
+    AVSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+    AVSpin->setDecimals( 3 );
+    AVSpin->setMinimum( -100 );
+    AVSpin->setMaximum( 100 );
+    AVSpin->setSingleStep( 0.1 );
+    AVSpin->setToolTip( qtr( "A positive value means that\n"
+                             "the audio is ahead of the video" ) );
+    AVSpin->setSuffix( "s" );
+    AVLayout->addWidget( AVSpin, 0, 2, 1, 1 );
+    mainLayout->addWidget( AVBox, 1, 0, 1, 5 );
+
+
+    /* Subs */
+    subsBox = new QGroupBox( qtr( "Subtitles/Video" ) );
+    QGridLayout *subsLayout = new QGridLayout( subsBox );
+
+    moinssubs = new QToolButton;
+    moinssubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
+    moinssubs->setAutoRaise( true );
+    moinssubs->setText( "-" );
+    subsLayout->addWidget( moinssubs, 0, 1, 1, 1 );
+
+    plussubs = new QToolButton;
+    plussubs->setToolButtonStyle( Qt::ToolButtonTextOnly );
+    plussubs->setAutoRaise( true );
+    plussubs->setText( "+" );
+    subsLayout->addWidget( plussubs, 0, 3, 1, 1 );
+
+    QLabel *subsLabel = new QLabel;
+    subsLabel->setText( qtr( "Advance of subtitles over video:" ) );
+    subsLayout->addWidget( subsLabel, 0, 0, 1, 1 );
+
+    subsSpin = new QDoubleSpinBox;
+    subsSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+    subsSpin->setDecimals( 3 );
+    subsSpin->setMinimum( -100 );
+    subsSpin->setMaximum( 100 );
+    subsSpin->setSingleStep( 0.1 );
+    subsSpin->setToolTip( qtr( "A positive value means that\n"
+                             "the subtitles are ahead of the video" ) );
+    subsSpin->setSuffix( "s" );
+    subsLayout->addWidget( subsSpin, 0, 2, 1, 1 );
+
+
+    moinssubSpeed = new QToolButton;
+    moinssubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
+    moinssubSpeed->setAutoRaise( true );
+    moinssubSpeed->setText( "-" );
+    subsLayout->addWidget( moinssubSpeed, 1, 1, 1, 1 );
+
+    plussubSpeed = new QToolButton;
+    plussubSpeed->setToolButtonStyle( Qt::ToolButtonTextOnly );
+    plussubSpeed->setAutoRaise( true );
+    plussubSpeed->setText( "+" );
+    subsLayout->addWidget( plussubSpeed, 1, 3, 1, 1 );
+
+    QLabel *subSpeedLabel = new QLabel;
+    subSpeedLabel->setText( qtr( "Speed of the subtitles:" ) );
+    subsLayout->addWidget( subSpeedLabel, 1, 0, 1, 3 );
+
+    subSpeedSpin = new QDoubleSpinBox;
+    subSpeedSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
+    subSpeedSpin->setDecimals( 3 );
+    subSpeedSpin->setMinimum( 1 );
+    subSpeedSpin->setMaximum( 100 );
+    subSpeedSpin->setSingleStep( 0.2 );
+    subsLayout->addWidget( subSpeedSpin, 1, 2, 1, 1 );
+
+    mainLayout->addWidget( subsBox, 2, 0, 2, 5 );
+
+    updateButton = new QToolButton;
+    updateButton->setAutoRaise( true );
+    updateButton->setText( "u" );
+    updateButton->setToolTip( qtr( "Force update of the values in this dialog" ) );
+    mainLayout->addWidget( updateButton, 0, 4, 1, 1 );
+
+
+    /* Various Connects */
+    CONNECT( moinsAV, clicked(), AVSpin, stepDown () );
+    CONNECT( plusAV, clicked(), AVSpin, stepUp () );
+    CONNECT( moinssubs, clicked(), subsSpin, stepDown () );
+    CONNECT( plussubs, clicked(), subsSpin, stepUp () );
+    CONNECT( moinssubSpeed, clicked(), subSpeedSpin, stepDown () );
+    CONNECT( plussubSpeed, clicked(), subSpeedSpin, stepUp () );
+    CONNECT( AVSpin, valueChanged ( double ), this, advanceAudio( double ) ) ;
+    CONNECT( subsSpin, valueChanged ( double ), this, advanceSubs( double ) ) ;
+    CONNECT( subSpeedSpin, valueChanged ( double ),
+             this, adjustSubsSpeed( double ) );
+    BUTTONACT( updateButton, update() );
+
+    /* Set it */
+    update();
+}
+
+void SyncControls::update()
+{
+    int64_t i_delay;
+    if( THEMIM->getInput() )
+    {
+        i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
+        AVSpin->setValue( ( (double)i_delay ) / 1000000 );
+        i_delay = var_GetTime( THEMIM->getInput(), "audio-delay" );
+        subsSpin->setValue( ( (double)i_delay ) / 1000000 );
+        subSpeedSpin->setValue( var_GetFloat( THEMIM->getInput(), "sub-fps" ) );
+    }
+}
+
+void SyncControls::advanceAudio( double f_advance )
+{
+    if( THEMIM->getInput() )
+    {
+        int64_t i_delay = var_GetTime( THEMIM->getInput(), "audio-delay" );
+        i_delay += f_advance * 1000000;
+        var_SetTime( THEMIM->getInput(), "audio-delay", i_delay );
+        msg_Dbg( p_intf, "I am advancing Audio %d", f_advance );
+    }
+}
+
+void SyncControls::advanceSubs( double f_advance )
+{
+    if( THEMIM->getInput() )
+    {
+        int64_t i_delay = var_GetTime( THEMIM->getInput(), "spu-delay" );
+        i_delay += f_advance * 1000000;
+        var_SetTime( THEMIM->getInput(), "spu-delay", i_delay );
+        msg_Dbg( p_intf, "I am advancing subtitles %d", f_advance );
+    }
+}
+
+void SyncControls::adjustSubsSpeed( double f_fps )
+{
+    if( THEMIM->getInput() )
+    {
+        var_SetFloat( THEMIM->getInput(), "sub-fps", f_fps );
+    }
+}
+
 /**********************************************************************
  * Video filters / Adjust
  **********************************************************************/