Qt4 - VLM improvements in the layout and in the function used.
[vlc.git] / modules / gui / qt4 / dialogs / vlm.cpp
1 /*****************************************************************************
2  * sout.cpp : stream output dialog ( old-style )
3  ****************************************************************************
4  * Copyright ( C ) 2006 the VideoLAN team
5  * $Id: sout.cpp 21875 2007-09-08 16:01:33Z jb $
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Jean-François Massol <jf.massol -at- gmail.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * ( at your option ) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #include "dialogs/vlm.hpp"
27 #include <vlc_streaming.h>
28
29 #include <iostream>
30 #include <QString>
31 #include <QFileDialog>
32 #include <QComboBox>
33 #include <QVBoxLayout>
34 #include <QStackedWidget>
35 #include <QLabel>
36 #include <QWidget>
37 #include <QGridLayout>
38 #include <QLineEdit>
39 #include <QCheckBox>
40 #include <QToolButton>
41 #include <QGroupBox>
42 #include <QPushButton>
43 #include <QHBoxLayout>
44 #include <QTimeEdit>
45 #include <QDateEdit>
46 #include <QSpinBox>
47
48 VLMDialog *VLMDialog::instance = NULL;
49
50
51 VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
52 {
53     // UI stuff
54     ui.setupUi( this );
55
56     /* Layout in the main groupBox */
57     layout = new QVBoxLayout( ui.groupBox );
58
59     mediatype = new QComboBox( ui.groupBox );
60     layout->addWidget( mediatype );
61
62 #define ADDMEDIATYPES( type ) mediatype->addItem( qtr( type ) );
63
64     ADDMEDIATYPES( "Broadcast" );
65     ADDMEDIATYPES( "Video On Demand ( VOD )" );
66     ADDMEDIATYPES( "Schedule" );
67
68     makeBcastPage();
69     makeVODPage();
70     makeSchedulePage();
71
72     /* Create a Stacked Widget to old the different phases */
73     slayout = new QStackedWidget( ui.groupBox );
74     slayout->addWidget( pBcast );
75     slayout->addWidget( pVod );
76     slayout->addWidget( pSchedule );
77
78     layout->addWidget( slayout );
79
80     QPushButton *closeButton = new QPushButton( qtr("Close") );
81     QPushButton *cancelButton = new QPushButton( qtr("Cancel") );
82     ui.buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
83     ui.buttonBox->addButton( cancelButton, QDialogButtonBox::RejectRole );
84
85     connect( mediatype, SIGNAL( currentIndexChanged( int ) ), slayout, SLOT( setCurrentIndex( int ) ) );
86
87 }
88
89 VLMDialog::~VLMDialog(){}
90
91 void VLMDialog::makeBcastPage()
92 {
93     pBcast = new QWidget( ui.groupBox );
94     bcastlayout = new QGridLayout( pBcast );
95     bcastname = new QLabel( qtr( "Name :" ),pBcast );
96     bcastnameledit = new QLineEdit( pBcast );
97     bcastenable = new QCheckBox( qtr( "Enable" ),pBcast );
98     bcastinput = new QLabel( qtr( "Input :" ),pBcast );
99     bcastinputledit = new QLineEdit( pBcast );
100     bcastinputtbutton = new QToolButton( pBcast );
101     bcastoutput = new QLabel( qtr( "Output :" ),pBcast );
102     bcastoutputledit = new QLineEdit( pBcast );
103     bcastoutputtbutton = new QToolButton( pBcast );
104     bcastcontrol = new QGroupBox( qtr( "Controls" ),pBcast );
105     bcastgbox = new QHBoxLayout( bcastcontrol );
106     bcastplay = new QPushButton( qtr( "Play" ),bcastcontrol );
107     bcastpause = new QPushButton( qtr( "Pause" ),bcastcontrol );
108     bcaststop = new QPushButton( qtr( "Stop" ),bcastcontrol );
109     bcastadd = new QPushButton( qtr( "Add" ),pBcast );
110     bcastremove = new QPushButton( qtr( "Remove" ),pBcast );
111
112 // Adding all widgets in the QGridLayout
113     bcastgbox->addWidget( bcastplay );
114     bcastgbox->addWidget( bcastpause );
115     bcastgbox->addWidget( bcaststop );
116     bcastlayout->addWidget( bcastname,0,0 );
117     bcastlayout->addWidget( bcastnameledit,0,1 );
118     bcastlayout->addWidget( bcastenable,0,2 );
119     bcastlayout->addWidget( bcastinput,1,0 );
120     bcastlayout->addWidget( bcastinputledit,1,1 );
121     bcastlayout->addWidget( bcastinputtbutton,1,2 );
122     bcastlayout->addWidget( bcastoutput,2,0 );
123     bcastlayout->addWidget( bcastoutputledit,2,1 );
124     bcastlayout->addWidget( bcastoutputtbutton,2,2 );
125     bcastlayout->addWidget( bcastcontrol,3,0,1,3 );
126     bcastlayout->addWidget( bcastadd,4,1 );
127     bcastlayout->addWidget( bcastremove,4,2 );
128 }
129
130 void VLMDialog::makeVODPage()
131 {
132     pVod = new QWidget( ui.groupBox );
133     vodlayout = new QGridLayout( pVod );
134     vodname = new QLabel( qtr( "Name :" ),pVod );
135     vodnameledit = new QLineEdit( pVod );
136     vodenable = new QCheckBox( qtr( "Enable" ),pVod );
137     vodinput = new QLabel( qtr( "Input :" ),pVod );
138     vodinputledit = new QLineEdit( pVod );
139     vodinputtbutton = new QToolButton( pVod );
140     vodoutput = new QLabel( qtr( "Output :" ),pVod );
141     vodoutputledit = new QLineEdit( pVod );
142     vodoutputtbutton = new QToolButton( pVod );
143     vodadd = new QPushButton( qtr( "Add" ),pVod );
144     vodremove = new QPushButton( qtr( "Remove" ),pVod );
145
146 // Adding all widgets in the QGridLayout
147     vodlayout->addWidget( vodname,0,0 );
148     vodlayout->addWidget( vodnameledit,0,1 );
149     vodlayout->addWidget( vodenable,0,2 );
150     vodlayout->addWidget( vodinput,1,0 );
151     vodlayout->addWidget( vodinputledit,1,1 );
152     vodlayout->addWidget( vodinputtbutton,1,2 );
153     vodlayout->addWidget( vodoutput,2,0 );
154     vodlayout->addWidget( vodoutputledit,2,1 );
155     vodlayout->addWidget( vodoutputtbutton,2,2 );
156     vodlayout->addWidget( vodadd,3,1 );
157     vodlayout->addWidget( vodremove,3,2 );
158 }
159
160 void VLMDialog::makeSchedulePage()
161 {
162     pSchedule = new QWidget( ui.groupBox );
163     schelayout = new QGridLayout( pSchedule );
164     schename = new QLabel( qtr( "Name :" ),pSchedule );
165     schenameledit = new QLineEdit( pSchedule );
166     scheenable = new QCheckBox( qtr( "Enable" ),pSchedule );
167     scheinput = new QLabel( qtr( "Input :" ),pSchedule );
168     scheinputledit = new QLineEdit( pSchedule );
169     scheinputtbutton = new QToolButton( pSchedule );
170     scheoutput = new QLabel( qtr( "Output :" ),pSchedule );
171     scheoutputledit = new QLineEdit( pSchedule );
172     scheoutputtbutton = new QToolButton( pSchedule );
173     schecontrol = new QGroupBox( qtr( "Time Control" ),pSchedule );
174     scheadd = new QPushButton( qtr( "Add" ),pSchedule );
175     scheremove = new QPushButton( qtr( "Remove" ),pSchedule );
176     schetimelayout = new QGridLayout( schecontrol );
177     schetimelabel = new QLabel( qtr( "Hours/Minutes/Seconds :" ), schecontrol );
178     schedatelabel = new QLabel( qtr( "Day/Month/Year :" ), schecontrol );
179     schetimerepeat = new QLabel( qtr( "Repeat :" ), schecontrol );
180     time = new QTimeEdit( schecontrol );
181     date = new QDateEdit( schecontrol );
182     scherepeatnumber = new QSpinBox( schecontrol );
183
184     //scheadd->setMaximumWidth( 30 );
185
186 // Adding all widgets in the QGridLayout
187     schetimelayout->addWidget( schetimelabel,0,0 );
188     schetimelayout->addWidget( time,0,1 );
189     schetimelayout->addWidget( schedatelabel,1,0 );
190     schetimelayout->addWidget( date,1,1 );
191     schetimelayout->addWidget( schetimerepeat,2,0 );
192     schetimelayout->addWidget( scherepeatnumber,2,1 );
193     schelayout->addWidget( schename,0,0 );
194     schelayout->addWidget( schenameledit,0,1 );
195     schelayout->addWidget( scheenable,0,2 );
196     schelayout->addWidget( scheinput,1,0 );
197     schelayout->addWidget( scheinputledit,1,1 );
198     schelayout->addWidget( scheinputtbutton,1,2 );
199     schelayout->addWidget( scheoutput,2,0 );
200     schelayout->addWidget( scheoutputledit,2,1 );
201     schelayout->addWidget( scheoutputtbutton,2,2 );
202     schelayout->addWidget( schecontrol,3,0,1,3 );
203     schelayout->addWidget( scheadd,4,1 );
204     schelayout->addWidget( scheremove,4,2 );
205 }
206