[vlc-devel] [PATCH v2 11/12] qt: remove qml instantiation and video embedding from the main_interface

Pierre Lamot pierre at videolabs.io
Thu May 14 14:05:30 CEST 2020


  QML UI is injected from MainUI and Video integration is handled by the
  compositor
---
 .../gui/qt/maininterface/main_interface.cpp   | 315 ++----------------
 .../gui/qt/maininterface/main_interface.hpp   |  39 +--
 modules/gui/qt/qt.cpp                         |  38 +--
 modules/gui/qt/qt.hpp                         |   4 +
 4 files changed, 56 insertions(+), 340 deletions(-)

diff --git a/modules/gui/qt/maininterface/main_interface.cpp b/modules/gui/qt/maininterface/main_interface.cpp
index 4b226e9bd5..320c22e0d8 100644
--- a/modules/gui/qt/maininterface/main_interface.cpp
+++ b/modules/gui/qt/maininterface/main_interface.cpp
@@ -35,6 +35,7 @@
 #include "widgets/native/customwidgets.hpp"               // qtEventToVLCKey, QVLCStackedWidget
 #include "util/qt_dirs.hpp"                     // toNativeSeparators
 #include "util/imagehelper.hpp"
+#include "util/recents.hpp"
 
 #include "widgets/native/interface_widgets.hpp"     // bgWidget, videoWidget
 #include "dialogs/firstrun/firstrun.hpp"                 // First Run
@@ -43,33 +44,6 @@
 #include "playlist/playlist_controller.hpp"
 #include <vlc_playlist.h>
 
-#include "medialibrary/medialib.hpp"
-#include "medialibrary/mlqmltypes.hpp"
-#include "medialibrary/mlalbummodel.hpp"
-#include "medialibrary/mlartistmodel.hpp"
-#include "medialibrary/mlalbumtrackmodel.hpp"
-#include "medialibrary/mlgenremodel.hpp"
-#include "medialibrary/mlvideomodel.hpp"
-#include "medialibrary/mlrecentsvideomodel.hpp"
-#include "medialibrary/mlfoldersmodel.hpp"
-
-#include "util/recent_media_model.hpp"
-#include "util/settings.hpp"
-
-#include "network/networkmediamodel.hpp"
-#include "network/networkdevicemodel.hpp"
-
-#include "util/navigation_history.hpp"
-#include "dialogs/help/aboutmodel.hpp"
-#include "dialogs/dialogs/dialogmodel.hpp"
-#include "player/playercontrolbarmodel.hpp"
-
-#include "util/qml_main_context.hpp"
-
-#include "util/qmleventfilter.hpp"
-#include "util/i18n.hpp"
-#include "util/systempalette.hpp"
-
 #include "videosurface.hpp"
 
 #include "menus/menus.hpp"                            // Menu creation
@@ -100,9 +74,6 @@
 
 #include <QtGlobal>
 #include <QTimer>
-#include <QtQml/QQmlContext>
-#include <QtQuick/QQuickItem>
-
 
 #include <vlc_actions.h>                    /* Wheel event */
 #include <vlc_vout_window.h>                /* VOUT_ events */
@@ -122,27 +93,11 @@ static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable,
                            vlc_value_t old_val, vlc_value_t new_val,
                            void *param );
 
-namespace {
-
-template<class T>
-void registerAnonymousType( const char *uri, int versionMajor )
-{
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
-    qmlRegisterAnonymousType<T>( uri, versionMajor );
-#else
-    qmlRegisterType<T>();
-    VLC_UNUSED( uri );
-    VLC_UNUSED( versionMajor );
-#endif
-}
-
-} // anonymous namespace
-
 const QEvent::Type MainInterface::ToolbarsNeedRebuild =
         (QEvent::Type)QEvent::registerEventType();
 
-MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ),
-    videoActive( ATOMIC_FLAG_INIT )
+MainInterface::MainInterface( intf_thread_t *_p_intf )
+    : QVLCMW( _p_intf )
 {
     /* Variables initialisation */
     lastWinScreen        = NULL;
@@ -161,12 +116,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ),
      *  Configuration and settings
      *  Pre-building of interface
      **/
