Commit 3005a8a9 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: add a --qt-embedded-open option to have the 0.9 integration of open panel...

Qt: add a --qt-embedded-open option to have the 0.9 integration of open panel using the NON-native Qt open dialog.

I know people prefer native dialog, but Qt4.5 improved the QFileDialog a lot, and some people (including devs) ask for it, so here it is. It doesn't increase the code a lot and the code is tested.
parent e725795f
...@@ -56,29 +56,64 @@ static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda", ...@@ -56,29 +56,64 @@ static const char *psz_devModule[] = { "v4l", "v4l2", "pvr", "dvb", "bda",
* Open Files and subtitles * * Open Files and subtitles *
**************************************************************************/ **************************************************************************/
FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
OpenPanel( _parent, _p_intf ) OpenPanel( _parent, _p_intf ), dialogBox( NULL )
{ {
/* Classic UI Setup */ /* Classic UI Setup */
ui.setupUi( this ); ui.setupUi( this );
#if 0
/** BEGIN QFileDialog tweaking **/
/* Use a QFileDialog and customize it because we don't want to
rewrite it all. Be careful to your eyes cause there are a few hacks.
Be very careful and test correctly when you modify this. */
/* Set Filters for file selection */ /* Set Filters for file selection */
QString fileTypes = ""; /* QString fileTypes = "";
ADD_FILTER_MEDIA( fileTypes ); ADD_FILTER_MEDIA( fileTypes );
ADD_FILTER_VIDEO( fileTypes ); ADD_FILTER_VIDEO( fileTypes );
ADD_FILTER_AUDIO( fileTypes ); ADD_FILTER_AUDIO( fileTypes );
ADD_FILTER_PLAYLIST( fileTypes ); ADD_FILTER_PLAYLIST( fileTypes );
ADD_FILTER_ALL( fileTypes ); ADD_FILTER_ALL( fileTypes );
fileTypes.replace( QString(";*"), QString(" *")); fileTypes.replace( QString(";*"), QString(" *")); */
/* lineFileEdit = ui.fileEdit;
//TODO later: fill the fileCompleteList with previous items played.
QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
fileCompleter->setModel( new QDirModel( fileCompleter ) );
lineFileEdit->setCompleter( fileCompleter );*/
if( config_GetInt( p_intf, "qt-embedded-open" ) )
{
ui.tempWidget->hide();
BuildOldPanel();
}
/* Subtitles */
/* Deactivate the subtitles control by default. */
ui.subFrame->setEnabled( false );
/* Build the subs size combo box */
setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
ui.sizeSubComboBox );
/* Build the subs align combo box */
setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox );
/* Connects */
BUTTONACT( ui.fileBrowseButton, browseFile() );
BUTTONACT( ui.delFileButton, deleteFile() );
BUTTONACT( ui.subBrowseButton, browseFileSub() );
CONNECT( ui.subCheckBox, toggled( bool ), this, toggleSubtitleFrame( bool ) );
CONNECT( ui.fileListWidg, itemChanged( QListWidgetItem * ), this, updateMRL() );
CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
}
inline void FileOpenPanel::BuildOldPanel()
{
/** BEGIN QFileDialog tweaking **/
/* Use a QFileDialog and customize it because we don't want to
rewrite it all. Be careful to your eyes cause there are a few hacks.
Be very careful and test correctly when you modify this. */
// Make this QFileDialog a child of tempWidget from the ui. /* Make this QFileDialog a child of tempWidget from the ui. */
dialogBox = new FileOpenBox( ui.tempWidget, NULL, dialogBox = new FileOpenBox( ui.tempWidget, NULL,
qfu( p_intf->p_sys->psz_filepath ), fileTypes ); qfu( p_intf->p_sys->psz_filepath ), "" );
dialogBox->setFileMode( QFileDialog::ExistingFiles ); dialogBox->setFileMode( QFileDialog::ExistingFiles );
dialogBox->setAcceptMode( QFileDialog::AcceptOpen ); dialogBox->setAcceptMode( QFileDialog::AcceptOpen );
...@@ -99,7 +134,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ...@@ -99,7 +134,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
/* Ugly hacks to get the good Widget */ /* Ugly hacks to get the good Widget */
//This lineEdit is the normal line in the fileDialog. //This lineEdit is the normal line in the fileDialog.
lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0]; QLineEdit *lineFileEdit = dialogBox->findChildren<QLineEdit*>()[0];
/* Make a list of QLabel inside the QFileDialog to access the good ones */ /* Make a list of QLabel inside the QFileDialog to access the good ones */
QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>(); QList<QLabel *> listLabel = dialogBox->findChildren<QLabel*>();
...@@ -114,40 +149,16 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ...@@ -114,40 +149,16 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
/** END of QFileDialog tweaking **/ /** END of QFileDialog tweaking **/
// Add the DialogBox to the layout // Add the DialogBox to the layout
ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 ); ui.gridLayout_3->addWidget( dialogBox, 0, 0, 1, 3 );
#endif
/* lineFileEdit = ui.fileEdit;
//TODO later: fill the fileCompleteList with previous items played.
QCompleter *fileCompleter = new QCompleter( fileCompleteList, this );
fileCompleter->setModel( new QDirModel( fileCompleter ) );
lineFileEdit->setCompleter( fileCompleter );*/
// Hide the subtitles control by default.
ui.subFrame->setEnabled( false );
/* Build the subs size combo box */
setfillVLCConfigCombo( "freetype-rel-fontsize" , p_intf,
ui.sizeSubComboBox );
/* Build the subs align combo box */ CONNECT( lineFileEdit, textChanged( QString ), this, updateMRL() );
setfillVLCConfigCombo( "subsdec-align", p_intf, ui.alignSubComboBox ); dialogBox->installEventFilter( this );
/* Connects */
BUTTONACT( ui.fileBrowseButton, browseFile() );
BUTTONACT( ui.delFileButton, deleteFile() );
BUTTONACT( ui.subBrowseButton, browseFileSub() );
CONNECT( ui.subCheckBox, toggled( bool ), this, toggleSubtitleFrame( bool ) );
CONNECT( ui.fileListWidg, itemChanged( QListWidgetItem * ), this, updateMRL() );
CONNECT( ui.subInput, textChanged( QString ), this, updateMRL() );
CONNECT( ui.alignSubComboBox, currentIndexChanged( int ), this, updateMRL() );
CONNECT( ui.sizeSubComboBox, currentIndexChanged( int ), this, updateMRL() );
} }
FileOpenPanel::~FileOpenPanel() FileOpenPanel::~FileOpenPanel()
{ {
// getSettings()->setValue( "file-dialog-state", dialogBox->saveState() ); if( dialogBox )
getSettings()->setValue( "file-dialog-state", dialogBox->saveState() );
} }
void FileOpenPanel::browseFile() void FileOpenPanel::browseFile()
...@@ -201,12 +212,17 @@ void FileOpenPanel::updateMRL() ...@@ -201,12 +212,17 @@ void FileOpenPanel::updateMRL()
QStringList fileList; QStringList fileList;
QString mrl; QString mrl;
for( int i = 0; i < ui.fileListWidg->count(); i++ ) /* File Listing */
{ if( dialogBox == NULL )
if( !ui.fileListWidg->item( i )->text().isEmpty() ) for( int i = 0; i < ui.fileListWidg->count(); i++ )
fileList << ui.fileListWidg->item( i )->text(); {
} if( !ui.fileListWidg->item( i )->text().isEmpty() )
fileList << ui.fileListWidg->item( i )->text();
}
else
fileList = dialogBox->selectedFiles();
/* Options */
if( ui.subCheckBox->isChecked() && !ui.subInput->text().isEmpty() ) { if( ui.subCheckBox->isChecked() && !ui.subInput->text().isEmpty() ) {
mrl.append( " :sub-file=" + colon_escape( ui.subInput->text() ) ); mrl.append( " :sub-file=" + colon_escape( ui.subInput->text() ) );
int align = ui.alignSubComboBox->itemData( int align = ui.alignSubComboBox->itemData(
......
...@@ -95,6 +95,19 @@ signals: ...@@ -95,6 +95,19 @@ signals:
void methodChanged( QString method ); void methodChanged( QString method );
}; };
class FileOpenBox: public QFileDialog
{
Q_OBJECT;
public:
FileOpenBox( QWidget *parent, const QString &caption,
const QString &directory, const QString &filter ):
QFileDialog( parent, caption, directory, filter ) {}
public slots:
void accept(){}
void reject(){}
};
class FileOpenPanel: public OpenPanel class FileOpenPanel: public OpenPanel
{ {
Q_OBJECT; Q_OBJECT;
...@@ -103,8 +116,22 @@ public: ...@@ -103,8 +116,22 @@ public:
virtual ~FileOpenPanel(); virtual ~FileOpenPanel();
virtual void clear() ; virtual void clear() ;
virtual void accept() ; virtual void accept() ;
protected:
bool eventFilter(QObject *obj, QEvent *event)
{
if( event->type() == QEvent::Hide ||
event->type() == QEvent::HideToParent )
{
msg_Warn( p_intf, "here" );
event->accept();
return true;
}
return false;
}
private: private:
Ui::OpenFile ui; Ui::OpenFile ui;
FileOpenBox *dialogBox;
void BuildOldPanel();
public slots: public slots:
virtual void updateMRL(); virtual void updateMRL();
private slots: private slots:
......
...@@ -154,6 +154,7 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * ); ...@@ -154,6 +154,7 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
#define QT_MINIMAL_MODE_TEXT N_( "Minimal look with no menus" ) #define QT_MINIMAL_MODE_TEXT N_( "Minimal look with no menus" )
#define QT_FULLSCREEN_TEXT N_( "Show a controller in fullscreen mode" ) #define QT_FULLSCREEN_TEXT N_( "Show a controller in fullscreen mode" )
#define QT_NATIVEOPEN_TEXT N_( "Integrate the file browser in open dialog" )
/* Various modes definition */ /* Various modes definition */
static const int i_mode_list[] = static const int i_mode_list[] =
...@@ -202,6 +203,8 @@ vlc_module_begin () ...@@ -202,6 +203,8 @@ vlc_module_begin ()
change_autosave () change_autosave ()
change_internal () change_internal ()
add_bool( "qt-embedded-open", false, NULL, QT_NATIVEOPEN_TEXT,
QT_NATIVEOPEN_TEXT, false )
add_bool( "qt-recentplay", true, NULL, RECENTPLAY_TEXT, add_bool( "qt-recentplay", true, NULL, RECENTPLAY_TEXT,
RECENTPLAY_TEXT, false ) RECENTPLAY_TEXT, false )
add_string( "qt-recentplay-filter", "", NULL, add_string( "qt-recentplay-filter", "", NULL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment