]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Win32: fix Win7's taskbar buttons
[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 #ifdef WIN32
101     bool winEvent( MSG *, long * );
102 #endif
103     virtual void dropEvent( QDropEvent *);
104     virtual void dragEnterEvent( QDragEnterEvent * );
105     virtual void dragMoveEvent( QDragMoveEvent * );
106     virtual void dragLeaveEvent( QDragLeaveEvent * );
107     virtual void closeEvent( QCloseEvent *);
108     virtual void customEvent( QEvent *);
109     virtual void keyPressEvent( QKeyEvent *);
110     virtual void wheelEvent( QWheelEvent * );
111     virtual void resizeEvent( QResizeEvent * event );
112
113 private:
114     void createMainWidget( QSettings* );
115     void createStatusBar();
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 restoreStackOldWidget();
125     void showVideo() { showTab( VIDEO_TAB ); }
126     void showBg() { showTab( BACKG_TAB ); }
127     void hideStackWidget() { showTab( HIDDEN_TAB ); }
128
129     QSettings           *settings;
130 #ifndef HAVE_MAEMO
131     QSystemTrayIcon     *sysTray;
132     QMenu               *systrayMenu;
133 #endif
134     QString              input_name;
135     QVBoxLayout         *mainLayout;
136     ControlsWidget      *controls;
137     InputControlsWidget *inputC;
138     FullscreenControllerWidget *fullscreenControls;
139     QStackedWidget      *stackCentralW;
140     /* Video */
141     VideoWidget         *videoWidget;
142
143     BackgroundWidget    *bgWidget;
144     VisualSelector      *visualSelector;
145     PlaylistWidget      *playlistWidget;
146
147     /* Status Bar */
148     QLabel              *nameLabel;
149     QLabel              *cryptedLabel;
150
151     /* Status and flags */
152     enum {
153         HIDDEN_TAB = -1,
154         BACKG_TAB  =  0,
155         VIDEO_TAB  = 1,
156         PLAYL_TAB  = 2,
157     };
158     int                  stackCentralOldState;
159
160 //    bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
161     bool                 videoEmbeddedFlag;   ///< Want an external Video Window
162     bool                 playlistVisible;     ///< Is the playlist visible ?
163     bool                 visualSelectorEnabled;
164     bool                 notificationEnabled; /// Systray Notifications
165
166     bool                 b_keep_size;         ///< persistent resizeable window
167     QSize                mainBasedSize;       ///< based Wnd (normal mode only)
168     QSize                mainVideoSize;       ///< Wnd with video (all modes)
169     int                  i_visualmode;        ///< Visual Mode
170     pl_dock_e            i_pl_dock;
171     int                  i_bg_height;         ///< Save height of bgWidget
172     bool                 b_hideAfterCreation;
173
174 #ifdef WIN32
175     HIMAGELIST himl;
176     LPTASKBARLIST3 p_taskbl;
177     UINT taskbar_wmsg;
178     void createTaskBarButtons();
179 #endif
180     void createPlaylist( bool );
181
182 public slots:
183     void undockPlaylist();
184     void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
185     void toggleMinimalView( bool );
186     void togglePlaylist();
187 #ifndef HAVE_MAEMO
188     void toggleUpdateSystrayMenu();
189 #endif
190     void toggleAdvanced();
191     void toggleFullScreen();
192     void toggleFSC();
193     void popupMenu( const QPoint& );
194     void changeThumbbarButtons( int );
195
196     /* Manage the Video Functions from the vout threads */
197     void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
198                        unsigned *pi_width, unsigned *pi_height );
199     void releaseVideoSlot( void );
200
201 private slots:
202     void debug();
203     void destroyPopupMenu();
204     void recreateToolbars();
205     void doComponentsUpdate();
206     void setName( const QString& );
207     void setVLCWindowsTitle( const QString& title = "" );
208 #if 0
209     void visual();
210 #endif
211 #ifndef HAVE_MAEMO
212     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
213     void updateSystrayTooltipName( const QString& );
214     void updateSystrayTooltipStatus( int );
215 #endif
216     void showCryptedLabel( bool );
217
218     void handleKeyPress( QKeyEvent * );
219
220 signals:
221     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
222                       unsigned *pi_width, unsigned *pi_height );
223     void askReleaseVideo( );
224     void askVideoToResize( unsigned int, unsigned int );
225     void askVideoSetFullScreen( bool );
226     void askUpdate();
227     void minimalViewToggled( bool );
228     void fullscreenInterfaceToggled( bool );
229     void playPauseSignal();
230     void prevSignal();
231     void nextSignal();
232 };
233
234 #endif