* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#include "qt4.hpp"
-#include "util/qvlcframe.hpp"
#include "input_manager.hpp"
#include "dialogs/open.hpp"
-#include "components/open.hpp"
#include <QTabWidget>
#include <QGridLayout>
ui.Tab->insertTab( OPEN_CAPTURE_TAB, captureOpenPanel,
qtr( "Capture &Device" ) );
+ /* Hide the Slave input widgets */
+ ui.slaveLabel->hide();
+ ui.slaveText->hide();
+ ui.slaveBrowseButton->hide();
+
/* Hide the advancedPanel */
if(! config_GetInt( p_intf, "qt-adv-options") )
- {
ui.advancedFrame->hide();
- }
else
- {
ui.advancedCheckBox->setCheckState( Qt::Checked );
- }
-
- ui.slaveLabel->hide();
- ui.slaveText->hide();
- ui.slaveBrowseButton->hide();
/* Buttons Creation */
- QSizePolicy buttonSizePolicy( static_cast<QSizePolicy::Policy>(7),
- static_cast<QSizePolicy::Policy>(1) );
- buttonSizePolicy.setHorizontalStretch(0);
- buttonSizePolicy.setVerticalStretch(0);
+ QSizePolicy buttonSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
+ buttonSizePolicy.setHorizontalStretch( 0 );
+ buttonSizePolicy.setVerticalStretch( 0 );
+ /* Play Button */
playButton = new QToolButton( this );
playButton->setText( qtr( "&Play" ) );
playButton->setSizePolicy( buttonSizePolicy );
playButton->setPopupMode( QToolButton::MenuButtonPopup );
playButton->setToolButtonStyle( Qt::ToolButtonTextOnly );
+ /* Cancel Button */
cancelButton = new QPushButton();
cancelButton->setText( qtr( "&Cancel" ) );
cancelButton->setSizePolicy( buttonSizePolicy );
+ /* Menu for the Play button */
QMenu * openButtonMenu = new QMenu( "Open" );
- openButtonMenu->addAction( qtr("&Enqueue"), this, SLOT( enqueue() ),
+ openButtonMenu->addAction( qtr( "&Enqueue" ), this, SLOT( enqueue() ),
QKeySequence( "Alt+E") );
- openButtonMenu->addAction( qtr("&Play"), this, SLOT( play() ),
+ openButtonMenu->addAction( qtr( "&Play" ), this, SLOT( play() ),
QKeySequence( "Alt+P" ) );
- openButtonMenu->addAction( qtr("&Stream"), this, SLOT( stream() ) ,
+ openButtonMenu->addAction( qtr( "&Stream" ), this, SLOT( stream() ) ,
QKeySequence( "Alt+S" ) );
- openButtonMenu->addAction( qtr("&Convert"), this, SLOT( transcode( ) ) ,
+ openButtonMenu->addAction( qtr( "&Convert" ), this, SLOT( transcode() ) ,
QKeySequence( "Alt+C" ) );
playButton->setMenu( openButtonMenu );
ui.buttonsBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
/* Force MRL update on tab change */
- CONNECT( ui.Tab, currentChanged(int), this, signalCurrent());
+ CONNECT( ui.Tab, currentChanged(int), this, signalCurrent() );
CONNECT( fileOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
CONNECT( netOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
CONNECT( discOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
- CONNECT( captureOpenPanel, mrlUpdated( QString ), this,
- updateMRL(QString) );
+ CONNECT( captureOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
CONNECT( fileOpenPanel, methodChanged( QString ),
- this, newMethod(QString) );
+ this, newCachingMethod(QString) );
CONNECT( netOpenPanel, methodChanged( QString ),
- this, newMethod(QString) );
+ this, newCachingMethod(QString) );
CONNECT( discOpenPanel, methodChanged( QString ),
- this, newMethod(QString) );
+ this, newCachingMethod(QString) );
CONNECT( captureOpenPanel, methodChanged( QString ),
- this, newMethod(QString) );
+ this, newCachingMethod(QString) );
/* Advanced frame Connects */
- CONNECT( ui.slaveText, textChanged(QString), this, updateMRL());
- CONNECT( ui.cacheSpinBox, valueChanged(int), this, updateMRL());
- CONNECT( ui.startTimeSpinBox, valueChanged(int), this, updateMRL());
+ CONNECT( ui.slaveText, textChanged(QString), this, updateMRL() );
+ CONNECT( ui.cacheSpinBox, valueChanged(int), this, updateMRL() );
+ CONNECT( ui.startTimeSpinBox, valueChanged(int), this, updateMRL() );
BUTTONACT( ui.advancedCheckBox , toggleAdvancedPanel() );
/* Buttons action */
- BUTTONACT( playButton, play());
- BUTTONACT( cancelButton, cancel());
+ BUTTONACT( playButton, selectSlots() );
+ BUTTONACT( cancelButton, cancel() );
/* At creation time, modify the default buttons */
if ( i_action_flag ) setMenuAction();
-
/* Initialize caching */
storedMethod = "";
- newMethod("file-caching");
+ newCachingMethod( "file-caching" );
mainHeight = advHeight = 0;
}
{
switch ( i_action_flag )
{
- case OPEN_AND_STREAM:
- playButton->setText( qtr("&Stream") );
- BUTTONACT( playButton, stream() );
- break;
- case OPEN_AND_SAVE:
- playButton->setText( qtr("&Convert / Save") );
- BUTTONACT( playButton, stream( true ) );
- break;
- case ENQUEUE:
- playButton->setText( qtr("&Enqueue") );
- BUTTONACT( playButton, enqueue() );
- break;
- case OPEN_AND_PLAY:
- default:
- playButton->setText( qtr("&Play") );
- BUTTONACT( playButton, play() );
+ case OPEN_AND_STREAM:
+ playButton->setText( qtr( "&Stream" ) );
+ break;
+ case OPEN_AND_SAVE:
+ playButton->setText( qtr( "&Convert / Save" ) );
+ break;
+ case OPEN_AND_ENQUEUE:
+ playButton->setText( qtr( "&Enqueue" ) );
+ break;
+ case OPEN_AND_PLAY:
+ default:
+ playButton->setText( qtr( "&Play" ) );
}
}
-void OpenDialog::showTab(int i_tab=0)
+void OpenDialog::showTab( int i_tab=0 )
{
this->show();
- ui.Tab->setCurrentIndex(i_tab);
+ ui.Tab->setCurrentIndex( i_tab );
}
void OpenDialog::signalCurrent() {
- if (ui.Tab->currentWidget() != NULL) {
- (dynamic_cast<OpenPanel*>(ui.Tab->currentWidget()))->updateMRL();
+ if (ui.Tab->currentWidget() != NULL)
+ (dynamic_cast<OpenPanel *>( ui.Tab->currentWidget() ))->updateMRL();
+}
+
+void OpenDialog::toggleAdvancedPanel()
+{
+ //FIXME does not work under Windows
+ if( ui.advancedFrame->isVisible() ) {
+ ui.advancedFrame->hide();
+#ifndef WIN32
+ setMinimumHeight( 1 );
+ resize( width(), mainHeight );
+#endif
+ } else {
+#ifndef WIN32
+ if( mainHeight == 0 )
+ mainHeight = height();
+#endif
+
+ ui.advancedFrame->show();
+#ifndef WIN32
+ if( advHeight == 0 ) {
+ advHeight = height() - mainHeight;
+ }
+ resize( width(), mainHeight + advHeight );
+#endif
}
}
/***********
* Actions *
***********/
-
/* If Cancel is pressed or escaped */
void OpenDialog::cancel()
{
- fileOpenPanel->clear();
- this->toggleVisible();
- if( isModal() )
- reject();
+ for( int i = 0; i < OPEN_TAB_MAX; i++ )
+ dynamic_cast<OpenPanel*>(ui.Tab->widget( i ))->clear();
+ toggleVisible();
+ if( isModal() ) reject();
}
/* If EnterKey is pressed */
void OpenDialog::close()
{
- /* FIXME */
- if ( !i_action_flag )
- {
- play();
- }
- else
+ selectSlots();
+}
+
+/* Play button */
+void OpenDialog::selectSlots()
+{
+ switch ( i_action_flag )
{
+ case OPEN_AND_STREAM:
stream();
+ break;
+ case OPEN_AND_SAVE:
+ transcode();
+ break;
+ case OPEN_AND_ENQUEUE:
+ enqueue();
+ break;
+ case OPEN_AND_PLAY:
+ default:
+ play();
}
}
-/* Play button */
void OpenDialog::play()
{
finish( false );
void OpenDialog::finish( bool b_enqueue = false )
{
- this->toggleVisible();
+ toggleVisible();
mrl = ui.advancedLineInput->text();
if( !isModal() )
{
bool b_start = !i && !b_enqueue;
input_item_t *p_input;
- const char *psz_utf8 = qtu( tempMRL[i] );
- p_input = input_ItemNew( p_intf, psz_utf8, NULL );
+ p_input = input_ItemNew( p_intf, qtu( tempMRL[i] ), NULL );
/* Insert options */
while( i + 1 < tempMRL.size() && tempMRL[i + 1].startsWith( ":" ) )
{
i++;
- psz_utf8 = qtu( tempMRL[i] );
- input_ItemAddOption( p_input, psz_utf8 );
+ input_ItemAddOption( p_input, qtu( tempMRL[i] ) );
}
+ /* Switch between enqueuing and starting the item */
if( b_start )
{
playlist_AddInput( THEPL, p_input,
else
{
playlist_AddInput( THEPL, p_input,
- PLAYLIST_APPEND|PLAYLIST_PREPARSE,
+ PLAYLIST_APPEND | PLAYLIST_PREPARSE,
PLAYLIST_END, VLC_TRUE, VLC_FALSE );
}
}
accept();
}
-void OpenDialog::toggleAdvancedPanel()
-{
- //FIXME does not work under Windows
- if( ui.advancedFrame->isVisible() ) {
- ui.advancedFrame->hide();
-#ifndef WIN32
- setMinimumHeight(1);
- resize( width(), mainHeight );
-#endif
- } else {
-#ifndef WIN32
- if( mainHeight == 0 )
- mainHeight = height();
-#endif
- ui.advancedFrame->show();
-#ifndef WIN32
- if( advHeight == 0 ) {
- advHeight = height() - mainHeight;
- }
- resize( width(), mainHeight + advHeight );
-#endif
- }
+/* Update the MRL */
+void OpenDialog::updateMRL( QString tempMRL )
+{
+ mainMRL = tempMRL;
+ updateMRL();
}
void OpenDialog::updateMRL() {
if( ui.slaveCheckbox->isChecked() ) {
mrl += " :input-slave=" + ui.slaveText->text();
}
- int i_cache = config_GetInt( p_intf, qta(storedMethod) );
+ int i_cache = config_GetInt( p_intf, qta( storedMethod ) );
if( i_cache != ui.cacheSpinBox->value() ) {
- mrl += QString(" :%1=%2").arg(storedMethod).
- arg(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());
+ if( ui.startTimeSpinBox->value() ) {
+ mrl += " :start-time=" + QString( "%1" ).
+ arg( ui.startTimeSpinBox->value() );
}
- ui.advancedLineInput->setText(mrl);
-}
-
-void OpenDialog::updateMRL(QString tempMRL)
-{
- mainMRL = tempMRL;
- updateMRL();
+ ui.advancedLineInput->setText( mrl );
}
-void OpenDialog::newMethod(QString method)
+void OpenDialog::newCachingMethod( QString method )
{
if( method != storedMethod ) {
storedMethod = method;
- int i_value = config_GetInt( p_intf, qta(storedMethod) );
- ui.cacheSpinBox->setValue(i_value);
+ int i_value = config_GetInt( p_intf, qta( storedMethod ) );
+ ui.cacheSpinBox->setValue( i_value );
}
}