]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/controller.cpp
Qt: Remove leading line break on modules prefs help text
[vlc] / modules / gui / qt4 / components / controller.cpp
index abbe9bd526018f26f6fcbd69dc5ac9cbfe37acef..6a75784ce33022120c10429c6af76bca9f0f4a5b 100644 (file)
 # include "config.h"
 #endif
 
-#include <vlc_vout.h>
-#include <vlc_keys.h>
+#include <vlc_vout.h>                       /* vout_thread_t for FSC */
 
+/* Widgets */
 #include "components/controller.hpp"
 #include "components/controller_widget.hpp"
 #include "components/interface_widgets.hpp"
+#include "util/buttons/DeckButtonsLayout.hpp"
+#include "util/buttons/BrowseButton.hpp"
+#include "util/buttons/RoundButton.hpp"
 
-#include "dialogs_provider.hpp" /* Opening Dialogs */
-#include "input_manager.hpp"
-#include "actions_manager.hpp"
+#include "dialogs_provider.hpp"                     /* Opening Dialogs */
+#include "actions_manager.hpp"                             /* *_ACTION */
 
-#include "util/input_slider.hpp" /* InputSlider */
-#include "util/customwidgets.hpp" /* qEventToKey */
+#include "util/input_slider.hpp"                         /* SeekSlider */
+#include "util/customwidgets.hpp"                       /* qEventToKey */
+
+#include "adapters/seekpoints.hpp"
 
-#include <QSpacerItem>
 #include <QToolButton>
 #include <QHBoxLayout>
 #include <QRegion>
@@ -63,6 +66,7 @@ AbstractController::AbstractController( intf_thread_t * _p_i, QWidget *_parent )
 {
     p_intf = _p_i;
     advControls = NULL;
+    buttonGroupLayout = NULL;
 
     /* Main action provider */
     toolbarActionsMapper = new QSignalMapper( this );
@@ -113,7 +117,7 @@ void AbstractController::parseAndCreate( const QString& config,
         QStringList list2 = list.at( i ).split( "-" );
         if( list2.size() < 1 )
         {
-            msg_Warn( p_intf, "Parsing error. Report this" );
+            msg_Warn( p_intf, "Parsing error 1. Please, report this." );
             continue;
         }
 
@@ -122,7 +126,7 @@ void AbstractController::parseAndCreate( const QString& config,
         buttonType_e i_type = (buttonType_e)list2.at( 0 ).toInt( &ok );
         if( !ok )
         {
-            msg_Warn( p_intf, "Parsing error 0. Please report this" );
+            msg_Warn( p_intf, "Parsing error 2. Please report this." );
             continue;
         }
 
@@ -131,13 +135,18 @@ void AbstractController::parseAndCreate( const QString& config,
             i_option = list2.at( 1 ).toInt( &ok );
             if( !ok )
             {
-                msg_Warn( p_intf, "Parsing error 1. Please report this" );
+                msg_Warn( p_intf, "Parsing error 3. Please, report this." );
                 continue;
-            }
-        }
+            }        }
 
         createAndAddWidget( controlLayout, -1, i_type, i_option );
     }
+
+    if( buttonGroupLayout )
+    {
+        controlLayout->addLayout( buttonGroupLayout );
+        buttonGroupLayout = NULL;
+    }
 }
 
 void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
@@ -145,23 +154,45 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
                                              buttonType_e i_type,
                                              int i_option )
 {
+    VLC_UNUSED( i_index ); // i_index should only be required for edition
+
+    /* Close the current buttonGroup if we have a special widget or a spacer */
+    if( buttonGroupLayout && i_type > BUTTON_MAX )
+    {
+        controlLayout->addLayout( buttonGroupLayout );
+        buttonGroupLayout = NULL;
+    }
+
     /* Special case for SPACERS, who aren't QWidgets */
     if( i_type == WIDGET_SPACER )
     {
-        controlLayout->insertSpacing( i_index, 12 );
-        return;
+        controlLayout->addSpacing( 12 );
     }
-
-    if(  i_type == WIDGET_SPACER_EXTEND )
+    else if(  i_type == WIDGET_SPACER_EXTEND )
     {
-        controlLayout->insertStretch( i_index, 12 );
-        return;
+        controlLayout->addStretch( 12 );
     }
+    else
+    {
+        /* Create the widget */
+        QWidget *widg = createWidget( i_type, i_option );
+        if( !widg ) return;
 
-    QWidget *widg = createWidget( i_type, i_option );
-    if( !widg ) return;
+        /* Buttons */
+        if( i_type < BUTTON_MAX )
+        {
+            if( !buttonGroupLayout )
+            {
+                buttonGroupLayout = new QHBoxLayout;
 
-    controlLayout->insertWidget( i_index, widg );
+            }
+            buttonGroupLayout->addWidget( widg );
+        }
+        else /* Special widgets */
+        {
+            controlLayout->addWidget( widg );
+        }
+    }
 }
 
 
