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