]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Fix Playlist resizing and positionning.
[vlc] / modules / gui / qt4 / main_interface.hpp
1 /*****************************************************************************
2  * main_interface.hpp : Main Interface
3  ****************************************************************************
4  * Copyright (C) 2006-2007 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 _MAIN_INTERFACE_H_
26 #define _MAIN_INTERFACE_H_
27
28 #include "qt4.hpp"
29 #include "util/qvlcframe.hpp"
30 #include "components/preferences_widgets.hpp"
31
32 #include <vlc_aout.h>
33
34 #include <QSystemTrayIcon>
35
36 class QSettings;
37 class QCloseEvent;
38 class QKeyEvent;
39 class QLabel;
40 class QEvent;
41 class InputManager;
42 class VideoWidget;
43 class BackgroundWidget;
44 class PlaylistWidget;
45 class VisualSelector;
46 class AdvControlsWidget;
47 class ControlsWidget;
48 class FullscreenControllerWidget;
49 class SpeedControlWidget;
50 class QMenu;
51 class QSize;
52 //class QDockWidet;
53
54 enum {
55     CONTROLS_HIDDEN = 0x0,
56     CONTROLS_VISIBLE = 0x1,
57     CONTROLS_ADVANCED = 0x2
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 VolumeClickHandler;
72     friend class InteractionDialog;
73
74 public:
75     MainInterface( intf_thread_t *);
76     virtual ~MainInterface();
77
78     /* Video requests from core */
79     void *requestVideo( vout_thread_t *p_nvout, int *pi_x,
80                         int *pi_y, unsigned int *pi_width,
81                         unsigned int *pi_height );
82     void releaseVideo( void * );
83     int controlVideo( void *p_window, int i_query, va_list args );
84
85     /* Getters */
86     QSystemTrayIcon *getSysTray() { return sysTray; };
87     QMenu *getSysTrayMenu() { return systrayMenu; };
88     int getControlsVisibilityStatus();
89
90     /* Sizehint() */
91     QSize sizeHint() const;
92 protected:
93 //    void resizeEvent( QResizeEvent * );
94     void dropEvent( QDropEvent *);
95     void dragEnterEvent( QDragEnterEvent * );
96     void dragMoveEvent( QDragMoveEvent * );
97     void dragLeaveEvent( QDragLeaveEvent * );
98     void closeEvent( QCloseEvent *);
99
100 private:
101     QSettings           *settings;
102     QSystemTrayIcon     *sysTray;
103     QMenu               *systrayMenu;
104     QString              input_name;
105     QVBoxLayout         *mainLayout;
106     ControlsWidget      *controls;
107     FullscreenControllerWidget *fullscreenControls;
108     QMenu               *speedControlMenu;
109     SpeedControlWidget  *speedControl;
110
111     void handleMainUi( QSettings* );
112     void askForPrivacy();
113     int  privacyDialog( QList<ConfigControl *> *controls );
114
115     /* Systray */
116     void handleSystray();
117     void createSystray();
118
119     void createStatusBar();
120     void initSystray();
121
122     /* Video */
123     VideoWidget         *videoWidget;
124
125     BackgroundWidget    *bgWidget;
126     VisualSelector      *visualSelector;
127     PlaylistWidget      *playlistWidget;
128
129     bool                 videoIsActive; ///< Having a video now / THEMIM->hasV
130     bool                 videoEmbeddedFlag; ///< Want an external Video Window
131     bool                 playlistVisible; ///< Is the playlist visible ?
132     bool                 visualSelectorEnabled;
133     bool                 notificationEnabled; /// Systray Notifications
134     bool                 b_remainingTime; /* Show elapsed or remaining time */
135     bool                 bgWasVisible;
136     int                  i_visualmode; ///< Visual Mode
137     pl_dock_e            i_pl_dock;
138     bool                 isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
139
140     input_thread_t      *p_input;    ///< Main input associated to the playlist
141
142     /* Status Bar */
143     QLabel              *timeLabel;
144     QLabel              *speedLabel;
145     QLabel              *nameLabel;
146
147     virtual void customEvent( QEvent *);
148     virtual void keyPressEvent( QKeyEvent *);
149     virtual void wheelEvent( QWheelEvent * );
150
151 public slots:
152     void undockPlaylist();
153     void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
154     void toggleMinimalView();
155     void togglePlaylist();
156     void toggleUpdateSystrayMenu();
157     void toggleAdvanced();
158     void toggleFullScreen();
159     void toggleFSC();
160
161     /* Manage the Video Functions from the vout threads */
162     void releaseVideoSlot( void * );
163
164 private slots:
165     void debug();
166     void updateOnTimer();
167     void doComponentsUpdate();
168     void setStatus( int );
169     void setRate( int );
170     void setName( QString );
171     void setVLCWindowsTitle( QString title = "" );
172     void setDisplayPosition( float, int, int );
173     void toggleTimeDisplay();
174 #if 0
175     void visual();
176 #endif
177     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
178     void updateSystrayTooltipName( QString );
179     void updateSystrayTooltipStatus( int );
180     void showSpeedMenu( QPoint );
181 signals:
182     void askReleaseVideo( void * );
183     void askVideoToResize( unsigned int, unsigned int );
184     void askVideoToToggle();
185     void askBgWidgetToToggle();
186     void askUpdate();
187 };
188
189 #endif