Commit 979719c9 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 : Some work on OpenDialog. Does not work with files with spaces... More work to do.

parent 016036cc
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "components/open.hpp" #include "components/open.hpp"
#include <QFileDialog>
/************************************************************************** /**************************************************************************
* Open panel * Open panel
***************************************************************************/ ***************************************************************************/
...@@ -41,7 +42,12 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) : ...@@ -41,7 +42,12 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
{ {
ui.setupUi( this ); ui.setupUi( this );
ui.audioGroupBox->hide(); ui.audioGroupBox->hide();
BUTTONACT( ui.extraAudioButton, toggleExtraAudio() ); 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() FileOpenPanel::~FileOpenPanel()
...@@ -50,6 +56,53 @@ FileOpenPanel::~FileOpenPanel() ...@@ -50,6 +56,53 @@ FileOpenPanel::~FileOpenPanel()
void FileOpenPanel::sendUpdate() 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() QString FileOpenPanel::getUpdatedMRL()
{ {
return ui.fileInput->currentText(); return ui.fileInput->currentText();
...@@ -67,6 +120,14 @@ void FileOpenPanel::toggleExtraAudio() ...@@ -67,6 +120,14 @@ void FileOpenPanel::toggleExtraAudio()
} }
} }
void FileOpenPanel::clear()
{
ui.fileInput->setEditText( "");
ui.subInput->setEditText( "");
ui.audioFileInput->setEditText( "");
}
/************************************************************************** /**************************************************************************
* Disk open * Disk open
...@@ -85,6 +146,7 @@ void DiskOpenPanel::sendUpdate() ...@@ -85,6 +146,7 @@ void DiskOpenPanel::sendUpdate()
QString DiskOpenPanel::getUpdatedMRL() QString DiskOpenPanel::getUpdatedMRL()
{ {
//return ui.DiskInput->currentText(); //return ui.DiskInput->currentText();
return NULL; return NULL;
} }
......
...@@ -55,13 +55,20 @@ public: ...@@ -55,13 +55,20 @@ public:
FileOpenPanel( QWidget *, intf_thread_t * ); FileOpenPanel( QWidget *, intf_thread_t * );
virtual ~FileOpenPanel(); virtual ~FileOpenPanel();
virtual QString getUpdatedMRL(); virtual QString getUpdatedMRL();
void clear();
private: private:
Ui::OpenFile ui; Ui::OpenFile ui;
QStringList browse();
void updateSubsMRL();
public slots: public slots:
virtual void sendUpdate() ; virtual void sendUpdate() ;
void toggleExtraAudio() ; void toggleExtraAudio() ;
void updateMRL();
void browseFile();
void browseFileSub();
void browseFileAudio();
signals: signals:
void dataUpdated( QString, QString ) ; void mrlUpdated( QString ) ;
}; };
class NetOpenPanel: public OpenPanel class NetOpenPanel: public OpenPanel
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "components/infopanels.hpp" #include "components/infopanels.hpp"
#include "qt4.hpp" #include "qt4.hpp"
static int ItemChanged( vlc_object_t *p_this, const char *psz_var, static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param ); vlc_value_t oldval, vlc_value_t newval, void *param );
MediaInfoDialog *MediaInfoDialog::instance = NULL; MediaInfoDialog *MediaInfoDialog::instance = NULL;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QTabWidget> #include <QTabWidget>
#include <QGridLayout> #include <QGridLayout>
#include <QFileDialog>
#include "dialogs/open.hpp" #include "dialogs/open.hpp"
#include "components/open.hpp" #include "components/open.hpp"
...@@ -36,7 +37,7 @@ OpenDialog *OpenDialog::instance = NULL; ...@@ -36,7 +37,7 @@ OpenDialog *OpenDialog::instance = NULL;
OpenDialog::OpenDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) OpenDialog::OpenDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{ {
setWindowTitle( _("Open" ) ); setWindowTitle( qtr("Open" ) );
ui.setupUi( this ); ui.setupUi( this );
fileOpenPanel = new FileOpenPanel(this , _p_intf ); fileOpenPanel = new FileOpenPanel(this , _p_intf );
diskOpenPanel = new DiskOpenPanel(this , _p_intf ); diskOpenPanel = new DiskOpenPanel(this , _p_intf );
...@@ -46,6 +47,8 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -46,6 +47,8 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
ui.Tab->addTab(netOpenPanel, "Network"); ui.Tab->addTab(netOpenPanel, "Network");
ui.advancedFrame->hide(); ui.advancedFrame->hide();
connect( fileOpenPanel, SIGNAL(mrlUpdated( QString )),
this, SLOT( updateMRL(QString)));
BUTTONACT( ui.closeButton, ok()); BUTTONACT( ui.closeButton, ok());
BUTTONACT( ui.cancelButton, cancel()); BUTTONACT( ui.cancelButton, cancel());
BUTTONACT( ui.advancedButton , toggleAdvancedPanel() ); BUTTONACT( ui.advancedButton , toggleAdvancedPanel() );
...@@ -55,6 +58,38 @@ OpenDialog::~OpenDialog() ...@@ -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() void OpenDialog::toggleAdvancedPanel()
{ {
if (ui.advancedFrame->isVisible()) if (ui.advancedFrame->isVisible())
...@@ -67,13 +102,9 @@ void OpenDialog::toggleAdvancedPanel() ...@@ -67,13 +102,9 @@ void OpenDialog::toggleAdvancedPanel()
} }
} }
void OpenDialog::cancel() void OpenDialog::updateMRL(QString tempMRL)
{
this->toggleVisible();
}
void OpenDialog::ok()
{ {
this->toggleVisible(); MRL = tempMRL;
ui.advancedLineInput->setText(MRL);
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <QTabWidget> #include <QTabWidget>
#include <QBoxLayout> #include <QBoxLayout>
#include <QString>
class InfoTab; class InfoTab;
...@@ -46,10 +47,16 @@ public: ...@@ -46,10 +47,16 @@ public:
return instance; return instance;
} }
virtual ~OpenDialog(); virtual ~OpenDialog();
void showTab( int);
QString MRL;
private: private:
OpenDialog( intf_thread_t * ); OpenDialog( intf_thread_t * );
static OpenDialog *instance; static OpenDialog *instance;
input_thread_t *p_input; input_thread_t *p_input;
QString mrlSub;
Ui::Open ui; Ui::Open ui;
FileOpenPanel *fileOpenPanel; FileOpenPanel *fileOpenPanel;
NetOpenPanel *netOpenPanel; NetOpenPanel *netOpenPanel;
...@@ -57,7 +64,9 @@ private: ...@@ -57,7 +64,9 @@ private:
public slots: public slots:
void cancel(); void cancel();
void ok(); void ok();
void changedTab();
void toggleAdvancedPanel(); void toggleAdvancedPanel();
void updateMRL(QString);
}; };
#endif #endif
...@@ -187,7 +187,7 @@ ...@@ -187,7 +187,7 @@
<item> <item>
<widget class="QPushButton" name="closeButton" > <widget class="QPushButton" name="closeButton" >
<property name="text" > <property name="text" >
<string>Close</string> <string>Open</string>
</property> </property>
</widget> </widget>
</item> </item>
......
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="sizeComboBox" > <widget class="QComboBox" name="sizeSubComboBox" >
<item> <item>
<property name="text" > <property name="text" >
<string>Very Small</string> <string>Very Small</string>
...@@ -265,6 +265,15 @@ ...@@ -265,6 +265,15 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="alignSubComboBox" > <widget class="QComboBox" name="alignSubComboBox" >
<property name="currentIndex" >
<number>0</number>
</property>
<property name="insertPolicy" >
<enum>QComboBox::NoInsert</enum>
</property>
<property name="minimumContentsLength" >
<number>0</number>
</property>
<item> <item>
<property name="text" > <property name="text" >
<string>Left</string> <string>Left</string>
...@@ -413,7 +422,7 @@ ...@@ -413,7 +422,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="audioBrowsButton" > <widget class="QPushButton" name="audioBrowseButton" >
<property name="text" > <property name="text" >
<string>Browse</string> <string>Browse</string>
</property> </property>
......
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