Commit 17413bf6 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - VLM improvements... Classing for the three kind of objects, more...

Qt4 - VLM improvements... Classing for the three kind of objects, more property editing and less segfaults (though there is one I have nooo clue ).
parent cf9db1b8
...@@ -38,8 +38,7 @@ ...@@ -38,8 +38,7 @@
#include <QGroupBox> #include <QGroupBox>
#include <QPushButton> #include <QPushButton>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QTimeEdit> #include <QDateTimeEdit>
#include <QDateEdit>
#include <QSpinBox> #include <QSpinBox>
#include <QHeaderView> #include <QHeaderView>
#include <QScrollArea> #include <QScrollArea>
...@@ -68,24 +67,37 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -68,24 +67,37 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
schetimelayout->addWidget( schedatelabel, 1, 0 ); schetimelayout->addWidget( schedatelabel, 1, 0 );
QLabel *scherepeatLabel = new QLabel( qtr( "Repeat:" ) ); QLabel *scherepeatLabel = new QLabel( qtr( "Repeat:" ) );
schetimelayout->addWidget( scherepeatLabel, 2, 0 ); schetimelayout->addWidget( scherepeatLabel, 2, 0 );
QLabel *scherepeatTimeLabel = new QLabel( qtr( "Repeat delay:" ) );
time = new QTimeEdit( QTime::currentTime() ); schetimelayout->addWidget( scherepeatTimeLabel, 3, 0 );
time = new QDateTimeEdit( QTime::currentTime() );
time->setAlignment( Qt::AlignRight ); time->setAlignment( Qt::AlignRight );
schetimelayout->addWidget( time, 0, 1 ); schetimelayout->addWidget( time, 0, 1, 1, 3 );
date = new QDateEdit( QDate::currentDate() ); date = new QDateTimeEdit( QDate::currentDate() );
date->setAlignment( Qt::AlignRight ); date->setAlignment( Qt::AlignRight );
date->setCalendarPopup( true );
#ifdef WIN32 #ifdef WIN32
date->setDisplayFormat( "dd MM yyyy" ); date->setDisplayFormat( "dd MM yyyy" );
#else #else
date->setDisplayFormat( "dd MMMM yyyy" ); date->setDisplayFormat( "dd MMMM yyyy" );
#endif #endif
schetimelayout->addWidget( date, 1, 1 ); schetimelayout->addWidget( date, 1, 1, 1, 3 );
scherepeatnumber = new QSpinBox; scherepeatnumber = new QSpinBox;
scherepeatnumber->setAlignment( Qt::AlignRight ); scherepeatnumber->setAlignment( Qt::AlignRight );
schetimelayout->addWidget( scherepeatnumber, 2, 1 ); schetimelayout->addWidget( scherepeatnumber, 2, 1, 1, 3 );
repeatDays = new QSpinBox;
repeatDays->setAlignment( Qt::AlignRight );
schetimelayout->addWidget( repeatDays, 3, 1, 1, 1 );
repeatDays->setSuffix( qtr(" days") );
repeatTime = new QDateTimeEdit;
repeatTime->setAlignment( Qt::AlignRight );
schetimelayout->addWidget( repeatTime, 3, 2, 1, 2 );
repeatTime->setDisplayFormat( "hh:mm:ss" );
/* scrollArea */ /* scrollArea */
ui.vlmItemScroll->setFrameStyle( QFrame::NoFrame ); ui.vlmItemScroll->setFrameStyle( QFrame::NoFrame );
ui.vlmItemScroll->setWidgetResizable( true ); ui.vlmItemScroll->setWidgetResizable( true );
...@@ -94,13 +106,14 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -94,13 +106,14 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
vlmItemWidget->setLayout( vlmItemLayout ); vlmItemWidget->setLayout( vlmItemLayout );
ui.vlmItemScroll->setWidget( vlmItemWidget ); ui.vlmItemScroll->setWidget( vlmItemWidget );
QSpacerItem *spacer = new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding); QSpacerItem *spacer =
new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
vlmItemLayout->addItem( spacer ); vlmItemLayout->addItem( spacer );
QPushButton *closeButton = new QPushButton( qtr( "Close" ) ); QPushButton *closeButton = new QPushButton( qtr( "Close" ) );
ui.buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole ); ui.buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
ui.schedBox->hide(); showScheduleWidget( QVLM_Broadcast );
/* Connect the comboBox to show the right Widgets */ /* Connect the comboBox to show the right Widgets */
CONNECT( ui.mediaType, currentIndexChanged( int ), CONNECT( ui.mediaType, currentIndexChanged( int ),
...@@ -109,7 +122,7 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -109,7 +122,7 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
/* Connect the leftList to show the good VLMItem */ /* Connect the leftList to show the good VLMItem */
CONNECT( ui.vlmListItem, currentRowChanged( int ), CONNECT( ui.vlmListItem, currentRowChanged( int ),
this, selectVLMItem( int ) ); this, selectVLMItem( int ) );
BUTTONACT( closeButton, close() ); BUTTONACT( closeButton, close() );
BUTTONACT( ui.addButton, addVLMItem() ); BUTTONACT( ui.addButton, addVLMItem() );
BUTTONACT( ui.clearButton, clearWidgets() ); BUTTONACT( ui.clearButton, clearWidgets() );
...@@ -121,6 +134,8 @@ VLMDialog::~VLMDialog(){} ...@@ -121,6 +134,8 @@ VLMDialog::~VLMDialog(){}
void VLMDialog::showScheduleWidget( int i ) void VLMDialog::showScheduleWidget( int i )
{ {
ui.schedBox->setVisible( ( i == QVLM_Schedule ) ); ui.schedBox->setVisible( ( i == QVLM_Schedule ) );
ui.loopBCast->setVisible( ( i == QVLM_Broadcast ) );
ui.vodBox->setVisible( ( i == QVLM_VOD ) );
} }
void VLMDialog::selectVLMItem( int i ) void VLMDialog::selectVLMItem( int i )
...@@ -151,18 +166,27 @@ void VLMDialog::addVLMItem() ...@@ -151,18 +166,27 @@ void VLMDialog::addVLMItem()
} }
int type = ui.mediaType->itemData( ui.mediaType->currentIndex() ).toInt(); int type = ui.mediaType->itemData( ui.mediaType->currentIndex() ).toInt();
QString typeShortName; QString typeShortName;
QString inputText = ui.inputLedit->text();
QString outputText = ui.outputLedit->text();
bool b_checked;
VLMAWidget * vlmAwidget;
switch( type ) switch( type )
{ {
case QVLM_Broadcast: case QVLM_Broadcast:
typeShortName = "Bcast"; typeShortName = "Bcast";
vlmAwidget = new VLMBroadcast( name, inputText, outputText, b_checked, this );
break; break;
case QVLM_VOD: case QVLM_VOD:
typeShortName = "VOD"; typeShortName = "VOD";
vlmAwidget = new VLMVod( name, inputText, outputText, b_checked, this );
break; break;
case QVLM_Schedule: case QVLM_Schedule:
typeShortName = "Sched"; typeShortName = "Sched";
vlmAwidget = new VLMSchedule( name, inputText, outputText, b_checked, this );
break; break;
default: default:
msg_Warn( p_intf, "Something bad happened" ); msg_Warn( p_intf, "Something bad happened" );
...@@ -173,15 +197,10 @@ void VLMDialog::addVLMItem() ...@@ -173,15 +197,10 @@ void VLMDialog::addVLMItem()
ui.vlmListItem->addItem( typeShortName + " : " + name ); ui.vlmListItem->addItem( typeShortName + " : " + name );
ui.vlmListItem->setCurrentRow( vlmItemCount - 1 ); ui.vlmListItem->setCurrentRow( vlmItemCount - 1 );
/* Add a new VLMObject on the main List */ /* Add a new VLMAWidget on the main List */
VLMObject *vlmObject = new VLMObject( type, name,
ui.inputLedit->text(),
ui.outputLedit->text(),
ui.enableCheck->isChecked(),
this );
vlmItemLayout->insertWidget( vlmItemCount, vlmObject ); vlmItemLayout->insertWidget( vlmItemCount, vlmAwidget );
vlmItems.append( vlmObject ); vlmItems.append( vlmAwidget );
/* HERE BE DRAGONS VLM REQUEST */ /* HERE BE DRAGONS VLM REQUEST */
} }
...@@ -199,7 +218,7 @@ void VLMDialog::clearWidgets() ...@@ -199,7 +218,7 @@ void VLMDialog::clearWidgets()
void VLMDialog::saveModifications() void VLMDialog::saveModifications()
{ {
VLMObject *vlmObj = vlmItems.at( currentIndex ); VLMAWidget *vlmObj = vlmItems.at( currentIndex );
if( vlmObj ) if( vlmObj )
{ {
vlmObj->input = ui.inputLedit->text(); vlmObj->input = ui.inputLedit->text();
...@@ -210,22 +229,23 @@ void VLMDialog::saveModifications() ...@@ -210,22 +229,23 @@ void VLMDialog::saveModifications()
ui.saveButton->hide(); ui.saveButton->hide();
ui.addButton->show(); ui.addButton->show();
clearWidgets(); clearWidgets();
} }
/* Object Modification */ /* Object Modification */
void VLMDialog::removeVLMItem( VLMObject *vlmObj ) void VLMDialog::removeVLMItem( VLMAWidget *vlmObj )
{ {
int index = vlmItems.indexOf( vlmObj ); int index = vlmItems.indexOf( vlmObj );
if( index < 0 ) return; if( index < 0 ) return;
//FIXME, this is going to segfault if the focus in on the ListWidget
delete ui.vlmListItem->takeItem( index ); delete ui.vlmListItem->takeItem( index );
vlmItems.removeAt( index ); vlmItems.removeAt( index );
delete vlmObj; delete vlmObj;
/* HERE BE DRAGONS VLM REQUEST */ /* HERE BE DRAGONS VLM REQUEST */
} }
void VLMDialog::startModifyVLMItem( VLMObject *vlmObj ) void VLMDialog::startModifyVLMItem( VLMAWidget *vlmObj )
{ {
currentIndex = vlmItems.indexOf( vlmObj ); currentIndex = vlmItems.indexOf( vlmObj );
if( currentIndex < 0 ) return; if( currentIndex < 0 ) return;
...@@ -243,15 +263,15 @@ void VLMDialog::startModifyVLMItem( VLMObject *vlmObj ) ...@@ -243,15 +263,15 @@ void VLMDialog::startModifyVLMItem( VLMObject *vlmObj )
/********************************* /*********************************
* VLMObject * VLMAWidget
********************************/ ********************************/
VLMObject::VLMObject( int type,
QString _name, VLMAWidget::VLMAWidget( QString _name,
QString _input, QString _input,
QString _output, QString _output,
bool _enabled, bool _enabled,
VLMDialog *_parent ) VLMDialog *_parent )
: QGroupBox( _name, _parent ) : QGroupBox( _name, _parent )
{ {
parent = _parent; parent = _parent;
name = _name; name = _name;
...@@ -260,68 +280,93 @@ VLMObject::VLMObject( int type, ...@@ -260,68 +280,93 @@ VLMObject::VLMObject( int type,
b_enabled = _enabled; b_enabled = _enabled;
setChecked( b_enabled ); setChecked( b_enabled );
QGridLayout *objLayout = new QGridLayout( this ); objLayout = new QGridLayout( this );
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ); setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
QLabel *label = new QLabel( psz_type[type] + ( ": " + name ) );
objLayout->addWidget( label, 0, 0, 1, 4 );
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( ":/pixmaps/menus_settings_16px.png" ) ) );
objLayout->addWidget( modifyButton, 0, 5 );
QToolButton *deleteButton = new QToolButton;
deleteButton->setIcon( QIcon( QPixmap( ":/pixmaps/menus_quit_16px.png" ) ) );
objLayout->addWidget( deleteButton, 0, 6 );
BUTTONACT( modifyButton, modify() );
BUTTONACT( deleteButton, del() );
}
void VLMAWidget::modify()
{
parent->startModifyVLMItem( this );
}
void VLMAWidget::del()
{
parent->removeVLMItem( this );
}
VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output,
bool _enabled, VLMDialog *_parent)
: VLMAWidget( _name, _input, _output,
_enabled, _parent)
{
nameLabel->setText( "Broadcast: " + name );
QToolButton *playButton = new QToolButton; QToolButton *playButton = new QToolButton;
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) ); playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
objLayout->addWidget( playButton, 1, 0 ); objLayout->addWidget( playButton, 1, 0 );
QToolButton *stopButton = new QToolButton; QToolButton *stopButton = new QToolButton;
stopButton->setIcon( QIcon( QPixmap( ":/pixmaps/stop_16px.png" ) ) ); stopButton->setIcon( QIcon( QPixmap( ":/pixmaps/stop_16px.png" ) ) );
objLayout->addWidget( stopButton, 1, 1 ); objLayout->addWidget( stopButton, 1, 1 );
QToolButton *loopButton = new QToolButton; QToolButton *loopButton = new QToolButton;
loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_off.png" ) ) ); loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_off.png" ) ) );
objLayout->addWidget( loopButton, 1, 2 ); objLayout->addWidget( loopButton, 1, 2 );
QLabel *time = new QLabel( "--:--/--:--" );
objLayout->addWidget( time, 1, 3, 1, 2 );
QToolButton *modifyButton = new QToolButton;
modifyButton->setIcon( QIcon( QPixmap( ":/pixmaps/menus_settings_16px.png" ) ) );
objLayout->addWidget( modifyButton, 0, 5 );
QToolButton *deleteButton = new QToolButton;
deleteButton->setIcon( QIcon( QPixmap( ":/pixmaps/menus_quit_16px.png" ) ) );
objLayout->addWidget( deleteButton, 0, 6 );
BUTTONACT( playButton, togglePlayPause() ); BUTTONACT( playButton, togglePlayPause() );
BUTTONACT( stopButton, stop() ); BUTTONACT( stopButton, stop() );
BUTTONACT( modifyButton, modify() );
BUTTONACT( deleteButton, del() );
BUTTONACT( loopButton, toggleLoop() ); BUTTONACT( loopButton, toggleLoop() );
} }
void VLMObject::modify()
void VLMBroadcast::togglePlayPause()
{ {
parent->startModifyVLMItem( this );
} }
void VLMObject::del() void VLMBroadcast::toggleLoop()
{ {
parent->removeVLMItem( this );
} }
void VLMObject::togglePlayPause() void VLMBroadcast::stop()
{ {
} }
void VLMObject::toggleLoop() void VLMAWidget::enterEvent( QEvent *event )
{ {
printf( "test" );
} }
void VLMObject::stop()
VLMSchedule::VLMSchedule( QString name, QString input, QString output,
bool enabled, VLMDialog *parent) : VLMAWidget( name, input,
output, enabled, parent)
{ {
nameLabel->setText( "Schedule: " + name );
} }
void VLMObject::enterEvent( QEvent *event ) VLMVod::VLMVod( QString name, QString input, QString output,
bool enabled, VLMDialog *parent) : VLMAWidget( name, input,
output, enabled, parent)
{ {
printf( "test" ); nameLabel->setText( "VOD:" + name );
} }
...@@ -47,10 +47,9 @@ class QToolButton; ...@@ -47,10 +47,9 @@ class QToolButton;
class QGroupBox; class QGroupBox;
class QPushButton; class QPushButton;
class QHBoxLayout; class QHBoxLayout;
class QDateEdit; class QDateTimeEdit;
class QTimeEdit;
class QSpinBox; class QSpinBox;
class VLMObject; class VLMAWidget;
class VLMDialog : public QVLCFrame class VLMDialog : public QVLCFrame
{ {
...@@ -69,20 +68,19 @@ private: ...@@ -69,20 +68,19 @@ private:
static VLMDialog *instance; static VLMDialog *instance;
Ui::Vlm ui; Ui::Vlm ui;
QList<VLMObject *> vlmItems; QList<VLMAWidget *> vlmItems;
int currentIndex; int currentIndex;
QVBoxLayout *vlmItemLayout; QVBoxLayout *vlmItemLayout;
QWidget *vlmItemWidget; QWidget *vlmItemWidget;
QComboBox *mediatype; QComboBox *mediatype;
QTimeEdit *time; QDateTimeEdit *time, *date, *repeatTime;
QDateEdit *date; QSpinBox *scherepeatnumber, *repeatDays;
QSpinBox *scherepeatnumber;
bool isNameGenuine( QString ); bool isNameGenuine( QString );
public slots: public slots:
void removeVLMItem( VLMObject * ); void removeVLMItem( VLMAWidget * );
void startModifyVLMItem( VLMObject * ); void startModifyVLMItem( VLMAWidget * );
private slots: private slots:
void addVLMItem(); void addVLMItem();
void clearWidgets(); void clearWidgets();
...@@ -91,27 +89,52 @@ private slots: ...@@ -91,27 +89,52 @@ private slots:
void selectVLMItem( int ); void selectVLMItem( int );
}; };
class VLMObject : public QGroupBox class VLMAWidget : public QGroupBox
{ {
Q_OBJECT Q_OBJECT
friend class VLMDialog; friend class VLMDialog;
public: public:
VLMObject( int type, QString name, QString input, QString output, bool _enable, VLMDialog *parent ); VLMAWidget( QString name, QString input, QString output, bool _enable, VLMDialog *parent );
private: protected:
QLabel *nameLabel;
QString name; QString name;
QString input; QString input;
QString output; QString output;
bool b_looped;
bool b_enabled; bool b_enabled;
VLMDialog *parent; VLMDialog *parent;
protected:
virtual void enterEvent( QEvent * ); virtual void enterEvent( QEvent * );
QGridLayout *objLayout;
private slots:
virtual void modify();
virtual void del();
};
class VLMBroadcast : public VLMAWidget
{
Q_OBJECT
public:
VLMBroadcast( QString name, QString input, QString output, bool _enable, VLMDialog *parent );
private:
bool b_looped;
private slots: private slots:
void modify();
void stop(); void stop();
void del();
void togglePlayPause(); void togglePlayPause();
void toggleLoop(); void toggleLoop();
}; };
class VLMVod : public VLMAWidget
{
public:
VLMVod( QString name, QString input, QString output, bool _enable, VLMDialog *parent );
private:
QString mux;
};
class VLMSchedule : public VLMAWidget
{
public:
VLMSchedule( QString name, QString input, QString output, bool _enable, VLMDialog *parent );
};
#endif #endif
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>738</width> <width>738</width>
<height>598</height> <height>693</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy" >
...@@ -112,6 +112,52 @@ ...@@ -112,6 +112,52 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="3" >
<widget class="QGroupBox" name="vodBox" >
<property name="title" >
<string>_("Mux Control")</string>
</property>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Muxer:</string>
</property>
<property name="margin" >
<number>3</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="muxLedit" >
<property name="inputMask" >
<string>AAAA; </string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>411</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="7" column="0" colspan="2" >
<widget class="QCheckBox" name="loopBCast" >
<property name="text" >
<string>_("Loop")</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
......
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