]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Qt: PostProc getter helper
[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     void createContinueDialog( QWidget *w );
115
116     /* Systray */
117     void createSystray();
118     void initSystray();
119     void handleSystray();
120
121     /* Central StackWidget Management */
122     void showTab( QWidget *);
123     void showVideo();
124     void restoreStackOldWidget();
125
126     /* */
127     void setMinimalView( bool );
128     void setInterfaceFullScreen( bool );
129     void computeMinimumSize();
130
131     /* */
132     QSettings           *settings;
133     QSystemTrayIcon     *sysTray;
134     QMenu               *systrayMenu;
135
136     QString              input_name;
137     QVBoxLayout         *mainLayout;
138     ControlsWidget      *controls;
139     InputControlsWidget *inputC;
140     FullscreenControllerWidget *fullscreenControls;
141
142     /* Widgets */
143     QStackedWidget      *stackCentralW;
144
145     VideoWidget         *videoWidget;
146     BackgroundWidget    *bgWidget;
147     PlaylistWidget      *playlistWidget;
148     //VisualSelector      *visualSelector;
149
150     /* continue */
151     QWidget             *continueDialog;
152     int64_t             i_continueTime;
153
154     /* Status Bar */
155     QLabel              *nameLabel;
156     QLabel              *cryptedLabel;
157
158     /* Status and flags */
159     QWidget             *stackCentralOldWidget;
160
161     QMap<QWidget *, QSize> stackWidgetsSizes;
162
163     /* Flags */
164     unsigned             i_notificationSetting; /// Systray Notifications
165     bool                 b_autoresize;          ///< persistent resizable window
166     bool                 b_videoEmbedded;       ///< Want an external Video Window
167     bool                 b_videoFullScreen;     ///< --fullscreen
168     bool                 b_hideAfterCreation;
169     bool                 b_minimalView;         ///< Minimal video
170     bool                 b_interfaceFullScreen;
171     bool                 b_pauseOnMinimize;
172
173     /* States */
174     bool                 playlistVisible;       ///< Is the playlist visible ?
175 //    bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
176 //    bool                 b_visualSelectorEnabled;
177     bool                 b_plDocked;            ///< Is the playlist docked ?
178
179     bool                 b_hasPausedWhenMinimized;
180     bool                 b_statusbarVisible;
181
182 #ifdef _WIN32
183     HWND WinId( QWidget *);
184     HIMAGELIST himl;
185     ITaskbarList3 *p_taskbl;
186     UINT taskbar_wmsg;
187     void createTaskBarButtons();
188 #endif
189
190     static const Qt::Key kc[10]; /* easter eggs */
191     int i_kc_offset;
192
193 public slots:
194     void dockPlaylist( bool b_docked = true );
195     void toggleMinimalView( bool );
196     void togglePlaylist();
197     void toggleUpdateSystrayMenu();
198     void showUpdateSystrayMenu();
199     void hideUpdateSystrayMenu();
200     void toggleAdvancedButtons();
201     void toggleInterfaceFullScreen();
202     void toggleFSC();
203
204     void setStatusBarVisibility(bool b_visible);
205     void setPlaylistVisibility(bool b_visible);
206
207 #ifdef _WIN32
208     void changeThumbbarButtons( int );
209 #endif
210
211     /* Manage the Video Functions from the vout threads */
212     void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
213                        unsigned *pi_width, unsigned *pi_height );
214     void releaseVideoSlot( void );
215
216     void emitBoss();
217     void emitRaise();
218
219     void reloadPrefs();
220     void toolBarConfUpdated();
221
222 private slots:
223     void debug();
224     void recreateToolbars();
225     void setName( const QString& );
226     void setVLCWindowsTitle( const QString& title = "" );
227 #if 0
228     void visual();
229 #endif
230     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
231     void updateSystrayTooltipName( const QString& );
232     void updateSystrayTooltipStatus( int );
233     void showCryptedLabel( bool );
234
235     void handleKeyPress( QKeyEvent * );
236
237     void showBuffering( float );
238
239     void resizeStack( int w, int h )
240     {
241         if( !isFullScreen() && !isMaximized() )
242         {
243             if( b_minimalView )
244                 resize( w, h ); /* Oh yes, it shouldn't
245                                    be possible that size() - stackCentralW->size() < 0
246                                    since stackCentralW is contained in the QMW... */
247             else
248                 resize( size() - stackCentralW->size() + QSize( w, h ) );
249         }
250         debug();
251     }
252
253     void setVideoSize( unsigned int, unsigned int );
254     void videoSizeChanged( int, int );
255     void setVideoFullScreen( bool );
256     void setVideoOnTop( bool );
257     void setBoss();
258     void setRaise();
259
260     void showContinueDialog( int64_t);
261     void continuePlayback();
262
263 signals:
264     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
265                       unsigned *pi_width, unsigned *pi_height );
266     void askReleaseVideo( );
267     void askVideoToResize( unsigned int, unsigned int );
268     void askVideoSetFullScreen( bool );
269     void askVideoOnTop( bool );
270     void minimalViewToggled( bool );
271     void fullscreenInterfaceToggled( bool );
272     void askToQuit();
273     void askBoss();
274     void askRaise();
275     void kc_pressed(); /* easter eggs */
276 };
277
278 #endif