]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/vlm.hpp
Qt4 - VLM: Schedule configuration. The VLM Dialog should work, still basic, but work.
[vlc] / modules / gui / qt4 / dialogs / vlm.hpp
1 /*****************************************************************************
2  * vlm.hpp : VLM Management
3  ****************************************************************************
4  * Copyright ( C ) 2006 the VideoLAN team
5  * $Id: vlm.hpp 21875 2007-09-08 16:01:33Z jb $
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 _VLM_DIALOG_H_
26 #define _VLM_DIALOG_H_
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc/vlc.h>
33
34 #ifdef ENABLE_VLM
35
36 #include <vlc_vlm.h>
37
38 #include "ui/vlm.h"
39 #include "util/qvlcframe.hpp"
40 #include <QDateTime>
41
42 enum{
43     QVLM_Broadcast,
44     QVLM_Schedule,
45     QVLM_VOD
46 };
47
48 enum{
49     ControlBroadcastPlay,
50     ControlBroadcastPause,
51     ControlBroadcastStop,
52     ControlBroadcastSeek
53 };
54
55 class QComboBox;
56 class QVBoxLayout;
57 class QStackedWidget;
58 class QLabel;
59 class QGridLayout;
60 class QLineEdit;
61 class QCheckBox;
62 class QToolButton;
63 class QGroupBox;
64 class QPushButton;
65 class QHBoxLayout;
66 class QDateTimeEdit;
67 class QSpinBox;
68 class VLMAWidget;
69 class VLMWrapper;
70
71
72 class VLMDialog : public QVLCDialog
73 {
74     Q_OBJECT;
75 public:
76     static VLMDialog * getInstance( intf_thread_t *p_intf )
77     {
78         if( !instance)
79              instance = new VLMDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
80         return instance;
81     };
82     virtual ~VLMDialog();
83
84     VLMWrapper *vlmWrapper;
85     vlm_t *p_vlm;
86 private:
87     VLMDialog( QWidget *, intf_thread_t * );
88     static VLMDialog *instance;
89     Ui::Vlm ui;
90
91     QList<VLMAWidget *> vlmItems;
92     int currentIndex;
93
94     QVBoxLayout *vlmItemLayout;
95     QWidget *vlmItemWidget;
96
97     QComboBox *mediatype;
98     QDateTimeEdit *time, *date, *repeatTime;
99     QSpinBox *scherepeatnumber, *repeatDays;
100     bool isNameGenuine( QString );
101 public slots:
102     void removeVLMItem( VLMAWidget * );
103     void startModifyVLMItem( VLMAWidget * );
104 private slots:
105     void addVLMItem();
106     void clearWidgets();
107     void saveModifications();
108     void showScheduleWidget( int );
109     void selectVLMItem( int );
110     void selectInput();
111     void selectOutput();
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, QString mux = "" );
130     static void AddVod( const QString, const QString, const QString,
131                        bool b_enabled = true, QString mux = "" );
132     static void EditVod( const QString, const QString, const QString,
133                        bool b_enabled = true, 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, 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( QString name, QString input, 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     virtual void enterEvent( QEvent * );
168     QGridLayout *objLayout;
169 private slots:
170     virtual void modify();
171     virtual void del();
172     virtual void toggleEnabled( bool );
173 };
174
175 class VLMBroadcast : public VLMAWidget
176 {
177     Q_OBJECT
178     friend class VLMDialog;
179 public:
180     VLMBroadcast( QString name, QString input, QString output,
181             bool _enable, bool _loop, VLMDialog *parent );
182     void update();
183 private:
184     bool b_looped;
185     bool b_playing;
186     QToolButton *loopButton, *playButton;
187 private slots:
188     void stop();
189     void togglePlayPause();
190     void toggleLoop();
191 };
192
193 class VLMVod : public VLMAWidget
194 {
195     Q_OBJECT
196     friend class VLMDialog;
197 public:
198     VLMVod( QString name, QString input, QString output,
199             bool _enable, QString _mux, VLMDialog *parent );
200     void update();
201 private:
202     QString mux;
203     QLabel *muxLabel;
204 };
205
206 class VLMSchedule : public VLMAWidget
207 {
208     Q_OBJECT
209     friend class VLMDialog;
210 public:
211     VLMSchedule( QString name, QString input, QString output,
212             QDateTime schetime, QDateTime schedate, int repeatnumber,
213             int repeatdays, bool enabled, VLMDialog *parent );
214     void update();
215 private:
216     QDateTime schetime;
217     QDateTime schedate;
218     int rNumber;
219     int rDays;
220 };
221
222 #endif
223
224 #endif
225