gui: qt: use float for rate
[vlc.git] / modules / gui / qt / main_interface.hpp
blobd6d861072613dfb8048f44b2e95726bcbf4ea47e
1 /*****************************************************************************
2 * main_interface.hpp : Main Interface
3 ****************************************************************************
4 * Copyright (C) 2006-2010 VideoLAN and AUTHORS
6 * Authors: Clément Stenac <zorglub@videolan.org>
7 * Jean-Baptiste Kempf <jb@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef QVLC_MAIN_INTERFACE_H_
25 #define QVLC_MAIN_INTERFACE_H_
27 #include "qt.hpp"
29 #include "util/qvlcframe.hpp"
31 #include <QSystemTrayIcon>
32 #include <QStackedWidget>
34 #ifdef _WIN32
35 # include <shobjidl.h>
36 #endif
38 #include <atomic>
40 class QSettings;
41 class QCloseEvent;
42 class QKeyEvent;
43 class QLabel;
44 class QEvent;
45 class VideoWidget;
46 class BackgroundWidget;
47 class PlaylistWidget;
48 class VisualSelector;
49 class ControlsWidget;
50 class InputControlsWidget;
51 class FullscreenControllerWidget;
52 class QVBoxLayout;
53 class QMenu;
54 class QSize;
55 class QScreen;
56 class QTimer;
57 class StandardPLPanel;
58 struct vout_window_t;
59 struct vout_window_cfg_t;
61 class MainInterface : public QVLCMW
63 Q_OBJECT
65 friend class PlaylistWidget;
67 public:
68 /* tors */
69 MainInterface( intf_thread_t *);
70 virtual ~MainInterface();
72 static const QEvent::Type ToolbarsNeedRebuild;
74 /* Video requests from core */
75 bool getVideo( struct vout_window_t * );
76 private:
77 std::atomic_flag videoActive;
78 static int enableVideo( struct vout_window_t *,
79 const struct vout_window_cfg_t * );
80 static void disableVideo( struct vout_window_t * );
81 static void releaseVideo( struct vout_window_t * );
82 static void resizeVideo( struct vout_window_t *, unsigned, unsigned );
83 static void requestVideoState( struct vout_window_t *, unsigned );
84 static void requestVideoWindowed( struct vout_window_t * );
85 static void requestVideoFullScreen( struct vout_window_t *, const char * );
87 public:
88 /* Getters */
89 QSystemTrayIcon *getSysTray() { return sysTray; }
90 QMenu *getSysTrayMenu() { return systrayMenu; }
91 FullscreenControllerWidget* getFullscreenControllerWidget() { return fullscreenControls; }
92 enum
94 CONTROLS_VISIBLE = 0x1,
95 CONTROLS_HIDDEN = 0x2,
96 CONTROLS_ADVANCED = 0x4,
98 enum
100 RAISE_NEVER,
101 RAISE_VIDEO,
102 RAISE_AUDIO,
103 RAISE_AUDIOVIDEO,
105 int getControlsVisibilityStatus();
106 bool isPlDocked() { return ( b_plDocked != false ); }
107 bool isInterfaceFullScreen() { return b_interfaceFullScreen; }
108 bool isInterfaceAlwaysOnTop() { return b_interfaceOnTop; }
109 StandardPLPanel* getPlaylistView();
111 protected:
112 void dropEventPlay( QDropEvent* event, bool b_play );
113 void changeEvent( QEvent * ) Q_DECL_OVERRIDE;
114 void dropEvent( QDropEvent *) Q_DECL_OVERRIDE;
115 void dragEnterEvent( QDragEnterEvent * ) Q_DECL_OVERRIDE;
116 void dragMoveEvent( QDragMoveEvent * ) Q_DECL_OVERRIDE;
117 void dragLeaveEvent( QDragLeaveEvent * ) Q_DECL_OVERRIDE;
118 void closeEvent( QCloseEvent *) Q_DECL_OVERRIDE;
119 void keyPressEvent( QKeyEvent *) Q_DECL_OVERRIDE;
120 void wheelEvent( QWheelEvent * ) Q_DECL_OVERRIDE;
121 bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
122 virtual void toggleUpdateSystrayMenuWhenVisible();
123 void resizeWindow(int width, int height);
125 protected:
126 /* Main Widgets Creation */
127 void createMainWidget( QSettings* );
128 void createStatusBar();
129 void createPlaylist();
130 void createResumePanel( QWidget *w );
132 /* Systray */
133 void createSystray();
134 void initSystray();
135 void handleSystray();
137 /* Central StackWidget Management */
138 void showTab( QWidget *, bool video_closing = false );
139 void showVideo();
140 void restoreStackOldWidget( bool video_closing = false );
142 /* */
143 void displayNormalView();
144 void setMinimalView( bool );
145 void setInterfaceFullScreen( bool );
146 void computeMinimumSize();
148 /* */
149 QSettings *settings;
150 QSystemTrayIcon *sysTray;
151 QMenu *systrayMenu;
153 QString input_name;
154 QVBoxLayout *mainLayout;
155 ControlsWidget *controls;
156 InputControlsWidget *inputC;
157 FullscreenControllerWidget *fullscreenControls;
159 /* Widgets */
160 QStackedWidget *stackCentralW;
162 VideoWidget *videoWidget;
163 BackgroundWidget *bgWidget;
164 PlaylistWidget *playlistWidget;
165 //VisualSelector *visualSelector;
167 /* resume panel */
168 QWidget *resumePanel;
169 QTimer *resumeTimer;
170 vlc_tick_t i_resumeTime;
172 /* Status Bar */
173 QLabel *nameLabel;
174 QLabel *cryptedLabel;
176 /* Status and flags */
177 QWidget *stackCentralOldWidget;
178 QPoint lastWinPosition;
179 QSize lastWinSize; /// To restore the same window size when leaving fullscreen
180 QScreen *lastWinScreen;
182 QSize pendingResize; // to be applied when fullscreen is disabled
184 QMap<QWidget *, QSize> stackWidgetsSizes;
186 /* Flags */
187 unsigned i_notificationSetting; /// Systray Notifications
188 bool b_autoresize; ///< persistent resizable window
189 bool b_videoFullScreen; ///< --fullscreen
190 bool b_hideAfterCreation;
191 bool b_minimalView; ///< Minimal video
192 bool b_interfaceFullScreen;
193 bool b_interfaceOnTop; ///keep UI on top
194 bool b_pauseOnMinimize;
195 bool b_maximizedView;
196 bool b_isWindowTiled;
197 #ifdef QT5_HAS_WAYLAND
198 bool b_hasWayland;
199 #endif
200 /* States */
201 bool playlistVisible; ///< Is the playlist visible ?
202 // bool videoIsActive; ///< Having a video now / THEMIM->hasV
203 // bool b_visualSelectorEnabled;
204 bool b_plDocked; ///< Is the playlist docked ?
206 bool b_hasPausedWhenMinimized;
207 bool b_statusbarVisible;
209 static const Qt::Key kc[10]; /* easter eggs */
210 int i_kc_offset;
212 public slots:
213 void dockPlaylist( bool b_docked = true );
214 void toggleMinimalView( bool );
215 void togglePlaylist();
216 void toggleUpdateSystrayMenu();
217 void showUpdateSystrayMenu();
218 void hideUpdateSystrayMenu();
219 void toggleAdvancedButtons();
220 void toggleInterfaceFullScreen();
221 void toggleFSC();
222 void setInterfaceAlwaysOnTop( bool );
224 void setStatusBarVisibility(bool b_visible);
225 void setPlaylistVisibility(bool b_visible);
227 /* Manage the Video Functions from the vout threads */
228 void getVideoSlot( struct vout_window_t *,
229 unsigned i_width, unsigned i_height, bool );
230 void releaseVideoSlot( void );
232 void emitBoss();
233 void emitRaise();
235 virtual void reloadPrefs();
236 void toolBarConfUpdated();
238 protected slots:
239 void debug();
240 void recreateToolbars();
241 void setName( const QString& );
242 void setVLCWindowsTitle( const QString& title = "" );
243 void handleSystrayClick( QSystemTrayIcon::ActivationReason );
244 void updateSystrayTooltipName( const QString& );
245 void updateSystrayTooltipStatus( int );
246 void showCryptedLabel( bool );
248 void handleKeyPress( QKeyEvent * );
250 void showBuffering( float );
252 void resizeStack( int w, int h )
254 if( isFullScreen() )
256 /* postpone resize, will be applied once fullscreen is disabled */
257 pendingResize = QSize( w, h );
259 else if( !isMaximized() && !b_isWindowTiled )
261 if( b_minimalView )
262 resizeWindow( w, h ); /* Oh yes, it shouldn't
263 be possible that size() - stackCentralW->size() < 0
264 since stackCentralW is contained in the QMW... */
265 else
266 resizeWindow( width() - stackCentralW->width() + w, height() - stackCentralW->height() + h );
268 debug();
271 void setVideoSize( unsigned int, unsigned int );
272 void videoSizeChanged( int, int );
273 virtual void setVideoFullScreen( bool );
274 void setVideoOnTop( bool );
275 void setBoss();
276 void setRaise();
277 void voutReleaseMouseEvents();
279 void showResumePanel( vlc_tick_t);
280 void hideResumePanel();
281 void resumePlayback();
282 void onInputChanged( bool );
284 signals:
285 void askGetVideo( struct vout_window_t *, unsigned, unsigned, bool );
286 void askReleaseVideo( );
287 void askVideoToResize( unsigned int, unsigned int );
288 void askVideoSetFullScreen( bool );
289 void askVideoOnTop( bool );
290 void minimalViewToggled( bool );
291 void fullscreenInterfaceToggled( bool );
292 void askToQuit();
293 void askBoss();
294 void askRaise();
295 void kc_pressed(); /* easter eggs */
298 #endif