* $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
#include "qt4.hpp"
#include "components/open.hpp"
-/**************************************************************************
- * Open panel
- ***************************************************************************/
-
-OpenPanel::~OpenPanel()
-{}
+#include <QFileDialog>
/**************************************************************************
* File open
OpenPanel( _parent, _p_intf )
{
ui.setupUi( this );
- BUTTONACT( ui.extraAudioButton, toggleExtraAudio() );
+
+
+ BUTTONACT( ui.fileBrowseButton, browseFile() );
+ BUTTONACT( ui.subBrowseButton, browseFileSub() );
+
+ 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(QString help)
+{
+ return QFileDialog::getOpenFileNames( this, help, "", "" );
+}
+
+void FileOpenPanel::browseFile()
+{
+ 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();
+}
+
+void FileOpenPanel::browseFileSub()
+{
+ ui.subInput->setEditText( browse( qtr("Open subtitles file") ).join(" ") );
+ updateMRL();
+}
-QString FileOpenPanel::getUpdatedMRL()
+void FileOpenPanel::updateMRL()
{
- 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::toggleExtraAudio()
+void FileOpenPanel::clear()
{
- if (ui.audioGroupBox->isVisible())
- {
- ui.audioGroupBox->hide();
- }
- else
- {
- ui.audioGroupBox->show();
- }
+ ui.fileInput->setEditText( "");
+ ui.subInput->setEditText( "");
}
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()
-{}
+void DiskOpenPanel::clear()
+{
+ ui.titleSpin->setValue(0);
+ ui.chapterSpin->setValue(0);
+}
-QString DiskOpenPanel::getUpdatedMRL()
+void DiskOpenPanel::updateMRL()
{
- //return ui.DiskInput->currentText();
- return NULL;
+ 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);
}
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);
+}