X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fdialogs%2Fvlm.cpp;h=2bbe79ea12a1d88c684a92968f79cd791f845fd9;hb=82b3b8dd0c9a27b1ba3ecb3599ad66a675beb773;hp=dc3b4c940318a6324a0a4037f5cc2e4b50d2946d;hpb=f6081e574edd09f4fda05d461eec23bb50e6d2c2;p=vlc diff --git a/modules/gui/qt4/dialogs/vlm.cpp b/modules/gui/qt4/dialogs/vlm.cpp index dc3b4c9403..2bbe79ea12 100644 --- a/modules/gui/qt4/dialogs/vlm.cpp +++ b/modules/gui/qt4/dialogs/vlm.cpp @@ -32,6 +32,7 @@ #ifdef ENABLE_VLM #include "dialogs/open.hpp" #include "dialogs/sout.hpp" +#include "util/qt_dirs.hpp" #include #include @@ -54,9 +55,7 @@ #include -VLMDialog *VLMDialog::instance = NULL; - -VLMDialog::VLMDialog( QWidget *parent, intf_thread_t *_p_intf ) : QVLCDialog( parent, _p_intf ) +VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf ) { p_vlm = vlm_New( p_intf ); @@ -157,12 +156,14 @@ VLMDialog::VLMDialog( QWidget *parent, intf_thread_t *_p_intf ) : QVLCDialog( pa BUTTONACT( ui.saveButton, saveModifications() ); BUTTONACT( ui.inputButton, selectInput() ); BUTTONACT( ui.outputButton, selectOutput() ); + //readSettings( "VLM", QSize( 700, 500 ) ); } VLMDialog::~VLMDialog() { delete vlmWrapper; + //writeSettings( "VLM" ); /* TODO :you have to destroy vlm here to close * but we shouldn't destroy vlm here in case somebody else wants it */ if( p_vlm ) @@ -184,7 +185,7 @@ void VLMDialog::selectVLMItem( int i ) ui.vlmItemScroll->ensureWidgetVisible( vlmItems.at( i ) ); } -bool VLMDialog::isNameGenuine( QString name ) +bool VLMDialog::isNameGenuine( const QString& name ) { for( int i = 0; i < vlmItems.size(); i++ ) { @@ -218,28 +219,29 @@ void VLMDialog::addVLMItem() int repeatnum = scherepeatnumber->value(); int repeatdays = repeatDays->value(); VLMAWidget * vlmAwidget; + outputText.remove( ":sout=" ); switch( type ) { case QVLM_Broadcast: typeShortName = "Bcast"; - vlmAwidget = new VLMBroadcast( name, inputText, outputText, + vlmAwidget = new VLMBroadcast( name, inputText, inputOptions, outputText, b_checked, b_looped, this ); - VLMWrapper::AddBroadcast( name, inputText, outputText, b_checked, + VLMWrapper::AddBroadcast( name, inputText, inputOptions, outputText, b_checked, b_looped ); break; case QVLM_VOD: typeShortName = "VOD"; - vlmAwidget = new VLMVod( name, inputText, outputText, + vlmAwidget = new VLMVod( name, inputText, inputOptions, outputText, b_checked, ui.muxLedit->text(), this ); - VLMWrapper::AddVod( name, inputText, outputText, b_checked ); + VLMWrapper::AddVod( name, inputText, inputOptions, outputText, b_checked ); break; case QVLM_Schedule: typeShortName = "Sched"; - vlmAwidget = new VLMSchedule( name, inputText, outputText, + vlmAwidget = new VLMSchedule( name, inputText, inputOptions, outputText, schetime, schedate, repeatnum, repeatdays, b_checked, this ); - VLMWrapper::AddSchedule( name, inputText, outputText, schetime, + VLMWrapper::AddSchedule( name, inputText, inputOptions, outputText, schetime, schedate, repeatnum, repeatdays, b_checked); break; default: @@ -261,10 +263,10 @@ void VLMDialog::addVLMItem() /* TODO : VOD are not exported to the file */ bool VLMDialog::exportVLMConf() { - QString saveVLMConfFileName = QFileDialog::getSaveFileName( - this, qtr( "Save VLM configuration as..." ), - qfu( config_GetHomeDir() ), - qtr( "VLM conf (*.vlm);;All (*)" ) ); + QString saveVLMConfFileName = QFileDialog::getSaveFileName( this, + qtr( "Save VLM configuration as..." ), + QVLCUserDir( VLC_DOCUMENTS_DIR ), + qtr( "VLM conf (*.vlm);;All (*)" ) ); if( !saveVLMConfFileName.isEmpty() ) { @@ -274,6 +276,7 @@ bool VLMDialog::exportVLMConf() vlm_MessageDelete( message ); return true; } + return false; } @@ -286,7 +289,7 @@ void VLMDialog::mediasPopulator() int vlmItemCount; vlm_media_t ***ppp_dsc = (vlm_media_t ***)malloc( sizeof( vlm_media_t ) ); - /* Get medias informations and numbers */ + /* Get medias information and numbers */ vlm_Control( p_vlm, VLM_GET_MEDIAS, ppp_dsc, &i_nMedias ); /* Loop on all of them */ @@ -302,19 +305,21 @@ void VLMDialog::mediasPopulator() QString outputText = qfu( (*ppp_dsc)[i]->psz_output ); - /* Schedule media is a quite especial, maybe there is another way to grab informations */ + /* Schedule media is a quite especial, maybe there is another way to grab information */ if( (*ppp_dsc)[i]->b_vod ) { typeShortName = "VOD"; QString mux = qfu( (*ppp_dsc)[i]->vod.psz_mux ); - vlmAwidget = new VLMVod( mediaName, inputText, outputText, - (*ppp_dsc)[i]->b_enabled, mux, this ); + vlmAwidget = new VLMVod( mediaName, inputText, inputOptions, + outputText, (*ppp_dsc)[i]->b_enabled, + mux, this ); } else { typeShortName = "Bcast"; - vlmAwidget = new VLMBroadcast( mediaName, inputText, outputText, - (*ppp_dsc)[i]->b_enabled, (*ppp_dsc)[i]->broadcast.b_loop, this ); + vlmAwidget = new VLMBroadcast( mediaName, inputText, inputOptions, + outputText, (*ppp_dsc)[i]->b_enabled, + (*ppp_dsc)[i]->broadcast.b_loop, this ); } /* Add an Item of the Side List */ ui.vlmListItem->addItem( typeShortName + " : " + mediaName ); @@ -331,10 +336,11 @@ void VLMDialog::mediasPopulator() bool VLMDialog::importVLMConf() { - QString openVLMConfFileName = QFileDialog::getOpenFileName( + QString openVLMConfFileName = toNativeSeparators( + QFileDialog::getOpenFileName( this, qtr( "Open VLM configuration..." ), - qfu( config_GetHomeDir() ), - qtr( "VLM conf (*.vlm);;All (*)" ) ); + QVLCUserDir( VLC_DOCUMENTS_DIR ), + qtr( "VLM conf (*.vlm);;All (*)" ) ) ); if( !openVLMConfFileName.isEmpty() ) { @@ -361,6 +367,7 @@ void VLMDialog::clearWidgets() { ui.nameLedit->clear(); ui.inputLedit->clear(); + inputOptions.clear(); ui.outputLedit->clear(); time->setTime( QTime::currentTime() ); date->setDate( QDate::currentDate() ); @@ -376,12 +383,13 @@ void VLMDialog::selectInput() { OpenDialog *o = OpenDialog::getInstance( this, p_intf, false, SELECT, true ); o->exec(); - ui.inputLedit->setText( o->getMRL() ); + ui.inputLedit->setText( o->getMRL( false ) ); + inputOptions = o->getOptions(); } void VLMDialog::selectOutput() { - SoutDialog *s = SoutDialog::getInstance( this, p_intf, false ); + SoutDialog *s = new SoutDialog( this, p_intf ); if( s->exec() == QDialog::Accepted ) ui.outputLedit->setText( s->getMrl() ); } @@ -434,7 +442,7 @@ void VLMDialog::saveModifications() if( vlmObj ) { vlmObj->input = ui.inputLedit->text(); - vlmObj->output = ui.outputLedit->text(); + vlmObj->output = ui.outputLedit->text().remove( ":sout=" ); vlmObj->setChecked( ui.enableCheck->isChecked() ); vlmObj->b_enabled = ui.enableCheck->isChecked(); switch( vlmObj->type ) @@ -462,17 +470,15 @@ void VLMDialog::saveModifications() * VLMAWidget - Abstract class ********************************/ -VLMAWidget::VLMAWidget( QString _name, - QString _input, - QString _output, - bool _enabled, - VLMDialog *_parent, - int _type ) +VLMAWidget::VLMAWidget( const QString& _name, const QString& _input, + const QString& _inputOptions, const QString& _output, + bool _enabled, VLMDialog *_parent, int _type ) : QGroupBox( _name, _parent ) { parent = _parent; name = _name; input = _input; + inputOptions = _inputOptions; output = _output; b_enabled = _enabled; type = _type; @@ -490,11 +496,11 @@ VLMAWidget::VLMAWidget( QString _name, objLayout->addWidget( time, 1, 3, 1, 2 );*/ QToolButton *modifyButton = new QToolButton; - modifyButton->setIcon( QIcon( QPixmap( ":/settings" ) ) ); + modifyButton->setIcon( QIcon( ":/menu/settings" ) ); objLayout->addWidget( modifyButton, 0, 5 ); QToolButton *deleteButton = new QToolButton; - deleteButton->setIcon( QIcon( QPixmap( ":/quit" ) ) ); + deleteButton->setIcon( QIcon( ":/menu/quit" ) ); objLayout->addWidget( deleteButton, 0, 6 ); BUTTONACT( modifyButton, modify() ); @@ -520,9 +526,11 @@ void VLMAWidget::toggleEnabled( bool b_enable ) /**************** * VLMBroadcast ****************/ -VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output, - bool _enabled, bool _looped, VLMDialog *_parent) - : VLMAWidget( _name, _input, _output, +VLMBroadcast::VLMBroadcast( const QString& _name, const QString& _input, + const QString& _inputOptions, + const QString& _output, bool _enabled, + bool _looped, VLMDialog *_parent ) + : VLMAWidget( _name, _input, _inputOptions, _output, _enabled, _parent, QVLM_Broadcast ) { nameLabel->setText( qtr("Broadcast: ") + name ); @@ -530,12 +538,12 @@ VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output, b_looped = _looped; playButton = new QToolButton; - playButton->setIcon( QIcon( QPixmap( ":/play" ) ) ); + playButton->setIcon( QIcon( ":/menu/play" ) ); objLayout->addWidget( playButton, 1, 0 ); b_playing = true; QToolButton *stopButton = new QToolButton; - stopButton->setIcon( QIcon( QPixmap( ":/stop_b" ) ) ); + stopButton->setIcon( QIcon( ":/toolbar/stop_b" ) ); objLayout->addWidget( stopButton, 1, 1 ); loopButton = new QToolButton; @@ -550,11 +558,11 @@ VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output, void VLMBroadcast::update() { - VLMWrapper::EditBroadcast( name, input, output, b_enabled, b_looped ); + VLMWrapper::EditBroadcast( name, input, inputOptions, output, b_enabled, b_looped ); if( b_looped ) - loopButton->setIcon( QIcon( QPixmap( ":/repeat_all" ) ) ); + loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_all" ) ); else - loopButton->setIcon( QIcon( QPixmap( ":/repeat_off" ) ) ); + loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_off" ) ); } void VLMBroadcast::togglePlayPause() @@ -562,12 +570,12 @@ void VLMBroadcast::togglePlayPause() if( b_playing ) { VLMWrapper::ControlBroadcast( name, ControlBroadcastPause ); - playButton->setIcon( QIcon( QPixmap( ":/pause_16px" ) ) ); + playButton->setIcon( QIcon( ":/menu/pause" ) ); } else { VLMWrapper::ControlBroadcast( name, ControlBroadcastPlay ); - playButton->setIcon( QIcon( QPixmap( ":/play_16px" ) ) ); + playButton->setIcon( QIcon( ":/menu/play" ) ); } b_playing = !b_playing; } @@ -581,17 +589,19 @@ void VLMBroadcast::toggleLoop() void VLMBroadcast::stop() { VLMWrapper::ControlBroadcast( name, ControlBroadcastStop ); - playButton->setIcon( QIcon( QPixmap( ":/play_16px" ) ) ); + playButton->setIcon( QIcon( ":/menu/play" ) ); } /**************** * VLMSchedule ****************/ -VLMSchedule::VLMSchedule( QString name, QString input, QString output, - QDateTime _schetime, QDateTime _schedate, - int _scherepeatnumber, int _repeatDays, - bool enabled, VLMDialog *parent ) - : VLMAWidget( name, input, output, enabled, parent, QVLM_Schedule ) +VLMSchedule::VLMSchedule( const QString& name, const QString& input, + const QString& inputOptions, + const QString& output, QDateTime _schetime, + QDateTime _schedate, int _scherepeatnumber, + int _repeatDays, bool enabled, VLMDialog *parent ) + : VLMAWidget( name, input, inputOptions, output, enabled, parent, + QVLM_Schedule ) { nameLabel->setText( qtr("Schedule: ") + name ); schetime = _schetime; @@ -604,16 +614,18 @@ VLMSchedule::VLMSchedule( QString name, QString input, QString output, void VLMSchedule::update() { - VLMWrapper::EditSchedule( name, input, output, schetime, schedate, + VLMWrapper::EditSchedule( name, input, inputOptions, output, schetime, schedate, rNumber, rDays, b_enabled); } /**************** * VLMVOD ****************/ -VLMVod::VLMVod( QString name, QString input, QString output, - bool enabled, QString _mux, VLMDialog *parent) - : VLMAWidget( name, input, output, enabled, parent, QVLM_VOD ) +VLMVod::VLMVod( const QString& name, const QString& input, + const QString& inputOptions, const QString& output, + bool enabled, const QString& _mux, VLMDialog *parent) + : VLMAWidget( name, input, inputOptions, output, enabled, parent, + QVLM_VOD ) { nameLabel->setText( qtr("VOD: ") + name ); @@ -627,7 +639,7 @@ VLMVod::VLMVod( QString name, QString input, QString output, void VLMVod::update() { muxLabel->setText( mux ); - VLMWrapper::EditVod( name, input, output, b_enabled, mux ); + VLMWrapper::EditVod( name, input, inputOptions, output, b_enabled, mux ); } @@ -646,19 +658,19 @@ VLMWrapper::~VLMWrapper() p_vlm = NULL; } -void VLMWrapper::AddBroadcast( const QString name, QString input, - QString output, +void VLMWrapper::AddBroadcast( const QString& name, const QString& input, + const QString& inputOptions, const QString& output, bool b_enabled, bool b_loop ) { vlm_message_t *message; QString command = "new \"" + name + "\" broadcast"; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); - EditBroadcast( name, input, output, b_enabled, b_loop ); + EditBroadcast( name, input, inputOptions, output, b_enabled, b_loop ); } -void VLMWrapper::EditBroadcast( const QString name, const QString input, - const QString output, +void VLMWrapper::EditBroadcast( const QString& name, const QString& input, + const QString& inputOptions, const QString& output, bool b_enabled, bool b_loop ) { vlm_message_t *message; @@ -667,9 +679,22 @@ void VLMWrapper::EditBroadcast( const QString name, const QString input, command = "setup \"" + name + "\" inputdel all"; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); - command = "setup \"" + name + "\" input \"" + input + "\""; - vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); - vlm_MessageDelete( message ); + + if( !input.isEmpty() ) + { + command = "setup \"" + name + "\" input \"" + input + "\""; + vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); + vlm_MessageDelete( message ); + + QStringList options = inputOptions.split( " :", QString::SkipEmptyParts ); + for( int i = 0; i < options.size(); i++ ) + { + command = "setup \"" + name + "\" option \"" + options[i].trimmed() + "\""; + vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); + vlm_MessageDelete( message ); + } + } + if( !output.isEmpty() ) { command = "setup \"" + name + "\" output \"" + output + "\""; @@ -690,7 +715,7 @@ void VLMWrapper::EditBroadcast( const QString name, const QString input, } } -void VLMWrapper::EnableItem( const QString name, bool b_enable ) +void VLMWrapper::EnableItem( const QString& name, bool b_enable ) { vlm_message_t *message; QString command = "setup \"" + name + ( b_enable ? " enable" : " disable" ); @@ -698,12 +723,12 @@ void VLMWrapper::EnableItem( const QString name, bool b_enable ) vlm_MessageDelete( message ); } -void VLMWrapper::ControlBroadcast( const QString name, int BroadcastStatus, +void VLMWrapper::ControlBroadcast( const QString& name, int BroadcastStatus, unsigned int seek ) { vlm_message_t *message; - QString command = "control \"" + name; + QString command = "control \"" + name + "\""; switch( BroadcastStatus ) { case ControlBroadcastPlay: @@ -723,26 +748,39 @@ void VLMWrapper::ControlBroadcast( const QString name, int BroadcastStatus, vlm_MessageDelete( message ); } -void VLMWrapper::AddVod( const QString name, const QString input, - const QString output, - bool b_enabled, const QString mux ) +void VLMWrapper::AddVod( const QString& name, const QString& input, + const QString& inputOptions, const QString& output, + bool b_enabled, const QString& mux ) { vlm_message_t *message; QString command = "new \"" + name + "\" vod"; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); - EditVod( name, input, output, b_enabled, mux ); + EditVod( name, input, inputOptions, output, b_enabled, mux ); } -void VLMWrapper::EditVod( const QString name, const QString input, - const QString output, +void VLMWrapper::EditVod( const QString& name, const QString& input, + const QString& inputOptions, const QString& output, bool b_enabled, - const QString mux ) + const QString& mux ) { vlm_message_t *message; - QString command = "setup \"" + name + "\" input \"" + input + "\""; - vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); - vlm_MessageDelete( message ); + QString command; + + if( !input.isEmpty() ) + { + command = "setup \"" + name + "\" input \"" + input + "\""; + vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); + vlm_MessageDelete( message ); + + QStringList options = inputOptions.split( " :", QString::SkipEmptyParts ); + for( int i = 0; i < options.size(); i++ ) + { + command = "setup \"" + name + "\" option \"" + options[i].trimmed() + "\""; + vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); + vlm_MessageDelete( message ); + } + } if( !output.isEmpty() ) { @@ -765,30 +803,43 @@ void VLMWrapper::EditVod( const QString name, const QString input, } } -void VLMWrapper::AddSchedule( const QString name, const QString input, - const QString output, QDateTime _schetime, - QDateTime _schedate, +void VLMWrapper::AddSchedule( const QString& name, const QString& input, + const QString& inputOptions, const QString& output, + QDateTime _schetime, QDateTime _schedate, int _scherepeatnumber, int _repeatDays, - bool b_enabled, const QString mux ) + bool b_enabled, const QString& mux ) { vlm_message_t *message; QString command = "new \"" + name + "\" schedule"; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); - EditSchedule( name, input, output, _schetime, _schedate, + EditSchedule( name, input, inputOptions, output, _schetime, _schedate, _scherepeatnumber, _repeatDays, b_enabled, mux ); } -void VLMWrapper::EditSchedule( const QString name, const QString input, - const QString output, QDateTime _schetime, - QDateTime _schedate, int _scherepeatnumber, - int _repeatDays, bool b_enabled, - const QString mux ) +void VLMWrapper::EditSchedule( const QString& name, const QString& input, + const QString& inputOptions, const QString& output, + QDateTime _schetime, QDateTime _schedate, + int _scherepeatnumber, int _repeatDays, + bool b_enabled, const QString& mux ) { vlm_message_t *message; - QString command = "setup \"" + name + "\" input \"" + input + "\""; - vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); - vlm_MessageDelete( message ); + QString command; + + if( !input.isEmpty() ) + { + command = "setup \"" + name + "\" input \"" + input + "\""; + vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); + vlm_MessageDelete( message ); + + QStringList options = inputOptions.split( " :", QString::SkipEmptyParts ); + for( int i = 0; i < options.size(); i++ ) + { + command = "setup \"" + name + "\" option \"" + options[i].trimmed() + "\""; + vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); + vlm_MessageDelete( message ); + } + } if( !output.isEmpty() ) { @@ -832,5 +883,20 @@ void VLMWrapper::EditSchedule( const QString name, const QString input, } } +void VLMDialog::toggleVisible() +{ + QList::iterator it; + for( it = vlmItems.begin(); it != vlmItems.end(); it++ ) + { + VLMAWidget *item = *it; + delete item; + item = NULL; + } + vlmItems.clear(); + ui.vlmListItem->clear(); + mediasPopulator(); + QVLCDialog::toggleVisible(); +} + #endif