Commit 3e3cfc16 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Open and Streaming Dialogs.

This commit should show the correct dialogs in the correct order. It keeps the previous behaviour of the "Streaming" from the "Media" menu. 
/!\ The intelligence is surely not accurate and stream() may need to be redirected to playOrEnqueue as open() and enqueue() do in order to be correctly parsed before... Need a bit more knowledge on playlist to be sure.
parent a1f00069
......@@ -37,10 +37,12 @@
OpenDialog *OpenDialog::instance = NULL;
OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
QVLCDialog( parent, _p_intf )
OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal,
bool _stream_after ) : QVLCDialog( parent, _p_intf )
{
setModal( modal );
b_stream_after = _stream_after;
ui.setupUi( this );
setWindowTitle( qtr("Open" ) );
resize( 500, 300);
......@@ -56,14 +58,8 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
ui.Tab->addTab( captureOpenPanel, qtr( "Capture &Device" ) );
ui.advancedFrame->hide();
QMenu * openButtonMenu = new QMenu( "Open" );
openButtonMenu->addAction( qtr("&Enqueue"), this, SLOT( enqueue() ),
QKeySequence( "Alt+E") );
openButtonMenu->addAction( qtr("&Stream"), this, SLOT( stream() ) ,
QKeySequence( "Alt+T" ) );
ui.playButton->setMenu( openButtonMenu );
/* Force MRL update on tab change */
CONNECT( ui.Tab, currentChanged(int), this, signalCurrent());
......@@ -73,7 +69,6 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
CONNECT( captureOpenPanel, mrlUpdated( QString ), this,
updateMRL(QString) );
CONNECT( fileOpenPanel, methodChanged( QString ),
this, newMethod(QString) );
CONNECT( netOpenPanel, methodChanged( QString ),
......@@ -84,7 +79,19 @@ OpenDialog::OpenDialog( QWidget *parent, intf_thread_t *_p_intf, bool modal ) :
CONNECT( ui.slaveText, textChanged(QString), this, updateMRL());
CONNECT( ui.cacheSpinBox, valueChanged(int), this, updateMRL());
openButtonMenu->addAction( qtr("&Enqueue"), this, SLOT( enqueue() ),
QKeySequence( "Alt+E") );
openButtonMenu->addAction( qtr("&Play"), this, SLOT( play() ),
QKeySequence( "Alt+P" ) );
openButtonMenu->addAction( qtr("&Stream"), this, SLOT( stream() ) ,
QKeySequence( "Alt+S" ) );
ui.playButton->setMenu( openButtonMenu );
BUTTONACT( ui.playButton, play());
if ( b_stream_after ) setAfter();
BUTTONACT( ui.cancelButton, cancel());
BUTTONACT( ui.advancedCheckBox , toggleAdvancedPanel() );
......@@ -99,6 +106,20 @@ OpenDialog::~OpenDialog()
{
}
void OpenDialog::setAfter()
{
if (!b_stream_after )
{
ui.playButton->setText( qtr("&Play") );
BUTTONACT( ui.playButton, play() );
}
else
{
ui.playButton->setText( qtr("&Stream") );
BUTTONACT( ui.playButton, stream() );
}
}
void OpenDialog::showTab(int i_tab=0)
{
this->show();
......@@ -111,6 +132,9 @@ void OpenDialog::signalCurrent() {
}
}
/* Actions */
/* If Cancel is pressed or escaped */
void OpenDialog::cancel()
{
fileOpenPanel->clear();
......@@ -119,10 +143,20 @@ void OpenDialog::cancel()
reject();
}
void OpenDialog::close()
/* If EnterKey is pressed */
void OpenDialog::close()
{
play();
if ( !b_stream_after )
{
play();
}
else
{
stream();
}
}
/* Play button */
void OpenDialog::play()
{
playOrEnqueue( false );
......@@ -133,6 +167,13 @@ void OpenDialog::enqueue()
playOrEnqueue( true );
}
void OpenDialog::stream()
{
/* not finished FIXME */
THEDP->streamingDialog( mrl );
}
void OpenDialog::playOrEnqueue( bool b_enqueue = false )
{
this->toggleVisible();
......@@ -175,11 +216,6 @@ void OpenDialog::playOrEnqueue( bool b_enqueue = false )
accept();
}
void OpenDialog::stream()
{
//TODO. Policy not yet defined
}
void OpenDialog::toggleAdvancedPanel()
{
//FIXME does not work under Windows
......
......@@ -38,26 +38,34 @@ class OpenDialog : public QVLCDialog
{
Q_OBJECT;
public:
static OpenDialog * getInstance( QWidget *parent, intf_thread_t *p_intf )
static OpenDialog * getInstance( QWidget *parent, intf_thread_t *p_intf,
bool _stream_after = false )
{
if( !instance)
instance = new OpenDialog( parent, p_intf, false );
instance = new OpenDialog( parent, p_intf, false, _stream_after );
else
{
instance->b_stream_after = _stream_after;
instance->setAfter();
}
return instance;
}
OpenDialog( QWidget *parent, intf_thread_t *, bool modal );
OpenDialog( QWidget *parent, intf_thread_t *, bool modal,
bool stream_after = false);
virtual ~OpenDialog();
void showTab( int );
QString mrl;
QString mainMRL;
public slots:
void play();
void stream();
void enqueue();
private:
static OpenDialog *instance;
input_thread_t *p_input;
QString mrlSub;
Ui::Open ui;
FileOpenPanel *fileOpenPanel;
......@@ -66,14 +74,17 @@ private:
CaptureOpenPanel *captureOpenPanel;
QString storedMethod;
QString mrlSub;
int advHeight, mainHeight;
bool b_stream_after;
QStringList SeparateEntries( QString );
void playOrEnqueue( bool );
QStringList SeparateEntries( QString );
private slots:
void setAfter();
void cancel();
void close();
void enqueue();
void toggleAdvancedPanel();
void updateMRL( QString );
void updateMRL();
......
......@@ -346,6 +346,29 @@ void DialogsProvider::MLAppendDir()
* Sout emulation
****************************************************************************/
void DialogsProvider::streamingDialog( QString mrl)
{
SoutDialog *s = new SoutDialog( p_intf->p_sys->p_mi, p_intf );
if( s->exec() == QDialog::Accepted )
{
msg_Err(p_intf, "mrl %s\n", qta(s->mrl));
/* Just do it */
int i_len = strlen( qtu(s->mrl) ) + 10;
char *psz_option = (char*)malloc(i_len);
snprintf( psz_option, i_len - 1, ":sout=%s", qtu(s->mrl));
playlist_AddExt( THEPL, qtu( mrl ), "Streaming",
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END,
-1, &psz_option, 1, VLC_TRUE, VLC_FALSE );
}
delete s;
}
void DialogsProvider::openThenStreamingDialogs()
{
OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, true )->showTab( 0 );
}
/*
void DialogsProvider::streamingDialog()
{
OpenDialog *o = new OpenDialog( p_intf->p_sys->p_mi, p_intf, true );
......@@ -355,7 +378,7 @@ void DialogsProvider::streamingDialog()
if( s->exec() == QDialog::Accepted )
{
msg_Err(p_intf, "mrl %s\n", qta(s->mrl));
/* Just do it */
/* Just do it
int i_len = strlen( qtu(s->mrl) ) + 10;
char *psz_option = (char*)malloc(i_len);
snprintf( psz_option, i_len - 1, ":sout=%s", qtu(s->mrl));
......@@ -367,7 +390,9 @@ void DialogsProvider::streamingDialog()
delete s;
}
delete o;
}
}*/
/****************************************************************************
* Menus / Interaction
......
......@@ -137,7 +137,8 @@ public slots:
void menuAction( QObject *);
void menuUpdateAction( QObject *);
void SDMenuAction( QString );
void streamingDialog();
void streamingDialog( QString mrl = "");
void openThenStreamingDialogs();
void openPlaylist();
void savePlaylist();
void PLAppendDir();
......
......@@ -202,7 +202,7 @@ QMenu *QVLCMenu::FileMenu()
DP_SADD( qtr("Open &Capture Device..." ), "", "", openCaptureDialog(),
"Ctrl+C" );
menu->addSeparator();
DP_SADD( qtr("&Streaming..."), "", "", streamingDialog(), "Ctrl+S" );
DP_SADD( qtr("&Streaming..."), "", "", openThenStreamingDialogs(), "Ctrl+S" );
menu->addSeparator();
DP_SADD( qtr("&Quit") , "", "", quit(), "Ctrl+Q");
return menu;
......
......@@ -33,7 +33,7 @@
<item>
<widget class="QCheckBox" name="advancedCheckBox" >
<property name="text" >
<string>&amp;Show more options</string>
<string>Show &amp;more options</string>
</property>
</widget>
</item>
......
......@@ -94,7 +94,7 @@
<item row="3" column="0" colspan="2" >
<widget class="QCheckBox" name="subCheckBox" >
<property name="text" >
<string>Use a subtitles file</string>
<string>Use a sub&amp;titles file</string>
</property>
</widget>
</item>
......@@ -153,7 +153,7 @@
</size>
</property>
<property name="currentIndex" >
<number>0</number>
<number>-1</number>
</property>
<property name="insertPolicy" >
<enum>QComboBox::NoInsert</enum>
......
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