-    /* Main settings */
-    setFocusPolicy( Qt::StrongFocus );
-    setAcceptDrops( true );
-    setWindowRole( "vlc-main" );
-    setWindowIcon( QApplication::windowIcon() );
-    setWindowOpacity( var_InheritFloat( p_intf, "qt-opacity" ) );
 
     /* Does the interface resize to video size or the opposite */
     b_autoresize = var_InheritBool( p_intf, "qt-video-autoresize" );
@@ -193,8 +142,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ),
     /* Should the UI stays on top of other windows */
     b_interfaceOnTop = var_InheritBool( p_intf, "video-on-top" );
 
-    b_hasMedialibrary = (vlc_ml_instance_get( p_intf ) != NULL);
-
     QString platformName = QGuiApplication::platformName();
 
 #ifdef QT5_HAS_WAYLAND
@@ -204,9 +151,17 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ),
     /**************************
      *  UI and Widgets design
      **************************/
-    setVLCWindowsTitle();
+    setWindowTitle("");
+
+    /* Main settings */
+    setFocusPolicy( Qt::StrongFocus );
+    setAcceptDrops( true );
+    setWindowRole( "vlc-main" );
+    setWindowIcon( QApplication::windowIcon() );
+    setWindowOpacity( var_InheritFloat( p_intf, "qt-opacity" ) );
+    if ( b_interfaceOnTop )
+        setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint );
 
-    createMainWidget( settings );
 
     /*********************************
      * Create the Systray Management *
@@ -225,7 +180,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ),
     /* and title of the Main Interface*/
     if( var_InheritBool( p_intf, "qt-name-in-title" ) )
     {
-        connect( THEMIM, &PlayerController::nameChanged, this, &MainInterface::setVLCWindowsTitle );
+        connect( THEMIM, &PlayerController::nameChanged, this, &MainInterface::setWindowTitle );
     }
     connect( THEMIM, &PlayerController::inputChanged, this, &MainInterface::onInputChanged );
 
@@ -233,18 +188,14 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ),
 
     /* VideoWidget connects for asynchronous calls */
     b_videoFullScreen = false;
-    connect( this, &MainInterface::askGetVideo, this, &MainInterface::getVideoSlot, Qt::BlockingQueuedConnection );
-    connect( this, &MainInterface::askReleaseVideo, this, &MainInterface::releaseVideoSlot, Qt::BlockingQueuedConnection );
     connect( this, &MainInterface::askVideoToResize, this, &MainInterface::setVideoSize, Qt::QueuedConnection );
+    connect( this, &MainInterface::askVideoSetFullScreen, this, &MainInterface::setVideoFullScreen, Qt::QueuedConnection );
+    connect( this, &MainInterface::askToQuit, THEDP, &DialogsProvider::quit, Qt::QueuedConnection  );
+    connect( this, &MainInterface::askBoss, this, &MainInterface::setBoss, Qt::QueuedConnection  );
+    connect( this, &MainInterface::askRaise, this, &MainInterface::setRaise, Qt::QueuedConnection  );
 
     connect( THEDP, &DialogsProvider::toolBarConfUpdated, this, &MainInterface::toolBarConfUpdated );
 
-    connect( this, &MainInterface::askToQuit, THEDP, &DialogsProvider::quit );
-    connect( this, &MainInterface::askBoss, this, &MainInterface::setBoss );
-    connect( this, &MainInterface::askRaise, this, &MainInterface::setRaise );
-
-    connect( this, &MainInterface::askVideoSetFullScreen, this, &MainInterface::setVideoFullScreen);
-
     /** END of CONNECTS**/
 
 
@@ -264,6 +215,12 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ),
 
     b_interfaceFullScreen = isFullScreen();
 
+    //add a dummy transparent widget
+    QWidget* widget = new QWidget(this);
+    widget->setStyleSheet("background-color: transparent");
+    setCentralWidget(widget);
+
+
     setVisible( !b_hideAfterCreation );
 
     computeMinimumSize();
@@ -306,10 +263,6 @@ void MainInterface::computeMinimumSize()
     setMinimumHeight( minHeight );
 }
 
