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