📄 vlm.cpp
字号:
case QVLM_Broadcast: ui.loopBCast->setChecked( (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped ); break; case QVLM_VOD: ui.muxLedit->setText( (qobject_cast<VLMVod *>(vlmObj))->mux ); break; case QVLM_Schedule: time->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schetime ); date->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schedate ); break; } ui.nameLedit->setReadOnly( true ); ui.addButton->hide(); ui.saveButton->show();}void VLMDialog::saveModifications(){ VLMAWidget *vlmObj = vlmItems.at( currentIndex ); if( vlmObj ) { vlmObj->input = ui.inputLedit->text(); vlmObj->output = ui.outputLedit->text(); vlmObj->setChecked( ui.enableCheck->isChecked() ); vlmObj->b_enabled = ui.enableCheck->isChecked(); switch( vlmObj->type ) { case QVLM_Broadcast: (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped = ui.loopBCast->isChecked(); break; case QVLM_VOD: (qobject_cast<VLMVod *>(vlmObj))->mux = ui.muxLedit->text(); break; case QVLM_Schedule: (qobject_cast<VLMSchedule *>(vlmObj))->schetime = time->dateTime(); (qobject_cast<VLMSchedule *>(vlmObj))->schedate = date->dateTime(); (qobject_cast<VLMSchedule *>(vlmObj))->rNumber = scherepeatnumber->value(); (qobject_cast<VLMSchedule *>(vlmObj))->rDays = repeatDays->value(); break; // vlmObj-> } vlmObj->update(); } clearWidgets();}/********************************* * VLMAWidget - Abstract class ********************************/VLMAWidget::VLMAWidget( QString _name, QString _input, QString _output, bool _enabled, VLMDialog *_parent, int _type ) : QGroupBox( _name, _parent ){ parent = _parent; name = _name; input = _input; output = _output; b_enabled = _enabled; type = _type; setCheckable( true ); setChecked( b_enabled ); objLayout = new QGridLayout( this ); setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ); nameLabel = new QLabel; objLayout->addWidget( nameLabel, 0, 0, 1, 4 ); /*QLabel *time = new QLabel( "--:--/--:--" ); objLayout->addWidget( time, 1, 3, 1, 2 );*/ QToolButton *modifyButton = new QToolButton; modifyButton->setIcon( QIcon( QPixmap( ":/settings" ) ) ); objLayout->addWidget( modifyButton, 0, 5 ); QToolButton *deleteButton = new QToolButton; deleteButton->setIcon( QIcon( QPixmap( ":/quit" ) ) ); objLayout->addWidget( deleteButton, 0, 6 ); BUTTONACT( modifyButton, modify() ); BUTTONACT( deleteButton, del() ); CONNECT( this, clicked( bool ), this, toggleEnabled( bool ) );}void VLMAWidget::modify(){ parent->startModifyVLMItem( this );}void VLMAWidget::del(){ parent->removeVLMItem( this );}void VLMAWidget::toggleEnabled( bool b_enable ){ VLMWrapper::EnableItem( name, b_enable );}/**************** * VLMBroadcast ****************/VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output, bool _enabled, bool _looped, VLMDialog *_parent) : VLMAWidget( _name, _input, _output, _enabled, _parent, QVLM_Broadcast ){ nameLabel->setText( "Broadcast: " + name ); type = QVLM_Broadcast; b_looped = _looped; playButton = new QToolButton; playButton->setIcon( QIcon( QPixmap( ":/play_16px" ) ) ); objLayout->addWidget( playButton, 1, 0 ); b_playing = true; QToolButton *stopButton = new QToolButton; stopButton->setIcon( QIcon( QPixmap( ":/stop_16px" ) ) ); objLayout->addWidget( stopButton, 1, 1 ); loopButton = new QToolButton; objLayout->addWidget( loopButton, 1, 2 ); BUTTONACT( playButton, togglePlayPause() ); BUTTONACT( stopButton, stop() ); BUTTONACT( loopButton, toggleLoop() ); update();}void VLMBroadcast::update(){ VLMWrapper::EditBroadcast( name, input, output, b_enabled, b_looped ); if( b_looped ) loopButton->setIcon( QIcon( QPixmap( ":/repeat_all" ) ) ); else loopButton->setIcon( QIcon( QPixmap( ":/repeat_off" ) ) );}void VLMBroadcast::togglePlayPause(){ if( b_playing = true ) { VLMWrapper::ControlBroadcast( name, ControlBroadcastPause ); playButton->setIcon( QIcon( QPixmap( ":/pause_16px" ) ) ); } else { VLMWrapper::ControlBroadcast( name, ControlBroadcastPlay ); playButton->setIcon( QIcon( QPixmap( ":/play_16px" ) ) ); } b_playing = !b_playing;}void VLMBroadcast::toggleLoop(){ b_enabled = !b_enabled; update();}void VLMBroadcast::stop(){ VLMWrapper::ControlBroadcast( name, ControlBroadcastStop ); playButton->setIcon( QIcon( QPixmap( ":/play_16px" ) ) );}/**************** * 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 ){ nameLabel->setText( "Schedule: " + name ); schetime = _schetime; schedate = _schedate; rNumber = _scherepeatnumber; rDays = _repeatDays; type = QVLM_Schedule; update();}void VLMSchedule::update(){ VLMWrapper::EditSchedule( name, input, 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 ){ nameLabel->setText( "VOD:" + name ); mux = _mux; muxLabel = new QLabel; objLayout->addWidget( muxLabel, 1, 0 ); update();}void VLMVod::update(){ muxLabel->setText( mux ); VLMWrapper::EditVod( name, input, output, b_enabled, mux );}/******************* * VLMWrapper *******************/vlm_t * VLMWrapper::p_vlm = NULL;VLMWrapper::VLMWrapper( vlm_t *_p_vlm ){ p_vlm = _p_vlm;}VLMWrapper::~VLMWrapper(){ p_vlm = NULL;}void VLMWrapper::AddBroadcast( const QString name, QString input, 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 );}void VLMWrapper::EditBroadcast( const QString name, const QString input, const QString output, bool b_enabled, bool b_loop ){ vlm_message_t *message; QString command; 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( !output.isEmpty() ) { command = "setup \"" + name + "\" output \"" + output + "\""; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); } if( b_enabled ) { command = "setup \"" + name + "\" enabled"; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); } if( b_loop ) { command = "setup \"" + name + "\" loop"; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); }}void VLMWrapper::EnableItem( const QString name, bool b_enable ){ vlm_message_t *message; QString command = "setup \"" + name + ( b_enable ? " enable" : " disable" );}void VLMWrapper::ControlBroadcast( const QString name, int BroadcastStatus, unsigned int seek ){ vlm_message_t *message; QString command = "control \"" + name; switch( BroadcastStatus ) { case ControlBroadcastPlay: command += " play"; break; case ControlBroadcastPause: command += " pause"; break; case ControlBroadcastStop: command += " stop"; break; case ControlBroadcastSeek: command += " seek" + seek; break; } vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message );}void VLMWrapper::AddVod( const QString name, const QString input, 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 );}void VLMWrapper::EditVod( const QString name, const QString input, const QString output, 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 ); if( !output.isEmpty() ) { command = "setup \"" + name + "\" output \"" + output + "\""; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); } if( b_enabled ) { command = "setup \"" + name + "\" enabled"; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); } if( !mux.isEmpty() ) { command = "setup \"" + name + "\" mux \"" + mux + "\""; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); }}void VLMWrapper::AddSchedule( const QString name, const QString input, const QString output, QDateTime _schetime, QDateTime _schedate, int _scherepeatnumber, int _repeatDays, 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, _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 ){ vlm_message_t *message; QString command = "setup \"" + name + "\" input \"" + input + "\""; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); if( !output.isEmpty() ) { command = "setup \"" + name + "\" output \"" + output + "\""; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); } if( b_enabled ) { command = "setup \"" + name + "\" enabled"; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); } if( !mux.isEmpty() ) { command = "setup \"" + name + "\" mux \"" + mux + "\""; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); } command = "setup \"" + name + "\" date \"" + _schedate.toString( "yyyy/MM/dd" )+ "-" + _schetime.toString( "hh:mm:ss" ) + "\""; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); if( _scherepeatnumber > 0 ) { command = "setup \"" + name + "\" repeat \"" + _scherepeatnumber + "\""; vlm_ExecuteCommand( p_vlm, qtu( command ), &message ); vlm_MessageDelete( message ); }}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -