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