]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
c3df6fe0bebec5ca063c5b905af501654b1168cb
[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 QMenu;
54 class QSize;
55
56 enum {
57     CONTROLS_VISIBLE  = 0x1,
58     CONTROLS_HIDDEN   = 0x2,
59     CONTROLS_ADVANCED = 0x4,
60 };
61
62 typedef enum pl_dock_e {
63     PL_UNDOCKED,
64     PL_BOTTOM,
65     PL_RIGHT,
66     PL_LEFT
67 } pl_dock_e;
68
69 class MainInterface : public QVLCMW
70 {
71     Q_OBJECT;
72
73     friend class PlaylistWidget;
74
75 public:
76     MainInterface( intf_thread_t *);
77     virtual ~MainInterface();
78
79     /* Video requests from core */
80     WId getVideo( int *pi_x, int *pi_y,
81                   unsigned int *pi_width, unsigned int *pi_height );
82     void releaseVideo( void  );
83     int controlVideo( int i_query, va_list args );
84
85     /* Getters */
86 #ifndef HAVE_MAEMO
87     QSystemTrayIcon *getSysTray() { return sysTray; }
88     QMenu *getSysTrayMenu() { return systrayMenu; }
89 #endif
90     int getControlsVisibilityStatus();
91
92     /* Sizehint() */
93     virtual QSize sizeHint() const;
94
95 protected:
96     void dropEventPlay( QDropEvent *, bool);
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 customEvent( QEvent *);
103     virtual void keyPressEvent( QKeyEvent *);
104     virtual void wheelEvent( QWheelEvent * );
105     virtual void resizeEvent( QResizeEvent * event );
106
107 private:
108     void createMainWidget( QSettings* );
109     void createStatusBar();
110
111     void askForPrivacy();
112     int  privacyDialog( QList<ConfigControl *> *controls );
113
114     /* Systray */
115     void handleSystray();
116     void createSystray();
117     void initSystray();
118     bool isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
119
120     QSettings           *settings;
121 #ifndef HAVE_MAEMO
122     QSystemTrayIcon     *sysTray;
123     QMenu               *systrayMenu;
124 #endif
125     QString              input_name;
126     QGridLayout         *mainLayout;
127     ControlsWidget      *controls;
128     InputControlsWidget *inputC;
129     FullscreenControllerWidget *fullscreenControls;
130
131     /* Video */
132     VideoWidget         *videoWidget;
133
134     BackgroundWidget    *bgWidget;
135     VisualSelector      *visualSelector;
136     PlaylistWidget      *playlistWidget;
137
138     /* Status Bar */
139     QLabel              *nameLabel;
140     QLabel              *cryptedLabel;
141
142     /* Status and flags */
143     bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
144     bool                 videoEmbeddedFlag;   ///< Want an external Video Window
145     bool                 playlistVisible;     ///< Is the playlist visible ?
146     bool                 visualSelectorEnabled;
147     bool                 notificationEnabled; /// Systray Notifications
148     bool                 bgWasVisible;
149     bool                 b_keep_size;         ///< persistent resizeable window
150     QSize                mainBasedSize;       ///< based Wnd (normal mode only)
151     QSize                mainVideoSize;       ///< Wnd with video (all modes)
152     int                  i_visualmode;        ///< Visual Mode
153     pl_dock_e            i_pl_dock;
154     int                  i_bg_height;         ///< Save height of bgWidget
155     bool                 b_shouldHide;
156
157 #ifdef WIN32
158     HIMAGELIST himl;
159     LPTASKBARLIST3 p_taskbl;
160     void createTaskBarButtons();
161 #endif
162
163 public slots:
164     void undockPlaylist();
165     void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
166     void toggleMinimalView( bool );
167     void togglePlaylist();
168 #ifndef HAVE_MAEMO
169     void toggleUpdateSystrayMenu();
170 #endif
171     void toggleAdvanced();
172     void toggleFullScreen();
173     void toggleFSC();
174     void popupMenu( const QPoint& );
175     void changeThumbbarButtons( int );
176
177     /* Manage the Video Functions from the vout threads */
178     void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
179                        unsigned *pi_width, unsigned *pi_height );
180     void releaseVideoSlot( void );
181
182 private slots:
183     void debug();
184     void destroyPopupMenu();
185     void recreateToolbars();
186     void doComponentsUpdate();
187     void setName( const QString& );
188     void setVLCWindowsTitle( const QString& title = "" );
189 #if 0
190     void visual();
191 #endif
192 #ifndef HAVE_MAEMO
193     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
194     void updateSystrayTooltipName( const QString& );
195     void updateSystrayTooltipStatus( int );
196 #endif
197     void showCryptedLabel( bool );
198
199     void handleKeyPress( QKeyEvent * );
200
201 signals:
202     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
203                       unsigned *pi_width, unsigned *pi_height );
204     void askReleaseVideo( );
205     void askVideoToResize( unsigned int, unsigned int );
206     void askVideoSetFullScreen( bool );
207     void askUpdate();
208     void minimalViewToggled( bool );
209     void fullscreenInterfaceToggled( bool );
210 };
211
212 #endif