1 /*****************************************************************************
2 * open.cpp : Panels for the open dialogs
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
27 #include "components/open.hpp"
28 #include "dialogs_provider.hpp"
30 /**************************************************************************
32 **************************************************************************/
33 FileOpenPanel::FileOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
34 OpenPanel( _parent, _p_intf )
39 BUTTONACT( ui.fileBrowseButton, browseFile() );
40 BUTTONACT( ui.subBrowseButton, browseFileSub() );
42 BUTTONACT( ui.subGroupBox, updateMRL());
43 CONNECT( ui.fileInput, editTextChanged(QString ), this, updateMRL());
44 CONNECT( ui.subInput, editTextChanged(QString ), this, updateMRL());
45 CONNECT( ui.alignSubComboBox, currentIndexChanged(int), this, updateMRL());
46 CONNECT( ui.sizeSubComboBox, currentIndexChanged(int), this, updateMRL());
49 FileOpenPanel::~FileOpenPanel()
52 QStringList FileOpenPanel::browse(QString help)
54 return THEDP->showSimpleOpen( help );
57 void FileOpenPanel::browseFile()
59 QString fileString = "";
60 QStringList files = browse( qtr("Open File") );
61 foreach( QString file, files) {
62 fileString += "\"" + file + "\" ";
64 ui.fileInput->setEditText( fileString );
65 ui.fileInput->addItem( fileString );
66 if ( ui.fileInput->count() > 8 ) ui.fileInput->removeItem(0);
71 void FileOpenPanel::browseFileSub()
73 ui.subInput->setEditText( browse( qtr("Open subtitles file") ).join(" ") );
77 void FileOpenPanel::updateMRL()
79 QString mrl = ui.fileInput->currentText();
81 if( ui.subGroupBox->isChecked() ) {
82 mrl.append( " :sub-file=" + ui.subInput->currentText() );
83 mrl.append( " :subsdec-align=" + ui.alignSubComboBox->currentText() );
84 mrl.append( " :sub-rel-fontsize=" + ui.sizeSubComboBox->currentText() );
87 emit methodChanged( "file-caching" );
90 void FileOpenPanel::clear()
92 ui.fileInput->setEditText( "");
93 ui.subInput->setEditText( "");
97 /**************************************************************************
99 **************************************************************************/
100 DiskOpenPanel::DiskOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
101 OpenPanel( _parent, _p_intf )
105 CONNECT( ui.deviceCombo, editTextChanged(QString ), this, updateMRL());
106 BUTTONACT( ui.dvdRadioButton, updateMRL());
107 BUTTONACT( ui.vcdRadioButton, updateMRL());
108 BUTTONACT( ui.audioCDRadioButton, updateMRL());
110 CONNECT( ui.titleSpin, valueChanged(int), this, updateMRL());
111 CONNECT( ui.chapterSpin, valueChanged(int), this, updateMRL());
114 DiskOpenPanel::~DiskOpenPanel()
117 void DiskOpenPanel::clear()
119 ui.titleSpin->setValue(0);
120 ui.chapterSpin->setValue(0);
123 void DiskOpenPanel::updateMRL()
127 if( ui.dvdRadioButton->isChecked() ) {
128 mrl = "dvd://" + ui.deviceCombo->currentText();
129 emit methodChanged( "dvdnav-caching" );
131 if ( ui.titleSpin->value() > 0 ) {
132 mrl += QString("@%1").arg(ui.titleSpin->value());
133 if ( ui.chapterSpin->value() > 0 ) {
134 mrl+= QString(":%1").arg(ui.chapterSpin->value());
139 } else if (ui.vcdRadioButton->isChecked() ) {
140 mrl = "vcd://" + ui.deviceCombo->currentText();
141 emit methodChanged( "vcd-caching" );
143 if( ui.titleSpin->value() > 0 ) {
144 mrl += QString("@%1").arg(ui.titleSpin->value());
149 mrl = "cdda://" + ui.deviceCombo->currentText();
152 emit mrlUpdated(mrl);
157 /**************************************************************************
159 **************************************************************************/
160 NetOpenPanel::NetOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
161 OpenPanel( _parent, _p_intf )
165 CONNECT( ui.protocolCombo, currentIndexChanged(int),
166 this, updateProtocol(int) );
167 CONNECT( ui.portSpin, valueChanged(int), this, updateMRL());
168 CONNECT( ui.addressText, textChanged(QString), this, updateAddress());
169 CONNECT( ui.timeShift, clicked(), this, updateMRL());
170 CONNECT( ui.ipv6, clicked(), this, updateMRL());
172 ui.protocolCombo->addItem("HTTP", QVariant("http"));
173 ui.protocolCombo->addItem("FTP", QVariant("ftp"));
174 ui.protocolCombo->addItem("MMS", QVariant("mms"));
175 ui.protocolCombo->addItem("RTSP", QVariant("rtsp"));
176 ui.protocolCombo->addItem("UDP/RTP (unicast)", QVariant("udp"));
177 ui.protocolCombo->addItem("UDP/RTP (multicast)", QVariant("udp"));
180 NetOpenPanel::~NetOpenPanel()
183 void NetOpenPanel::clear()
186 void NetOpenPanel::updateProtocol(int idx) {
187 QString addr = ui.addressText->text();
188 QString proto = ui.protocolCombo->itemData(idx).toString();
190 ui.timeShift->setEnabled( idx >= 4);
191 ui.ipv6->setEnabled( idx == 4 );
192 ui.addressText->setEnabled( idx != 4 );
193 ui.portSpin->setEnabled( idx >= 4 );
195 /* If we already have a protocol in the address, replace it */
196 if( addr.contains( "://")) {
197 msg_Err( p_intf, "replace");
198 addr.replace(QRegExp("^.*://"), proto + "://");
199 ui.addressText->setText(addr);
205 void NetOpenPanel::updateAddress() {
209 void NetOpenPanel::updateMRL() {
211 QString addr = ui.addressText->text();
212 int proto = ui.protocolCombo->currentIndex();
214 if( addr.contains( "://") && proto != 4 ) {
219 mrl = "http://" + addr;
220 emit methodChanged("http-caching");
223 mrl = "mms://" + addr;
224 emit methodChanged("mms-caching");
227 mrl = "ftp://" + addr;
228 emit methodChanged("ftp-caching");
231 mrl = "rtsp://" + addr;
232 emit methodChanged("rtsp-caching");
236 if( ui.ipv6->isEnabled() && ui.ipv6->isChecked() ) {
239 mrl += QString(":%1").arg(ui.portSpin->value());
240 emit methodChanged("udp-caching");
242 case 5: /* UDP multicast */
245 if ( addr.contains(':') && !addr.contains('[') ) {
246 mrl += "[" + addr + "]";
248 mrl += QString(":%1").arg(ui.portSpin->value());
249 emit methodChanged("udp-caching");
252 if( ui.timeShift->isEnabled() && ui.timeShift->isChecked() ) {
253 mrl += " :access-filter=timeshift";
255 emit mrlUpdated(mrl);
258 /**************************************************************************
260 **************************************************************************/
261 CaptureOpenPanel::CaptureOpenPanel( QWidget *_parent, intf_thread_t *_p_intf ) :
262 OpenPanel( _parent, _p_intf )
267 CaptureOpenPanel::~CaptureOpenPanel()
270 void CaptureOpenPanel::clear()
273 void CaptureOpenPanel::updateMRL()