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