]> git.sesse.net Git - vlc/commitdiff
Merge branch 'master' of git://git.videolan.org/vlc
authorSteinar H. Gunderson <steinar+vlc@gunderson.no>
Wed, 29 Sep 2010 23:39:51 +0000 (01:39 +0200)
committerSteinar H. Gunderson <steinar+vlc@gunderson.no>
Wed, 29 Sep 2010 23:39:51 +0000 (01:39 +0200)
modules/gui/qt4/components/open_panels.cpp
modules/gui/qt4/components/open_panels.hpp
modules/gui/qt4/ui/open_net.ui
modules/misc/lua/extension.c
modules/misc/lua/vlc.h

index 59fe5c0bbe1974c700590141645a60736b7a9266..ee38d4af406de1e599352a45531e19d12ef3a96c 100644 (file)
@@ -50,7 +50,6 @@
 #include <QStringListModel>
 #include <QDropEvent>
 
-
 #define I_DEVICE_TOOLTIP \
     I_DIR_OR_FOLDER( N_("Select a device or a VIDEO_TS directory"), \
                      N_("Select a device or a VIDEO_TS folder") )
@@ -539,21 +538,22 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
     ui.setupUi( this );
 
     /* CONNECTs */
-    CONNECT( ui.urlText, textChanged( const QString& ), this, updateMRL());
+    CONNECT( ui.urlComboBox->lineEdit(), textChanged( const QString& ), this, updateMRL());
+    CONNECT( ui.urlComboBox, currentIndexChanged( const QString& ), this, updateMRL());
 
     if( var_InheritBool( p_intf, "qt-recentplay" ) )
     {
         mrlList = new QStringListModel(
                 getSettings()->value( "Open/netMRL" ).toStringList() );
-        QCompleter *completer = new QCompleter( mrlList, this );
-        ui.urlText->setCompleter( completer );
-
-        CONNECT( ui.urlText, editingFinished(), this, updateCompleter() );
+        ui.urlComboBox->setModel( mrlList );
+        ui.urlComboBox->clearEditText();
+        CONNECT( ui.urlComboBox->lineEdit(), editingFinished(), this, updateModel() );
     }
     else
         mrlList = NULL;
 
-    ui.urlText->setValidator( new UrlValidator( this ) );
+    ui.urlComboBox->setValidator( new UrlValidator( this ) );
+    ui.urlComboBox->setFocus();
 }
 
 NetOpenPanel::~NetOpenPanel()
@@ -601,7 +601,7 @@ void NetOpenPanel::updateMRL()
         { "udp",   "udp"   },
     };
 
-    QString url = ui.urlText->text();
+    QString url = ui.urlComboBox->lineEdit()->text();
     if( !url.contains( "://") )
         return; /* nothing to do this far */
 
@@ -618,12 +618,12 @@ void NetOpenPanel::updateMRL()
     emit mrlUpdated( qsl, "" );
 }
 
-void NetOpenPanel::updateCompleter()
+void NetOpenPanel::updateModel()
 {
     assert( mrlList );
     QStringList tempL = mrlList->stringList();
-    if( !tempL.contains( ui.urlText->text() ) )
-        tempL.append( ui.urlText->text() );
+    if( !tempL.contains( ui.urlComboBox->lineEdit()->text() ) )
+        tempL.append( ui.urlComboBox->lineEdit()->text() );
     mrlList->setStringList( tempL );
 }
 
