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 "widgets/native/qvlcframe.hpp"
30 #include "player/player_controller.hpp"
31 #include "components/voutwindow/qvoutwindow.hpp"
33 #include <QSystemTrayIcon>
34 #include <QStackedWidget>
35 #include <QtQuick/QQuickView>
36 #include <QtQuickWidgets/QQuickWidget>
37 #include <QtQuick/QQuickWindow>
40 # include <shobjidl.h>
58 class StandardPLPanel
;
60 struct vout_window_cfg_t
;
62 class MainInterface
: public QVLCMW
66 Q_PROPERTY(bool playlistDocked READ isPlaylistDocked WRITE setPlaylistDocked NOTIFY playlistDockedChanged
)
67 Q_PROPERTY(bool playlistVisible READ isPlaylistVisible WRITE setPlaylistVisible NOTIFY playlistVisibleChanged
)
68 Q_PROPERTY(bool interfaceAlwaysOnTop READ isInterfaceAlwaysOnTop WRITE setInterfaceAlwaysOnTop NOTIFY interfaceAlwaysOnTopChanged
)
69 Q_PROPERTY(bool interfaceFullScreen READ isInterfaceFullScreen WRITE setInterfaceFullScreen NOTIFY interfaceFullScreenChanged
)
70 Q_PROPERTY(bool hasEmbededVideo READ hasEmbededVideo NOTIFY hasEmbededVideoChanged
)
71 Q_PROPERTY(bool showRemainingTime READ isShowRemainingTime WRITE setShowRemainingTime NOTIFY showRemainingTimeChanged
)
72 Q_PROPERTY(VLCVarChoiceModel
* extraInterfaces READ getExtraInterfaces CONSTANT
)
76 MainInterface( intf_thread_t
*);
77 virtual ~MainInterface();
79 static const QEvent::Type ToolbarsNeedRebuild
;
81 /* Video requests from core */
82 bool getVideo( struct vout_window_t
* );
84 bool m_hasEmbededVideo
= false;
85 bool m_showRemainingTime
= false;
86 VLCVarChoiceModel
* m_extraInterfaces
;
87 std::atomic_flag videoActive
;
88 static int enableVideo( struct vout_window_t
*,
89 const struct vout_window_cfg_t
* );
90 static void disableVideo( struct vout_window_t
* );
91 static void releaseVideo( struct vout_window_t
* );
92 static void resizeVideo( struct vout_window_t
*, unsigned, unsigned );
93 static void requestVideoState( struct vout_window_t
*, unsigned );
94 static void requestVideoWindowed( struct vout_window_t
* );
95 static void requestVideoFullScreen( struct vout_window_t
*, const char * );
98 QQmlContext
* getRootCtx() { return mediacenterView
->rootContext(); }
99 QQuickWindow
* getRootQuickWindow();
100 QQmlEngine
* getEngine(){ return mediacenterView
->engine(); }
101 VideoSurfaceProvider
* getVideoSurfaceProvider() const;
104 QSystemTrayIcon
*getSysTray() { return sysTray
; }
105 QMenu
*getSysTrayMenu() { return systrayMenu
; }
108 CONTROLS_VISIBLE
= 0x1,
109 CONTROLS_HIDDEN
= 0x2,
110 CONTROLS_ADVANCED
= 0x4,
119 bool isInterfaceFullScreen() { return b_interfaceFullScreen
; }
120 bool isPlaylistDocked() { return b_playlistDocked
; }
121 bool isPlaylistVisible() { return playlistVisible
; }
122 bool isInterfaceAlwaysOnTop() { return b_interfaceOnTop
; }
123 bool hasEmbededVideo() { return m_hasEmbededVideo
; }
124 inline bool isShowRemainingTime() const { return m_showRemainingTime
; }
125 QList
<QQmlError
> qmlErrors() const;
128 void dropEventPlay( QDropEvent
* event
, bool b_play
);
129 void changeEvent( QEvent
* ) Q_DECL_OVERRIDE
;
130 void dropEvent( QDropEvent
*) Q_DECL_OVERRIDE
;
131 void dragEnterEvent( QDragEnterEvent
* ) Q_DECL_OVERRIDE
;
132 void dragMoveEvent( QDragMoveEvent
* ) Q_DECL_OVERRIDE
;
133 void dragLeaveEvent( QDragLeaveEvent
* ) Q_DECL_OVERRIDE
;
134 void closeEvent( QCloseEvent
*) Q_DECL_OVERRIDE
;
135 virtual void toggleUpdateSystrayMenuWhenVisible();
136 void resizeWindow(int width
, int height
);
139 /* Main Widgets Creation */
140 void createMainWidget( QSettings
* );
143 void createSystray();
145 void handleSystray();
148 void setInterfaceFullScreen( bool );
149 void computeMinimumSize();
153 QSystemTrayIcon
*sysTray
;
157 QVBoxLayout
*mainLayout
;
159 std::unique_ptr
<QVoutWindow
> m_videoRenderer
;
161 QQuickWidget
*mediacenterView
;
162 QWidget
*mediacenterWrapper
;
166 QLabel
*cryptedLabel
;
168 /* Status and flags */
169 QPoint lastWinPosition
;
170 QSize lastWinSize
; /// To restore the same window size when leaving fullscreen
171 QScreen
*lastWinScreen
;
173 QSize pendingResize
; // to be applied when fullscreen is disabled
175 QMap
<QWidget
*, QSize
> stackWidgetsSizes
;
178 unsigned i_notificationSetting
; /// Systray Notifications
179 bool b_autoresize
; ///< persistent resizable window
180 bool b_videoFullScreen
; ///< --fullscreen
181 bool b_hideAfterCreation
;
182 bool b_minimalView
; ///< Minimal video
183 bool b_playlistDocked
;
184 bool b_interfaceFullScreen
;
185 bool b_interfaceOnTop
; ///keep UI on top
186 bool b_pauseOnMinimize
;
187 bool b_maximizedView
;
188 bool b_isWindowTiled
;
189 #ifdef QT5_HAS_WAYLAND
192 bool b_hasMedialibrary
= false;
194 bool playlistVisible
; ///< Is the playlist visible ?
195 // bool videoIsActive; ///< Having a video now / THEMIM->hasV
196 // bool b_visualSelectorEnabled;
198 bool b_hasPausedWhenMinimized
;
200 static const Qt::Key kc
[10]; /* easter eggs */
204 void toggleUpdateSystrayMenu();
205 void showUpdateSystrayMenu();
206 void hideUpdateSystrayMenu();
207 void toggleInterfaceFullScreen();
208 void setPlaylistDocked( bool );
209 void setPlaylistVisible( bool );
210 void setInterfaceAlwaysOnTop( bool );
211 void setShowRemainingTime( bool );
216 void popupMenu( bool show
);
218 virtual void reloadPrefs();
219 VLCVarChoiceModel
* getExtraInterfaces();
222 void setVLCWindowsTitle( const QString
& title
= "" );
223 void handleSystrayClick( QSystemTrayIcon::ActivationReason
);
224 void updateSystrayTooltipName( const QString
& );
225 void updateSystrayTooltipStatus( PlayerController::PlayingState
);
227 void showBuffering( float );
229 /* Manage the Video Functions from the vout threads */
230 void getVideoSlot( bool );
231 void releaseVideoSlot( void );
233 void setVideoSize(unsigned int w
, unsigned int h
);
234 virtual void setVideoFullScreen( bool );
235 void setVideoOnTop( bool );
238 void setFullScreen( bool );
239 void onInputChanged( bool );
241 void sendHotkey(Qt::Key key
, Qt::KeyboardModifiers modifiers
);
244 void askGetVideo( bool );
245 void askReleaseVideo( );
246 void askVideoToResize( unsigned int, unsigned int );
247 void askVideoSetFullScreen( bool );
248 void askVideoOnTop( bool );
249 void minimalViewToggled( bool );
250 void fullscreenInterfaceToggled( bool );
255 void askPopupMenu( bool show
);
256 void kc_pressed(); /* easter eggs */
258 void playlistDockedChanged(bool);
259 void playlistVisibleChanged(bool);
260 void interfaceAlwaysOnTopChanged(bool);
261 void interfaceFullScreenChanged(bool);
262 void hasEmbededVideoChanged(bool);
263 void toolBarConfUpdated();
264 void showRemainingTimeChanged(bool);