]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
274d4a96f034a21edef96a32d37a60b2089340b5
[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
53 enum {
54     CONTROLS_VISIBLE = 0x1,
55     CONTROLS_HIDDEN = 0x2,
56     CONTROLS_ADVANCED = 0x4,
57 };
58
59 typedef enum pl_dock_e {
60     PL_UNDOCKED,
61     PL_BOTTOM,
62     PL_RIGHT,
63     PL_LEFT
64 } pl_dock_e;
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     QSystemTrayIcon *getSysTray() { return sysTray; };
84     QMenu *getSysTrayMenu() { return systrayMenu; };
85     int getControlsVisibilityStatus();
86
87     /* Sizehint() */
88     virtual QSize sizeHint() const;
89
90 protected:
91     void dropEventPlay( QDropEvent *, bool);
92     virtual void dropEvent( QDropEvent *);
93     virtual void dragEnterEvent( QDragEnterEvent * );
94     virtual void dragMoveEvent( QDragMoveEvent * );
95     virtual void dragLeaveEvent( QDragLeaveEvent * );
96     virtual void closeEvent( QCloseEvent *);
97     virtual void customEvent( QEvent *);
98     virtual void keyPressEvent( QKeyEvent *);
99     virtual void wheelEvent( QWheelEvent * );
100     virtual void resizeEvent( QResizeEvent * event );
101
102 private:
103     QSettings           *settings;
104     QSystemTrayIcon     *sysTray;
105     QMenu               *systrayMenu;
106     QString              input_name;
107     QGridLayout         *mainLayout;
108     ControlsWidget      *controls;
109     InputControlsWidget *inputC;
110     FullscreenControllerWidget *fullscreenControls;
111
112     void createMainWidget( QSettings* );
113     void createStatusBar();
114
115     void askForPrivacy();
116     int  privacyDialog( QList<ConfigControl *> *controls );
117
118     /* Systray */
119     void handleSystray();
120     void createSystray();
121     void initSystray();
122
123
124     /* Video */
125     VideoWidget         *videoWidget;
126
127     BackgroundWidget    *bgWidget;
128     VisualSelector      *visualSelector;
129     PlaylistWidget      *playlistWidget;
130
131     bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
132     bool                 videoEmbeddedFlag;   ///< Want an external Video Window
133     bool                 playlistVisible;     ///< Is the playlist visible ?
134     bool                 visualSelectorEnabled;
135     bool                 notificationEnabled; /// Systray Notifications
136     bool                 bgWasVisible;
137     bool                 b_keep_size;         ///< persistent resizeable window
138     QSize                mainBasedSize;       ///< based Wnd (normal mode only)
139     QSize                mainVideoSize;       ///< Wnd with video (all modes)
140     int                  i_visualmode;        ///< Visual Mode
141     pl_dock_e            i_pl_dock;
142     bool                 isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
143     int                  i_bg_height;         ///< Save height of bgWidget
144     bool                 b_shouldHide;
145
146     /* Status Bar */
147     QLabel              *nameLabel;
148     QLabel              *cryptedLabel;
149
150 public slots:
151     void undockPlaylist();
152     void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
153     void toggleMinimalView( bool );
154     void togglePlaylist();
155     void toggleUpdateSystrayMenu();
156     void toggleAdvanced();
157     void toggleFullScreen();
158     void toggleFSC();
159     void popupMenu( const QPoint& );
160
161     /* Manage the Video Functions from the vout threads */
162     void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
163                        unsigned *pi_width, unsigned *pi_height );
164     void releaseVideoSlot( void );
165
166 private slots:
167     void debug();
168     void destroyPopupMenu();
169     void recreateToolbars();
170     void doComponentsUpdate();
171     void setName( const QString& );
172     void setVLCWindowsTitle( const QString& title = "" );
173 #if 0
174     void visual();
175 #endif
176     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
177     void updateSystrayTooltipName( const QString& );
178     void updateSystrayTooltipStatus( int );
179
180     void showCryptedLabel( bool );
181
182     void handleKeyPress( QKeyEvent * );
183
184 signals:
185     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
186                       unsigned int *pi_width, unsigned int *pi_height );
187     void askReleaseVideo( );
188     void askVideoToResize( unsigned int, unsigned int );
189     void askVideoSetFullScreen( bool );
190     void askUpdate();
191     void minimalViewToggled( bool );
192     void fullscreenInterfaceToggled( bool );
193 };
194
195 #endif