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