]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/vlm.hpp
QT4_vlm: really fix #3938.
[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     QString inputOptions;
87
88     QList<VLMAWidget *> vlmItems;
89     int currentIndex;
90
91     QVBoxLayout *vlmItemLayout;
92     QWidget *vlmItemWidget;
93
94     QComboBox *mediatype;
95     QDateTimeEdit *time, *date, *repeatTime;
96     QSpinBox *scherepeatnumber, *repeatDays;
97     bool isNameGenuine( const QString& );
98     void mediasPopulator();
99 public slots:
100     void removeVLMItem( VLMAWidget * );
101     void startModifyVLMItem( VLMAWidget * );
102 private slots:
103     void addVLMItem();
104     void clearWidgets();
105     void saveModifications();
106     void showScheduleWidget( int );
107     void selectVLMItem( int );
108     void selectInput();
109     void selectOutput();
110     bool exportVLMConf();
111     bool importVLMConf();
112
113     friend class    Singleton<VLMDialog>;
114 };
115
116 class VLMWrapper
117 {
118 public:
119     VLMWrapper( vlm_t * );
120     virtual ~VLMWrapper();
121
122     static void AddBroadcast( const QString&, const QString&,
123                               const QString&, const QString&,
124                               bool b_enabled = true, bool b_loop = false );
125     static void EditBroadcast( const QString&, const QString&,
126                                const QString&, const QString&,
127                                bool b_enabled = true, bool b_loop = false );
128     static void EditSchedule( const QString&, const QString&,
129                               const QString&, const QString&,
130                               QDateTime _schetime, QDateTime _schedate,
131                               int _scherepeatnumber, int _repeatDays,
132                               bool b_enabled = true, const QString& mux = "" );
133     static void AddVod( const QString&, const QString&,
134                         const QString&, const QString&,
135                         bool b_enabled = true, const QString& mux = "" );
136     static void EditVod( const QString&, const QString&,
137                          const QString&, const QString&,
138                          bool b_enabled = true, const QString& mux = "" );
139     static void AddSchedule( const QString&, const QString&,
140                              const QString&, const QString&,
141                              QDateTime _schetime, QDateTime _schedate,
142                              int _scherepeatnumber, int _repeatDays,
143                              bool b_enabled = true, const QString& mux = "" );
144
145     static void ControlBroadcast( const QString&, int, unsigned int seek = 0 );
146     static void EnableItem( const QString&, bool );
147
148     /* We don't have yet the accessors in the core, so the following is commented */
149     //unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; }
150    /* vlm_media_t *GetMedia( int i )
151     { if( p_vlm ) return p_vlm->media[i]; return NULL; }*/
152
153 private:
154     static vlm_t *p_vlm;
155 };
156
157 class VLMAWidget : public QGroupBox
158 {
159     Q_OBJECT
160     friend class VLMDialog;
161 public:
162     VLMAWidget( const QString& name, const QString& input,
163                 const QString& inputOptions, const QString& output,
164                 bool _enable, VLMDialog *parent, int _type = QVLM_Broadcast );
165     virtual void update() = 0;
166 protected:
167     QLabel *nameLabel;
168     QString name;
169     QString input;
170     QString inputOptions;
171     QString output;
172     bool b_enabled;
173     int type;
174     VLMDialog *parent;
175     QGridLayout *objLayout;
176 private slots:
177     virtual void modify();
178     virtual void del();
179     virtual void toggleEnabled( bool );
180 };
181
182 class VLMBroadcast : public VLMAWidget
183 {
184     Q_OBJECT
185     friend class VLMDialog;
186 public:
187     VLMBroadcast( const QString& name, const QString& input,
188                   const QString& inputOptions, const QString& output,
189                   bool _enable, bool _loop, VLMDialog *parent );
190     void update();
191 private:
192     bool b_looped;
193     bool b_playing;
194     QToolButton *loopButton, *playButton;
195 private slots:
196     void stop();
197     void togglePlayPause();
198     void toggleLoop();
199 };
200
201 class VLMVod : public VLMAWidget
202 {
203     Q_OBJECT
204     friend class VLMDialog;
205 public:
206     VLMVod( const QString& name, const QString& input,
207             const QString& inputOptions, const QString& output,
208             bool _enable, const QString& _mux, VLMDialog *parent );
209     void update();
210 private:
211     QString mux;
212     QLabel *muxLabel;
213 };
214
215 class VLMSchedule : public VLMAWidget
216 {
217     Q_OBJECT
218     friend class VLMDialog;
219 public:
220     VLMSchedule( const QString& name, const QString& input,
221                  const QString& inputOptions, const QString& output,
222                  QDateTime schetime, QDateTime schedate, int repeatnumber,
223                  int repeatdays, bool enabled, VLMDialog *parent );
224     void update();
225 private:
226     QDateTime schetime;
227     QDateTime schedate;
228     int rNumber;
229     int rDays;
230 };
231
232 #endif
233
234 #endif
235