@@ -194,7 +225,6 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
 
 QWidget *AbstractController::createWidget( buttonType_e button, int options )
 {
-
     bool b_flat  = options & WIDGET_FLAT;
     bool b_big   = options & WIDGET_BIG;
     bool b_shiny = options & WIDGET_SHINY;
@@ -209,7 +239,7 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         BUTTON_SET_BAR(  playButton );
         CONNECT_MAP_SET( playButton, PLAY_ACTION );
         CONNECT( this, inputPlaying( bool ),
-                 playButton, updateButton( bool ));
+                 playButton, updateButtonIcons( bool ));
         widget = playButton;
         }
         break;
@@ -221,6 +251,10 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         NORMAL_BUTTON( OPEN );
         }
         break;
+    case OPEN_SUB_BUTTON:{
+        NORMAL_BUTTON( OPEN_SUB );
+        }
+        break;
     case PREVIOUS_BUTTON:{
         NORMAL_BUTTON( PREVIOUS );
         }
@@ -239,6 +273,24 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         ENABLE_ON_INPUT( FASTERButton );
         }
         break;
+    case PREV_SLOW_BUTTON:{
+        QToolButtonExt *but = new QToolButtonExt;
+        setupButton( but );
+        BUTTON_SET_BAR( but );
+        CONNECT( but, shortClicked(), THEMIM, prev() );
+        CONNECT( but, longClicked(), THEAM, skipBackward() );
+        widget = but;
+        }
+        break;
+    case NEXT_FAST_BUTTON:{
+        QToolButtonExt *but = new QToolButtonExt;
+        setupButton( but );
+        BUTTON_SET_BAR( but );
+        CONNECT( but, shortClicked(), THEMIM, next() );
+        CONNECT( but, longClicked(), THEAM, skipForward() );
+        widget = but;
+        }
+        break;
     case FRAME_BUTTON: {
         NORMAL_BUTTON( FRAME );
         ENABLE_ON_VIDEO( FRAMEButton );
@@ -284,12 +336,15 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         ENABLE_ON_INPUT( ABButton );
         CONNECT_MAP_SET( ABButton, ATOB_ACTION );
         CONNECT( THEMIM->getIM(), AtoBchanged( bool, bool),
-                 ABButton, setIcons( bool, bool ) );
+                 ABButton, updateButtonIcons( bool, bool ) );
         widget = ABButton;
         }
         break;
     case INPUT_SLIDER: {
-        InputSlider *slider = new InputSlider( Qt::Horizontal, NULL );
+        SeekSlider *slider = new SeekSlider( Qt::Horizontal, NULL );
+        SeekPoints *chapters = new SeekPoints( this, p_intf );
+        CONNECT( THEMIM->getIM(), titleChanged( bool ), chapters, update() );
+        slider->setChapters( chapters );
 
         /* Update the position when the IM has changed */
         CONNECT( THEMIM->getIM(), positionUpdated( float, int64_t, int ),
@@ -297,6 +352,8 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         /* And update the IM, when the position has changed */
         CONNECT( slider, sliderDragged( float ),
                  THEMIM->getIM(), sliderUpdate( float ) );
+        CONNECT( THEMIM->getIM(), cachingChanged( float ),
+                 slider, updateBuffering( float ) );
         widget = slider;
         }
         break;
@@ -378,8 +435,8 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         setupButton( loopButton );
         loopButton->setToolTip( qtr( "Click to toggle between loop one, loop all" ) );
         loopButton->setCheckable( true );
-        loopButton->updateIcons( NORMAL );
-        CONNECT( THEMIM, repeatLoopChanged( int ), loopButton, updateIcons( int ) );
+        loopButton->updateButtonIcons( NORMAL );
+        CONNECT( THEMIM, repeatLoopChanged( int ), loopButton, updateButtonIcons( int ) );
         CONNECT( loopButton, clicked(), THEMIM, loopRepeatLoopStatus() );
         widget = loopButton;
         }
@@ -388,6 +445,20 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         NORMAL_BUTTON( INFO );
         }
         break;
+    case PLAYBACK_BUTTONS:{
+        widget = new QWidget;
+        DeckButtonsLayout *layout = new DeckButtonsLayout( widget );
+        BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward );
+        BrowseButton *next = new BrowseButton( widget );
+        RoundButton *play = new RoundButton( widget );
+        layout->setBackwardButton( prev );
+        layout->setForwardButton( next );
+        layout->setRoundButton( play );
+        CONNECT_MAP_SET( prev, PREVIOUS_ACTION );
+        CONNECT_MAP_SET( next, NEXT_ACTION );
+        CONNECT_MAP_SET( play, PLAY_ACTION );
+        }
+        break;
     default:
         msg_Warn( p_intf, "This should not happen %i", button );
         break;
@@ -554,12 +625,12 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
     /* advanced Controls handling */
     b_advancedVisible = b_advControls;
 #if DEBUG_LAYOUT
-    setStyleSheet( " background: red ");
+    setStyleSheet( "background: red ");
 #endif
 
     setAttribute( Qt::WA_MacBrushedMetal);
     QVBoxLayout *controlLayout = new QVBoxLayout( this );