@@ -796,33 +796,62 @@ void CaptureOpenPanel::initialize()
     if( module_exists( "v4l2" ) ){
     addModuleAndLayouts( V4L2_DEVICE, v4l2, "Video for Linux 2", QGridLayout );
 
+    char const * const ppsz_v4lvdevices[] = {
+        "video*"
+    };
+
+    char const * const ppsz_v4ladevices[] = {
+        "dsp*",
+        "radio*"
+    };
+
+    #define POPULATE_WITH_DEVS(ppsz_devlist, targetCombo) \
+    QStringList targetCombo ## StringList = QStringList(); \
+    for ( int i = 0; i< sizeof(ppsz_devlist) / sizeof(*ppsz_devlist); i++ ) \
+        targetCombo ## StringList << QString( ppsz_devlist[ i ] ); \
+    QDir targetCombo ## Dir = QDir( "/dev/" ); \
+    targetCombo->addItems( \
+        targetCombo ## Dir\
+        .entryList( targetCombo ## StringList, QDir::System )\
+        .replaceInStrings( QRegExp("^"), "/dev/" ) \
+    );
+
     /* V4l Main panel */
     QLabel *v4l2VideoDeviceLabel = new QLabel( qtr( "Video device name" ) );
     v4l2DevLayout->addWidget( v4l2VideoDeviceLabel, 0, 0 );
 
-    v4l2VideoDevice = new QLineEdit;
+    v4l2VideoDevice = new QComboBox( this );
+    v4l2VideoDevice->setEditable( true );
+    POPULATE_WITH_DEVS( ppsz_v4lvdevices, v4l2VideoDevice );
+    v4l2VideoDevice->clearEditText();
     v4l2DevLayout->addWidget( v4l2VideoDevice, 0, 1 );
 
     QLabel *v4l2AudioDeviceLabel = new QLabel( qtr( "Audio device name" ) );
     v4l2DevLayout->addWidget( v4l2AudioDeviceLabel, 1, 0 );
 
-    v4l2AudioDevice = new QLineEdit;
+    v4l2AudioDevice = new QComboBox( this );
+    v4l2AudioDevice->setEditable( true );
+    POPULATE_WITH_DEVS( ppsz_v4ladevices, v4l2AudioDevice );
+    v4l2AudioDevice->clearEditText();
     v4l2DevLayout->addWidget( v4l2AudioDevice, 1, 1 );
 
     /* v4l2 Props panel */
-    QLabel *v4l2StdLabel = new QLabel( qtr( "Standard" ) );
+    QLabel *v4l2StdLabel = new QLabel( qtr( "Video standard" ) );
     v4l2PropLayout->addWidget( v4l2StdLabel, 0 , 0 );
 
     v4l2StdBox = new QComboBox;
     setfillVLCConfigCombo( "v4l2-standard", p_intf, v4l2StdBox );
     v4l2PropLayout->addWidget( v4l2StdBox, 0 , 1 );
     v4l2PropLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ),
-            1, 0, 3, 1 );
+            1, 0, 3, 2 );
 
     /* v4l2 CONNECTs */
-    CuMRL( v4l2VideoDevice, textChanged( const QString& ) );
-    CuMRL( v4l2AudioDevice, textChanged( const QString& ) );
+    CuMRL( v4l2VideoDevice->lineEdit(), textChanged( const QString& ) );
+    CuMRL( v4l2VideoDevice,  currentIndexChanged ( int ) );
+    CuMRL( v4l2AudioDevice->lineEdit(), textChanged( const QString& ) );
+    CuMRL( v4l2AudioDevice,  currentIndexChanged ( int ) );
     CuMRL( v4l2StdBox,  currentIndexChanged ( int ) );
