]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
vlc_epg: add parental rating from ts streams.
[vlc] / modules / gui / qt4 / main_interface.hpp
1 /*****************************************************************************
2  * main_interface.hpp : Main Interface
3  ****************************************************************************
4  * Copyright (C) 2006-2010 VideoLAN and AUTHORS
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
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_MAIN_INTERFACE_H_
26 #define QVLC_MAIN_INTERFACE_H_
27
28 #include "qt4.hpp"
29
30 #include "util/qvlcframe.hpp"
31
32 #ifdef WIN32
33  #include <vlc_windows_interfaces.h>
34 #endif
35
36 #include <QSystemTrayIcon>
37 #include <QStackedWidget>
38
39 class QSettings;
40 class QCloseEvent;
41 class QKeyEvent;
42 class QLabel;
43 class QEvent;
44 class InputManager;
45 class VideoWidget;
46 class BackgroundWidget;
47 class PlaylistWidget;
48 class VisualSelector;
49 class AdvControlsWidget;
50 class ControlsWidget;
51 class InputControlsWidget;
52 class FullscreenControllerWidget;
53 class SpeedControlWidget;
54 class QVBoxLayout;
55 class QMenu;
56 class QSize;
57 class StandardPLPanel;
58
59 class MainInterface : public QVLCMW
60 {
61     Q_OBJECT
62
63     friend class PlaylistWidget;
64
65 public:
66     /* tors */
67     MainInterface( intf_thread_t *);
68     virtual ~MainInterface();
69
70     static const QEvent::Type ToolbarsNeedRebuild;
71
72     /* Video requests from core */
73     WId  getVideo( int *pi_x, int *pi_y,
74                   unsigned int *pi_width, unsigned int *pi_height );
75     void releaseVideo( void );
76     int  controlVideo( int i_query, va_list args );
77
78     /* Getters */
79     QSystemTrayIcon *getSysTray() { return sysTray; }
80     QMenu *getSysTrayMenu() { return systrayMenu; }
81     FullscreenControllerWidget* getFullscreenControllerWidget() { return fullscreenControls; }
82     enum
83     {
84         CONTROLS_VISIBLE  = 0x1,
85         CONTROLS_HIDDEN   = 0x2,
86         CONTROLS_ADVANCED = 0x4,
87     };
88     int getControlsVisibilityStatus();
89     bool isPlDocked() { return ( b_plDocked != false ); }
90     bool isInterfaceFullScreen() { return b_interfaceFullScreen; }
91     StandardPLPanel* getPlaylistView();
92
93 protected:
94     void dropEventPlay( QDropEvent* event, bool b_play ) { dropEventPlay(event, b_play, true); }
95     void dropEventPlay( QDropEvent *, bool, bool );
96 #ifdef WIN32
97     virtual bool winEvent( MSG *, long * );
98 #endif
99     virtual void changeEvent( QEvent * );
100     virtual void dropEvent( QDropEvent *);
101     virtual void dragEnterEvent( QDragEnterEvent * );
102     virtual void dragMoveEvent( QDragMoveEvent * );
103     virtual void dragLeaveEvent( QDragLeaveEvent * );
104     virtual void closeEvent( QCloseEvent *);
105     virtual void keyPressEvent( QKeyEvent *);
106     virtual void wheelEvent( QWheelEvent * );
107     virtual bool eventFilter(QObject *, QEvent *);
108
109 private:
110     /* Main Widgets Creation */
111     void createMainWidget( QSettings* );
112     void createStatusBar();
113     void createPlaylist();
114
115     /* Systray */
116     void createSystray();
117     void initSystray();
118     void handleSystray();
119
120     /* Central StackWidget Management */
121     void showTab( QWidget *);
122     void showVideo();
123     void restoreStackOldWidget();
124
125     /* */
126     void setMinimalView( bool );
127     void setInterfaceFullScreen( bool );
128     void computeMinimumSize();
129
130     /* */
131     QSettings           *settings;
132     QSystemTrayIcon     *sysTray;
133     QMenu               *systrayMenu;
134
135     QString              input_name;
136     QVBoxLayout         *mainLayout;
137     ControlsWidget      *controls;
138     InputControlsWidget *inputC;
139     FullscreenControllerWidget *fullscreenControls;
140
141     /* Widgets */
142     QStackedWidget      *stackCentralW;
143
144     VideoWidget         *videoWidget;
145     BackgroundWidget    *bgWidget;
146     PlaylistWidget      *playlistWidget;
147     //VisualSelector      *visualSelector;
148
149     /* Status Bar */
150     QLabel              *nameLabel;
151     QLabel              *cryptedLabel;
152
153     /* Status and flags */
154     QWidget             *stackCentralOldWidget;
155
156     QMap<QWidget *, QSize> stackWidgetsSizes;
157
158     /* Flags */
159     unsigned             i_notificationSetting; /// Systray Notifications
160     bool                 b_autoresize;          ///< persistent resizable window
161     bool                 b_videoEmbedded;       ///< Want an external Video Window
162     bool                 b_videoFullScreen;     ///< --fullscreen
163     bool                 b_hideAfterCreation;
164     bool                 b_minimalView;         ///< Minimal video
165     bool                 b_interfaceFullScreen;
166     bool                 b_pauseOnMinimize;
167
168     /* States */
169     bool                 playlistVisible;       ///< Is the playlist visible ?
170 //    bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
171 //    bool                 b_visualSelectorEnabled;
172     bool                 b_plDocked;            ///< Is the playlist docked ?
173
174     bool                 b_hasPausedWhenMinimized;
175     bool                 b_statusbarVisible;
176
177 #ifdef WIN32
178     HIMAGELIST himl;
179     ITaskbarList3 *p_taskbl;
180     UINT taskbar_wmsg;
181     void createTaskBarButtons();
182 #endif
183
184     static const Qt::Key kc[10]; /* easter eggs */
185     int i_kc_offset;
186
187 public slots:
188     void dockPlaylist( bool b_docked = true );
189     void toggleMinimalView( bool );
190     void togglePlaylist();
191     void toggleUpdateSystrayMenu();
192     void showUpdateSystrayMenu();
193     void hideUpdateSystrayMenu();
194     void toggleAdvancedButtons();
195     void toggleInterfaceFullScreen();
196     void toggleFSC();
197
198     void setStatusBarVisibility(bool b_visible);
199     void setPlaylistVisibility(bool b_visible);
200
201     void popupMenu( const QPoint& );
202 #ifdef WIN32
203     void changeThumbbarButtons( int );
204 #endif
205
206     /* Manage the Video Functions from the vout threads */
207     void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
208                        unsigned *pi_width, unsigned *pi_height );
209     void releaseVideoSlot( void );
210
211     void emitBoss();
212     void emitRaise();
213
214     void reloadPrefs();
215     void toolBarConfUpdated();
216
217 private slots:
218     void debug();
219     void destroyPopupMenu();
220     void recreateToolbars();
221     void setName( const QString& );
222     void setVLCWindowsTitle( const QString& title = "" );
223 #if 0
224     void visual();
225 #endif
226     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
227     void updateSystrayTooltipName( const QString& );
228     void updateSystrayTooltipStatus( int );
229     void showCryptedLabel( bool );
230
231     void handleKeyPress( QKeyEvent * );
232
233     void showBuffering( float );
234
235     void resizeStack( int w, int h )
236     {
237         if( !isFullScreen() && !isMaximized() )
238         {
239             if( b_minimalView )
240                 resize( w, h ); /* Oh yes, it shouldn't
241                                    be possible that size() - stackCentralW->size() < 0
242                                    since stackCentralW is contained in the QMW... */
243             else
244                 resize( size() - stackCentralW->size() + QSize( w, h ) );
245         }
246         debug();
247     }
248
249     void setVideoSize( unsigned int, unsigned int );
250     void videoSizeChanged( int, int );
251     void setVideoFullScreen( bool );
252     void setVideoOnTop( bool );
253     void setBoss();
254     void setRaise();
255
256 signals:
257     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
258                       unsigned *pi_width, unsigned *pi_height );
259     void askReleaseVideo( );
260     void askVideoToResize( unsigned int, unsigned int );
261     void askVideoSetFullScreen( bool );
262     void askVideoOnTop( bool );
263     void minimalViewToggled( bool );
264     void fullscreenInterfaceToggled( bool );
265     void askToQuit();
266     void askBoss();
267     void askRaise();
268     void kc_pressed(); /* easter eggs */
269 };
270
271 #endif