]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Qt: code cosmetics
[vlc] / modules / gui / qt4 / main_interface.hpp
1 /*****************************************************************************
2  * main_interface.hpp : Main Interface
3  ****************************************************************************
4  * Copyright (C) 2006-2008 the VideoLAN team
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 #include "components/preferences_widgets.hpp" /* First Start */
32 #ifdef WIN32
33  #include <vlc_windows_interfaces.h>
34 #endif
35
36 #include <QSystemTrayIcon>
37
38 class QSettings;
39 class QCloseEvent;
40 class QKeyEvent;
41 class QLabel;
42 class QEvent;
43 class InputManager;
44 class VideoWidget;
45 class BackgroundWidget;
46 class PlaylistWidget;
47 class VisualSelector;
48 class AdvControlsWidget;
49 class ControlsWidget;
50 class InputControlsWidget;
51 class FullscreenControllerWidget;
52 class SpeedControlWidget;
53 class QVBoxLayout;
54 class QMenu;
55 class QSize;
56 class QStackedWidget;
57
58 enum {
59     CONTROLS_VISIBLE  = 0x1,
60     CONTROLS_HIDDEN   = 0x2,
61     CONTROLS_ADVANCED = 0x4,
62 };
63
64
65 typedef enum pl_dock_e {
66     PL_UNDOCKED,
67     PL_BOTTOM,
68     PL_RIGHT,
69     PL_LEFT
70 } pl_dock_e;
71
72 class MainInterface : public QVLCMW
73 {
74     Q_OBJECT;
75
76     friend class PlaylistWidget;
77
78 public:
79     MainInterface( intf_thread_t *);
80     virtual ~MainInterface();
81
82     /* Video requests from core */
83     WId getVideo( int *pi_x, int *pi_y,
84                   unsigned int *pi_width, unsigned int *pi_height );
85     void releaseVideo( void  );
86     int controlVideo( int i_query, va_list args );
87
88     /* Getters */
89 #ifndef HAVE_MAEMO
90     QSystemTrayIcon *getSysTray() { return sysTray; }
91     QMenu *getSysTrayMenu() { return systrayMenu; }
92 #endif
93     int getControlsVisibilityStatus();
94
95     /* Sizehint() */
96     virtual QSize sizeHint() const;
97
98 protected:
99     void dropEventPlay( QDropEvent *, bool);
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 customEvent( QEvent *);
106     virtual void keyPressEvent( QKeyEvent *);
107     virtual void wheelEvent( QWheelEvent * );
108     virtual void resizeEvent( QResizeEvent * event );
109
110 private:
111     void createMainWidget( QSettings* );
112     void createStatusBar();
113
114     void askForPrivacy();
115     int  privacyDialog( QList<ConfigControl *> *controls );
116
117     /* Systray */
118     void handleSystray();
119     void createSystray();
120     void initSystray();
121     bool isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
122
123     void showTab( int i_tab );
124     void showVideo() { showTab( VIDEO_TAB ); }
125     void showBg() { showTab( BACKG_TAB ); }
126
127     QSettings           *settings;
128 #ifndef HAVE_MAEMO
129     QSystemTrayIcon     *sysTray;
130     QMenu               *systrayMenu;
131 #endif
132     QString              input_name;
133     QVBoxLayout         *mainLayout;
134     ControlsWidget      *controls;
135     InputControlsWidget *inputC;
136     FullscreenControllerWidget *fullscreenControls;
137     QStackedWidget      *stackCentralW;
138     /* Video */
139     VideoWidget         *videoWidget;
140
141     BackgroundWidget    *bgWidget;
142     VisualSelector      *visualSelector;
143     PlaylistWidget      *playlistWidget;
144
145     /* Status Bar */
146     QLabel              *nameLabel;
147     QLabel              *cryptedLabel;
148
149     /* Status and flags */
150     enum {
151         HIDDEN_TAB = -1,
152         BACKG_TAB  =  0,
153         VIDEO_TAB,
154         PLAYL_TAB,
155     };
156     int                  stackCentralOldState;
157
158 //    bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
159     bool                 videoEmbeddedFlag;   ///< Want an external Video Window
160     bool                 playlistVisible;     ///< Is the playlist visible ?
161     bool                 visualSelectorEnabled;
162     bool                 notificationEnabled; /// Systray Notifications
163
164     bool                 b_keep_size;         ///< persistent resizeable window
165     QSize                mainBasedSize;       ///< based Wnd (normal mode only)
166     QSize                mainVideoSize;       ///< Wnd with video (all modes)
167     int                  i_visualmode;        ///< Visual Mode
168     pl_dock_e            i_pl_dock;
169     int                  i_bg_height;         ///< Save height of bgWidget
170     bool                 b_hideAfterCreation;
171
172 #ifdef WIN32
173     HIMAGELIST himl;
174     LPTASKBARLIST3 p_taskbl;
175     void createTaskBarButtons();
176 #endif
177
178 public slots:
179     void undockPlaylist();
180     void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
181     void toggleMinimalView( bool );
182     void togglePlaylist();
183 #ifndef HAVE_MAEMO
184     void toggleUpdateSystrayMenu();
185 #endif
186     void toggleAdvanced();
187     void toggleFullScreen();
188     void toggleFSC();
189     void popupMenu( const QPoint& );
190     void changeThumbbarButtons( int );
191
192     /* Manage the Video Functions from the vout threads */
193     void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
194                        unsigned *pi_width, unsigned *pi_height );
195     void releaseVideoSlot( void );
196
197 private slots:
198     void debug();
199     void destroyPopupMenu();
200     void recreateToolbars();
201     void doComponentsUpdate();
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 signals:
217     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
218                       unsigned *pi_width, unsigned *pi_height );
219     void askReleaseVideo( );
220     void askVideoToResize( unsigned int, unsigned int );
221     void askVideoSetFullScreen( bool );
222     void askUpdate();
223     void minimalViewToggled( bool );
224     void fullscreenInterfaceToggled( bool );
225 };
226
227 #endif