+    #undef POPULATE_WITH_DEVS
     }
 
     /*******
@@ -1158,8 +1187,8 @@ void CaptureOpenPanel::updateMRL()
         mrl += " :v4l-frequency=" + QString::number( v4lFreq->value() );
         break;
     case V4L2_DEVICE:
-        fileList << "v4l2://" + v4l2VideoDevice->text();
-        mrl += " :input-slave=alsa://" + v4l2AudioDevice->text();
+        fileList << "v4l2://" + v4l2VideoDevice->currentText();
+        mrl += " :input-slave=alsa://" + v4l2AudioDevice->currentText();
         mrl += " :v4l2-standard=" + QString::number( v4l2StdBox->currentIndex() );
         break;
     case JACK_DEVICE:
index bcd09e2c4fc459d59300dac1336c83a2f10e96e3..0160972bad15e4e307ddfb93500f903a4eb205bc 100644 (file)
@@ -146,7 +146,7 @@ private:
 public slots:
     virtual void updateMRL();
 private slots:
-    void updateCompleter();
+    void updateModel();
 };
 
 class UrlValidator : public QValidator
@@ -211,7 +211,7 @@ private:
     QLabel *dvbBandLabel, *dvbSrateLabel;
     QSpinBox  *v4lFreq, *pvrFreq, *pvrBitr;
     QLineEdit *v4lVideoDevice, *v4lAudioDevice;
-    QLineEdit *v4l2VideoDevice, *v4l2AudioDevice;
+    QComboBox *v4l2VideoDevice, *v4l2AudioDevice;
     QLineEdit *pvrDevice, *pvrRadioDevice;
     QComboBox *v4lNormBox, *v4l2StdBox, *pvrNormBox, *dvbBandBox;
     QSpinBox *dvbCard, *dvbFreq, *dvbSrate;
index 34b6d22dd74b95a2aaaf2cce27a004440aacc9e5..91e5319864572e25bc67d1bacde9b52b3db8f6b0 100644 (file)
         <property name="text">
          <string>Please enter a network URL:</string>
         </property>
-        <property name="buddy">
-         <cstring>urlText</cstring>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="0">
-       <widget class="QLineEdit" name="urlText">
-        <property name="toolTip">
-         <string>Enter the URL of the network stream here.</string>
-        </property>
        </widget>
       </item>
       <item row="2" column="0">
@@ -52,7 +42,7 @@
 p, li { white-space: pre-wrap; }
 p { margin: 0; -qt-block-indent: 0; text-indent: 0;}
 body { font-family: 'sans'; font-size: 8pt; font-weight: 400; }
-p > span { color: #838383; }
+p &gt; span { color: #838383; }
 &lt;/style&gt;&lt;/head&gt;&lt;body&gt;
 &lt;p&gt;&lt;span&gt;http://www.example.com/stream.avi&lt;/span&gt;&lt;/p&gt;
 &lt;p&gt;&lt;span&gt;rtp://@:1234&lt;/span&gt;&lt;/p&gt;
@@ -68,6 +58,16 @@ p > span { color: #838383; }
         </property>
        </widget>
       </item>
+      <item row="1" column="0">
+       <widget class="QComboBox" name="urlComboBox">
+        <property name="editable">
+         <bool>true</bool>
+        </property>
+        <property name="insertPolicy">
+         <enum>QComboBox::NoInsert</enum>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
@@ -90,7 +90,7 @@ p > span { color: #838383; }
   </layout>
  </widget>
  <tabstops>
-  <tabstop>urlText</tabstop>
+  <tabstop>urlComboBox</tabstop>
  </tabstops>
  <resources/>
  <connections/>
index 2a529b85a5e6415f9c94e096946125652dc6931c..745350fdeeb7b2d6363c8c784f1a3e244e6bab6f 100644 (file)
@@ -341,32 +341,27 @@ int ScanLuaCallback( vlc_object_t *p_this, const char *psz_script,
 
             /* Get author */
             lua_getfield( L, -1, "author" );
-            if( lua_isstring( L, -1 ) )
-                p_ext->psz_author = strdup( luaL_optstring( L, -1, NULL ) );
+            p_ext->psz_author = luaL_strdupornull( L, -1 );
             lua_pop( L, 1 );
 
             /* Get description */
             lua_getfield( L, -1, "description" );
-            if( lua_isstring( L, -1 ) )
-                p_ext->psz_description = strdup( luaL_optstring( L, -1, NULL ) );
+            p_ext->psz_description = luaL_strdupornull( L, -1 );
             lua_pop( L, 1 );
 
             /* Get short description */
             lua_getfield( L, -1, "shortdesc" );
-            if( lua_isstring( L, -1 ) )
-                p_ext->psz_shortdescription = strdup( luaL_optstring( L, -1, NULL ) );
+            p_ext->psz_shortdescription = luaL_strdupornull( L, -1 );
             lua_pop( L, 1 );
 
             /* Get URL */
             lua_getfield( L, -1, "url" );
-            if( lua_isstring( L, -1 ) )
-                p_ext->psz_url = strdup( luaL_optstring( L, -1, NULL ) );
+            p_ext->psz_url = luaL_strdupornull( L, -1 );
             lua_pop( L, 1 );
 
             /* Get version */
             lua_getfield( L, -1, "version" );
-            if( lua_isstring( L, -1 ) )
-                p_ext->psz_version = strdup( luaL_optstring( L, -1, NULL ) );
+            p_ext->psz_version = luaL_strdupornull( L, -1 );
             lua_pop( L, 1 );
         }
         else
index ff3d4da6eb58a97f5772fb04725e81e0880a4c32..d3187e76beb4ab2b32959e4a4668fde3a8cbc20a 100644 (file)
@@ -91,6 +91,13 @@ static inline const char *luaL_nilorcheckstring( lua_State *L, int narg )
     return luaL_checkstring( L, narg );
 }
 
+static inline char *luaL_strdupornull( lua_State *L, int narg )
+{
+    if( lua_isstring( L, narg ) )
+        return strdup( luaL_checkstring( L, narg ) );
+    return NULL;
+}
+
 void vlclua_set_this( lua_State *, vlc_object_t * );
 #define vlclua_set_this(a, b) vlclua_set_this(a, VLC_OBJECT(b))
 vlc_object_t * vlclua_get_this( lua_State * );