]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Qt: fix a signal in the media_info dialog
[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 #ifndef HAVE_MAEMO
84     QSystemTrayIcon *getSysTray() { return sysTray; }
85     QMenu *getSysTrayMenu() { return systrayMenu; }
86 #endif
87     int getControlsVisibilityStatus();
88     bool isPlDocked() { return ( b_plDocked != false ); }
89     bool isInterfaceFullScreen() { return b_interfaceFullScreen; }
90
91 protected:
92     void dropEventPlay( QDropEvent *, 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 #ifndef HAVE_MAEMO
129     QSystemTrayIcon     *sysTray;
130     QMenu               *systrayMenu;
131 #endif
132
133     QString              input_name;
134     QVBoxLayout         *mainLayout;
135     ControlsWidget      *controls;
136     InputControlsWidget *inputC;
137     FullscreenControllerWidget *fullscreenControls;
138
139     /* Widgets */
140     QStackedWidget      *stackCentralW;
141
142     VideoWidget         *videoWidget;
143     BackgroundWidget    *bgWidget;
144     PlaylistWidget      *playlistWidget;
145     //VisualSelector      *visualSelector;
146
147     /* Status Bar */
148     QLabel              *nameLabel;
149     QLabel              *cryptedLabel;
150
151     /* Status and flags */
152     QWidget             *stackCentralOldWidget;
153
154     QMap<QWidget *, QSize> stackWidgetsSizes;
155
156     /* Flags */
157     bool                 b_notificationEnabled; /// Systray Notifications
158     bool                 b_autoresize;          ///< persistent resizable window
159     bool                 b_videoEmbedded;       ///< Want an external Video Window
160     bool                 b_videoFullScreen;     ///< --fullscreen
161     bool                 b_videoOnTop;          ///< --video-on-top
162     bool                 b_hideAfterCreation;
163     bool                 b_minimalView;         ///< Minimal video
164     bool                 b_interfaceFullScreen;
165
166     /* States */
167     bool                 playlistVisible;       ///< Is the playlist visible ?
168 //    bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
169 //    bool                 b_visualSelectorEnabled;
170     bool                 b_plDocked;            ///< Is the playlist docked ?
171
172     bool                 b_hasPausedWhenMinimized;
173     bool                 b_statusbarVisible;
174
175 #ifdef WIN32
176     HIMAGELIST himl;
177     LPTASKBARLIST3 p_taskbl;
178     UINT taskbar_wmsg;
179     void createTaskBarButtons();
180 #endif
181
182 public slots:
183     void dockPlaylist( bool b_docked = true );
184     void toggleMinimalView( bool );
185     void togglePlaylist();
186 #ifndef HAVE_MAEMO
187     void toggleUpdateSystrayMenu();
188     void showUpdateSystrayMenu();
189     void hideUpdateSystrayMenu();
190 #endif
191     void toggleAdvancedButtons();
192     void toggleInterfaceFullScreen();
193     void toggleFSC();
194
195     void setStatusBarVisibility(bool b_visible);
196
197     void popupMenu( const QPoint& );
198     void changeThumbbarButtons( int );
199
200     /* Manage the Video Functions from the vout threads */
201     void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
202                        unsigned *pi_width, unsigned *pi_height );
203     void releaseVideoSlot( void );
204
205 private slots:
206     void debug();
207     void destroyPopupMenu();
208     void recreateToolbars();
209     void setName( const QString& );
210     void setVLCWindowsTitle( const QString& title = "" );
211 #if 0
212     void visual();
213 #endif
214 #ifndef HAVE_MAEMO
215     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
216     void updateSystrayTooltipName( const QString& );
217     void updateSystrayTooltipStatus( int );
218 #endif
219     void showCryptedLabel( bool );
220
221     void handleKeyPress( QKeyEvent * );
222
223     void showBuffering( float );
224
225     void resizeStack( int w, int h )
226     {
227         if( !isFullScreen() && !isMaximized() )
228         {
229             if( b_minimalView )
230                 resize( w, h ); /* Oh yes, it shouldn't
231                                    be possible that size() - stackCentralW->size() < 0
232                                    since stackCentralW is contained in the QMW... */
233             else
234                 resize( size() - stackCentralW->size() + QSize( w, h ) );
235         }
236         debug();
237     }
238
239     void setVideoSize( unsigned int, unsigned int );
240     void setVideoFullScreen( bool );
241     void setVideoOnTop( bool );
242
243 signals:
244     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
245                       unsigned *pi_width, unsigned *pi_height );
246     void askReleaseVideo( );
247     void askVideoToResize( unsigned int, unsigned int );
248     void askVideoSetFullScreen( bool );
249     void askVideoOnTop( bool );
250     void minimalViewToggled( bool );
251     void fullscreenInterfaceToggled( bool );
252     void askToQuit();
253
254 };
255
256 #endif