X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fdialogs%2Fopen.cpp;h=3a13ca9e67ecbedc17f71a907cbd0f9dae43338c;hb=33e8266df2b1de424d15506d22d827b297ea65a6;hp=975e94bb49423bc22cff47639e2a6f5ba332509d;hpb=97f221eb4d6876bb37de2e4c3adbc622b4908101;p=vlc diff --git a/modules/gui/qt4/dialogs/open.cpp b/modules/gui/qt4/dialogs/open.cpp index 975e94bb49..3a13ca9e67 100644 --- a/modules/gui/qt4/dialogs/open.cpp +++ b/modules/gui/qt4/dialogs/open.cpp @@ -1,7 +1,7 @@ /***************************************************************************** * open.cpp : Advanced open dialog ***************************************************************************** - * Copyright ( C ) 2006-2007 the VideoLAN team + * Copyright © 2006-2007 the VideoLAN team * $Id$ * * Authors: Jean-Baptiste Kempf @@ -9,7 +9,7 @@ * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or - * ( at your option ) any later version. + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,6 +20,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include "input_manager.hpp" @@ -34,31 +37,36 @@ OpenDialog *OpenDialog::instance = NULL; OpenDialog* OpenDialog::getInstance( QWidget *parent, intf_thread_t *p_intf, - int _action_flag, bool modal ) + bool b_rawInstance, int _action_flag, bool b_selectMode ) { /* Creation */ if( !instance ) - instance = new OpenDialog( parent, p_intf, modal, _action_flag ); - else + instance = new OpenDialog( parent, p_intf, b_selectMode, _action_flag ); + else if( !b_rawInstance ) { /* Request the instance but change small details: - Button menu - Modality on top of the parent dialog */ + if( b_selectMode ) + { + instance->setWindowModality( Qt::WindowModal ); + _action_flag = SELECT; /* This should be useless, but we never know + if the call is correct */ + } instance->i_action_flag = _action_flag; instance->setMenuAction(); - if( modal ) instance->setWindowModality( Qt::WindowModal ); } return instance; } OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, - bool modal, + bool b_selectMode, int _action_flag ) : QVLCDialog( parent, _p_intf ) { i_action_flag = _action_flag; - if( modal ) /* Select mode */ + if( b_selectMode ) /* Select mode */ { setWindowModality( Qt::WindowModal ); i_action_flag = SELECT; @@ -67,7 +75,8 @@ OpenDialog::OpenDialog( QWidget *parent, /* Basic Creation of the Window */ ui.setupUi( this ); setWindowTitle( qtr( "Open" ) ); - resize( 410, 300 ); + /* resize( 410, 600 ); */ + setMinimumSize( 520, 460 ); /* Tab definition and creation */ fileOpenPanel = new FileOpenPanel( ui.Tab, p_intf ); @@ -88,27 +97,14 @@ OpenDialog::OpenDialog( QWidget *parent, ui.slaveBrowseButton->hide(); /* Buttons Creation */ - 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->setMinimumSize( QSize( 90, 0 ) ); - playButton->setPopupMode( QToolButton::MenuButtonPopup ); - playButton->setToolButtonStyle( Qt::ToolButtonTextOnly ); + playButton = ui.playButton; /* Cancel Button */ - cancelButton = new QPushButton(); - cancelButton->setText( qtr( "&Cancel" ) ); - cancelButton->setSizePolicy( buttonSizePolicy ); + cancelButton = new QPushButton( qtr( "&Cancel" ) ); /* Select Button */ - selectButton = new QPushButton; - selectButton->setText( qtr( "Select" ) ); - selectButton->setSizePolicy( buttonSizePolicy ); + selectButton = new QPushButton( qtr( "&Select" ) ); /* Menu for the Play button */ QMenu * openButtonMenu = new QMenu( "Open" ); @@ -121,10 +117,9 @@ OpenDialog::OpenDialog( QWidget *parent, openButtonMenu->addAction( qtr( "&Convert" ), this, SLOT( transcode() ) , QKeySequence( "Alt+C" ) ); - playButton->setMenu( openButtonMenu ); + ui.menuButton->setMenu( openButtonMenu ); /* Add the three Buttons */ - ui.buttonsBox->addButton( playButton, QDialogButtonBox::ActionRole ); ui.buttonsBox->addButton( selectButton, QDialogButtonBox::AcceptRole ); ui.buttonsBox->addButton( cancelButton, QDialogButtonBox::RejectRole ); @@ -152,7 +147,8 @@ OpenDialog::OpenDialog( QWidget *parent, 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() ); + BUTTONACT( ui.advancedCheckBox, toggleAdvancedPanel() ); + BUTTONACT( ui.slaveBrowseButton, browseInputSlave() ); /* Buttons action */ BUTTONACT( playButton, selectSlots() ); @@ -180,6 +176,7 @@ void OpenDialog::setMenuAction() { playButton->hide(); selectButton->show(); + selectButton->setDefault( true ); } else { @@ -200,10 +197,11 @@ void OpenDialog::setMenuAction() } playButton->show(); selectButton->hide(); + playButton->setDefault( true ); } } -void OpenDialog::showTab( int i_tab=0 ) +void OpenDialog::showTab( int i_tab ) { ui.Tab->setCurrentIndex( i_tab ); show(); @@ -221,12 +219,18 @@ void OpenDialog::toggleAdvancedPanel() if( ui.advancedFrame->isVisible() ) { ui.advancedFrame->hide(); - //FIXME: Clear Bug here. Qt ? - resize( size().width(), size().height() - ui.advancedFrame->height() ); + //setMinimumSize( 520, 460 ); + if( size().isValid() ) + resize( size().width(), size().height() + - ui.advancedFrame->height() ); } else { ui.advancedFrame->show(); + //setMinimumSize( 520, 460 + ui.advancedFrame->height() ); + if( size().isValid() ) + resize( size().width(), size().height() + + ui.advancedFrame->height() ); } } @@ -245,14 +249,15 @@ void OpenDialog::cancel() mainMRL.clear(); /* If in Select Mode, reject instead of hiding */ - if( windowModality() != Qt::NonModal ) reject(); + if( i_action_flag == SELECT ) reject(); else hide(); } /* If EnterKey is pressed */ void OpenDialog::close() { - if( windowModality() != Qt::NonModal ) + /* If in Select Mode, accept instead of selecting a Slot */ + if( i_action_flag == SELECT ) accept(); else selectSlots(); @@ -294,7 +299,7 @@ void OpenDialog::finish( bool b_enqueue = false ) toggleVisible(); mrl = ui.advancedLineInput->text(); - if( windowModality() == Qt::NonModal ) + if( i_action_flag != SELECT ) { QStringList tempMRL = SeparateEntries( mrl ); for( size_t i = 0; i < tempMRL.size(); i++ ) @@ -312,18 +317,11 @@ void OpenDialog::finish( bool b_enqueue = false ) } /* Switch between enqueuing and starting the item */ - if( b_start ) - { - playlist_AddInput( THEPL, p_input, - PLAYLIST_APPEND | PLAYLIST_GO, - PLAYLIST_END, VLC_TRUE, VLC_FALSE ); - } - else - { - playlist_AddInput( THEPL, p_input, - PLAYLIST_APPEND | PLAYLIST_PREPARSE, - PLAYLIST_END, VLC_TRUE, VLC_FALSE ); - } + /* FIXME: playlist_AddInput() can fail */ + playlist_AddInput( THEPL, p_input, + PLAYLIST_APPEND | ( b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE ), + PLAYLIST_END, true, pl_Unlocked ); + vlc_gc_decref( p_input ); } } else @@ -339,7 +337,9 @@ void OpenDialog::stream( bool b_transcode_only ) { mrl = ui.advancedLineInput->text(); toggleVisible(); - THEDP->streamingDialog( mrl, b_transcode_only ); + QStringList listMRL = SeparateEntries( mrl ); + if( listMRL.size() > 0 ) + THEDP->streamingDialog( this, SeparateEntries( mrl )[0], b_transcode_only ); } /* Update the MRL */ @@ -422,3 +422,11 @@ QStringList OpenDialog::SeparateEntries( QString entries ) return entries_array; } + +void OpenDialog::browseInputSlave() +{ + OpenDialog *od = new OpenDialog( this, p_intf, true, SELECT ); + od->exec(); + ui.slaveText->setText( od->getMRL() ); + delete od; +}