]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/vlm.hpp
bcb89dc53ea857d8aebe51f782ec6e8c24373e9a
[vlc] / modules / gui / qt4 / dialogs / vlm.hpp
1 /*****************************************************************************
2  * vlm.hpp : VLM Management
3  ****************************************************************************
4  * Copyright ( C ) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jean-François Massol <jf.massol@gmail.com>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * ( at your option ) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef QVLC_VLM_DIALOG_H_
26 #define QVLC_VLM_DIALOG_H_ 1
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #ifdef ENABLE_VLM
33
34 #include <vlc_vlm.h>
35
36 #include "ui/vlm.h"
37 #include "util/qvlcframe.hpp"
38 #include "util/singleton.hpp"
39 #include <QDateTime>
40
41 enum{
42     QVLM_Broadcast,
43     QVLM_Schedule,
44     QVLM_VOD
45 };
46
47 enum{
48     ControlBroadcastPlay,
49     ControlBroadcastPause,
50     ControlBroadcastStop,
51     ControlBroadcastSeek
52 };
53
54 class QComboBox;
55 class QVBoxLayout;
56 class QStackedWidget;
57 class QLabel;
58 class QGridLayout;
59 class QLineEdit;
60 class QCheckBox;
61 class QToolButton;
62 class QGroupBox;
63 class QPushButton;
64 class QHBoxLayout;
65 class QDateTimeEdit;
66 class QSpinBox;
67 class VLMAWidget;
68 class VLMWrapper;
69
70
71 class VLMDialog : public QVLCDialog, public Singleton<VLMDialog>
72 {
73     Q_OBJECT
74
75 public:
76     void toggleVisible();
77
78     VLMWrapper *vlmWrapper;
79     vlm_t *p_vlm;
80 private:
81     VLMDialog( intf_thread_t * );
82     virtual ~VLMDialog();
83
84     Ui::Vlm ui;
85
86     QList<VLMAWidget *> vlmItems;
87     int currentIndex;
88
89     QVBoxLayout *vlmItemLayout;
90     QWidget *vlmItemWidget;
91
92     QComboBox *mediatype;
93     QDateTimeEdit *time, *date, *repeatTime;
94     QSpinBox *scherepeatnumber, *repeatDays;
95     bool isNameGenuine( const QString& );
96     void mediasPopulator();
97 public slots:
98     void removeVLMItem( VLMAWidget * );
99     void startModifyVLMItem( VLMAWidget * );
100 private slots:
101     void addVLMItem();
102     void clearWidgets();
103     void saveModifications();
104     void showScheduleWidget( int );
105     void selectVLMItem( int );
106     void selectInput();
107     void selectOutput();
108     bool exportVLMConf();
109     bool importVLMConf();
110
111     friend class    Singleton<VLMDialog>;
112 };
113
114 class VLMWrapper
115 {
116 public:
117     VLMWrapper( vlm_t * );
118     virtual ~VLMWrapper();
119
120     static void AddBroadcast( const QString&, const QString&, const QString&,
121                        bool b_enabled = true,
122                        bool b_loop = false );
123     static void EditBroadcast( const QString&, const QString&, const QString&,
124                        bool b_enabled = true,
125                        bool b_loop = false );
126     static void EditSchedule( const QString&, const QString&, const QString&,
127                        QDateTime _schetime, QDateTime _schedate,
128                        int _scherepeatnumber, int _repeatDays,
129                        bool b_enabled = true, const QString& mux = "" );
130     static void AddVod( const QString&, const QString&, const QString&,
131                        bool b_enabled = true, const QString& mux = "" );
132     static void EditVod( const QString&, const QString&, const QString&,
133                        bool b_enabled = true, const QString& mux = "" );
134     static void AddSchedule( const QString&, const QString&, const QString&,
135                        QDateTime _schetime, QDateTime _schedate,
136                        int _scherepeatnumber, int _repeatDays,
137                        bool b_enabled = true, const QString& mux = "" );
138
139     static void ControlBroadcast( const QString&, int, unsigned int seek = 0 );
140     static void EnableItem( const QString&, bool );
141
142     /* We don't have yet the accessors in the core, so the following is commented */
143     //unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; }
144    /* vlm_media_t *GetMedia( int i )
145     { if( p_vlm ) return p_vlm->media[i]; return NULL; }*/
146
147 private:
148     static vlm_t *p_vlm;
149 };
150
151 class VLMAWidget : public QGroupBox
152 {
153     Q_OBJECT
154     friend class VLMDialog;
155 public:
156     VLMAWidget( const QString& name, const QString& input, const QString& output,
157             bool _enable, VLMDialog *parent, int _type = QVLM_Broadcast );
158     virtual void update() = 0;
159 protected:
160     QLabel *nameLabel;
161     QString name;
162     QString input;
163     QString output;
164     bool b_enabled;
165     int type;
166     VLMDialog *parent;
167     QGridLayout *objLayout;
168 private slots:
169     virtual void modify();
170     virtual void del();
171     virtual void toggleEnabled( bool );
172 };
173
174 class VLMBroadcast : public VLMAWidget
175 {
176     Q_OBJECT
177     friend class VLMDialog;
178 public:
179     VLMBroadcast( const QString& name, const QString& input, const QString& output,
180             bool _enable, bool _loop, VLMDialog *parent );
181     void update();
182 private:
183     bool b_looped;
184     bool b_playing;
185     QToolButton *loopButton, *playButton;
186 private slots:
187     void stop();
188     void togglePlayPause();
189     void toggleLoop();
190 };
191
192 class VLMVod : public VLMAWidget
193 {
194     Q_OBJECT
195     friend class VLMDialog;
196 public:
197     VLMVod( const QString& name, const QString& input, const QString& output,
198             bool _enable, const QString& _mux, VLMDialog *parent );
199     void update();
200 private:
201     QString mux;
202     QLabel *muxLabel;
203 };
204
205 class VLMSchedule : public VLMAWidget
206 {
207     Q_OBJECT
208     friend class VLMDialog;
209 public:
210     VLMSchedule( const QString& name, const QString& input, const QString& output,
211             QDateTime schetime, QDateTime schedate, int repeatnumber,
212             int repeatdays, bool enabled, VLMDialog *parent );
213     void update();
214 private:
215     QDateTime schetime;
216     QDateTime schedate;
217     int rNumber;
218     int rDays;
219 };
220
221 #endif
222
223 #endif
224