-QList<QQmlError> MainInterface::qmlErrors() const
-{
-    return mediacenterView->errors();
-}
 
 /*****************************
  *   Main UI handling        *
@@ -349,99 +302,6 @@ void MainInterface::sendHotkey(Qt::Key key , Qt::KeyboardModifiers modifiers)
     var_SetInteger(vlc_object_instance(p_intf), "key-pressed", vlckey);
 }
 
-void MainInterface::createMainWidget( QSettings * )
-{
-    qRegisterMetaType<VLCTick>();
-    qmlRegisterUncreatableType<VLCTick>("org.videolan.vlc", 0, 1, "VLCTick", "");
-
-    qmlRegisterType<VideoSurface>("org.videolan.vlc", 0, 1, "VideoSurface");
-
-    if (b_hasMedialibrary)
-    {
-        qRegisterMetaType<MLParentId>();
-        qmlRegisterType<MLAlbumModel>( "org.videolan.medialib", 0, 1, "MLAlbumModel" );
-        qmlRegisterType<MLArtistModel>( "org.videolan.medialib", 0, 1, "MLArtistModel" );
-        qmlRegisterType<MLAlbumTrackModel>( "org.videolan.medialib", 0, 1, "MLAlbumTrackModel" );
-        qmlRegisterType<MLGenreModel>( "org.videolan.medialib", 0, 1, "MLGenreModel" );
-        qmlRegisterType<MLVideoModel>( "org.videolan.medialib", 0, 1, "MLVideoModel" );
-        qmlRegisterType<MLRecentsVideoModel>( "org.videolan.medialib", 0, 1, "MLRecentsVideoModel" );
-        qRegisterMetaType<NetworkTreeItem>();
-        qmlRegisterType<NetworkMediaModel>( "org.videolan.medialib", 0, 1, "NetworkMediaModel");
-        qmlRegisterType<NetworkDeviceModel>( "org.videolan.medialib", 0, 1, "NetworkDeviceModel");
-        qmlRegisterType<MlFoldersModel>( "org.videolan.medialib", 0, 1, "MLFolderModel");
-
-        //expose base object, they aren't instanciable from QML side
-        registerAnonymousType<MLAlbum>( "org.videolan.medialib", 1 );
-        registerAnonymousType<MLArtist>( "org.videolan.medialib", 1 );
-        registerAnonymousType<MLAlbumTrack>( "org.videolan.medialib", 1 );
-        registerAnonymousType<MLGenre>( "org.videolan.medialib", 1 );
-        registerAnonymousType<MLVideo>( "org.videolan.medialib", 1 );
-    }
-
-    qmlRegisterUncreatableType<NavigationHistory>("org.videolan.vlc", 0, 1, "History", "Type of global variable history" );
-
-    qmlRegisterUncreatableType<TrackListModel>("org.videolan.vlc", 0, 1, "TrackListModel", "available tracks of a media (audio/video/sub)" );
-    qmlRegisterUncreatableType<TitleListModel>("org.videolan.vlc", 0, 1, "TitleListModel", "available titles of a media" );
-    qmlRegisterUncreatableType<ChapterListModel>("org.videolan.vlc", 0, 1, "ChapterListModel", "available titles of a media" );
-    qmlRegisterUncreatableType<ProgramListModel>("org.videolan.vlc", 0, 1, "ProgramListModel", "available programs of a media" );
-    qmlRegisterUncreatableType<VLCVarChoiceModel>("org.videolan.vlc", 0, 1, "VLCVarChoiceModel", "generic variable with choice model" );
-    qmlRegisterUncreatableType<PlayerController>("org.videolan.vlc", 0, 1, "PlayerController", "player controller" );
-
-    qRegisterMetaType<PlaylistPtr>();
-    qRegisterMetaType<PlaylistItem>();
-    qmlRegisterUncreatableType<PlaylistItem>("org.videolan.vlc", 0, 1, "PlaylistItem", "");
-    qmlRegisterType<PlaylistListModel>( "org.videolan.vlc", 0, 1, "PlaylistListModel" );
-    qmlRegisterType<PlaylistControllerModel>( "org.videolan.vlc", 0, 1, "PlaylistControllerModel" );
-
-    qmlRegisterType<AboutModel>( "org.videolan.vlc", 0, 1, "AboutModel" );
-    qRegisterMetaType<DialogId>();
-    qmlRegisterType<DialogModel>("org.videolan.vlc", 0, 1, "DialogModel");
-
-    qmlRegisterType<QmlEventFilter>( "org.videolan.vlc", 0, 1, "EventFilter" );
-
-    qmlRegisterType<PlayerControlBarModel>( "org.videolan.vlc", 0, 1, "PlayerControlBarModel");
-
-    mediacenterView = new QQuickWidget(this);
-    mediacenterView->setClearColor(Qt::transparent);
-
-    I18n* i18n = new I18n(this);
-    NavigationHistory* navigation_history = new NavigationHistory(mediacenterView);
-
-    QmlMainContext* mainCtx = new QmlMainContext(p_intf, this, mediacenterView);
-
-
-    QQmlContext *rootCtx = mediacenterView->rootContext();
-
-    rootCtx->setContextProperty( "history", navigation_history );
-    rootCtx->setContextProperty( "player", p_intf->p_sys->p_mainPlayerController );
-    rootCtx->setContextProperty( "i18n", i18n );
-    rootCtx->setContextProperty( "mainctx", mainCtx);
-    rootCtx->setContextProperty( "topWindow", this->windowHandle());
-    rootCtx->setContextProperty( "mainInterface", this);
-    rootCtx->setContextProperty( "dialogProvider", DialogsProvider::getInstance());
-    rootCtx->setContextProperty( "recentsMedias",  new VLCRecentMediaModel( p_intf, this ));
-    rootCtx->setContextProperty( "settings",  new Settings( p_intf, this ));
-    rootCtx->setContextProperty( "systemPalette", new SystemPalette(this));
-
-    if (b_hasMedialibrary)
-    {
-        MediaLib *medialib = new MediaLib(p_intf, mediacenterView);
-        rootCtx->setContextProperty( "medialib", medialib );
-    }
-    else
-    {
-        rootCtx->setContextProperty( "medialib", nullptr );
-    }
-
-    mediacenterView->setSource( QUrl ( QStringLiteral("qrc:/main/MainInterface.qml") ) );
-    mediacenterView->setResizeMode( QQuickWidget::SizeRootObjectToView );
-
-    setCentralWidget( mediacenterView );
-
-    if ( b_interfaceOnTop )
-        setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint );
-}
-
 inline void MainInterface::initSystray()
 {
     bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
@@ -467,41 +327,6 @@ inline void MainInterface::initSystray()
  * Video Handling
  ****************************************************************************/
 
