]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/dialogs/open.cpp
qt4: attempt to work around a design flaw in the toolbar editor
[vlc] / modules / gui / qt4 / dialogs / open.cpp
index db1e67f67996f1a634c892c7619a5a5b20fafc5a..29aa55d12adef0369d534c43f21450b8f5f69d1f 100644 (file)
@@ -51,14 +51,11 @@ OpenDialog* OpenDialog::getInstance( QWidget *parent, intf_thread_t *p_intf,
     else if( !b_rawInstance )
     {
         /* Request the instance but change small details:
-           - Button menu
-           - Modality on top of the parent dialog */
+           - Button menu */
         if( b_selectMode )
-        {
-            instance->setWindowModality( Qt::WindowModal );
             _action_flag = SELECT; /* This should be useless, but we never know
                                       if the call is correct */
-        }
+        instance->setWindowModality( Qt::WindowModal );
         instance->i_action_flag = _action_flag;
         instance->b_pl = _b_pl;
         instance->setMenuAction();
@@ -75,20 +72,14 @@ OpenDialog::OpenDialog( QWidget *parent,
     i_action_flag = _action_flag;
     b_pl =_b_pl;
 
-    /* Workaround the Win32 Vout that put the video on top at regular times */
-#ifdef WIN32
-    setWindowFlags( Qt::WindowStaysOnTopHint | Qt::Dialog );
-#endif
-
     if( b_selectMode ) /* Select mode */
-    {
         i_action_flag = SELECT;
-        setWindowModality( Qt::WindowModal );
-    }
 
     /* Basic Creation of the Window */
     ui.setupUi( this );
     setWindowTitle( qtr( "Open Media" ) );
+    setWindowRole( "vlc-open-media" );
+    setWindowModality( Qt::WindowModal );
 
     /* Tab definition and creation */
     fileOpenPanel    = new FileOpenPanel( this, p_intf );
@@ -97,11 +88,14 @@ OpenDialog::OpenDialog( QWidget *parent,
     captureOpenPanel = new CaptureOpenPanel( this, p_intf );
 
     /* Insert the tabs */
-    ui.Tab->insertTab( OPEN_FILE_TAB, fileOpenPanel, qtr( "&File" ) );
-    ui.Tab->insertTab( OPEN_DISC_TAB, discOpenPanel, qtr( "&Disc" ) );
-    ui.Tab->insertTab( OPEN_NETWORK_TAB, netOpenPanel, qtr( "&Network" ) );
+    ui.Tab->insertTab( OPEN_FILE_TAB, fileOpenPanel, QIcon( ":/type/folder-grey" ),
+                       qtr( "&File" ) );
+    ui.Tab->insertTab( OPEN_DISC_TAB, discOpenPanel, QIcon( ":/type/disc" ),
+                       qtr( "&Disc" ) );
+    ui.Tab->insertTab( OPEN_NETWORK_TAB, netOpenPanel, QIcon( ":/type/network" ),
+                       qtr( "&Network" ) );
     ui.Tab->insertTab( OPEN_CAPTURE_TAB, captureOpenPanel,
-                       qtr( "Capture &Device" ) );
+                       QIcon( ":/type/capture-card" ), qtr( "Capture &Device" ) );
 
     /* Hide the Slave input widgets */
     ui.slaveLabel->hide();
@@ -129,8 +123,7 @@ OpenDialog::OpenDialog( QWidget *parent,
     openButtonMenu->addAction( qtr( "&Convert" ), this, SLOT( transcode() ) ,
                                     QKeySequence( "Alt+C" ) );
 
-    ui.menuButton->setMenu( openButtonMenu );
-    ui.menuButton->setIcon( QIcon( ":/down_arrow" ) );
+    playButton->setMenu( openButtonMenu );
 
     /* Add the three Buttons */
     ui.buttonsBox->addButton( selectButton, QDialogButtonBox::AcceptRole );
@@ -142,29 +135,29 @@ OpenDialog::OpenDialog( QWidget *parent,
     /* Force MRL update on tab change */
     CONNECT( ui.Tab, currentChanged( int ), this, signalCurrent( int ) );
 
-    CONNECT( fileOpenPanel, mrlUpdated( QStringList, QString ),
-             this, updateMRL( QStringList, QString ) );
-    CONNECT( netOpenPanel, mrlUpdated( QStringList, QString ),
-             this, updateMRL( QStringList, QString ) );
-    CONNECT( discOpenPanel, mrlUpdated( QStringList, QString ),
-             this, updateMRL( QStringList, QString ) );
-    CONNECT( captureOpenPanel, mrlUpdated( QStringList, QString ),
-             this, updateMRL( QStringList, QString ) );
-
-    CONNECT( fileOpenPanel, methodChanged( QString ),
-             this, newCachingMethod( QString ) );
-    CONNECT( netOpenPanel, methodChanged( QString ),
-             this, newCachingMethod( QString ) );
-    CONNECT( discOpenPanel, methodChanged( QString ),
-             this, newCachingMethod( QString ) );
-    CONNECT( captureOpenPanel, methodChanged( QString ),
-             this, newCachingMethod( QString ) );
+    CONNECT( fileOpenPanel, mrlUpdated( const QStringList&, const QString& ),
+             this, updateMRL( const QStringList&, const QString& ) );
+    CONNECT( netOpenPanel, mrlUpdated( const QStringList&, const QString& ),
+             this, updateMRL( const QStringList&, const QString& ) );
+    CONNECT( discOpenPanel, mrlUpdated( const QStringList&, const QString& ),
+             this, updateMRL( const QStringList&, const QString& ) );
+    CONNECT( captureOpenPanel, mrlUpdated( const QStringList&, const QString& ),
+             this, updateMRL( const QStringList&, const QString& ) );
+
+    CONNECT( fileOpenPanel, methodChanged( const QString& ),
+             this, newCachingMethod( const QString& ) );
+    CONNECT( netOpenPanel, methodChanged( const QString& ),
+             this, newCachingMethod( const QString& ) );
+    CONNECT( discOpenPanel, methodChanged( const QString& ),
+             this, newCachingMethod( const QString& ) );
+    CONNECT( captureOpenPanel, methodChanged( const QString& ),
+             this, newCachingMethod( const QString& ) );
 
     /* Advanced frame Connects */
     CONNECT( ui.slaveCheckbox, toggled( bool ), this, updateMRL() );
-    CONNECT( ui.slaveText, textChanged( QString ), this, updateMRL() );
+    CONNECT( ui.slaveText, textChanged( const QString& ), this, updateMRL() );
     CONNECT( ui.cacheSpinBox, valueChanged( int ), this, updateMRL() );
-    CONNECT( ui.startTimeSpinBox, valueChanged( int ), this, updateMRL() );
+    CONNECT( ui.startTimeDoubleSpinBox, valueChanged( double ), this, updateMRL() );
     BUTTONACT( ui.advancedCheckBox, toggleAdvancedPanel() );
     BUTTONACT( ui.slaveBrowseButton, browseInputSlave() );
 
@@ -174,8 +167,11 @@ OpenDialog::OpenDialog( QWidget *parent,
     BUTTONACT( cancelButton, cancel() );
 
     /* Hide the advancedPanel */
-    if( !config_GetInt( p_intf, "qt-adv-options" ) )
+    if( !var_InheritBool( p_intf, "qt-adv-options" ) )
+    {
         ui.advancedFrame->hide();
+        ui.advancedFrame->setEnabled( false );
+    }
     else
         ui.advancedCheckBox->setChecked( true );
 
@@ -190,7 +186,9 @@ OpenDialog::OpenDialog( QWidget *parent,
 
 OpenDialog::~OpenDialog()
 {
-    getSettings()->setValue( "opendialog-size", size() );
+    getSettings()->setValue( "opendialog-size", size() -
+                 ( ui.advancedFrame->isEnabled() ?
+                   QSize(0, ui.advancedFrame->height()) : QSize(0, 0) ) );
 }
 
 /* Used by VLM dialog and inputSlave selection */
@@ -201,6 +199,11 @@ QString OpenDialog::getMRL( bool b_all )
                  : itemsMRL[0];
 }
 
+QString OpenDialog::getOptions()
+{
+    return ui.advancedLineInput->text();
+}
+
 /* Finish the dialog and decide if you open another one after */
 void OpenDialog::setMenuAction()
 {
@@ -229,7 +232,6 @@ void OpenDialog::setMenuAction()
         }
         playButton->show();
         selectButton->hide();
-        playButton->setDefault( true );
     }
 }
 
@@ -254,6 +256,7 @@ void OpenDialog::toggleAdvancedPanel()
     if( ui.advancedFrame->isVisible() )
     {
         ui.advancedFrame->hide();
+        ui.advancedFrame->setEnabled( false );
         if( size().isValid() )
             resize( size().width(), size().height()
                     - ui.advancedFrame->height() );
@@ -261,6 +264,7 @@ void OpenDialog::toggleAdvancedPanel()
     else
     {
         ui.advancedFrame->show();
+        ui.advancedFrame->setEnabled( true );
         if( size().isValid() )
             resize( size().width(), size().height()
                     + ui.advancedFrame->height() );
@@ -346,7 +350,9 @@ void OpenDialog::finish( bool b_enqueue = false )
         bool b_start = !i && !b_enqueue;
 
         input_item_t *p_input;
-        p_input = input_item_New( p_intf, qtu( itemsMRL[i] ), NULL );
+        char* psz_uri = make_URI( qtu( itemsMRL[i] ), "file" );
+        p_input = input_item_New( p_intf, psz_uri, NULL );
+        free( psz_uri );
 
         /* Insert options only for the first element.
            We don't know how to edit that anyway. */
@@ -396,11 +402,11 @@ void OpenDialog::stream( bool b_transcode_only )
     /* Dbg and send :D */
     msg_Dbg( p_intf, "MRL passed to the Sout: %s", qtu( soutMRL ) );
     THEDP->streamingDialog( this, soutMRL, b_transcode_only,
-                            ui.advancedLineInput->text().split( ":" ) );
+                            ui.advancedLineInput->text().split( " :" ) );
 }
 
 /* Update the MRL */
-void OpenDialog::updateMRL( QStringList item, QString tempMRL )
+void OpenDialog::updateMRL( const QStringList& item, const QString& tempMRL )
 {
     optionsMRL = tempMRL;
     itemsMRL = item;
@@ -412,29 +418,25 @@ void OpenDialog::updateMRL() {
     if( ui.slaveCheckbox->isChecked() ) {
         mrl += " :input-slave=" + ui.slaveText->text();
     }
-    int i_cache = config_GetInt( p_intf, qtu( storedMethod ) );
-    if( i_cache != ui.cacheSpinBox->value() ) {
-        mrl += QString( " :%1=%2" ).arg( storedMethod ).
-                                  arg( ui.cacheSpinBox->value() );
-    }
-    if( ui.startTimeSpinBox->value() ) {
-        mrl += " :start-time=" + QString( "%1" ).
-            arg( ui.startTimeSpinBox->value() );
+    mrl += QString( " :%1=%2" ).arg( storedMethod ).
+                                arg( ui.cacheSpinBox->value() );
+    if( ui.startTimeDoubleSpinBox->value() ) {
+        mrl += " :start-time=" + QString::number( ui.startTimeDoubleSpinBox->value() );
     }
     ui.advancedLineInput->setText( mrl );
     ui.mrlLine->setText( itemsMRL.join( " " ) );
 }
 
-void OpenDialog::newCachingMethod( QString method )
+void OpenDialog::newCachingMethod( const QString& method )
 {
     if( method != storedMethod ) {
         storedMethod = method;
-        int i_value = config_GetInt( p_intf, qtu( storedMethod ) );
+        int i_value = var_InheritInteger( p_intf, qtu( storedMethod ) );
         ui.cacheSpinBox->setValue( i_value );
     }
 }
 
-QStringList OpenDialog::SeparateEntries( QString entries )
+QStringList OpenDialog::SeparateEntries( const QString& entries )
 {
     bool b_quotes_mode = false;