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