-/**
- * NOTE:
- * You must not change the state of this object or other Qt UI objects,
- * from the video output thread - only from the Qt UI main loop thread.
- * All window provider queries must be handled through signals or events.
- * That's why we have all those emit statements...
- */
-bool MainInterface::getVideo( struct vout_window_t *p_wnd )
-{
-    static const struct vout_window_operations ops = {
-        MainInterface::enableVideo,
-        MainInterface::disableVideo,
-        MainInterface::resizeVideo,
-        MainInterface::releaseVideo,
-        MainInterface::requestVideoState,
-        MainInterface::requestVideoWindowed,
-        MainInterface::requestVideoFullScreen,
-        NULL,
-    };
-
-    if( videoActive.test_and_set() )
-        return false;
-
-    p_wnd->ops = &ops;
-    p_wnd->info.has_double_click = true;
-    p_wnd->sys = this;
-    if (!m_videoRenderer->setupVoutWindow(p_wnd))
-        return false;
-
-    m_hasEmbededVideo = true;
-    emit hasEmbededVideoChanged(true);
-
-    return true;
-}
-
 void MainInterface::setVideoFullScreen( bool fs )
 {
     b_videoFullScreen = fs;
@@ -615,81 +440,25 @@ void MainInterface::setInterfaceAlwaysOnTop( bool on_top )
     emit interfaceAlwaysOnTopChanged(on_top);
 }
 
