/*****************************************************************************
* open.cpp : Advanced open dialog
*****************************************************************************
- * Copyright © 2006-2009 the VideoLAN team
- * $Id$
+ * Copyright © 2006-2011 the VideoLAN team
*
* Authors: Jean-Baptiste Kempf <jb@videolan.org>
*
#endif
#include "dialogs/open.hpp"
-
#include "dialogs_provider.hpp"
-
#include "recents.hpp"
#include "util/qt_dirs.hpp"
#include <QTabWidget>
-#include <QGridLayout>
#include <QRegExp>
#include <QMenu>
-#define DEBUG_QT 1
+#ifndef NDEBUG
+# define DEBUG_QT 1
+#endif
OpenDialog *OpenDialog::instance = NULL;
QKeySequence( "Alt+P" ) );
openButtonMenu->addAction( qtr( "&Stream" ), this, SLOT( stream() ) ,
QKeySequence( "Alt+S" ) );
- openButtonMenu->addAction( qtr( "&Convert" ), this, SLOT( transcode() ) ,
- QKeySequence( "Alt+C" ) );
+ openButtonMenu->addAction( qtr( "C&onvert" ), this, SLOT( transcode() ) ,
+ QKeySequence( "Alt+O" ) );
playButton->setMenu( openButtonMenu );
CONNECT( ui.slaveCheckbox, toggled( bool ), this, updateMRL() );
CONNECT( ui.slaveText, textChanged( const QString& ), this, updateMRL() );
CONNECT( ui.cacheSpinBox, valueChanged( int ), this, updateMRL() );
- CONNECT( ui.startTimeTimeEdit, timeChanged ( const QTime& ), this, updateMRL() );
+ CONNECT( ui.startTimeTimeEdit, timeChanged ( const QTime& ), this, updateMRL() );
BUTTONACT( ui.advancedCheckBox, toggleAdvancedPanel() );
BUTTONACT( ui.slaveBrowseButton, browseInputSlave() );
BUTTONACT( cancelButton, cancel() );
/* Hide the advancedPanel */
- if( !getSettings()->value( "opendialog-advanced", false ).toBool())
+ if( !getSettings()->value( "OpenDialog/advanced", false ).toBool())
{
ui.advancedFrame->hide();
ui.advancedFrame->setEnabled( false );
setMinimumSize( sizeHint() );
setMaximumWidth( 900 );
- resize( getSettings()->value( "opendialog-size", QSize( 500, 400 ) ).toSize() );
-}
-
-OpenDialog::~OpenDialog()
-{
- getSettings()->setValue( "opendialog-size", size() -
- ( ui.advancedFrame->isEnabled() ?
- QSize(0, ui.advancedFrame->height()) : QSize(0, 0) ) );
- getSettings()->setValue( "opendialog-advanced", ui.advancedFrame->isVisible() );
-}
-
-/* Used by VLM dialog and inputSlave selection */
-QString OpenDialog::getMRL( bool b_all )
-{
- if( itemsMRL.count() == 0 ) return "";
- return b_all ? itemsMRL[0] + ui.advancedLineInput->text()
- : itemsMRL[0];
-}
-
-QString OpenDialog::getOptions()
-{
- return ui.advancedLineInput->text();
+ resize( getSettings()->value( "OpenDialog/size", QSize( 500, 400 ) ).toSize() );
}
/* Finish the dialog and decide if you open another one after */
playButton->setText( qtr( "&Stream" ) );
break;
case OPEN_AND_SAVE:
- playButton->setText( qtr( "&Convert / Save" ) );
+ playButton->setText( qtr( "C&onvert / Save" ) );
break;
case OPEN_AND_ENQUEUE:
playButton->setText( qtr( "&Enqueue" ) );
}
}
-void OpenDialog::showTab( int i_tab )
+OpenDialog::~OpenDialog()
{
- if( i_tab == OPEN_CAPTURE_TAB ) captureOpenPanel->initialize();
- ui.Tab->setCurrentIndex( i_tab );
- show();
- if( ui.Tab->currentWidget() != NULL )
- {
- OpenPanel *panel = dynamic_cast<OpenPanel *>( ui.Tab->currentWidget() );
- assert( panel );
- panel->onFocus();
- }
+ getSettings()->setValue( "OpenDialog/size", size() -
+ ( ui.advancedFrame->isEnabled() ?
+ QSize(0, ui.advancedFrame->height()) : QSize(0, 0) ) );
+ getSettings()->setValue( "OpenDialog/advanced", ui.advancedFrame->isVisible() );
}
-/* Function called on signal currentChanged triggered */
-void OpenDialog::signalCurrent( int i_tab )
+/* Used by VLM dialog and inputSlave selection */
+QString OpenDialog::getMRL( bool b_all )
+{
+ if( itemsMRL.count() == 0 ) return "";
+ return b_all ? itemsMRL[0] + getOptions()
+ : itemsMRL[0];
+}
+
+QString OpenDialog::getOptions()
+{
+ return ui.advancedLineInput->text();
+}
+
+void OpenDialog::showTab( int i_tab )
{
if( i_tab == OPEN_CAPTURE_TAB ) captureOpenPanel->initialize();
+ ui.Tab->setCurrentIndex( i_tab );
+ show();
if( ui.Tab->currentWidget() != NULL )
{
- OpenPanel *panel = dynamic_cast<OpenPanel *>( ui.Tab->currentWidget() );
+ OpenPanel *panel = qobject_cast<OpenPanel *>( ui.Tab->currentWidget() );
assert( panel );
panel->onFocus();
- panel->updateMRL();
}
}
}
}
+void OpenDialog::browseInputSlave()
+{
+ OpenDialog *od = new OpenDialog( this, p_intf, true, SELECT );
+ od->exec();
+ ui.slaveText->setText( od->getMRL( false ) );
+ delete od;
+}
+
+/* Function called on signal currentChanged triggered */
+void OpenDialog::signalCurrent( int i_tab )
+{
+ if( i_tab == OPEN_CAPTURE_TAB ) captureOpenPanel->initialize();
+ if( ui.Tab->currentWidget() != NULL )
+ {
+ OpenPanel *panel = qobject_cast<OpenPanel *>( ui.Tab->currentWidget() );
+ assert( panel );
+ panel->onFocus();
+ panel->updateMRL();
+ }
+}
+
/***********
* Actions *
***********/
{
/* Clear the panels */
for( int i = 0; i < OPEN_TAB_MAX; i++ )
- dynamic_cast<OpenPanel*>( ui.Tab->widget( i ) )->clear();
+ qobject_cast<OpenPanel*>( ui.Tab->widget( i ) )->clear();
/* Clear the variables */
itemsMRL.clear();
}
}
+/* Play Action, called from selectSlots or play Menu */
void OpenDialog::play()
{
- finish( false );
+ enqueue( false );
}
-void OpenDialog::enqueue()
-{
- finish( true );
-}
-
-
-void OpenDialog::finish( bool b_enqueue = false )
+/* Enqueue Action, called from selectSlots or enqueue Menu */
+void OpenDialog::enqueue( bool b_enqueue )
{
toggleVisible();
return;
}
+ for( int i = 0; i < OPEN_TAB_MAX; i++ )
+ qobject_cast<OpenPanel*>( ui.Tab->widget( i ) )->onAccept();
+
/* Sort alphabetically */
itemsMRL.sort();
{
bool b_start = !i && !b_enqueue;
- input_item_t *p_input;
- p_input = input_item_New( qtu( itemsMRL[i] ), NULL );
+ input_item_t *p_input_item;
+ p_input_item = input_item_New( qtu( itemsMRL[i] ), NULL );
- /* Insert options only for the first element.
- We don't know how to edit that anyway. */
- if( i == 0 )
- {
- /* Take options from the UI, not from what we stored */
- QStringList optionsList = ui.advancedLineInput->text().split( " :" );
+ /* Take options from the UI, not from what we stored */
+ QStringList optionsList = getOptions().split( " :" );
- /* Insert options */
- for( int j = 0; j < optionsList.count(); j++ )
+ /* Insert options */
+ for( int j = 0; j < optionsList.count(); j++ )
+ {
+ QString qs = colon_unescape( optionsList[j] );
+ if( !qs.isEmpty() )
{
- QString qs = colon_unescape( optionsList[j] );
- if( !qs.isEmpty() )
- {
- input_item_AddOption( p_input, qtu( qs ),
- VLC_INPUT_OPTION_TRUSTED );
+ input_item_AddOption( p_input_item, qtu( qs ),
+ VLC_INPUT_OPTION_TRUSTED );
#ifdef DEBUG_QT
- msg_Warn( p_intf, "Input option: %s", qtu( qs ) );
+ msg_Warn( p_intf, "Input option: %s", qtu( qs ) );
#endif
- }
}
}
/* Switch between enqueuing and starting the item */
/* FIXME: playlist_AddInput() can fail */
- playlist_AddInput( THEPL, p_input,
+ playlist_AddInput( THEPL, p_input_item,
PLAYLIST_APPEND | ( b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE ),
PLAYLIST_END, b_pl ? true : false, pl_Unlocked );
- vlc_gc_decref( p_input );
+ vlc_gc_decref( p_input_item );
/* Do not add the current MRL if playlist_AddInput fail */
RecentsMRL::getInstance( p_intf )->addRecent( itemsMRL[i] );
/* 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( " :" ) );
+ getOptions().split( " :" ) );
}
-/* Update the MRL */
+/* Update the MRL items from the panels */
void OpenDialog::updateMRL( const QStringList& item, const QString& tempMRL )
{
optionsMRL = tempMRL;
updateMRL();
}
+/* Update the complete MRL */
void OpenDialog::updateMRL() {
QString mrl = optionsMRL;
if( ui.slaveCheckbox->isChecked() ) {
ui.mrlLine->setText( itemsMRL.join( " " ) );
}
+/* Change the caching combobox */
void OpenDialog::newCachingMethod( const QString& method )
{
if( method != storedMethod ) {
}
}
+/* Split the entries
+ * FIXME! */
QStringList OpenDialog::SeparateEntries( const QString& entries )
{
bool b_quotes_mode = false;
return entries_array;
}
-void OpenDialog::browseInputSlave()
-{
- OpenDialog *od = new OpenDialog( this, p_intf, true, SELECT );
- od->exec();
- ui.slaveText->setText( od->getMRL( false ) );
- delete od;
-}