From 93a51f20cf1545b31c0020653c7098d8eed5be9a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Mon, 19 Mar 2007 00:19:47 +0000 Subject: [PATCH] Qt4 - Open: New way and interface for File Open using an integration of QFileDialog inside the FileOpenPanel. The integration should be alright. Be careful for your eyes when reading the code, it can burn them :) Anyway, there are still a few bugs (the main one is the disapearing of QFileDialog on acceptance) and some alignment issues. I got NO idea how this behaves under Windows... A special code may be needed. --- modules/gui/qt4/components/open.cpp | 61 +++++++++++--- modules/gui/qt4/components/open.hpp | 6 ++ modules/gui/qt4/dialogs/open.cpp | 1 + modules/gui/qt4/ui/open.ui | 77 ++++++++++++------ modules/gui/qt4/ui/open_disk.ui | 105 +++++++++++++++++++++---- modules/gui/qt4/ui/open_file.ui | 79 +++++++++++++------ modules/gui/qt4/ui/sprefs_subtitles.ui | 9 ++- 7 files changed, 263 insertions(+), 75 deletions(-) diff --git a/modules/gui/qt4/components/open.cpp b/modules/gui/qt4/components/open.cpp index 3fbab4628d..bc90e3a4e5 100644 --- a/modules/gui/qt4/components/open.cpp +++ b/modules/gui/qt4/components/open.cpp @@ -26,6 +26,11 @@ #include "qt4.hpp" #include "components/open.hpp" #include "dialogs_provider.hpp" +#include "util/customwidgets.hpp" + +#include +#include +#include /************************************************************************** * File open @@ -33,10 +38,39 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : OpenPanel( _parent, _p_intf ) { + /* Classic UI Setup */ ui.setupUi( this ); + /* 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. + dialogBox = new QFileDialog( ui.tempWidget ); + dialogBox->setFileMode( QFileDialog::ExistingFiles ); + dialogBox->setDirectory( qfu( p_intf->p_libvlc->psz_homedir ) ); + /* We don't want to see a grip in the middle of the window, do we? */ + dialogBox->setSizeGripEnabled( false ); + + // Add it to the layout + ui.gridLayout->addWidget( dialogBox, 0, 0, 1, 3 ); + + // But hide the two OK/Cancel buttons. Enable them for debug. + findChild()->hide(); + + /* Ugly hacks to get the good Widget */ + //This lineEdit is the normal line in the fileDialog. + lineFileEdit = findChildren()[3]; + lineFileEdit->hide(); + + /* Make a list of QLabel inside the QFileDialog to access the good ones */ + QList listLabel = findChildren(); + + /* Hide the FileNames one. Enable it for debug */ + listLabel[4]->hide(); + /* Change the text that was uncool in the usual box */ + listLabel[5]->setText( qtr( "Filter:" ) ); - BUTTONACT( ui.fileBrowseButton, browseFile() ); BUTTONACT( ui.subBrowseButton, browseFileSub() ); BUTTONACT( ui.subGroupBox, updateMRL()); @@ -44,6 +78,7 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : CONNECT( ui.subInput, editTextChanged(QString ), this, updateMRL()); CONNECT( ui.alignSubComboBox, currentIndexChanged(int), this, updateMRL()); CONNECT( ui.sizeSubComboBox, currentIndexChanged(int), this, updateMRL()); + CONNECT( lineFileEdit, textChanged( QString ), this, browseFile()); } FileOpenPanel::~FileOpenPanel() @@ -57,14 +92,10 @@ QStringList FileOpenPanel::browse(QString help) void FileOpenPanel::browseFile() { QString fileString = ""; - QStringList files = browse( qtr("Open File") ); - foreach( QString file, files) { - fileString += "\"" + file + "\" "; + foreach( QString file, dialogBox->selectedFiles() ) { + fileString += "\"" + file + "\" "; } ui.fileInput->setEditText( fileString ); - ui.fileInput->addItem( fileString ); - if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem(0); - updateMRL(); } @@ -83,14 +114,24 @@ void FileOpenPanel::updateMRL() mrl.append( " :subsdec-align=" + ui.alignSubComboBox->currentText() ); mrl.append( " :sub-rel-fontsize=" + ui.sizeSubComboBox->currentText() ); } - emit mrlUpdated(mrl); + emit mrlUpdated( mrl ); emit methodChanged( "file-caching" ); } + +/* Function called by Open Dialog when clicke on Play/Enqueue */ +void FileOpenPanel::accept() +{ + ui.fileInput->addItem(ui.fileInput->currentText()); + if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem(0); +} + + +/* Function called by Open Dialog when clicked on cancel */ void FileOpenPanel::clear() { - ui.fileInput->setEditText( ""); - ui.subInput->setEditText( ""); + ui.fileInput->setEditText( "" ); + ui.subInput->setEditText( "" ); } diff --git a/modules/gui/qt4/components/open.hpp b/modules/gui/qt4/components/open.hpp index d3b6a127a7..81ec2b4c0a 100644 --- a/modules/gui/qt4/components/open.hpp +++ b/modules/gui/qt4/components/open.hpp @@ -33,6 +33,9 @@ #include "ui/open_net.h" #include "ui/open_capture.h" +class QFileDialog; +class QLineEdit; + class OpenPanel: public QWidget { Q_OBJECT; @@ -59,9 +62,12 @@ public: FileOpenPanel( QWidget *, intf_thread_t * ); virtual ~FileOpenPanel(); virtual void clear() ; + virtual void accept() ; private: Ui::OpenFile ui; QStringList browse( QString ); + QFileDialog *dialogBox; + QLineEdit *lineFileEdit; public slots: virtual void updateMRL(); private slots: diff --git a/modules/gui/qt4/dialogs/open.cpp b/modules/gui/qt4/dialogs/open.cpp index 71030d9b1c..f23fe4e91e 100644 --- a/modules/gui/qt4/dialogs/open.cpp +++ b/modules/gui/qt4/dialogs/open.cpp @@ -42,6 +42,7 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) : setModal( modal ); ui.setupUi( this ); setWindowTitle( qtr("Open" ) ); + resize( 500, 300); fileOpenPanel = new FileOpenPanel( this , p_intf ); diskOpenPanel = new DiskOpenPanel( this , p_intf ); diff --git a/modules/gui/qt4/ui/open.ui b/modules/gui/qt4/ui/open.ui index 0981a688dd..88b7363940 100644 --- a/modules/gui/qt4/ui/open.ui +++ b/modules/gui/qt4/ui/open.ui @@ -60,21 +60,11 @@ 6 - - - - ms - - - - - + + false - - Extra media - @@ -92,6 +82,30 @@ + + + + ms + + + + + + + Customize + + + + + + + false + + + Extra media + + + @@ -102,29 +116,28 @@ 0 + + Qt::AlignRight + 999999 - - + + + + false + - Customize + Browse - + - - - - false - - - - + Play another media synchronously (extra audio file, ...) @@ -226,5 +239,21 @@ + + slaveCheckbox + clicked(bool) + slaveBrowseButton + setEnabled(bool) + + + 219 + 102 + + + 386 + 131 + + + diff --git a/modules/gui/qt4/ui/open_disk.ui b/modules/gui/qt4/ui/open_disk.ui index 2166c0daa3..76aa262709 100644 --- a/modules/gui/qt4/ui/open_disk.ui +++ b/modules/gui/qt4/ui/open_disk.ui @@ -6,8 +6,8 @@ 0 0 - 487 - 254 + 539 + 246 @@ -32,28 +32,74 @@ 6 - + + + + SVCD/VCD + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + Disk device - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::LeftToRight + - SVCD/VCD + DVD + + + true - + true - + + + + Browse + + + + Audio CD @@ -61,12 +107,35 @@ - - - DVD + + + Qt::Horizontal - - true + + + 21 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal @@ -102,6 +171,9 @@ + + Qt::AlignRight + @@ -128,6 +200,9 @@ false + + Qt::AlignRight + @@ -149,8 +224,8 @@ - 20 - 40 + 469 + 16 diff --git a/modules/gui/qt4/ui/open_file.ui b/modules/gui/qt4/ui/open_file.ui index b7ae83784d..0ac290b1dc 100644 --- a/modules/gui/qt4/ui/open_file.ui +++ b/modules/gui/qt4/ui/open_file.ui @@ -6,20 +6,20 @@ 0 0 - 487 - 181 + 400 + 210 - 3 + 7 3 0 0 - Form + Open File @@ -28,20 +28,23 @@ 6 - + - Qt::Vertical + Qt::Horizontal + + + QSizePolicy::Fixed - 20 - 40 + 3 + 20 - + @@ -62,10 +65,10 @@ - 9 + 6 - 6 + 5 @@ -191,21 +194,10 @@ - - - - File - - - - - - - Browse - - + + - + @@ -223,8 +215,45 @@ + + + + File / Directory Names; + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 273 + 16 + + + + + + + + Qt::Vertical + + + + 525 + 31 + + + + + diff --git a/modules/gui/qt4/ui/sprefs_subtitles.ui b/modules/gui/qt4/ui/sprefs_subtitles.ui index 44be37b0f2..91f7096364 100644 --- a/modules/gui/qt4/ui/sprefs_subtitles.ui +++ b/modules/gui/qt4/ui/sprefs_subtitles.ui @@ -67,7 +67,14 @@ - + + + 12 + + + false + + -- 2.39.2