]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/vlm.hpp
Qt: toolbar editor, show the saved positionCombo item at start.
[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 _VLM_DIALOG_H_
26 #define _VLM_DIALOG_H_
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 <QDateTime>
39
40 enum{
41     QVLM_Broadcast,
42     QVLM_Schedule,
43     QVLM_VOD
44 };
45
46 enum{
47     ControlBroadcastPlay,
48     ControlBroadcastPause,
49     ControlBroadcastStop,
50     ControlBroadcastSeek
51 };
52
53 class QComboBox;
54 class QVBoxLayout;
55 class QStackedWidget;
56 class QLabel;
57 class QGridLayout;
58 class QLineEdit;
59 class QCheckBox;
60 class QToolButton;
61 class QGroupBox;
62 class QPushButton;
63 class QHBoxLayout;
64 class QDateTimeEdit;
65 class QSpinBox;
66 class VLMAWidget;
67 class VLMWrapper;
68
69
70 class VLMDialog : public QVLCDialog
71 {
72     Q_OBJECT;
73 public:
74     static VLMDialog * getInstance( intf_thread_t *p_intf )
75     {
76         if( !instance)
77              instance = new VLMDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
78         return instance;
79     };
80     virtual ~VLMDialog();
81
82     VLMWrapper *vlmWrapper;
83     vlm_t *p_vlm;
84 private:
85     VLMDialog( QWidget *, intf_thread_t * );
86     static VLMDialog *instance;
87     Ui::Vlm ui;
88
89     QList<VLMAWidget *> vlmItems;
90     int currentIndex;
91
92     QVBoxLayout *vlmItemLayout;
93     QWidget *vlmItemWidget;
94
95     QComboBox *mediatype;
96     QDateTimeEdit *time, *date, *repeatTime;
97     QSpinBox *scherepeatnumber, *repeatDays;
98     bool isNameGenuine( QString );
99     void mediasPopulator();
100 public slots:
101     void removeVLMItem( VLMAWidget * );
102     void startModifyVLMItem( VLMAWidget * );
103 private slots:
104     void addVLMItem();
105     void clearWidgets();
106     void saveModifications();
107     void showScheduleWidget( int );
108     void selectVLMItem( int );
109     void selectInput();
110     void selectOutput();
111     bool exportVLMConf();
112     bool importVLMConf();
113 };
114
115 class VLMWrapper
116 {
117 public:
118     VLMWrapper( vlm_t * );
119     virtual ~VLMWrapper();
120
121     static void AddBroadcast( const QString, const QString, const QString,
122                        bool b_enabled = true,
123                        bool b_loop = false );
124     static void EditBroadcast( const QString, const QString, const QString,
125                        bool b_enabled = true,
126                        bool b_loop = false );
127     static void EditSchedule( const QString, const QString, const QString,
128                        QDateTime _schetime, QDateTime _schedate,
129                        int _scherepeatnumber, int _repeatDays,
130                        bool b_enabled = true, QString mux = "" );
131     static void AddVod( const QString, const QString, const QString,
132                        bool b_enabled = true, QString mux = "" );
133     static void EditVod( const QString, const QString, const QString,
134                        bool b_enabled = true, QString mux = "" );
135     static void AddSchedule( const QString, const QString, const QString,
136                        QDateTime _schetime, QDateTime _schedate,
137                        int _scherepeatnumber, int _repeatDays,
138                        bool b_enabled = true, QString mux = "" );
139
140     static void ControlBroadcast( const QString, int, unsigned int seek = 0 );
141     static void EnableItem( const QString, bool );
142
143     /* We don't have yet the accessors in the core, so the following is commented */
144     //unsigned int NbMedia() { if( p_vlm ) return p_vlm->i_media; return 0; }
145    /* vlm_media_t *GetMedia( int i )
146     { if( p_vlm ) return p_vlm->media[i]; return NULL; }*/
147
148 private:
149     static vlm_t *p_vlm;
150 };
151
152 class VLMAWidget : public QGroupBox
153 {
154     Q_OBJECT
155     friend class VLMDialog;
156 public:
157     VLMAWidget( QString name, QString input, QString output,
158             bool _enable, VLMDialog *parent, int _type = QVLM_Broadcast );
159     virtual void update() = 0;
160 protected:
161     QLabel *nameLabel;
162     QString name;
163     QString input;
164     QString output;
165     bool b_enabled;
166     int type;
167     VLMDialog *parent;
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