From 979719c9b4019ce515b6ffb938b8445721be5722 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Wed, 29 Nov 2006 03:35:26 +0000 Subject: [PATCH] Qt4 : Some work on OpenDialog. Does not work with files with spaces... More work to do. --- modules/gui/qt4/components/open.cpp | 62 +++++++++++++++++++++++++++ modules/gui/qt4/components/open.hpp | 9 +++- modules/gui/qt4/dialogs/mediainfo.cpp | 1 + modules/gui/qt4/dialogs/open.cpp | 47 ++++++++++++++++---- modules/gui/qt4/dialogs/open.hpp | 9 ++++ modules/gui/qt4/ui/open.ui | 2 +- modules/gui/qt4/ui/open_file.ui | 13 +++++- 7 files changed, 131 insertions(+), 12 deletions(-) diff --git a/modules/gui/qt4/components/open.cpp b/modules/gui/qt4/components/open.cpp index 525351ce61..0120f02db2 100644 --- a/modules/gui/qt4/components/open.cpp +++ b/modules/gui/qt4/components/open.cpp @@ -26,6 +26,7 @@ #include "qt4.hpp" #include "components/open.hpp" +#include /************************************************************************** * Open panel ***************************************************************************/ @@ -41,7 +42,12 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : { ui.setupUi( this ); ui.audioGroupBox->hide(); + BUTTONACT( ui.extraAudioButton, toggleExtraAudio() ); + BUTTONACT( ui.fileBrowseButton, browseFile() ); + BUTTONACT( ui.subBrowseButton, browseFileSub() ); + BUTTONACT( ui.audioBrowseButton, browseFileAudio() ); + CONNECT( ui.fileInput, editTextChanged(QString ), this, updateMRL()); } FileOpenPanel::~FileOpenPanel() @@ -50,6 +56,53 @@ FileOpenPanel::~FileOpenPanel() void FileOpenPanel::sendUpdate() {} +QStringList FileOpenPanel::browse() +{ + return QFileDialog::getOpenFileNames( this, qtr("Open File"), "", "" ); +} + +void FileOpenPanel::browseFile() +{ + //FIXME ! files with spaces + QString files = browse().join(" "); + ui.fileInput->setEditText( files ); + ui.fileInput->addItem( files ); + + if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem(0); + + updateMRL(); +} + +void FileOpenPanel::browseFileSub() +{ + ui.subInput->setEditText( browse().join(" ") ); + + updateSubsMRL(); +} + +void FileOpenPanel::browseFileAudio() +{ + ui.audioFileInput->setEditText( browse().join(" ") ); +} + +void FileOpenPanel::updateSubsMRL() +{ + QStringList* subsMRL = new QStringList("sub-file="); + subsMRL->append( ui.subInput->currentText() ); + //FIXME !! + subsMRL->append( "subsdec-align=" + ui.alignSubComboBox->currentText() ); + subsMRL->append( "sub-rel-fontsize=" + ui.sizeSubComboBox->currentText() ); + + subsMRL->join(" "); +} + +void FileOpenPanel::updateMRL() +{ + QString MRL = ui.fileInput->currentText(); + + emit(mrlUpdated(MRL)); +} + QString FileOpenPanel::getUpdatedMRL() { return ui.fileInput->currentText(); @@ -67,6 +120,14 @@ void FileOpenPanel::toggleExtraAudio() } } +void FileOpenPanel::clear() +{ + ui.fileInput->setEditText( ""); + ui.subInput->setEditText( ""); + ui.audioFileInput->setEditText( ""); +} + + /************************************************************************** * Disk open @@ -85,6 +146,7 @@ void DiskOpenPanel::sendUpdate() QString DiskOpenPanel::getUpdatedMRL() { + //return ui.DiskInput->currentText(); return NULL; } diff --git a/modules/gui/qt4/components/open.hpp b/modules/gui/qt4/components/open.hpp index 3e86a36184..0b46478379 100644 --- a/modules/gui/qt4/components/open.hpp +++ b/modules/gui/qt4/components/open.hpp @@ -55,13 +55,20 @@ public: FileOpenPanel( QWidget *, intf_thread_t * ); virtual ~FileOpenPanel(); virtual QString getUpdatedMRL(); + void clear(); private: Ui::OpenFile ui; + QStringList browse(); + void updateSubsMRL(); public slots: virtual void sendUpdate() ; void toggleExtraAudio() ; + void updateMRL(); + void browseFile(); + void browseFileSub(); + void browseFileAudio(); signals: - void dataUpdated( QString, QString ) ; + void mrlUpdated( QString ) ; }; class NetOpenPanel: public OpenPanel diff --git a/modules/gui/qt4/dialogs/mediainfo.cpp b/modules/gui/qt4/dialogs/mediainfo.cpp index 769e634575..5c23853ffa 100644 --- a/modules/gui/qt4/dialogs/mediainfo.cpp +++ b/modules/gui/qt4/dialogs/mediainfo.cpp @@ -31,6 +31,7 @@ #include "components/infopanels.hpp" #include "qt4.hpp" + static int ItemChanged( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *param ); MediaInfoDialog *MediaInfoDialog::instance = NULL; diff --git a/modules/gui/qt4/dialogs/open.cpp b/modules/gui/qt4/dialogs/open.cpp index 844cb59498..11aac01fd5 100644 --- a/modules/gui/qt4/dialogs/open.cpp +++ b/modules/gui/qt4/dialogs/open.cpp @@ -22,6 +22,7 @@ #include #include +#include #include "dialogs/open.hpp" #include "components/open.hpp" @@ -36,7 +37,7 @@ OpenDialog *OpenDialog::instance = NULL; OpenDialog::OpenDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) { - setWindowTitle( _("Open" ) ); + setWindowTitle( qtr("Open" ) ); ui.setupUi( this ); fileOpenPanel = new FileOpenPanel(this , _p_intf ); diskOpenPanel = new DiskOpenPanel(this , _p_intf ); @@ -46,6 +47,8 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ui.Tab->addTab(netOpenPanel, "Network"); ui.advancedFrame->hide(); + connect( fileOpenPanel, SIGNAL(mrlUpdated( QString )), + this, SLOT( updateMRL(QString))); BUTTONACT( ui.closeButton, ok()); BUTTONACT( ui.cancelButton, cancel()); BUTTONACT( ui.advancedButton , toggleAdvancedPanel() ); @@ -55,6 +58,38 @@ OpenDialog::~OpenDialog() { } +void OpenDialog::showTab(int i_tab=0) +{ + this->show(); + ui.Tab->setCurrentIndex(i_tab); +} + +void OpenDialog::cancel() +{ + fileOpenPanel->clear(); + this->toggleVisible(); +} + +void OpenDialog::ok() +{ + QStringList tempMRL = MRL.split(" "); + for( size_t i = 0 ; i< tempMRL.size(); i++ ) + { + const char * psz_utf8 = qtu( tempMRL[i] ); + /* Play the first one, parse and enqueue the other ones */ + playlist_Add( THEPL, psz_utf8, NULL, + PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO) | + ( i ? PLAYLIST_PREPARSE : 0 ), + PLAYLIST_END, VLC_TRUE ); + } + + this->toggleVisible(); +} + +void OpenDialog::changedTab() +{ +} + void OpenDialog::toggleAdvancedPanel() { if (ui.advancedFrame->isVisible()) @@ -67,13 +102,9 @@ void OpenDialog::toggleAdvancedPanel() } } -void OpenDialog::cancel() -{ - this->toggleVisible(); -} - -void OpenDialog::ok() +void OpenDialog::updateMRL(QString tempMRL) { - this->toggleVisible(); + MRL = tempMRL; + ui.advancedLineInput->setText(MRL); } diff --git a/modules/gui/qt4/dialogs/open.hpp b/modules/gui/qt4/dialogs/open.hpp index 09b5d65fb8..0c23a47b7d 100644 --- a/modules/gui/qt4/dialogs/open.hpp +++ b/modules/gui/qt4/dialogs/open.hpp @@ -32,6 +32,7 @@ #include #include +#include class InfoTab; @@ -46,10 +47,16 @@ public: return instance; } virtual ~OpenDialog(); + + void showTab( int); + + QString MRL; private: OpenDialog( intf_thread_t * ); static OpenDialog *instance; input_thread_t *p_input; + QString mrlSub; + Ui::Open ui; FileOpenPanel *fileOpenPanel; NetOpenPanel *netOpenPanel; @@ -57,7 +64,9 @@ private: public slots: void cancel(); void ok(); + void changedTab(); void toggleAdvancedPanel(); + void updateMRL(QString); }; #endif diff --git a/modules/gui/qt4/ui/open.ui b/modules/gui/qt4/ui/open.ui index c43260c149..095a09ffc8 100644 --- a/modules/gui/qt4/ui/open.ui +++ b/modules/gui/qt4/ui/open.ui @@ -187,7 +187,7 @@ - Close + Open diff --git a/modules/gui/qt4/ui/open_file.ui b/modules/gui/qt4/ui/open_file.ui index c0fe79bf14..e2af5cdb62 100644 --- a/modules/gui/qt4/ui/open_file.ui +++ b/modules/gui/qt4/ui/open_file.ui @@ -212,7 +212,7 @@ - + Very Small @@ -265,6 +265,15 @@ + + 0 + + + QComboBox::NoInsert + + + 0 + Left @@ -413,7 +422,7 @@ - + Browse -- 2.39.5