]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Qt: put Win32 Main Interface function in its own file.
[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
33 #ifdef WIN32
34  #include <vlc_windows_interfaces.h>
35 #endif
36
37 #include <QSystemTrayIcon>
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 class QStackedWidget;
58
59 enum {
60     CONTROLS_VISIBLE  = 0x1,
61     CONTROLS_HIDDEN   = 0x2,
62     CONTROLS_ADVANCED = 0x4,
63 };
64
65
66 class MainInterface : public QVLCMW
67 {
68     Q_OBJECT;
69
70     friend class PlaylistWidget;
71
72 public:
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
90     /* Sizehint() */
91 //    virtual QSize sizeHint() const;
92
93 protected:
94     void dropEventPlay( QDropEvent *, bool);
95 #ifdef WIN32
96     virtual bool winEvent( MSG *, long * );
97 #endif
98     virtual void dropEvent( QDropEvent *);
99     virtual void dragEnterEvent( QDragEnterEvent * );
100     virtual void dragMoveEvent( QDragMoveEvent * );
101     virtual void dragLeaveEvent( QDragLeaveEvent * );
102     virtual void closeEvent( QCloseEvent *);
103     virtual void customEvent( QEvent *);
104     virtual void keyPressEvent( QKeyEvent *);
105     virtual void wheelEvent( QWheelEvent * );
106     virtual void resizeEvent( QResizeEvent * event );
107
108 private:
109     /* Main Widgets Creation */
110     void createMainWidget( QSettings* );
111     void createStatusBar();
112     void createPlaylist();
113
114     /* Systray */
115     void createSystray();
116     void handleSystray();
117     void initSystray();
118
119     /* Mess about stackWidget */
120     void showTab( QWidget *);
121     void showVideo();
122     void showBg();
123     void restoreStackOldWidget();
124
125     /* */
126     QSettings           *settings;
127 #ifndef HAVE_MAEMO
128     QSystemTrayIcon     *sysTray;
129     QMenu               *systrayMenu;
130 #endif
131     QString              input_name;
132     QVBoxLayout         *mainLayout;
133     ControlsWidget      *controls;
134     InputControlsWidget *inputC;
135     FullscreenControllerWidget *fullscreenControls;
136
137     /* Widgets */
138     QStackedWidget      *stackCentralW;
139
140     VideoWidget         *videoWidget;
141     BackgroundWidget    *bgWidget;
142     PlaylistWidget      *playlistWidget;
143     //VisualSelector      *visualSelector;
144
145     /* Status Bar */
146     QLabel              *nameLabel;
147     QLabel              *cryptedLabel;
148
149     /* Status and flags */
150     QWidget             *stackCentralOldWidget;
151
152     /* Flags */
153     bool                 b_notificationEnabled; /// Systray Notifications
154     bool                 b_keep_size;         ///< persistent resizeable window
155     bool                 b_videoEmbedded;   ///< Want an external Video Window
156     bool                 b_hideAfterCreation;
157     int                  i_visualmode;        ///< Visual Mode
158
159     /* States */
160     bool                 playlistVisible;     ///< Is the playlist visible ?
161 //    bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
162 //    bool                 b_visualSelectorEnabled;
163     bool                 b_plDocked;          ///< Is the playlist docked ?
164
165     QSize                mainBasedSize;       ///< based Wnd (normal mode only)
166     QSize                mainVideoSize;       ///< Wnd with video (all modes)
167     int                  i_bg_height;         ///< Save height of bgWidget
168
169 #ifdef WIN32
170     HIMAGELIST himl;
171     LPTASKBARLIST3 p_taskbl;
172     UINT taskbar_wmsg;
173     void createTaskBarButtons();
174 #endif
175
176 public slots:
177     void dockPlaylist( bool b_docked = true );
178     void toggleMinimalView( bool );
179     void togglePlaylist();
180 #ifndef HAVE_MAEMO
181     void toggleUpdateSystrayMenu();
182 #endif
183     void toggleAdvanced();
184     void toggleFullScreen();
185     void toggleFSC();
186     void popupMenu( const QPoint& );
187     void changeThumbbarButtons( int );
188
189     /* Manage the Video Functions from the vout threads */
190     void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
191                        unsigned *pi_width, unsigned *pi_height );
192     void releaseVideoSlot( void );
193
194 private slots:
195     void debug();
196     void destroyPopupMenu();
197     void recreateToolbars();
198     void doComponentsUpdate();
199     void setName( const QString& );
200     void setVLCWindowsTitle( const QString& title = "" );
201 #if 0
202     void visual();
203 #endif
204 #ifndef HAVE_MAEMO
205     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
206     void updateSystrayTooltipName( const QString& );
207     void updateSystrayTooltipStatus( int );
208 #endif
209     void showCryptedLabel( bool );
210
211     void handleKeyPress( QKeyEvent * );
212
213     void showBuffering( float );
214
215 signals:
216     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
217                       unsigned *pi_width, unsigned *pi_height );
218     void askReleaseVideo( );
219     void askVideoToResize( unsigned int, unsigned int );
220     void askVideoSetFullScreen( bool );
221     void askUpdate();
222     void minimalViewToggled( bool );
223     void fullscreenInterfaceToggled( bool );
224
225 };
226
227 #endif