]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Merge branch 1.0-bugfix
[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 #include <QSystemTrayIcon>
34
35 class QSettings;
36 class QCloseEvent;
37 class QKeyEvent;
38 class QLabel;
39 class QEvent;
40 class InputManager;
41 class VideoWidget;
42 class BackgroundWidget;
43 class PlaylistWidget;
44 class VisualSelector;
45 class AdvControlsWidget;
46 class ControlsWidget;
47 class InputControlsWidget;
48 class FullscreenControllerWidget;
49 class SpeedControlWidget;
50 class QMenu;
51 class QSize;
52 class DialogHandler;
53
54 enum {
55     CONTROLS_VISIBLE = 0x1,
56     CONTROLS_HIDDEN = 0x2,
57     CONTROLS_ADVANCED = 0x4,
58 };
59
60 typedef enum pl_dock_e {
61     PL_UNDOCKED,
62     PL_BOTTOM,
63     PL_RIGHT,
64     PL_LEFT
65 } pl_dock_e;
66
67 class MainInterface : public QVLCMW
68 {
69     Q_OBJECT;
70
71     friend class PlaylistWidget;
72
73 public:
74     MainInterface( intf_thread_t *);
75     virtual ~MainInterface();
76
77     /* Video requests from core */
78     WId requestVideo( vout_thread_t *p_nvout, int *pi_x,
79                       int *pi_y, unsigned int *pi_width,
80                       unsigned int *pi_height );
81     void releaseVideo( void  );
82     int controlVideo( int i_query, va_list args );
83
84     /* Getters */
85     QSystemTrayIcon *getSysTray() { return sysTray; };
86     QMenu *getSysTrayMenu() { return systrayMenu; };
87     int getControlsVisibilityStatus();
88
89     /* Sizehint() */
90     virtual QSize sizeHint() const;
91
92 protected:
93     void dropEventPlay( QDropEvent *, bool);
94     virtual void dropEvent( QDropEvent *);
95     virtual void dragEnterEvent( QDragEnterEvent * );
96     virtual void dragMoveEvent( QDragMoveEvent * );
97     virtual void dragLeaveEvent( QDragLeaveEvent * );
98     virtual void closeEvent( QCloseEvent *);
99     virtual void customEvent( QEvent *);
100     virtual void keyPressEvent( QKeyEvent *);
101     virtual void wheelEvent( QWheelEvent * );
102     virtual void resizeEvent( QResizeEvent * event );
103
104 private:
105     QSettings           *settings;
106     QSystemTrayIcon     *sysTray;
107     QMenu               *systrayMenu;
108     QString              input_name;
109     QVBoxLayout         *mainLayout;
110     ControlsWidget      *controls;
111     InputControlsWidget *inputC;
112     FullscreenControllerWidget *fullscreenControls;
113     DialogHandler       *dialogHandler;
114
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
126
127     /* Video */
128     VideoWidget         *videoWidget;
129
130     BackgroundWidget    *bgWidget;
131     VisualSelector      *visualSelector;
132     PlaylistWidget      *playlistWidget;
133
134     bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
135     bool                 videoEmbeddedFlag;   ///< Want an external Video Window
136     bool                 playlistVisible;     ///< Is the playlist visible ?
137     bool                 visualSelectorEnabled;
138     bool                 notificationEnabled; /// Systray Notifications
139     bool                 bgWasVisible;
140     bool                 b_keep_size;         ///< persistent resizeable window
141     QSize                mainBasedSize;       ///< based Wnd (normal mode only)
142     QSize                mainVideoSize;       ///< Wnd with video (all modes)
143     int                  i_visualmode;        ///< Visual Mode
144     pl_dock_e            i_pl_dock;
145     bool                 isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
146     int                  i_bg_height;         ///< Save height of bgWidget
147     bool                 b_shouldHide;
148
149     /* Status Bar */
150     QLabel              *nameLabel;
151     QLabel              *cryptedLabel;
152
153 public slots:
154     void undockPlaylist();
155     void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
156     void toggleMinimalView( bool );
157     void togglePlaylist();
158     void toggleUpdateSystrayMenu();
159     void toggleAdvanced();
160     void toggleFullScreen();
161     void toggleFSC();
162     void popupMenu( const QPoint& );
163
164     /* Manage the Video Functions from the vout threads */
165     void releaseVideoSlot( void );
166
167 private slots:
168     void debug();
169     void destroyPopupMenu();
170     void recreateToolbars();
171     void doComponentsUpdate();
172     void setName( QString );
173     void setVLCWindowsTitle( QString title = "" );
174 #if 0
175     void visual();
176 #endif
177     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
178     void updateSystrayTooltipName( QString );
179     void updateSystrayTooltipStatus( int );
180
181     void showCryptedLabel( bool );
182 signals:
183     void askReleaseVideo( );
184     void askVideoToResize( unsigned int, unsigned int );
185     void askVideoToShow( unsigned int, unsigned int );
186     void askBgWidgetToToggle();
187     void askUpdate();
188     void minimalViewToggled( bool );
189     void fullscreenInterfaceToggled( bool );
190 };
191
192 #endif