-/* Asynchronous calls for video window contrlos */
-int MainInterface::enableVideo( vout_window_t *p_wnd,
-                                 const vout_window_cfg_t *cfg )
-{
-    MainInterface *p_mi = (MainInterface *)p_wnd->sys;
-
-    msg_Dbg( p_wnd, "requesting video window..." );
-    p_mi->m_videoRenderer->enableVideo(cfg->width, cfg->height, cfg->is_fullscreen);
-    /* This is a blocking call signal. Results are stored directly in the
-     * vout_window_t and boolean pointers. Beware of deadlocks! */
-    emit p_mi->askGetVideo( cfg->is_fullscreen );
-    return VLC_SUCCESS;
-}
-
-void MainInterface::disableVideo( vout_window_t *p_wnd )
+void MainInterface::requestResizeVideo( unsigned i_width, unsigned i_height )
 {
-    MainInterface *p_mi = (MainInterface *)p_wnd->sys;
-    p_mi->m_videoRenderer->disableVideo();
-    msg_Dbg( p_wnd, "releasing video..." );
-    emit p_mi->askReleaseVideo();
+    emit askVideoToResize( i_width, i_height );
 }
 
-void MainInterface::resizeVideo( vout_window_t *p_wnd,
-                                 unsigned i_width, unsigned i_height )
+void MainInterface::requestVideoWindowed( )
 {
-    MainInterface *p_mi = (MainInterface *)p_wnd->sys;
-
-    emit p_mi->askVideoToResize( i_width, i_height );
+   emit askVideoSetFullScreen( false );
 }
 
-
-void MainInterface::requestVideoWindowed( struct vout_window_t *wnd )
+void MainInterface::requestVideoFullScreen(const char * )
 {
-   MainInterface *p_mi = (MainInterface *)wnd->sys;
-   msg_Warn( wnd, "requestVideoWindowed..." );
-
-   emit p_mi->askVideoSetFullScreen( false );
-}
-
-void MainInterface::requestVideoFullScreen( vout_window_t *wnd, const char * )
-{
-    MainInterface *p_mi = (MainInterface *)wnd->sys;
-    msg_Warn( wnd, "requestVideoFullScreen..." );
-
-    emit p_mi->askVideoSetFullScreen( true );
+    emit askVideoSetFullScreen( true );
 }
 
-void MainInterface::requestVideoState( vout_window_t *p_wnd, unsigned i_arg )
+void MainInterface::requestVideoState(  unsigned i_arg )
 {
-    MainInterface *p_mi = (MainInterface *)p_wnd->sys;
     bool on_top = (i_arg & VOUT_WINDOW_STATE_ABOVE) != 0;
-
-    emit p_mi->askVideoOnTop( on_top );
-}
-
-void MainInterface::releaseVideo( vout_window_t *p_wnd )
-{
-    MainInterface *p_mi = (MainInterface *)p_wnd->sys;
-
-    /* Releasing video (in disableVideo()) was a blocking call.
-     * The video is no longer active by this point.
-     */
-    p_mi->videoActive.clear();
-    p_mi->m_videoRenderer->setupVoutWindow(nullptr);
-    p_mi->m_hasEmbededVideo = false;
-    emit p_mi->hasEmbededVideoChanged(false);
-}
-
-QQuickWindow*MainInterface::getRootQuickWindow()
-{
-    //FIXME, thread safety
-    QQuickItem* rootObject = mediacenterView->rootObject();
-    if (!rootObject)
-        return nullptr;
-    return rootObject->window();
+    emit askVideoOnTop( on_top );
 }
 
 
@@ -723,14 +492,6 @@ const Qt::Key MainInterface::kc[10] =
     Qt::Key_B, Qt::Key_A
 };
 
-/**
- * Give the decorations of the Main Window a correct Name.
- * If nothing is given, set it to VLC...
- **/
-void MainInterface::setVLCWindowsTitle( const QString& aTitle )
-{
-    setWindowTitle( aTitle );
-}
 
 void MainInterface::showBuffering( float f_cache )
 {
@@ -738,18 +499,6 @@ void MainInterface::showBuffering( float f_cache )
     statusBar()->showMessage( amount, 1000 );
 }
 
