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_
29 #include "util/qvlcframe.hpp"
31 #include <QSystemTrayIcon>
32 #include <QStackedWidget>
35 # include <shobjidl.h>
46 class BackgroundWidget
;
50 class InputControlsWidget
;
51 class FullscreenControllerWidget
;
57 class StandardPLPanel
;
59 struct vout_window_cfg_t
;
61 class MainInterface
: public QVLCMW
65 friend class PlaylistWidget
;
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
* );
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 * );
89 QSystemTrayIcon
*getSysTray() { return sysTray
; }
90 QMenu
*getSysTrayMenu() { return systrayMenu
; }
91 FullscreenControllerWidget
* getFullscreenControllerWidget() { return fullscreenControls
; }
94 CONTROLS_VISIBLE
= 0x1,
95 CONTROLS_HIDDEN
= 0x2,
96 CONTROLS_ADVANCED
= 0x4,
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();
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
);
126 /* Main Widgets Creation */
127 void createMainWidget( QSettings
* );
128 void createStatusBar();
129 void createPlaylist();
130 void createResumePanel( QWidget
*w
);
133 void createSystray();
135 void handleSystray();
137 /* Central StackWidget Management */
138 void showTab( QWidget
*, bool video_closing
= false );
140 void restoreStackOldWidget( bool video_closing
= false );
143 void displayNormalView();
144 void setMinimalView( bool );
145 void setInterfaceFullScreen( bool );
146 void computeMinimumSize();
150 QSystemTrayIcon
*sysTray
;
154 QVBoxLayout
*mainLayout
;
155 ControlsWidget
*controls
;
156 InputControlsWidget
*inputC
;
157 FullscreenControllerWidget
*fullscreenControls
;
160 QStackedWidget
*stackCentralW
;
162 VideoWidget
*videoWidget
;
163 BackgroundWidget
*bgWidget
;
164 PlaylistWidget
*playlistWidget
;
165 //VisualSelector *visualSelector;
168 QWidget
*resumePanel
;
170 vlc_tick_t i_resumeTime
;
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
;
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
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 */
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();
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 );
235 virtual void reloadPrefs();
236 void toolBarConfUpdated();
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
)
256 /* postpone resize, will be applied once fullscreen is disabled */
257 pendingResize
= QSize( w
, h
);
259 else if( !isMaximized() && !b_isWindowTiled
)
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... */
266 resizeWindow( width() - stackCentralW
->width() + w
, height() - stackCentralW
->height() + h
);
271 void setVideoSize( unsigned int, unsigned int );
272 void videoSizeChanged( int, int );
273 virtual void setVideoFullScreen( bool );
274 void setVideoOnTop( bool );
277 void voutReleaseMouseEvents();
279 void showResumePanel( vlc_tick_t
);
280 void hideResumePanel();
281 void resumePlayback();
282 void onInputChanged( bool );
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 );
295 void kc_pressed(); /* easter eggs */