Commit 240dc04a authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf
Browse files

Qt4 - Rewrite of the VLM Dialog. It features a list on the left of the VLM...

Qt4 - Rewrite of the VLM Dialog. It features a list on the left of the VLM object, and a right pane to see them in details. Creation and modification is doable. This is not yet a VCR, but it could be :D
The code is way not finished and uncleaned, but feel free to improve.
Only Brodcast elements have a start of code.


parent accc4e29
/*****************************************************************************
* sout.cpp : stream output dialog ( old-style )
* vlm.cpp : VLM Management
****************************************************************************
* Copyright ( C ) 2006 the VideoLAN team
* $Id: sout.cpp 21875 2007-09-08 16:01:33Z jb $
*
* Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
* Authors: Jean-Baptiste Kempf <jb@videolan.org>
* Jean-François Massol <jf.massol -at- gmail.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -27,7 +26,6 @@
#include <vlc_streaming.h>
#include <QString>
#include <QFileDialog>
#include <QComboBox>
#include <QVBoxLayout>
#include <QStackedWidget>
......@@ -44,106 +42,37 @@
#include <QDateEdit>
#include <QSpinBox>
#include <QHeaderView>
#include <QScrollArea>
VLMDialog *VLMDialog::instance = NULL;
static const char *psz_type[] = { "Broadcast", "Schedule", "VOD" };
VLMDialog *VLMDialog::instance = NULL;
VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{
// UI stuff
ui.setupUi( this );
ui.saveButton->hide();
#define ADDMEDIATYPES( str, type ) ui.mediaType->addItem( qtr( str ), QVariant( type ) );
ADDMEDIATYPES( "Broadcast", QVLM_Broadcast );
ADDMEDIATYPES( "Video On Demand ( VOD )", QVLM_VOD );
ADDMEDIATYPES( "Schedule", QVLM_Schedule );
ADDMEDIATYPES( "Video On Demand ( VOD )", QVLM_VOD );
#undef ADDMEDIATYPES
/* ui.mediasDB->horizontalHeader()->setResizeMode( 0, QHeaderView::ResizeToContents );
ui.mediasDB->horizontalHeader()->resizeSection( 1, 160 );
ui.mediasDB->horizontalHeader()->resizeSection( 2, 120 );
ui.mediasDB->horizontalHeader()->resizeSection( 3, 120 );
ui.mediasDB->horizontalHeader()->setStretchLastSection ( true );*/
QGridLayout *bcastlayout = new QGridLayout( ui.pBcast );
QLabel *bcastname = new QLabel( qtr( "Name:" ) );
bcastnameledit = new QLineEdit;
bcastenable = new QCheckBox( qtr( "Enable" ) );
bcastenable->setCheckState( Qt::Checked );
QLabel *bcastinput = new QLabel( qtr( "Input:" ) );
bcastinputledit = new QLineEdit;
bcastinputtbutton = new QToolButton;
QLabel *bcastoutput = new QLabel( qtr( "Output:" ) );
bcastoutputledit = new QLineEdit;
bcastoutputtbutton = new QToolButton;
QGroupBox *bcastcontrol = new QGroupBox( qtr( "Controls" ) );
QHBoxLayout *bcastgbox = new QHBoxLayout( bcastcontrol );
bcastplay = new QPushButton( qtr( "Play" ) );
bcastpause = new QPushButton( qtr( "Pause" ) );
bcaststop = new QPushButton( qtr( "Stop" ) );
bcastgbox->addWidget( bcastplay );
bcastgbox->addWidget( bcastpause );
bcastgbox->addWidget( bcaststop );
bcastlayout->addWidget( bcastname, 0, 0 );
bcastlayout->addWidget( bcastnameledit, 0, 1 );
bcastlayout->addWidget( bcastenable, 0, 2 );
bcastlayout->addWidget( bcastinput, 1, 0 );
bcastlayout->addWidget( bcastinputledit, 1, 1 );
bcastlayout->addWidget( bcastinputtbutton, 1, 2 );
bcastlayout->addWidget( bcastoutput, 2, 0 );
bcastlayout->addWidget( bcastoutputledit, 2, 1 );
bcastlayout->addWidget( bcastoutputtbutton, 2, 2 );
bcastlayout->addWidget( bcastcontrol, 3, 0, 1, 3 );
QSpacerItem *spacerItem = new QSpacerItem(10, 5,
QSizePolicy::Expanding, QSizePolicy::MinimumExpanding );
bcastlayout->addItem(spacerItem, 4, 0, 1, 1);
QGridLayout *vodlayout = new QGridLayout( ui.pVod );
QLabel *vodname = new QLabel( qtr( "Name :" ) );
vodnameledit = new QLineEdit;
vodenable = new QCheckBox( qtr( "Enable" ) );
QLabel *vodinput = new QLabel( qtr( "Input :" ) );
vodinputledit = new QLineEdit;
vodinputtbutton = new QToolButton;
QLabel *vodoutput = new QLabel( qtr( "Output :" ) );
vodoutputledit = new QLineEdit;
vodoutputtbutton = new QToolButton;
vodlayout->addWidget( vodname, 0, 0 );
vodlayout->addWidget( vodnameledit, 0, 1 );
vodlayout->addWidget( vodenable, 0, 2 );
vodlayout->addWidget( vodinput, 1, 0 );
vodlayout->addWidget( vodinputledit, 1, 1 );
vodlayout->addWidget( vodinputtbutton, 1, 2 );
vodlayout->addWidget( vodoutput, 2, 0 );
vodlayout->addWidget( vodoutputledit, 2, 1 );
vodlayout->addWidget( vodoutputtbutton, 2, 2 );
QSpacerItem *spacerVod = new QSpacerItem(10, 5,
QSizePolicy::Expanding, QSizePolicy::MinimumExpanding );
vodlayout->addItem( spacerVod, 4, 0, 1, 1);
QGridLayout *schelayout = new QGridLayout( ui.pSched );
QLabel *schename = new QLabel( qtr( "Name:" ) );
schenameledit = new QLineEdit;
scheenable = new QCheckBox( qtr( "Enable" ) );
QLabel *scheinput = new QLabel( qtr( "Input:" ) );
scheinputledit = new QLineEdit;
scheinputtbutton = new QToolButton;
QLabel *scheoutput = new QLabel( qtr( "Output:" ) );
scheoutputledit = new QLineEdit;
scheoutputtbutton = new QToolButton;
QGroupBox *schecontrol = new QGroupBox( qtr( "Time Control" ), ui.pSched );
QGridLayout *schetimelayout = new QGridLayout( schecontrol );
/* Schedule Stuffs */
QGridLayout *schetimelayout = new QGridLayout( ui.schedBox );
QLabel *schetimelabel = new QLabel( qtr( "Hours/Minutes/Seconds:" ) );
schetimelayout->addWidget( schetimelabel, 0, 0 );
QLabel *schedatelabel = new QLabel( qtr( "Day Month Year:" ) );
QLabel *schetimerepeat = new QLabel( qtr( "Repeat:" ) );
schetimelayout->addWidget( schedatelabel, 1, 0 );
QLabel *scherepeatLabel = new QLabel( qtr( "Repeat:" ) );
schetimelayout->addWidget( scherepeatLabel, 2, 0 );
time = new QTimeEdit( QTime::currentTime() );
time->setAlignment( Qt::AlignRight );
schetimelayout->addWidget( time, 0, 1 );
date = new QDateEdit( QDate::currentDate() );
date->setAlignment( Qt::AlignRight );
#ifdef WIN32
......@@ -151,98 +80,248 @@ VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
#else
date->setDisplayFormat( "dd MMMM yyyy" );
#endif
schetimelayout->addWidget( date, 1, 1 );
scherepeatnumber = new QSpinBox;
scherepeatnumber->setAlignment( Qt::AlignRight );
schecontrol->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
schetimelayout->addWidget( schetimelabel, 0, 0 );
schetimelayout->addWidget( time, 0, 1 );
schetimelayout->addWidget( schedatelabel, 1, 0 );
schetimelayout->addWidget( date, 1, 1 );
schetimelayout->addWidget( schetimerepeat, 2, 0 );
schetimelayout->addWidget( scherepeatnumber, 2, 1 );
schelayout->addWidget( schename, 0, 0 );
schelayout->addWidget( schenameledit, 0, 1 );
schelayout->addWidget( scheenable, 0, 2 );
schelayout->addWidget( scheinput, 1, 0 );
schelayout->addWidget( scheinputledit, 1, 1 );
schelayout->addWidget( scheinputtbutton, 1, 2 );
schelayout->addWidget( scheoutput, 2, 0 );
schelayout->addWidget( scheoutputledit, 2, 1 );
schelayout->addWidget( scheoutputtbutton, 2, 2 );
schelayout->addWidget( schecontrol, 3, 0, 1, 3 );
/* scrollArea */
ui.vlmItemScroll->setFrameStyle( QFrame::NoFrame );
ui.vlmItemScroll->setWidgetResizable( true );
vlmItemWidget = new QWidget;
vlmItemLayout = new QVBoxLayout( vlmItemWidget );
vlmItemWidget->setLayout( vlmItemLayout );
ui.vlmItemScroll->setWidget( vlmItemWidget );
QSpacerItem *spacer = new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
vlmItemLayout->addItem( spacer );
QPushButton *closeButton = new QPushButton( qtr( "Close" ) );
QPushButton *cancelButton = new QPushButton( qtr( "Cancel" ) );
ui.buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
ui.buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
ui.mediaStacked->setCurrentIndex( QVLM_Broadcast );
CONNECT( ui.mediaType, currentIndexChanged( int ),
ui.mediaStacked, setCurrentIndex( int ) );
ui.schedBox->hide();
BUTTONACT( closeButton, finish() );
BUTTONACT( cancelButton, cancel() );
/* Connect the comboBox to show the right Widgets */
CONNECT( ui.mediaType, currentIndexChanged( int ),
this, showScheduleWidget( int ) );
/* Connect the leftList to show the good VLMItem */
CONNECT( ui.vlmListItem, currentRowChanged( int ),
this, selectVLMItem( int ) );
BUTTONACT( closeButton, close() );
BUTTONACT( ui.addButton, addVLMItem() );
BUTTONACT( ui.clearButton, clearVLMItem() );
BUTTONACT( ui.clearButton, clearWidgets() );
BUTTONACT( ui.saveButton, saveModifications() );
}
VLMDialog::~VLMDialog(){}
void VLMDialog::cancel()
void VLMDialog::showScheduleWidget( int i )
{
hide();
ui.schedBox->setVisible( ( i == QVLM_Schedule ) );
}
void VLMDialog::selectVLMItem( int i )
{
ui.vlmItemScroll->ensureWidgetVisible( vlmItems.at( i ) );
}
void VLMDialog::finish()
bool VLMDialog::isNameGenuine( QString name )
{
// for( int i = 0; i < ui.mediasDB->topLevelItemCount(); i++ );
hide();
for( int i = 0; i < vlmItems.size(); i++ )
{
if( vlmItems.at( i )->name == name )
return false;
}
return true;
}
void VLMDialog::addVLMItem()
{
// int row = ui.mediasDB->rowCount() -1 ;
int type = ui.mediaType->itemData( ui.mediaType->currentIndex() ).toInt();
QString str;
QString name;
int vlmItemCount = vlmItems.size();
/* Take the name and Check it */
QString name = ui.nameLedit->text();
if( name.isEmpty() || !isNameGenuine( name ) )
{
msg_Dbg( p_intf, "VLM Name is empty or already exists, I can't do it" );
return;
}
int type = ui.mediaType->itemData( ui.mediaType->currentIndex() ).toInt();
QString typeShortName;
switch( type )
{
case QVLM_Broadcast:
str = "broadcast";
name = bcastnameledit->text();
typeShortName = "Bcast";
break;
case QVLM_VOD:
str = "vod";
name = vodnameledit->text();
typeShortName = "VOD";
break;
case QVLM_Schedule:
str = "schedule";
name = schenameledit->text();
typeShortName = "Sched";
break;
default:
break;
msg_Warn( p_intf, "Something bad happened" );
return;
}
QGroupBox *groupItem = new QGroupBox( name );
/* Add an Item of the Side List */
ui.vlmListItem->addItem( typeShortName + " : " + name );
ui.vlmListItem->setCurrentRow( vlmItemCount - 1 );
/* Add a new VLMObject on the main List */
VLMObject *vlmObject = new VLMObject( type, name,
ui.inputLedit->text(),
ui.outputLedit->text(),
ui.enableCheck->isChecked(),
this );
vlmItemLayout->insertWidget( vlmItemCount, vlmObject );
vlmItems.append( vlmObject );
/* HERE BE DRAGONS VLM REQUEST */
}
void VLMDialog::clearWidgets()
{
ui.nameLedit->clear();
ui.inputLedit->clear();
ui.outputLedit->clear();
time->setTime( QTime::currentTime() );
date->setDate( QDate::currentDate() );
ui.enableCheck->setChecked( true );
ui.nameLedit->setReadOnly( false );
}
void VLMDialog::saveModifications()
{
VLMObject *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();
}
ui.saveButton->hide();
ui.addButton->show();
clearWidgets();
}
/* Object Modification */
void VLMDialog::removeVLMItem( VLMObject *vlmObj )
{
int index = vlmItems.indexOf( vlmObj );
if( index < 0 ) return;
delete ui.vlmListItem->takeItem( index );
vlmItems.removeAt( index );
delete vlmObj;
/* HERE BE DRAGONS VLM REQUEST */
}
void VLMDialog::startModifyVLMItem( VLMObject *vlmObj )
{
currentIndex = vlmItems.indexOf( vlmObj );
if( currentIndex < 0 ) return;
ui.vlmListItem->setCurrentRow( currentIndex );
ui.nameLedit->setText( vlmObj->name );
ui.inputLedit->setText( vlmObj->input );
ui.outputLedit->setText( vlmObj->output );
ui.enableCheck->setChecked( vlmObj->b_enabled );
ui.nameLedit->setReadOnly( true );
ui.addButton->hide();
ui.saveButton->show();
}
/*********************************
* VLMObject
********************************/
VLMObject::VLMObject( int type,
QString _name,
QString _input,
QString _output,
bool _enabled,
VLMDialog *_parent )
: QGroupBox( _name, _parent )
{
parent = _parent;
name = _name;
input = _input;
output = _output;
b_enabled = _enabled;
setChecked( b_enabled );
QGridLayout *objLayout = new QGridLayout( this );
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
QLabel *label = new QLabel( psz_type[type] + ( ": " + name ) );
objLayout->addWidget( label, 0, 0, 1, 4 );
QToolButton *playButton = new QToolButton;
playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
objLayout->addWidget( playButton, 1, 0 );
QToolButton *stopButton = new QToolButton;
stopButton->setIcon( QIcon( QPixmap( ":/pixmaps/stop_16px.png" ) ) );
objLayout->addWidget( stopButton, 1, 1 );
QToolButton *loopButton = new QToolButton;
loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_off.png" ) ) );
objLayout->addWidget( loopButton, 1, 2 );
/*QTableWidgetItem *newItem = new QTableWidgetItem( str );
ui.mediasDB->setItem( row, 0, newItem );
QTableWidgetItem *newItem2 = new QTableWidgetItem( name );
ui.mediasDB->setItem( row, 1, newItem2 );*/
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( stopButton, stop() );
BUTTONACT( modifyButton, modify() );
BUTTONACT( deleteButton, del() );
BUTTONACT( loopButton, toggleLoop() );
}
void VLMObject::modify()
{
parent->startModifyVLMItem( this );
}
void VLMDialog::removeVLMItem()
void VLMObject::del()
{
parent->removeVLMItem( this );
}
void VLMObject::togglePlayPause()
{
}
void VLMObject::toggleLoop()
{
}
void VLMDialog::clearVLMItem()
void VLMObject::stop()
{
}
void VLMObject::enterEvent( QEvent *event )
{
printf( "test" );
}
/*****************************************************************************
* vlm.hpp : Stream output dialog ( old-style, ala WX )
* vlm.hpp : VLM Management
****************************************************************************
* Copyright ( C ) 2006 the VideoLAN team
* $Id: vlm.hpp 21875 2007-09-08 16:01:33Z jb $
......@@ -32,8 +32,8 @@
enum{
QVLM_Broadcast,
QVLM_VOD,
QVLM_Schedule
QVLM_Schedule,
QVLM_VOD
};
class QComboBox;
......@@ -50,6 +50,7 @@ class QHBoxLayout;
class QDateEdit;
class QTimeEdit;
class QSpinBox;
class VLMObject;
class VLMDialog : public QVLCFrame
{
......@@ -67,28 +68,50 @@ private:
VLMDialog( intf_thread_t * );
static VLMDialog *instance;
Ui::Vlm ui;
QGridLayout *vlmItemLayout;
QList<VLMObject *> vlmItems;
int currentIndex;
QVBoxLayout *vlmItemLayout;
QWidget *vlmItemWidget;
QComboBox *mediatype;
QCheckBox *bcastenable, *vodenable, *scheenable;
QLineEdit *bcastnameledit, *vodnameledit, *schenameledit, *bcastinputledit, *vodinputledit, *scheinputledit;
QLineEdit *bcastoutputledit, *vodoutputledit, *scheoutputledit;
QTimeEdit *time;
QDateEdit *date;
QSpinBox *scherepeatnumber;
QToolButton *bcastinputtbutton, *vodinputtbutton, *scheinputtbutton;
QToolButton *bcastoutputtbutton, *vodoutputtbutton, *scheoutputtbutton;
QPushButton *bcastplay, *bcastpause, *bcaststop;
QPushButton *bcastadd, *vodadd, *scheadd, *bcastremove, *vodremove, *scheremove;
bool isNameGenuine( QString );
public slots:
void removeVLMItem( VLMObject * );
void startModifyVLMItem( VLMObject * );
private slots:
void finish();
void cancel();
void addVLMItem();
void removeVLMItem();
void clearVLMItem();
void clearWidgets();
void saveModifications();
void showScheduleWidget( int );
void selectVLMItem( int );
};
class VLMObject : public QGroupBox
{
Q_OBJECT
friend class VLMDialog;
public:
VLMObject( int type, QString name, QString input, QString output, bool _enable, VLMDialog *parent );
private:
QString name;
QString input;
QString output;
bool b_looped;
bool b_enabled;
VLMDialog *parent;
protected:
virtual void enterEvent( QEvent * );
private slots:
void modify();
void stop();
void del();
void togglePlayPause();
void toggleLoop();
};
#endif
......@@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>588</width>
<height>393</height>
<width>738</width>
<height>598</height>
</rect>
</property>
<property name="sizePolicy" >
......@@ -22,7 +22,7 @@
<string>_("VLM configurator")</string>
</property>
<layout class="QGridLayout" >
<item rowspan="3" row="0" column="0" >
<item rowspan="5" row="0" column="0" >
<widget class="QGroupBox" name="mediaConfBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
......@@ -31,10 +31,10 @@
</sizepolicy>
</property>
<property name="title" >
<string>_("Media Creation")</string>
<string>_("Media Manager Edition")</string>
</property>
<layout class="QVBoxLayout" >
<item>
<layout class="QGridLayout" >
<item row="0" column="0" colspan="3" >
<widget class="QComboBox" name="mediaType" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
......@@ -44,41 +44,115 @@
</property>
</widget>
</item>
<item>
<item row="1" column="0" colspan="3" >
<widget class="Line" name="line" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="mediaStacked" >
<property name="currentIndex" >
<number>2</number>
<item row="2" column="0" >
<widget class="QLabel" name="nameLabel" >
<property name="text" >
<string>_("Name:")</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="nameLedit" />
</item>
<item row="2" column="2" >
<widget class="QCheckBox" name="enableCheck" >
<property name="text" >
<string>_("Enable")</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="inputLabel" >
<property name="text" >
<string>_("Input:")</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLineEdit" name="inputLedit" />
</item>
<item row="3" column="2" >
<widget class="QPushButton" name="inputButton" >
<property name="text" >
<string>_("Select Input")</string>