-void MainInterface::getVideoSlot(bool fullscreen)
-{
-    setVideoFullScreen(fullscreen);
-}
-
-
-void MainInterface::releaseVideoSlot( void )
-{
-    setVideoOnTop( false );
-    setVideoFullScreen( false );
-}
-
 void MainInterface::setVideoSize(unsigned int w, unsigned int h)
 {
     if (!isFullScreen() && !isMaximized() )
diff --git a/modules/gui/qt/maininterface/main_interface.hpp b/modules/gui/qt/maininterface/main_interface.hpp
index a339b36c37..8566a471c8 100644
--- a/modules/gui/qt/maininterface/main_interface.hpp
+++ b/modules/gui/qt/maininterface/main_interface.hpp
@@ -77,21 +77,11 @@ public:
 
     static const QEvent::Type ToolbarsNeedRebuild;
 
-    /* Video requests from core */
-    bool getVideo( struct vout_window_t * );
-private:
-    bool m_hasEmbededVideo = false;
-    bool m_showRemainingTime = false;
-    VLCVarChoiceModel* m_extraInterfaces;
-    std::atomic_flag videoActive;
-    static int enableVideo( struct vout_window_t *,
-                            const struct vout_window_cfg_t * );
-    static void disableVideo( struct vout_window_t * );
-    static void releaseVideo( struct vout_window_t * );
-    static void resizeVideo( struct vout_window_t *, unsigned, unsigned );
-    static void requestVideoState( struct vout_window_t *, unsigned );
-    static void requestVideoWindowed( struct vout_window_t * );
-    static void requestVideoFullScreen( struct vout_window_t *, const char * );
+public:
+    void requestResizeVideo( unsigned, unsigned );
+    void requestVideoState( unsigned );
+    void requestVideoWindowed( );
+    void requestVideoFullScreen( const char * );
 
 public:
     /* Getters */
@@ -114,10 +104,7 @@ public:
     bool isPlaylistDocked() { return b_playlistDocked; }
     bool isPlaylistVisible() { return playlistVisible; }
     bool isInterfaceAlwaysOnTop() { return b_interfaceOnTop; }
-    bool hasEmbededVideo() { return m_hasEmbededVideo; }
-
     inline bool isShowRemainingTime() const  { return m_showRemainingTime; }
-    QList<QQmlError> qmlErrors() const;
 
     bool hasEmbededVideo() const;
     VideoSurfaceProvider* getVideoSurfaceProvider() const;
@@ -135,9 +122,6 @@ protected:
     void resizeWindow(int width, int height);
 
 protected:
-    /* Main Widgets Creation */
-    void createMainWidget( QSettings* );
-
     /* Systray */
     void createSystray();
     void initSystray();
@@ -159,9 +143,6 @@ protected:
     QString              input_name;
     QVBoxLayout         *mainLayout;
 
-    QQuickWidget        *mediacenterView;
-    QWidget             *mediacenterWrapper;
-
     /* Status Bar */
     QLabel              *nameLabel;
     QLabel              *cryptedLabel;
@@ -193,14 +174,14 @@ protected:
     bool                 b_hasMedialibrary = false;
     /* States */
     bool                 playlistVisible;       ///< Is the playlist visible ?
-//    bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
-//    bool                 b_visualSelectorEnabled;
 
     bool                 b_hasPausedWhenMinimized;
 
     static const Qt::Key kc[10]; /* easter eggs */
     int i_kc_offset;
 
+    VLCVarChoiceModel* m_extraInterfaces;
+
 public slots:
     void toggleUpdateSystrayMenu();
     void showUpdateSystrayMenu();
@@ -220,7 +201,6 @@ public slots:
     VLCVarChoiceModel* getExtraInterfaces();
 
 protected slots:
-    void setVLCWindowsTitle( const QString& title = "" );
     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
     void updateSystrayTooltipName( const QString& );
     void updateSystrayTooltipStatus( PlayerController::PlayingState );
@@ -228,9 +208,6 @@ protected slots:
     void showBuffering( float );
 
     /* Manage the Video Functions from the vout threads */
-    void getVideoSlot( bool );
-    void releaseVideoSlot( void );
-
     void setVideoSize(unsigned int w, unsigned int h);
     virtual void setVideoFullScreen( bool );
     void setVideoOnTop( bool );
@@ -242,8 +219,6 @@ protected slots:
     void sendHotkey(Qt::Key key, Qt::KeyboardModifiers modifiers );
 
 signals:
-    void askGetVideo( bool );
-    void askReleaseVideo( );
     void askVideoToResize( unsigned int, unsigned int );
     void askVideoSetFullScreen( bool );
     void askVideoOnTop( bool );
diff --git a/modules/gui/qt/qt.cpp b/modules/gui/qt/qt.cpp
index edecb4a588..9bab39e933 100644
--- a/modules/gui/qt/qt.cpp
+++ b/modules/gui/qt/qt.cpp
@@ -59,6 +59,7 @@ extern "C" char **environ;
 #include "dialogs/help/help.hpp"     /* Launch Update */
 #include "util/recents.hpp"          /* Recents Item destruction */
 #include "util/qvlcapp.hpp"     /* QVLCApplication definition */
+#include "maininterface/compositor.hpp"
 
 #include <QVector>
 #include "playlist/playlist_item.hpp"
@@ -561,6 +562,8 @@ static void *Thread( void *obj )
 
     Q_INIT_RESOURCE( vlc );
 
+    p_intf->p_sys->p_compositor = vlc::Compositor::createCompositor(p_intf);
+
 #if HAS_QT56
     QApplication::setAttribute( Qt::AA_EnableHighDpiScaling );
     QApplication::setAttribute( Qt::AA_UseHighDpiPixmaps );
@@ -637,25 +640,12 @@ static void *Thread( void *obj )
 
     if( !p_sys->b_isDialogProvider )
     {
-#ifdef _WIN32
-        p_mi = new MainInterfaceWin32( p_intf );
-#else
-        p_mi = new MainInterface( p_intf );
-#endif
+        p_mi = p_intf->p_sys->p_compositor->makeMainInterface();
         p_sys->p_mi = p_mi;
 
-        QList<QQmlError> qmlErrors = p_sys->p_mi->qmlErrors();
-        if( !qmlErrors.isEmpty() )
+        if (!p_mi)
         {
-            msg_Err( p_intf, "Missing qml modules: " );
-
-            for( QQmlError &qmlError : qmlErrors )
-                msg_Err( p_intf, "%s", qtu(qmlError.description()) );
-#ifdef QT_STATICPLUGIN
-            assert( !"Missing qml modules from qt contribs." );
-#else
-            msg_Err( p_intf, "Install missing modules using your packaging tool" );
-#endif
+            msg_Err(p_intf, "unable to create main interface");
             return ThreadCleanup( p_intf, true );
         }
 
@@ -750,13 +740,13 @@ static void *ThreadCleanup( intf_thread_t *p_intf, bool error )
             open_state = OPEN_STATE_INIT;
     }
 
-    if( p_sys->p_mi != NULL)
+    if (p_sys->p_compositor)
     {
-        MainInterface *p_mi = p_sys->p_mi;
-        p_sys->p_mi = NULL;
-        /* Destroy first the main interface because it is connected to some
-           slots in the MainInputManager */
-        delete p_mi;
+        p_sys->p_compositor->destroyMainInterface();
+        p_sys->p_mi = nullptr;
+
+        delete p_sys->p_compositor;
+        p_sys->p_compositor = nullptr;
     }
 
     /* */
@@ -831,8 +821,6 @@ static int WindowOpen( vout_window_t *p_wnd )
     if (unlikely(open_state != OPEN_STATE_OPENED))
         return VLC_EGENERIC;
 
-    MainInterface *p_mi = p_intf->p_sys->p_mi;
-
-    return p_mi->getVideo( p_wnd ) ? VLC_SUCCESS : VLC_EGENERIC;
+    return p_intf->p_sys->p_compositor->setupVoutWindow( p_wnd ) ? VLC_SUCCESS : VLC_EGENERIC;
 
 }
diff --git a/modules/gui/qt/qt.hpp b/modules/gui/qt/qt.hpp
index 2cccdce754..c8a2241782 100644
--- a/modules/gui/qt/qt.hpp
+++ b/modules/gui/qt/qt.hpp
@@ -62,9 +62,12 @@ enum{
 };
 
 namespace vlc {
+class Compositor;
+
 namespace playlist {
 class PlaylistControllerModel;
 }
+
 }
 class PlayerController;
 struct intf_sys_t
@@ -84,6 +87,7 @@ struct intf_sys_t
     vlc_player_t *p_player; /* player */
     vlc::playlist::PlaylistControllerModel* p_mainPlaylistController;
     PlayerController* p_mainPlayerController;
+    vlc::Compositor*  p_compositor;
 
 #ifdef _WIN32
     bool disable_volume_keys;
-- 
2.25.1



More information about the vlc-devel mailing list