-    controlLayout->setContentsMargins( 4, 1, 4, 0 );
+    controlLayout->setContentsMargins( 4, 1, 0, 0 );
     controlLayout->setSpacing( 0 );
     QHBoxLayout *controlLayout1 = new QHBoxLayout;
     controlLayout1->setSpacing( 0 ); controlLayout1->setMargin( 0 );
@@ -574,15 +645,15 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
                                         .toString();
     parseAndCreate( line2, controlLayout2 );
 
+    grip = new QSizeGrip( this );
+    controlLayout2->addWidget( grip, 0, Qt::AlignBottom|Qt::AlignRight );
+
     if( !b_advancedVisible && advControls ) advControls->hide();
 
     controlLayout->addLayout( controlLayout1 );
     controlLayout->addLayout( controlLayout2 );
 }
 
-ControlsWidget::~ControlsWidget()
-{}
-
 void ControlsWidget::toggleAdvanced()
 {
     if( !advControls ) return;
@@ -607,7 +678,7 @@ AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i, QWidget *_parent ) :
     controlLayout->setMargin( 0 );
     controlLayout->setSpacing( 0 );
 #if DEBUG_LAYOUT
-    setStyleSheet( " background: orange ");
+    setStyleSheet( "background: orange ");
 #endif
 
 
@@ -623,7 +694,7 @@ InputControlsWidget::InputControlsWidget( intf_thread_t *_p_i, QWidget *_parent
     controlLayout->setMargin( 0 );
     controlLayout->setSpacing( 0 );
 #if DEBUG_LAYOUT
-    setStyleSheet( " background: green ");
+    setStyleSheet( "background: green ");
 #endif
 
     QString line = getSettings()->value( "InputToolbar", INPT_TB_DEFAULT ).toString();
@@ -650,12 +721,7 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWi
 
     vout.clear();
 
-#ifdef Q_WS_X11
-    setWindowFlags( Qt::Window | Qt::FramelessWindowHint );
-    setWindowModality( Qt::ApplicationModal );
-#else
     setWindowFlags( Qt::ToolTip );
-#endif
     setMinimumWidth( 600 );
 
     setFrameShape( QFrame::StyledPanel );
@@ -676,13 +742,14 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWi
 
     /* hiding timer */
     p_hideTimer = new QTimer( this );
-    CONNECT( p_hideTimer, timeout(), this, hideFSC() );
     p_hideTimer->setSingleShot( true );
+    CONNECT( p_hideTimer, timeout(), this, hideFSC() );
 
     /* slow hiding timer */
 #if HAVE_TRANSPARENCY
     p_slowHideTimer = new QTimer( this );
     CONNECT( p_slowHideTimer, timeout(), this, slowHideFSC() );
+    f_opacity = var_InheritFloat( p_intf, "qt-fs-opacity" );
 #endif
 
     vlc_mutex_init_recursive( &lock );
@@ -751,7 +818,7 @@ void FullscreenControllerWidget::showFSC()
     }
 
 #if HAVE_TRANSPARENCY
-    setWindowOpacity( var_InheritFloat( p_intf, "qt-fs-opacity" )  );
+    setWindowOpacity( f_opacity );
 #endif
 
 #ifdef Q_WS_X11
@@ -912,7 +979,7 @@ void FullscreenControllerWidget::enterEvent( QEvent *event )
     p_hideTimer->stop();
 #if HAVE_TRANSPARENCY
     p_slowHideTimer->stop();
-    setWindowOpacity( DEFAULT_OPACITY );
+    setWindowOpacity( f_opacity );
 #endif
     event->accept();
 }
@@ -941,6 +1008,8 @@ static int FullscreenControllerWidgetFullscreenChanged( vlc_object_t *vlc_object
                 const char *variable, vlc_value_t old_val,
                 vlc_value_t new_val,  void *data )
 {
+    VLC_UNUSED( variable ); VLC_UNUSED( old_val );
+
     vout_thread_t *p_vout = (vout_thread_t *) vlc_object;
 
     msg_Dbg( p_vout, "Qt4: Fullscreen state changed" );
@@ -955,6 +1024,8 @@ static int FullscreenControllerWidgetMouseMoved( vlc_object_t *vlc_object, const
                                                  vlc_value_t old_val, vlc_value_t new_val,
                                                  void *data )
 {
+    VLC_UNUSED( variable ); VLC_UNUSED( old_val );
+
     vout_thread_t *p_vout = (vout_thread_t *)vlc_object;
     FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;
 
@@ -1059,7 +1130,7 @@ void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout,
 /**
  * Mouse change callback (show/hide the controller on mouse movement)
  */
-void FullscreenControllerWidget::mouseChanged( vout_thread_t *p_vout, int i_mousex, int i_mousey )
+void FullscreenControllerWidget::mouseChanged( vout_thread_t *, int i_mousex, int i_mousey )
 {
     bool b_toShow;