Commit 9040f4ed authored by Clément Stenac's avatar Clément Stenac

Qt4 open:

* Implement MRL handling for file, disc and network
* Moved input slave option to the global dialog (not file specific and
  avoid cluttering the file subpanel)
* Initial implementation of the network panel based on ideas and work by
  Leo Spalteholz. Thanks !
* Improve layouting and handling of the advanced options subpanel

--This line, and those below, will beignored--

M    modules/gui/qt4/dialogs/open.cpp
M    modules/gui/qt4/dialogs/open.hpp
M    modules/gui/qt4/components/open.cpp
M    modules/gui/qt4/components/open.hpp
M    modules/gui/qt4/ui/open_net.ui
M    modules/gui/qt4/ui/open_disk.ui
M    modules/gui/qt4/ui/open_file.ui
M    modules/gui/qt4/ui/open.ui
parent c256165f
......@@ -5,7 +5,7 @@
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
*
* 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
......@@ -27,12 +27,6 @@
#include "components/open.hpp"
#include <QFileDialog>
/**************************************************************************
* Open panel
***************************************************************************/
OpenPanel::~OpenPanel()
{}
/**************************************************************************
* File open
......@@ -42,30 +36,39 @@ FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
{
ui.setupUi( this );
BUTTONACT( ui.fileBrowseButton, browseFile() );
BUTTONACT( ui.subBrowseButton, browseFileSub() );
BUTTONACT( ui.audioBrowseButton, browseFileAudio() );
BUTTONACT( ui.subGroupBox, updateMRL());
CONNECT( ui.fileInput, editTextChanged(QString ), this, updateMRL());
CONNECT( ui.subInput, editTextChanged(QString ), this, updateMRL());
CONNECT( ui.alignSubComboBox, currentIndexChanged(int), this, updateMRL());
CONNECT( ui.sizeSubComboBox, currentIndexChanged(int), this, updateMRL());
}
FileOpenPanel::~FileOpenPanel()
{}
void FileOpenPanel::sendUpdate()
{}
QStringList FileOpenPanel::browse()
QStringList FileOpenPanel::browse(QString help)
{
return QFileDialog::getOpenFileNames( this, qtr("Open File"), "", "" );
return QFileDialog::getOpenFileNames( this, help, "", "" );
}
void FileOpenPanel::browseFile()
{
//FIXME ! files with spaces
QString files = browse().join(" ");
ui.fileInput->setEditText( files );
ui.fileInput->addItem( files );
QString fileString = "";
QStringList files = browse( qtr("Open File") );
foreach( QString file, files) {
if( file.contains(" ") ) {
fileString += "\"" + file + "\"";
} else {
fileString += file;
}
}
ui.fileInput->setEditText( fileString );
ui.fileInput->addItem( fileString );
if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem(0);
updateMRL();
......@@ -73,48 +76,30 @@ void FileOpenPanel::browseFile()
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(" ");
ui.subInput->setEditText( browse( qtr("Open subtitles file") ).join(" ") );
updateMRL();
}
void FileOpenPanel::updateMRL()
{
QString MRL = ui.fileInput->currentText();
emit(mrlUpdated(MRL));
}
QString FileOpenPanel::getUpdatedMRL()
{
return ui.fileInput->currentText();
QString mrl = ui.fileInput->currentText();
if( ui.subGroupBox->isChecked() ) {
mrl.append( " :sub-file=" + ui.subInput->currentText() );
mrl.append( " :subsdec-align=" + ui.alignSubComboBox->currentText() );
mrl.append( " :sub-rel-fontsize=" + ui.sizeSubComboBox->currentText() );
}
emit mrlUpdated(mrl);
emit methodChanged( "file-caching" );
}
void FileOpenPanel::clear()
{
ui.fileInput->setEditText( "");
ui.subInput->setEditText( "");
ui.audioFileInput->setEditText( "");
}
/**************************************************************************
* Disk open
**************************************************************************/
......@@ -122,19 +107,55 @@ DiskOpenPanel::DiskOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
OpenPanel( _parent, _p_intf )
{
ui.setupUi( this );
CONNECT( ui.deviceCombo, editTextChanged(QString ), this, updateMRL());
BUTTONACT( ui.dvdRadioButton, updateMRL());
BUTTONACT( ui.vcdRadioButton, updateMRL());
BUTTONACT( ui.audioCDRadioButton, updateMRL());
CONNECT( ui.titleSpin, valueChanged(int), this, updateMRL());
CONNECT( ui.chapterSpin, valueChanged(int), this, updateMRL());
}
DiskOpenPanel::~DiskOpenPanel()
{}
void DiskOpenPanel::sendUpdate()
{}
QString DiskOpenPanel::getUpdatedMRL()
void DiskOpenPanel::clear()
{
ui.titleSpin->setValue(0);
ui.chapterSpin->setValue(0);
}
//return ui.DiskInput->currentText();
return NULL;
void DiskOpenPanel::updateMRL()
{
QString mrl = "";
/* DVD */
if( ui.dvdRadioButton->isChecked() ) {
mrl = "dvd://" + ui.deviceCombo->currentText();
emit methodChanged( "dvdnav-caching" );
if ( ui.titleSpin->value() > 0 ) {
mrl += QString("@%1").arg(ui.titleSpin->value());
if ( ui.chapterSpin->value() > 0 ) {
mrl+= QString(":%1").arg(ui.chapterSpin->value());
}
}
/* VCD */
} else if (ui.vcdRadioButton->isChecked() ) {
mrl = "vcd://" + ui.deviceCombo->currentText();
emit methodChanged( "vcd-caching" );
if( ui.titleSpin->value() > 0 ) {
mrl += QString("@%1").arg(ui.titleSpin->value());
}
/* CDDA */
} else {
mrl = "cdda://" + ui.deviceCombo->currentText();
}
emit mrlUpdated(mrl);
}
......@@ -146,25 +167,96 @@ NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
OpenPanel( _parent, _p_intf )
{
ui.setupUi( this );
CONNECT( ui.protocolCombo, currentIndexChanged(int),
this, updateProtocol(int) );
CONNECT( ui.portSpin, valueChanged(int), this, updateMRL());
CONNECT( ui.addressText, textChanged(QString), this, updateAddress());
CONNECT( ui.timeShift, clicked(), this, updateMRL());
CONNECT( ui.ipv6, clicked(), this, updateMRL());
ui.protocolCombo->addItem("HTTP", QVariant("http"));
ui.protocolCombo->addItem("FTP", QVariant("ftp"));
ui.protocolCombo->addItem("MMS", QVariant("mms"));
ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
}
NetOpenPanel::~NetOpenPanel()
{}
void NetOpenPanel::sendUpdate()
void NetOpenPanel::clear()
{}
/*
void NetOpenPanel::sendUpdate()
{
QString *mrl = new QString();
QString *cache = new QString();
getUpdatedMRL( mrl, cache );,
emit dataUpdated( mrl, cache );
}*/
QString NetOpenPanel::getUpdatedMRL()
{
// return ui.NetInput->currentText();
return NULL;
void NetOpenPanel::updateProtocol(int idx) {
QString addr = ui.addressText->text();
QString proto = ui.protocolCombo->itemData(idx).toString();
ui.timeShift->setEnabled( idx >= 4);
ui.ipv6->setEnabled( idx == 4 );
ui.addressText->setEnabled( idx != 4 );
ui.portSpin->setEnabled( idx >= 4 );
/* If we already have a protocol in the address, replace it */
if( addr.contains( "://")) {
msg_Err( p_intf, "replace");
addr.replace(QRegExp("^.*://"), proto + "://");
ui.addressText->setText(addr);
}
updateMRL();
}
void NetOpenPanel::updateAddress() {
updateMRL();
}
void NetOpenPanel::updateMRL() {
QString mrl = "";
QString addr = ui.addressText->text();
int proto = ui.protocolCombo->currentIndex();
if( addr.contains( "://") && proto != 4 ) {
mrl = addr;
} else {
switch(proto) {
case 0:
mrl = "http://" + addr;
emit methodChanged("http-caching");
break;
case 2:
mrl = "mms://" + addr;
emit methodChanged("mms-caching");
break;
case 1:
mrl = "ftp://" + addr;
emit methodChanged("ftp-caching");
break;
case 3: /* RTSP */
mrl = "rtsp://" + addr;
emit methodChanged("rtsp-caching");
break;
case 4:
mrl = "udp://@";
if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
mrl += "[::]";
}
mrl += QString(":%1").arg(ui.portSpin->value());
emit methodChanged("udp-caching");
break;
case 5: /* UDP multicast */
mrl = "udp://@";
/* Add [] to IPv6 */
if ( addr.contains(':') && !addr.contains('[') ) {
mrl += "[" + addr + "]";
} else mrl += addr;
mrl += QString(":%1").arg(ui.portSpin->value());
emit methodChanged("udp-caching");
}
}
if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
mrl += " :access-filter=timeshift";
}
emit mrlUpdated(mrl);
}
......@@ -5,7 +5,7 @@
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
*
* 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
......@@ -40,12 +40,15 @@ public:
{
p_intf = _p_intf;
}
virtual ~OpenPanel();
virtual QString getUpdatedMRL() = 0;
private:
virtual ~OpenPanel() {};
virtual void clear() = 0;
protected:
intf_thread_t *p_intf;
public slots:
virtual void sendUpdate() = 0;
virtual void updateMRL() = 0;
signals:
void mrlUpdated(QString);
void methodChanged( QString method );
};
class FileOpenPanel: public OpenPanel
......@@ -54,20 +57,15 @@ class FileOpenPanel: public OpenPanel
public:
FileOpenPanel( QWidget *, intf_thread_t * );
virtual ~FileOpenPanel();
virtual QString getUpdatedMRL();
void clear();
virtual void clear() ;
private:
Ui::OpenFile ui;
QStringList browse();
void updateSubsMRL();
QStringList browse( QString );
public slots:
virtual void sendUpdate() ;
void updateMRL();
virtual void updateMRL();
private slots:
void browseFile();
void browseFileSub();
void browseFileAudio();
signals:
void mrlUpdated( QString ) ;
};
class NetOpenPanel: public OpenPanel
......@@ -76,14 +74,14 @@ class NetOpenPanel: public OpenPanel
public:
NetOpenPanel( QWidget *, intf_thread_t * );
virtual ~NetOpenPanel();
virtual QString getUpdatedMRL();
virtual void clear() ;
private:
Ui::OpenNetwork ui;
public slots:
virtual void sendUpdate() ;
signals:
void dataUpdated( QString, QString ) ;
virtual void updateMRL();
private slots:
void updateProtocol(int);
void updateAddress();
};
class DiskOpenPanel: public OpenPanel
......@@ -92,14 +90,11 @@ class DiskOpenPanel: public OpenPanel
public:
DiskOpenPanel( QWidget *, intf_thread_t * );
virtual ~DiskOpenPanel();
virtual QString getUpdatedMRL();
virtual void clear() ;
private:
Ui::OpenDisk ui;
public slots:
virtual void sendUpdate() ;
signals:
void dataUpdated( QString, QString ) ;
virtual void updateMRL() ;
};
#endif
......@@ -39,20 +39,41 @@ OpenDialog::OpenDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{
setWindowTitle( qtr("Open" ) );
ui.setupUi( this );
ui.vboxLayout->setSizeConstraint(QLayout::SetFixedSize);
fileOpenPanel = new FileOpenPanel(this , _p_intf );
diskOpenPanel = new DiskOpenPanel(this , _p_intf );
netOpenPanel = new NetOpenPanel(this , _p_intf );
ui.Tab->addTab(fileOpenPanel, "File");
ui.Tab->addTab(diskOpenPanel, "Disk");
ui.Tab->addTab(netOpenPanel, "Network");
fileOpenPanel = new FileOpenPanel(this , p_intf );
diskOpenPanel = new DiskOpenPanel(this , p_intf );
netOpenPanel = new NetOpenPanel(this , p_intf );
ui.Tab->addTab(fileOpenPanel, qtr("File"));
ui.Tab->addTab(diskOpenPanel, qtr("Disk"));
ui.Tab->addTab(netOpenPanel, qtr("Network"));
ui.advancedFrame->hide();
connect( fileOpenPanel, SIGNAL(mrlUpdated( QString )),
this, SLOT( updateMRL(QString)));
/* Force MRL update on tab change */
CONNECT( ui.Tab, currentChanged(int), this, signalCurrent());
CONNECT( fileOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
CONNECT( netOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
CONNECT( diskOpenPanel, mrlUpdated( QString ), this, updateMRL(QString) );
CONNECT( fileOpenPanel, methodChanged( QString ),
this, newMethod(QString) );
CONNECT( netOpenPanel, methodChanged( QString ),
this, newMethod(QString) );
CONNECT( diskOpenPanel, methodChanged( QString ),
this, newMethod(QString) );
CONNECT( ui.slaveText, textChanged(QString), this, updateMRL());
CONNECT( ui.cacheSpinBox, valueChanged(int), this, updateMRL());
BUTTONACT( ui.closeButton, ok());
BUTTONACT( ui.cancelButton, cancel());
BUTTONACT( ui.advancedButton , toggleAdvancedPanel() );
BUTTONACT( ui.advancedCheckBox , toggleAdvancedPanel() );
/* Initialize caching */
storedMethod = "";
newMethod("file-caching");
mainHeight = advHeight = 0;
}
OpenDialog::~OpenDialog()
......@@ -65,6 +86,12 @@ void OpenDialog::showTab(int i_tab=0)
ui.Tab->setCurrentIndex(i_tab);
}
void OpenDialog::signalCurrent() {
if (ui.Tab->currentWidget() != NULL) {
(dynamic_cast<OpenPanel*>(ui.Tab->currentWidget()))->updateMRL();
}
}
void OpenDialog::cancel()
{
fileOpenPanel->clear();
......@@ -73,7 +100,8 @@ void OpenDialog::cancel()
void OpenDialog::ok()
{
QStringList tempMRL = MRL.split(" ");
QString mrl = ui.advancedLineInput->text();
QStringList tempMRL = mrl.split(" ");
for( size_t i = 0 ; i< tempMRL.size(); i++ )
{
const char * psz_utf8 = qtu( tempMRL[i] );
......@@ -93,19 +121,47 @@ void OpenDialog::changedTab()
void OpenDialog::toggleAdvancedPanel()
{
if (ui.advancedFrame->isVisible())
{
if (ui.advancedFrame->isVisible()) {
ui.advancedFrame->hide();
}
else
{
setMinimumHeight(1);
resize( width(), mainHeight );
} else {
if( mainHeight == 0 )
mainHeight = height();
ui.advancedFrame->show();
if( advHeight == 0 ) {
advHeight = height() - mainHeight;
}
resize( width(), mainHeight + advHeight );
}
}
void OpenDialog::updateMRL() {
QString mrl = mainMRL;
if( ui.slaveCheckbox->isChecked() ) {
mrl += " :input-slave=" + ui.slaveText->text();
}
int i_cache = config_GetInt( p_intf, qta(storedMethod) );
if( i_cache != ui.cacheSpinBox->value() ) {
mrl += QString(" :%1=%2").arg(storedMethod).
arg(ui.cacheSpinBox->value());
}
ui.advancedLineInput->setText(mrl);
}
void OpenDialog::updateMRL(QString tempMRL)
{
MRL = tempMRL;
ui.advancedLineInput->setText(MRL);
mainMRL = tempMRL;
updateMRL();
}
void OpenDialog::newMethod(QString method)
{
if( method != storedMethod ) {
storedMethod = method;
int i_value = config_GetInt( p_intf, qta(storedMethod) );
ui.cacheSpinBox->setValue(i_value);
}
}
......@@ -34,8 +34,6 @@
#include <QBoxLayout>
#include <QString>
class InfoTab;
class OpenDialog : public QVLCFrame
{
Q_OBJECT;
......@@ -48,9 +46,9 @@ public:
}
virtual ~OpenDialog();
void showTab( int);
void showTab( int );
QString MRL;
QString mainMRL;
private:
OpenDialog( intf_thread_t * );
static OpenDialog *instance;
......@@ -61,12 +59,18 @@ private:
FileOpenPanel *fileOpenPanel;
NetOpenPanel *netOpenPanel;
DiskOpenPanel *diskOpenPanel;
public slots:
QString storedMethod;
int advHeight, mainHeight;
private slots:
void cancel();
void ok();
void changedTab();
void toggleAdvancedPanel();
void updateMRL(QString);
void updateMRL();
void newMethod(QString);
void signalCurrent();
};
#endif
......@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>435</width>
<height>441</height>
<width>525</width>
<height>231</height>
</rect>
</property>
<property name="windowTitle" >
......@@ -25,54 +25,17 @@
</property>
<item>
<widget class="QTabWidget" name="Tab" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>417</width>
<height>290</height>
</size>
</property>
<property name="currentIndex" >
<number>-1</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
<widget class="QCheckBox" name="advancedCheckBox" >
<property name="text" >
<string>Show more options</string>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="advancedButton" >
<property name="text" >
<string>More...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="advancedFrame" >
......@@ -82,90 +45,93 @@
<property name="frameShadow" >
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<widget class="QLabel" name="advancedLabel" >
<property name="text" >
<string>Personalize:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" >
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2" >
<widget class="QSpinBox" name="cacheSpinBox" />
</item>
<item row="0" column="4" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Minimum</enum>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="sizeHint" >
<size>
<width>10</width>
<height>20</height>
</size>
<property name="spacing" >
<number>6</number>
</property>
</spacer>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="cacheLabel" >
<property name="text" >
<string>Caching:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="3" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>ms</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="3" >
<widget class="QLineEdit" name="advancedLineInput" />
<item row="0" column="2" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>ms</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="enabled" >
<bool>false</bool>
</property>