]> git.sesse.net Git - vlc/commitdiff
Qt4: Add aspect ratio combobox to toolbar editor
authorEdward Wang <edward.c.wang@compdigitec.com>
Wed, 28 Dec 2011 00:25:48 +0000 (01:25 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 28 Dec 2011 00:29:29 +0000 (01:29 +0100)
Close #4127

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/qt4/components/controller.cpp
modules/gui/qt4/components/controller.hpp
modules/gui/qt4/components/controller_widget.cpp
modules/gui/qt4/components/controller_widget.hpp
modules/gui/qt4/dialogs/toolbar.cpp

index 3d1bd7865aff76a979dca03e5970a1a4d4f3ebed..22d3792b14487e1c84ff376de4104fb99f9a5ad7 100644 (file)
@@ -465,6 +465,9 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         CONNECT_MAP_SET( play, PLAY_ACTION );
         }
         break;
+    case ASPECT_RATIO_COMBOBOX:
+        widget = new AspectRatioComboBox( p_intf );
+        break;
     default:
         msg_Warn( p_intf, "This should not happen %i", button );
         break;
index d3ba78bcc35da8ce2f377d238c3b0eb90b73a233..96d53c0306134a38bee4ccc8ba3ccd5316de61d3 100644 (file)
@@ -99,6 +99,7 @@ typedef enum buttonType_e
     TELETEXT_BUTTONS,
     ADVANCED_CONTROLLER,
     PLAYBACK_BUTTONS,
+    ASPECT_RATIO_COMBOBOX,
     SPECIAL_MAX,
 
     WIDGET_SPACER = 0x40,
index acd8b7f2ca5819d6082721b1abf93b1439b8b917..370ef3f706d507b7ad1d786e66242dad768f5713 100644 (file)
@@ -267,3 +267,26 @@ void LoopButton::updateButtonIcons( int value )
     setIcon( ( value == REPEAT_ONE ) ? QIcon( ":/buttons/playlist/repeat_one" )
                                      : QIcon( ":/buttons/playlist/repeat_all" ) );
 }
+
+void AspectRatioComboBox::updateRatios() {
+    /* Clear the list before updating */
+    this->clear();
+    vlc_value_t val_list, text_list;
+    vout_thread_t* p_vout = THEMIM->getVout();
+    /* Disable if there is no vout */
+    if( p_vout == NULL ) {
+        addItem("Aspect Ratio");
+        setDisabled( true );
+        return;
+    }
+    var_Change( p_vout, "aspect-ratio", VLC_VAR_GETLIST, &val_list, &text_list );
+    for( int i = 0; i < val_list.p_list->i_count; i++ )
+        addItem( QString( text_list.p_list->p_values[i].psz_string ), QString( val_list.p_list->p_values[i].psz_string ) );
+    setEnabled( true );
+    var_FreeList( &val_list, &text_list );
+}
+
+void AspectRatioComboBox::updateAspectRatio( int x ) {
+    vout_thread_t* p_vout = THEMIM->getVout();
+    if( p_vout && x >= 0 ) var_SetString( p_vout, "aspect-ratio", qtu( itemData(x).toString() ) );
+}
index 9b5af889c3c0f2f4726eb21d33478264d8ab72a2..04663f526c069dcfaaad8e50661fbc07e5a9f19c 100644 (file)
 #endif
 
 #include "qt4.hpp"
+#include "input_manager.hpp"
+#include <vlc_vout.h>                       /* vout_thread_t for aspect ratio combobox */
 
 #include <QWidget>
 #include <QToolButton>
+#include <QComboBox>
 
 class QLabel;
 class QFrame;
@@ -67,6 +70,27 @@ private slots:
     void updateButtonIcons( bool, bool );
 };
 
+class AspectRatioComboBox : public QComboBox
+{
+    Q_OBJECT
+    public:
+    AspectRatioComboBox( intf_thread_t* _p_intf ) {
+        p_intf = _p_intf;
+        CONNECT( THEMIM->getIM(), voutChanged( bool ),
+                 this, updateRatios() );
+        CONNECT( this, currentIndexChanged( int ),
+                 this, updateAspectRatio( int ) );
+        this->updateRatios();
+    }
+
+    public slots:
+    void updateRatios();
+    void updateAspectRatio( int );
+
+    private:
+    intf_thread_t* p_intf;
+};
+
 #define VOLUME_MAX 200
 class SoundWidget : public QWidget
 {
index 8f6bb097113e72ec6ceffedda894f55dfa01db2f..43ebf09ec708c0dc617fa2068c75526b7ea6aa0d 100644 (file)
 #include "util/buttons/BrowseButton.hpp"
 #include "util/buttons/RoundButton.hpp"
 
+#include "qt4.hpp"
+#include "input_manager.hpp"
+#include <vlc_vout.h>                       /* vout_thread_t for aspect ratio combobox */
+
 #include <QScrollArea>
 #include <QGroupBox>
 #include <QLabel>
@@ -441,6 +445,10 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
             }
             widgetItem->setText( qtr("Playback Buttons") );
             break;
+        case ASPECT_RATIO_COMBOBOX:
+            widget = new AspectRatioComboBox( p_intf );
+            widgetItem->setText( qtr("Aspect ratio selector") );
+            break;
         default:
             msg_Warn( p_intf, "This should not happen %i", i );
             break;