[vlc-commits] [Git][videolan/vlc][master] 11 commits: qt: dialog provider sub-dialogs don't need to be singletons

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sat Sep 7 16:05:26 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
bffbee66 by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: dialog provider sub-dialogs don't need to be singletons

- - - - -
bcfec54b by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: separate model from view in UpdateDialog

this allows triggering the model without creating the dialog

- - - - -
ba794b0c by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: enforce strong types for OpenDialog tab and action flags

- - - - -
e3d45b34 by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: OpenDialog is always retrieved with b_rawInstance = false

no need to specify it explicitly

- - - - -
519cb4ad by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: remove redundant flag in OpenDialog

b_select is redundant with the ActionFlag

- - - - -
f68390fa by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: set action flag independently from constructor in OpenDialog

- - - - -
9c61a4f3 by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: OpenDialog is no longer a singleton

- - - - -
931093a6 by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: fix dialog leak in VLMDialog

- - - - -
97c656f3 by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: allow manually pushing errors in DialogErrorModel

- - - - -
23293fe0 by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: push preference save failure through the DialogErrorModel

- - - - -
cf2df443 by Pierre Lamot at 2024-09-07T15:52:25+00:00
qt: remove obsolete ErrorsDialog

errors are handled in the MessageDialog and in the Qml

- - - - -


29 changed files:

- modules/gui/qt/Makefile.am
- modules/gui/qt/dialogs/bookmarks/bookmarks.hpp
- modules/gui/qt/dialogs/dialogs/dialogmodel.cpp
- modules/gui/qt/dialogs/dialogs/dialogmodel.hpp
- modules/gui/qt/dialogs/dialogs_provider.cpp
- modules/gui/qt/dialogs/dialogs_provider.hpp
- modules/gui/qt/dialogs/epg/epg.hpp
- − modules/gui/qt/dialogs/errors/errors.cpp
- − modules/gui/qt/dialogs/errors/errors.hpp
- modules/gui/qt/dialogs/extended/extended.hpp
- modules/gui/qt/dialogs/firstrun/firstrunwizard.hpp
- modules/gui/qt/dialogs/gototime/gototime.hpp
- modules/gui/qt/dialogs/help/help.cpp
- modules/gui/qt/dialogs/help/help.hpp
- modules/gui/qt/dialogs/mediainfo/mediainfo.hpp
- modules/gui/qt/dialogs/messages/messages.hpp
- modules/gui/qt/dialogs/open/open.cpp
- modules/gui/qt/dialogs/open/open.hpp
- modules/gui/qt/dialogs/playlists/playlists.hpp
- modules/gui/qt/dialogs/plugins/plugins.hpp
- modules/gui/qt/dialogs/podcast/podcast_configuration.hpp
- modules/gui/qt/dialogs/preferences/preferences.cpp
- modules/gui/qt/dialogs/vlm/vlm.cpp
- modules/gui/qt/dialogs/vlm/vlm.hpp
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/meson.build
- modules/gui/qt/qt.cpp
- po/POTFILES.in


Changes:

=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -97,7 +97,6 @@ libqt_plugin_la_SOURCES = \
 	dialogs/epg/EPGWidget.cpp \
 	dialogs/epg/EPGWidget.hpp \
 	dialogs/epg/epg.cpp dialogs/epg/epg.hpp \
-	dialogs/errors/errors.cpp dialogs/errors/errors.hpp \
 	dialogs/extended/extended.cpp dialogs/extended/extended.hpp \
 	dialogs/extended/extended_panels.cpp \
 	dialogs/extended/extended_panels.hpp \
@@ -372,7 +371,6 @@ nodist_libqt_plugin_la_SOURCES = \
 	dialogs/epg/EPGView.moc.cpp \
 	dialogs/epg/EPGWidget.moc.cpp \
 	dialogs/epg/epg.moc.cpp \
-	dialogs/errors/errors.moc.cpp \
 	dialogs/extended/extended.moc.cpp \
 	dialogs/extended/extended_panels.moc.cpp \
 	dialogs/extensions/extensions.moc.cpp \


=====================================
modules/gui/qt/dialogs/bookmarks/bookmarks.hpp
=====================================
@@ -25,21 +25,23 @@
 #define QVLC_BOOKMARKS_H_ 1
 
 #include "widgets/native/qvlcframe.hpp"
-#include "util/singleton.hpp"
 
 class QPushButton;
 class MLBookmarkModel;
 class QTreeView;
 
-class BookmarksDialog : public QVLCFrame, public Singleton<BookmarksDialog>
+class BookmarksDialog : public QVLCFrame
 {
     Q_OBJECT
+
 public:
-    void toggleVisible();
-private:
     BookmarksDialog( qt_intf_t * );
     virtual ~BookmarksDialog();
 
+public:
+    void toggleVisible();
+
+private:
     QTreeView *bookmarksList;
     QPushButton *clearButton;
     QPushButton *delButton;
@@ -53,8 +55,6 @@ private slots:
     void extract();
     void activateItem( const QModelIndex& index );
     void updateButtons();
-
-    friend class    Singleton<BookmarksDialog>;
 };
 
 #endif


=====================================
modules/gui/qt/dialogs/dialogs/dialogmodel.cpp
=====================================
@@ -99,6 +99,14 @@ void DialogErrorModel::onError(void * p_data,
     });
 }
 
+void DialogErrorModel::pushError(const QString & title, const QString& message)
+{
+    DialogError error;
+    error.title = title;
+    error.text = message;
+    pushError(error);
+}
+
 void DialogErrorModel::pushError(const DialogError & error)
 {
     int row = m_data.count();


=====================================
modules/gui/qt/dialogs/dialogs/dialogmodel.hpp
=====================================
@@ -92,6 +92,10 @@ public: // QAbstractItemModel implementation
 public: // QAbstractItemModel reimplementation
     QHash<int, QByteArray> roleNames() const override;
 
+public slots:
+    ///manually push an error
+    void pushError(const QString & title, const QString& message);
+
 private: // Functions
     void pushError(const DialogError & error);
 


=====================================
modules/gui/qt/dialogs/dialogs_provider.cpp
=====================================
@@ -54,7 +54,6 @@
 #include "dialogs/podcast/podcast_configuration.hpp"
 #include "dialogs/plugins/plugins.hpp"
 #include "dialogs/epg/epg.hpp"
-#include "dialogs/errors/errors.hpp"
 #include "dialogs/playlists/playlists.hpp"
 #include "dialogs/firstrun/firstrunwizard.hpp"
 
@@ -79,27 +78,6 @@ DialogsProvider::DialogsProvider( qt_intf_t *_p_intf )
 
 DialogsProvider::~DialogsProvider()
 {
-    MediaInfoDialog::killInstance();
-    MessagesDialog::killInstance();
-    BookmarksDialog::killInstance();
-#ifdef ENABLE_VLM
-    VLMDialog::killInstance();
-#endif
-    HelpDialog::killInstance();
-#ifdef UPDATE_CHECK
-    UpdateDialog::killInstance();
-#endif
-    PluginDialog::killInstance();
-    EpgDialog::killInstance();
-    PlaylistsDialog::killInstance();
-    ExtendedDialog::killInstance();
-    GotoTimeDialog::killInstance();
-    AboutDialog::killInstance();
-    PodcastConfigDialog::killInstance();
-    OpenDialog::killInstance();
-    ErrorsDialog::killInstance();
-    FirstRunWizard::killInstance();
-
     /* free parentless menus  */
     VLCMenuBar::freeRendererMenu();
 }
@@ -269,79 +247,76 @@ void DialogsProvider::prefsDialog()
 
 void DialogsProvider::firstRunDialog()
 {
-    FirstRunWizard *p = FirstRunWizard::getInstance( p_intf );
-    QVLCDialog::setWindowTransientParent(p, nullptr, p_intf);
-    p->show();
+    ensureDialog(m_firstRunDialog);
+    QVLCDialog::setWindowTransientParent(m_firstRunDialog.get(), nullptr, p_intf);
+    m_firstRunDialog->show();
 }
 
 void DialogsProvider::extendedDialog()
 {
-    ExtendedDialog *extDialog = ExtendedDialog::getInstance(p_intf );
-
-    if( !extDialog->isVisible() || /* Hidden */
-        extDialog->currentTab() != 0 )  /* wrong tab */
-        extDialog->showTab( 0 );
+    ensureDialog(m_extendedDialog);
+    if( !m_extendedDialog->isVisible() || /* Hidden */
+        m_extendedDialog->currentTab() != 0 )  /* wrong tab */
+        m_extendedDialog->showTab( 0 );
     else
-        extDialog->hide();
+        m_extendedDialog->hide();
 }
 
 void DialogsProvider::synchroDialog()
 {
-    ExtendedDialog *extDialog = ExtendedDialog::getInstance(p_intf );
-
-    if( !extDialog->isVisible() || /* Hidden */
-        extDialog->currentTab() != 2 )  /* wrong tab */
-        extDialog->showTab( 2 );
+    ensureDialog(m_extendedDialog);
+    if( !m_extendedDialog->isVisible() || /* Hidden */
+        m_extendedDialog->currentTab() != 2 )  /* wrong tab */
+        m_extendedDialog->showTab( 2 );
     else
-        extDialog->hide();
+        m_extendedDialog->hide();
 }
 
 void DialogsProvider::messagesDialog(int page)
 {
-    MessagesDialog *msgDialog = MessagesDialog::getInstance( p_intf );
-
-    if(!msgDialog->isVisible() || page)
-        msgDialog->showTab(page);
+    ensureDialog(m_messagesDialog);
+    if(!m_messagesDialog->isVisible() || page)
+        m_messagesDialog->showTab(page);
     else
-        msgDialog->toggleVisible();
+        m_messagesDialog->toggleVisible();
 }
 
 void DialogsProvider::gotoTimeDialog()
 {
-    GotoTimeDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_vlmDialog);
 }
 
 #ifdef ENABLE_VLM
 void DialogsProvider::vlmDialog()
 {
-    VLMDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_vlmDialog);
 }
 #endif
 
 void DialogsProvider::helpDialog()
 {
-    HelpDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_helpDialog);
 }
 
 #ifdef UPDATE_CHECK
 void DialogsProvider::updateDialog()
 {
-    UpdateDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_updateDialog);
 }
 #endif
 
 void DialogsProvider::aboutDialog()
 {
-    AboutDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_aboutDialog);
 }
 
 void DialogsProvider::mediaInfoDialog( void )
 {
-    MediaInfoDialog *dialog = MediaInfoDialog::getInstance( p_intf );
-    if( !dialog->isVisible() || dialog->currentTab() != MediaInfoDialog::META_PANEL )
-        dialog->showTab( MediaInfoDialog::META_PANEL );
+    ensureDialog(m_mediaInfoDialog);
+    if( !m_mediaInfoDialog->isVisible() || m_mediaInfoDialog->currentTab() != MediaInfoDialog::META_PANEL )
+        m_mediaInfoDialog->showTab( MediaInfoDialog::META_PANEL );
     else
-        dialog->hide();
+        m_mediaInfoDialog->hide();
 }
 
 void DialogsProvider::mediaInfoDialog( const SharedInputItem& inputItem )
@@ -425,48 +400,49 @@ void DialogsProvider::mediaInfoDialog( const MLItemId& itemId )
 
 void DialogsProvider::mediaCodecDialog()
 {
-    MediaInfoDialog *dialog = MediaInfoDialog::getInstance( p_intf );
-    if( !dialog->isVisible() || dialog->currentTab() != MediaInfoDialog::INFO_PANEL )
-        dialog->showTab( MediaInfoDialog::INFO_PANEL );
+    ensureDialog(m_mediaInfoDialog);
+
+    if( !m_mediaInfoDialog->isVisible() || m_mediaInfoDialog->currentTab() != MediaInfoDialog::INFO_PANEL )
+        m_mediaInfoDialog->showTab( MediaInfoDialog::INFO_PANEL );
     else
-        dialog->hide();
+        m_mediaInfoDialog->hide();
 }
 
 void DialogsProvider::playlistsDialog()
 {
-    PlaylistsDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_playlistDialog);
 }
 
 void DialogsProvider::playlistsDialog( const QVariantList & medias )
 {
-    PlaylistsDialog * dialog = PlaylistsDialog::getInstance( p_intf );
+    ensureDialog(m_playlistDialog);
 
-    dialog->setMedias(medias);
+    m_playlistDialog->setMedias(medias);
 
-    dialog->show();
+    m_playlistDialog->show();
 
     // FIXME: We shouldn't have to call this on here.
-    dialog->getInstance( p_intf )->activateWindow();
+    m_playlistDialog->activateWindow();
 }
 
 void DialogsProvider::bookmarksDialog()
 {
-    BookmarksDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_bookmarkDialog);
 }
 
 void DialogsProvider::podcastConfigureDialog()
 {
-    PodcastConfigDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_podcastDialog);
 }
 
 void DialogsProvider::pluginDialog()
 {
-    PluginDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_pluginDialog);
 }
 
 void DialogsProvider::epgDialog()
 {
-    EpgDialog::getInstance( p_intf )->toggleVisible();
+    toggleDialogVisible(m_egpDialog);
 }
 
 void DialogsProvider::setPopupMenu()
@@ -549,36 +525,37 @@ void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
  * Open Dialog first - Simple Open then
  ****************************************************************************/
 
-void DialogsProvider::openDialog( int i_tab )
+void DialogsProvider::openDialog( OpenDialog::OpenTab i_tab )
 {
-    OpenDialog::getInstance(p_intf )->showTab( i_tab );
+    ensureDialog(m_openDialog);
+    m_openDialog->showTab( i_tab, OpenDialog::OPEN_AND_PLAY );
 }
 void DialogsProvider::openDialog()
 {
-    openDialog( OPEN_FILE_TAB );
+    openDialog( OpenDialog::OPEN_FILE_TAB );
 }
 void DialogsProvider::openFileDialog()
 {
-    openDialog( OPEN_FILE_TAB );
+    openDialog( OpenDialog::OPEN_FILE_TAB );
 }
 void DialogsProvider::openDiscDialog()
 {
-    openDialog( OPEN_DISC_TAB );
+    openDialog( OpenDialog::OPEN_DISC_TAB );
 }
 void DialogsProvider::openNetDialog()
 {
-    openDialog( OPEN_NETWORK_TAB );
+    openDialog( OpenDialog::OPEN_NETWORK_TAB );
 }
 void DialogsProvider::openCaptureDialog()
 {
-    openDialog( OPEN_CAPTURE_TAB );
+    openDialog( OpenDialog::OPEN_CAPTURE_TAB );
 }
 
 /* Same as the open one, but force the enqueue */
-void DialogsProvider::PLAppendDialog( int tab )
+void DialogsProvider::PLAppendDialog( OpenDialog::OpenTab tab )
 {
-    OpenDialog::getInstance(p_intf, false,
-                             OPEN_AND_ENQUEUE )->showTab( tab );
+    ensureDialog(m_openDialog);
+    m_openDialog->showTab( tab, OpenDialog::OPEN_AND_ENQUEUE );
 }
 
 /**
@@ -877,14 +854,14 @@ void DialogsProvider::streamingDialog(const QList<QUrl> &urls, bool b_stream )
 
 void DialogsProvider::openAndStreamingDialogs()
 {
-    OpenDialog::getInstance(p_intf, false, OPEN_AND_STREAM )
-                                ->showTab( OPEN_FILE_TAB );
+    ensureDialog(m_openDialog);
+    m_openDialog->showTab( OpenDialog::OPEN_FILE_TAB, OpenDialog::OPEN_AND_STREAM );
 }
 
 void DialogsProvider::openAndTranscodingDialogs()
 {
-    OpenDialog::getInstance(p_intf, false, OPEN_AND_SAVE )
-                                ->showTab( OPEN_FILE_TAB );
+    ensureDialog(m_openDialog);
+    m_openDialog->showTab( OpenDialog::OPEN_FILE_TAB, OpenDialog::OPEN_AND_SAVE );
 }
 
 void  DialogsProvider::loadMediaFile( const es_format_category_e category, const int filter , const QString &dialogTitle)
@@ -964,3 +941,18 @@ void DialogsProvider::sendKey( int key )
      // forward key to vlc core when not a key accelerator
      var_SetInteger( vlc_object_instance(p_intf), "key-pressed", key );
 }
+
+
+template<typename T>
+void DialogsProvider::ensureDialog(std::unique_ptr<T>& dialog)
+{
+    if (!dialog)
+        dialog = std::make_unique<T>(p_intf);
+}
+
+template<typename T>
+void DialogsProvider::toggleDialogVisible(std::unique_ptr<T>& dialog)
+{
+    ensureDialog(dialog);
+    dialog->toggleVisible();
+}


=====================================
modules/gui/qt/dialogs/dialogs_provider.hpp
=====================================
@@ -71,6 +71,22 @@ class QEvent;
 class QSignalMapper;
 class VLCMenuBar;
 
+class OpenDialog;
+class FirstRunWizard;
+class ExtendedDialog;
+class MessagesDialog;
+class GotoTimeDialog;
+class VLMDialog;
+class HelpDialog;
+class AboutDialog;
+class MediaInfoDialog;
+class PlaylistsDialog;
+class BookmarksDialog;
+class PodcastConfigDialog;
+class PluginDialog;
+class EpgDialog;
+class UpdateDialog;
+
 class DialogsProvider : public QObject, public Singleton<DialogsProvider>
 {
     Q_OBJECT
@@ -123,10 +139,34 @@ private:
     std::unique_ptr<QMenu> audioPopupMenu;
     std::unique_ptr<QMenu> miscPopupMenu;
 
+    std::unique_ptr<OpenDialog> m_openDialog;
+    std::unique_ptr<FirstRunWizard> m_firstRunDialog;
+    std::unique_ptr<ExtendedDialog> m_extendedDialog;
+    std::unique_ptr<MessagesDialog> m_messagesDialog;
+    std::unique_ptr<GotoTimeDialog> m_gotoTimeDialog;
+    std::unique_ptr<VLMDialog> m_vlmDialog;
+    std::unique_ptr<HelpDialog> m_helpDialog;
+    std::unique_ptr<AboutDialog> m_aboutDialog;
+    std::unique_ptr<MediaInfoDialog> m_mediaInfoDialog;
+    std::unique_ptr<PlaylistsDialog> m_playlistDialog;
+    std::unique_ptr<BookmarksDialog> m_bookmarkDialog;
+    std::unique_ptr<PodcastConfigDialog> m_podcastDialog;
+    std::unique_ptr<PluginDialog> m_pluginDialog;
+    std::unique_ptr<EpgDialog> m_egpDialog;
+#ifdef UPDATE_CHECK
+    std::unique_ptr<UpdateDialog> m_updateDialog;
+#endif
+
+
     QWidget* root;
     bool b_isDying;
 
-    void openDialog( int );
+    void openDialog( OpenDialog::OpenTab );
+
+    template<typename T>
+    inline void ensureDialog(std::unique_ptr<T>& dialog);
+    template<typename T>
+    void toggleDialogVisible(std::unique_ptr<T>& dialog);
 
 public slots:
     void playlistsDialog();
@@ -169,8 +209,6 @@ public slots:
     void openNetDialog();
     void openCaptureDialog();
 
-    void PLAppendDialog( int tab = OPEN_FILE_TAB );
-
     void PLOpenDir();
     void PLAppendDir();
 
@@ -188,6 +226,9 @@ public slots:
 
     void quit();
 
+public:
+    void PLAppendDialog( OpenDialog::OpenTab tab = OpenDialog::OPEN_FILE_TAB );
+
 signals:
     void releaseMouseEvents();
     void showToolbarEditorDialog();


=====================================
modules/gui/qt/dialogs/epg/epg.hpp
=====================================
@@ -25,31 +25,28 @@
 
 #include "widgets/native/qvlcframe.hpp"
 
-#include "util/singleton.hpp"
-
 class QLabel;
 class QTextEdit;
 class QTimer;
 class EPGItem;
 class EPGWidget;
 
-class EpgDialog : public QVLCFrame, public Singleton<EpgDialog>
+class EpgDialog : public QVLCFrame
 {
     Q_OBJECT
-protected:
-    void showEvent(QShowEvent * event) override;
+public:
 
-private:
     EpgDialog( qt_intf_t * );
     virtual ~EpgDialog();
 
+protected:
+    void showEvent(QShowEvent * event) override;
+
     EPGWidget *epg;
     QTextEdit *description;
     QLabel *title;
     QTimer *timer;
 
-    friend class    Singleton<EpgDialog>;
-
 private slots:
     void scheduleUpdate();
     void inputChanged();


=====================================
modules/gui/qt/dialogs/errors/errors.cpp deleted
=====================================
@@ -1,105 +0,0 @@
-/*****************************************************************************
- * errors.cpp : Errors
- ****************************************************************************
- * Copyright ( C ) 2006 the VideoLAN team
- *
- * Authors: Clément Stenac <zorglub at videolan.org>
- *          Jean-Baptiste Kempf <jb at videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * ( at your option ) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "errors.hpp"
-
-#include <QTextCursor>
-#include <QTextEdit>
-#include <QCheckBox>
-#include <QGridLayout>
-#include <QDialogButtonBox>
-#include <QPushButton>
-
-#include <vlc_configuration.h>
-
-ErrorsDialog::ErrorsDialog( qt_intf_t *_p_intf )
-             : QVLCDialog( nullptr, _p_intf )
-{
-    setWindowTitle( qtr( "Errors" ) );
-    setWindowRole( "vlc-errors" );
-    resize( 500 , 300 );
-
-    QGridLayout *layout = new QGridLayout( this );
-
-    QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal, this );
-    QPushButton *clearButton = new QPushButton( qtr( "Cl&ear" ), this );
-    buttonBox->addButton( clearButton, QDialogButtonBox::ActionRole );
-    buttonBox->addButton( new QPushButton( qtr("&Close"), this ), QDialogButtonBox::RejectRole );
-
-    messages = new QTextEdit();
-    messages->setReadOnly( true );
-    messages->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
-    stopShowing = new QCheckBox( qtr( "Hide future errors" ) );
-    stopShowing->setChecked( var_InheritBool( p_intf, "qt-error-dialogs" ) );
-
-    layout->addWidget( messages, 0, 0, 1, 3 );
-    layout->addWidget( stopShowing, 1, 0 );
-    layout->addWidget( buttonBox, 1, 2 );
-
-    connect( buttonBox, &QDialogButtonBox::rejected, this, &ErrorsDialog::close );
-    BUTTONACT( clearButton, &ErrorsDialog::clear );
-    BUTTONACT( stopShowing, &ErrorsDialog::dontShow );
-}
-
-void ErrorsDialog::addError( const QString& title, const QString& text )
-{
-    add( true, title, text );
-}
-
-/*void ErrorsDialog::addWarning( QString title, QString text )
-{
-    add( false, title, text );
-}*/
-
-void ErrorsDialog::add( bool error, const QString& title, const QString& text )
-{
-    messages->textCursor().movePosition( QTextCursor::End );
-    messages->setTextColor( error ? "red" : "yellow" );
-    messages->insertPlainText( title + QString( ":\n" ) );
-    messages->setTextColor( "black" );
-    messages->insertPlainText( text + QString( "\n" ) );
-    messages->ensureCursorVisible();
-    if ( var_InheritBool( p_intf, "qt-error-dialogs" ) )
-        show();
-}
-
-void ErrorsDialog::close()
-{
-    hide();
-}
-
-void ErrorsDialog::clear()
-{
-    messages->clear();
-}
-
-void ErrorsDialog::dontShow()
-{
-    if( stopShowing->isChecked() )
-    {
-        config_PutInt( "qt-error-dialogs", 0 );
-    }
-}


=====================================
modules/gui/qt/dialogs/errors/errors.hpp deleted
=====================================
@@ -1,54 +0,0 @@
-/*****************************************************************************
- * errors.hpp : Errors
- ****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
- *
- * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifndef QVLC_ERRORS_DIALOG_H_
-#define QVLC_ERRORS_DIALOG_H_ 1
-
-#include "widgets/native/qvlcframe.hpp"
-#include "util/singleton.hpp"
-
-class QCheckBox;
-class QTextEdit;
-
-class ErrorsDialog : public QVLCDialog, public Singleton<ErrorsDialog>
-{
-    Q_OBJECT
-public:
-
-    void addError( const QString&, const QString& );
-    /*void addWarning( QString, QString );*/
-private:
-    virtual ~ErrorsDialog() {}
-    ErrorsDialog( qt_intf_t * );
-    void add( bool, const QString&, const QString& );
-
-    QCheckBox *stopShowing;
-    QTextEdit *messages;
-private slots:
-    void close();
-    void clear();
-    void dontShow();
-
-    friend class    Singleton<ErrorsDialog>;
-};
-
-#endif


=====================================
modules/gui/qt/dialogs/extended/extended.hpp
=====================================
@@ -26,12 +26,11 @@
 #include "widgets/native/qvlcframe.hpp"
 
 #include "extended_panels.hpp"
-#include "util/singleton.hpp"
 #include "player/player_controller.hpp"
 
 class QTabWidget;
 
-class ExtendedDialog : public QVLCDialog, public Singleton<ExtendedDialog>
+class ExtendedDialog : public QVLCDialog
 {
     Q_OBJECT
 public:
@@ -44,10 +43,12 @@ public:
     };
     void showTab( int i );
     int currentTab();
-private:
+
+public:
     ExtendedDialog( qt_intf_t * );
     virtual ~ExtendedDialog();
 
+private:
     SyncControls *syncW;
     ExtVideo *videoEffect;
     Equalizer *equal;
@@ -60,8 +61,6 @@ private slots:
     void saveConfig();
     void putAudioConfig( const QString& name, const QVariant value );
     void putVideoConfig( const QString& name, const QVariant value );
-
-    friend class    Singleton<ExtendedDialog>;
 };
 
 #endif


=====================================
modules/gui/qt/dialogs/firstrun/firstrunwizard.hpp
=====================================
@@ -20,17 +20,17 @@
 #define VLC_FIRSTRUNWIZARD_H
 
 #include "ui_firstrunwizard.h"
-#include "util/singleton.hpp"
 
 #include <QWizard>
 
 class MLFoldersEditor;
 class MLFoldersModel;
 
-class FirstRunWizard : public QWizard, public Singleton<FirstRunWizard>
+class FirstRunWizard : public QWizard
 {
     Q_OBJECT
-private:
+
+public:
     explicit FirstRunWizard ( qt_intf_t*, QWidget* parent = nullptr );
     enum { WELCOME_PAGE, FOLDER_PAGE, COLOR_SCHEME_PAGE, LAYOUT_PAGE };
     enum { MODERN, CLASSIC };
@@ -61,8 +61,6 @@ private slots:
     void updateLayoutLabel (QAbstractButton* );
     void imageColorSchemeClick ( QAbstractButton* );
     void imageLayoutClick( QAbstractButton* );
-
-    friend class Singleton<FirstRunWizard>;
 };
 
 #endif // VLC_FIRSTRUNWIZARD_H


=====================================
modules/gui/qt/dialogs/gototime/gototime.hpp
=====================================
@@ -24,25 +24,25 @@
 #define QVLC_GOTOTIME_DIALOG_H_ 1
 
 #include "widgets/native/qvlcframe.hpp"
-#include "util/singleton.hpp"
 
 class QTimeEdit;
 
-class GotoTimeDialog : public QVLCDialog, public Singleton<GotoTimeDialog>
+class GotoTimeDialog : public QVLCDialog
 {
     Q_OBJECT
-private:
+public:
     GotoTimeDialog( qt_intf_t * );
     virtual ~GotoTimeDialog();
-    QTimeEdit *timeEdit;
+
+    void toggleVisible();
+
 private slots:
     void close() override;
     void cancel() override;
     void reset();
 
-    friend class    Singleton<GotoTimeDialog>;
-public:
-    void toggleVisible();
+private:
+    QTimeEdit *timeEdit = nullptr;
 };
 
 #endif


=====================================
modules/gui/qt/dialogs/help/help.cpp
=====================================
@@ -28,6 +28,7 @@
 #include "qt.hpp"
 #include "help.hpp"
 #include "util/qt_dirs.hpp"
+#include "maininterface/mainctx.hpp"
 
 #include <vlc_about.h>
 #include <vlc_intf_strings.h>
@@ -180,27 +181,131 @@ void AboutDialog::showEvent( QShowEvent *event )
 
 #ifdef UPDATE_CHECK
 
-/*****************************************************************************
- * UpdateDialog
- *****************************************************************************/
-/* callback to get information from the core */
-static void UpdateCallback( void *data, bool b_ret )
+struct UpdateModelPrivate
 {
-    UpdateDialog* UDialog = (UpdateDialog *)data;
-    QEvent* event;
+    Q_DECLARE_PUBLIC(UpdateModel)
+public:
+    UpdateModelPrivate(UpdateModel * pub)
+        : q_ptr(pub)
+    {
+    }
 
-    if( b_ret )
-        event = new QEvent( UpdateDialog::UDOkEvent );
-    else
-        event = new QEvent( UpdateDialog::UDErrorEvent );
+    update_t* m_update = nullptr;
+
+    update_release_t* m_release = nullptr;
+    UpdateModel::Status m_status = UpdateModel::Unchecked;
+
+    UpdateModel* q_ptr = nullptr;
+};
+
+static void UpdateCallback(void *data, bool b_ret)
+{
+    auto that = (UpdateModelPrivate*)data;
+    QMetaObject::invokeMethod(that->q_func(), [that, b_ret](){
+        if (!b_ret)
+        {
+            that->m_status = UpdateModel::CheckFailed;
+            that->m_release = nullptr;
+        }
+        else
+        {
+            bool needUpdate = update_NeedUpgrade( that->m_update );
+            if (!needUpdate)
+            {
+                that->m_status = UpdateModel::UpToDate;
+                that->m_release = nullptr;
+            }
+            else
+            {
+                that->m_status = UpdateModel::NeedUpdate;
+                that->m_release = update_GetRelease(that->m_update);
+            }
+        }
+        emit that->q_func()->updateStatusChanged();
+    });
+}
+
+UpdateModel::UpdateModel(qt_intf_t * p_intf)
+    : d_ptr(new UpdateModelPrivate(this))
+{
+    Q_D(UpdateModel);
+    d->m_update = update_New( p_intf );
+}
 
-    QApplication::postEvent( UDialog, event );
+UpdateModel::~UpdateModel()
+{
+    Q_D(UpdateModel);
+    update_Delete( d->m_update );
+}
+
+void UpdateModel::checkUpdate()
+{
+    Q_D(UpdateModel);
+    if (d->m_status == Checking)
+        return;
+    d->m_release = nullptr;
+    d->m_status = Checking;
+    emit updateStatusChanged();
+    update_Check( d->m_update, UpdateCallback, d );
+}
+
+bool UpdateModel::download(QString destDir)
+{
+    Q_D(UpdateModel);
+    if (d->m_status != NeedUpdate)
+        return false;
+    update_Download( d->m_update, qtu( destDir ) );
+    return true;
+}
+
+UpdateModel::Status UpdateModel::updateStatus() const
+{
+    Q_D(const UpdateModel);
+    return d->m_status;
+}
+
+int UpdateModel::getMajor() const
+{
+    Q_D(const UpdateModel);
+    if (!d->m_release) return 0;
+    return d->m_release->i_major;
+}
+int UpdateModel::getMinor() const
+{
+    Q_D(const UpdateModel);
+    if (!d->m_release) return 0;
+    return d->m_release->i_minor;
+}
+int UpdateModel::getRevision() const
+{
+    Q_D(const UpdateModel);
+    if (!d->m_release) return 0;
+    return d->m_release->i_revision;
+}
+int UpdateModel::getExtra() const
+{
+    Q_D(const UpdateModel);
+    if (!d->m_release) return 0;
+    return d->m_release->i_extra;
+}
+QString UpdateModel::getDescription() const
+{
+    Q_D(const UpdateModel);
+    if (!d->m_release) return 0;
+    return qfu( d->m_release->psz_desc );
+}
+QString UpdateModel::getUrl() const
+{
+    Q_D(const UpdateModel);
+    if (!d->m_release) return 0;
+    return qfu( d->m_release->psz_desc );
 }
 
-const QEvent::Type UpdateDialog::UDOkEvent =
-        (QEvent::Type)QEvent::registerEventType();
-const QEvent::Type UpdateDialog::UDErrorEvent =
-        (QEvent::Type)QEvent::registerEventType();
+
+
+/*****************************************************************************
+ * UpdateDialog
+ *****************************************************************************/
 
 UpdateDialog::UpdateDialog( qt_intf_t *_p_intf ) : QVLCFrame( _p_intf )
 {
@@ -219,40 +324,41 @@ UpdateDialog::UpdateDialog( qt_intf_t *_p_intf ) : QVLCFrame( _p_intf )
     setWindowTitle( qtr( "VLC media player updates" ) );
     setWindowRole( "vlc-update" );
 
-    BUTTONACT( recheckButton, &UpdateDialog::UpdateOrDownload );
+    BUTTONACT( recheckButton, &UpdateDialog::checkOrDownload );
     connect( ui.updateDialogButtonBox, &QDialogButtonBox::rejected, this, &UpdateDialog::close );
 
-    connect( ui.updateNotifyButtonBox, &QDialogButtonBox::accepted, this, &UpdateDialog::UpdateOrDownload );
+    connect( ui.updateNotifyButtonBox, &QDialogButtonBox::accepted, this, &UpdateDialog::checkOrDownload );
     connect( ui.updateNotifyButtonBox, &QDialogButtonBox::rejected, this, &UpdateDialog::close );
 
-    /* Create the update structure */
-    p_update = update_New( p_intf );
-    b_checked = false;
-
     setMinimumSize( 300, 300 );
     setMaximumSize( 500, 300 );
 
     restoreWidgetPosition( "Update", maximumSize() );
 
-    /* Check for updates */
-    UpdateOrDownload();
+    m_model = p_intf->p_mi->getUpdateModel();
+    connect(m_model, &UpdateModel::updateStatusChanged, this, &UpdateDialog::updateUI);
+    /* update status*/
+    updateUI();
 }
 
 UpdateDialog::~UpdateDialog()
 {
-    update_Delete( p_update );
     saveWidgetPosition( "Update" );
 }
 
 /* Check for updates */
-void UpdateDialog::UpdateOrDownload()
+void UpdateDialog::checkOrDownload()
 {
-    if( !b_checked )
+    switch (m_model->updateStatus()) {
+    case UpdateModel::Unchecked:
+    case UpdateModel::UpToDate:
+    case UpdateModel::CheckFailed:
     {
         ui.stackedWidget->setCurrentWidget( ui.updateRequestPage );
-        update_Check( p_update, UpdateCallback, this );
+        m_model->checkUpdate();
+        break;
     }
-    else
+    case UpdateModel::NeedUpdate:
     {
         QString dest_dir = QDir::tempPath();
         if( !dest_dir.isEmpty() )
@@ -260,67 +366,65 @@ void UpdateDialog::UpdateOrDownload()
             dest_dir = toNativeSepNoSlash( dest_dir ) + DIR_SEP;
             msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) );
             toggleVisible();
-            update_Download( p_update, qtu( dest_dir ) );
+            m_model->download(dest_dir);
             /* FIXME: We should trigger a change to another dialog here ! */
         }
+        break;
+    }
+    default: // Checking
+        break;
     }
-}
-
-/* Handle the events */
-void UpdateDialog::customEvent( QEvent *event )
-{
-    if( event->type() == UDOkEvent )
-        updateNotify( true );
-    else
-        updateNotify( false );
 }
 
 /* Notify the end of the update_Check */
-void UpdateDialog::updateNotify( bool b_result )
+void UpdateDialog::updateUI( )
 {
-    /* The update finish without errors */
-    if( b_result )
+    switch (m_model->updateStatus()) {
+    case UpdateModel::NeedUpdate:
     {
-        if( update_NeedUpgrade( p_update ) )
-        {
-            ui.stackedWidget->setCurrentWidget( ui.updateNotifyPage );
-            update_release_t *p_release = update_GetRelease( p_update );
-            assert( p_release );
-            b_checked = true;
-            QString message = QString(
-                    qtr( "A new version of VLC (%1.%2.%3%4) is available." ) )
-                .arg( QString::number( p_release->i_major ) )
-                .arg( QString::number( p_release->i_minor ) )
-                .arg( QString::number( p_release->i_revision ) )
-                .arg( p_release->i_extra == 0 ? "" : "." + QString::number( p_release->i_extra ) );
-
-            ui.updateNotifyLabel->setText( message );
-            message = qfu( p_release->psz_desc ).replace( "\n", "<br/>" );
-
-            /* Try to highlight releases featuring security changes */
-            int i_index = message.indexOf( "security", Qt::CaseInsensitive );
-            if ( i_index >= 0 )
-            {
-                message.insert( i_index + 8, "</font>" );
-                message.insert( i_index, "<font style=\"color:red\">" );
-            }
-            ui.updateNotifyTextEdit->setHtml( message );
-
-            /* Force the dialog to be shown */
-            this->show();
-        }
-        else
+        ui.stackedWidget->setCurrentWidget( ui.updateNotifyPage );
+        int extra = m_model->getExtra();
+        QString message = QString(
+                              qtr( "A new version of VLC (%1.%2.%3%4) is available." ) )
+                              .arg( m_model->getMajor() )
+                              .arg( m_model->getMinor() )
+                              .arg( m_model->getRevision()  )
+                              .arg( extra == 0 ? "" : "." + QString::number( extra ) );
+
+        ui.updateNotifyLabel->setText( message );
+        message = m_model->getDescription().replace( "\n", "<br/>" );
+
+        /* Try to highlight releases featuring security changes */
+        int i_index = message.indexOf( "security", Qt::CaseInsensitive );
+        if ( i_index >= 0 )
         {
-            ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
-            ui.updateDialogLabel->setText(
-                    qtr( "You have the latest version of VLC media player." ) );
+            message.insert( i_index + 8, "</font>" );
+            message.insert( i_index, "<font style=\"color:red\">" );
         }
+        ui.updateNotifyTextEdit->setHtml( message );
+        break;
     }
-    else
+    case UpdateModel::UpToDate:
     {
         ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
         ui.updateDialogLabel->setText(
-                    qtr( "An error occurred while checking for updates..." ) );
+            qtr( "You have the latest version of VLC media player." ) );
+        break;
+    }
+    case UpdateModel::CheckFailed:
+    {
+        ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
+        ui.updateDialogLabel->setText(
+            qtr( "An error occurred while checking for updates..." ) );
+        break;
+    }
+    case UpdateModel::Checking:
+    {
+        ui.stackedWidget->setCurrentWidget( ui.updateDialogPage );
+        ui.updateDialogLabel->setText(
+            qtr( "Checking for updates..." ) );
+        break;
+    }
     }
 }
 


=====================================
modules/gui/qt/dialogs/help/help.hpp
=====================================
@@ -38,28 +38,22 @@
 
 class QEvent;
 
-class HelpDialog : public QVLCFrame, public Singleton<HelpDialog>
+class HelpDialog : public QVLCFrame
 {
     Q_OBJECT
-private:
+public:
     HelpDialog( qt_intf_t * );
     virtual ~HelpDialog();
 
 public slots:
     void close() override { toggleVisible(); }
-
-    friend class    Singleton<HelpDialog>;
 };
 
-class AboutDialog : public QVLCDialog, public Singleton<AboutDialog>
+class AboutDialog : public QVLCDialog
 {
     Q_OBJECT
-private:
+public:
     AboutDialog( qt_intf_t * );
-    Ui::aboutWidget ui;
-
-public slots:
-    friend class    Singleton<AboutDialog>;
 
 protected:
     bool eventFilter(QObject *obj, QEvent *event) override;
@@ -67,6 +61,7 @@ protected:
 
 private:
     bool b_advanced;
+    Ui::aboutWidget ui;
 
 private slots:
     void showLicense();
@@ -76,29 +71,68 @@ private slots:
 
 #if defined(UPDATE_CHECK)
 
-class UpdateDialog : public QVLCFrame, public Singleton<UpdateDialog>
+class UpdateModelPrivate;
+class UpdateModel : public QObject
 {
     Q_OBJECT
+
+public:
+    enum Status {
+        Unchecked,
+        Checking,
+        UpToDate,
+        NeedUpdate,
+        CheckFailed
+    };
+    Q_ENUM(Status)
+
+    Q_PROPERTY(Status updateStatus READ updateStatus NOTIFY updateStatusChanged FINAL)
+    Q_PROPERTY(int major READ getMajor NOTIFY updateStatusChanged FINAL)
+    Q_PROPERTY(int minor READ getMinor NOTIFY updateStatusChanged FINAL)
+    Q_PROPERTY(int revision READ getRevision NOTIFY updateStatusChanged FINAL)
+    Q_PROPERTY(int extra READ getExtra NOTIFY updateStatusChanged FINAL)
+    Q_PROPERTY(QString description READ getDescription NOTIFY updateStatusChanged FINAL)
+    Q_PROPERTY(QString url READ getUrl NOTIFY updateStatusChanged FINAL)
+
 public:
-    static const QEvent::Type UDOkEvent;
-    static const QEvent::Type UDErrorEvent;
-    void updateNotify( bool );
+    explicit UpdateModel(qt_intf_t * p_intf);
+    ~UpdateModel();
+
+    Q_INVOKABLE void checkUpdate();
+
+    Q_INVOKABLE bool download(QString destDir);
+
+    Status updateStatus() const;
+    int getMajor() const;
+    int getMinor() const;
+    int getRevision() const;
+    int getExtra() const;
+    QString getDescription() const;
+    QString getUrl() const;
+
+signals:
+    void updateStatusChanged();
 
 private:
+    Q_DECLARE_PRIVATE(UpdateModel)
+    QScopedPointer<UpdateModelPrivate> d_ptr;
+};
+
+class UpdateDialog : public QVLCFrame
+{
+    Q_OBJECT
+public:
     UpdateDialog( qt_intf_t * );
     virtual ~UpdateDialog();
 
+private:
     Ui::updateWidget ui;
-    update_t *p_update;
-    void customEvent( QEvent * ) override;
-    bool b_checked;
+    UpdateModel* m_model = nullptr;
 
 private slots:
+    void checkOrDownload();
+    void updateUI();
     void close() override { toggleVisible(); }
-
-    void UpdateOrDownload();
-
-    friend class    Singleton<UpdateDialog>;
 };
 #endif
 


=====================================
modules/gui/qt/dialogs/mediainfo/mediainfo.hpp
=====================================
@@ -26,17 +26,17 @@
 
 #include "widgets/native/qvlcframe.hpp"
 #include "info_panels.hpp"
-#include "util/singleton.hpp"
 #include "util/shared_input_item.hpp"
 
 class QTabWidget;
 
-class MediaInfoDialog : public QVLCFrame, public Singleton<MediaInfoDialog>
+class MediaInfoDialog : public QVLCFrame
 {
     Q_OBJECT
 public:
     MediaInfoDialog( qt_intf_t *,
                      SharedInputItem input = {} );
+    virtual ~MediaInfoDialog();
 
     enum panel
     {
@@ -53,8 +53,6 @@ public:
 #endif
 
 private:
-    virtual ~MediaInfoDialog();
-
     bool isMainInputInfo;
 
     QTabWidget *infoTabW;
@@ -76,8 +74,6 @@ private slots:
     void saveMeta();
     void updateButtons( int i_tab );
     void updateURI( const QString& );
-
-    friend class    Singleton<MediaInfoDialog>;
 };
 
 #endif


=====================================
modules/gui/qt/dialogs/messages/messages.hpp
=====================================
@@ -24,7 +24,6 @@
 #define QVLC_MESSAGES_DIALOG_H_ 1
 
 #include "widgets/native/qvlcframe.hpp"
-#include "util/singleton.hpp"
 
 /* Auto-generated from .ui files */
 #include "ui_messages_panel.h"
@@ -35,13 +34,15 @@ class QTreeWidget;
 class QTreeWidgetItem;
 class MsgEvent;
 
-class MessagesDialog : public QVLCFrame, public Singleton<MessagesDialog>
+class MessagesDialog : public QVLCFrame
 {
     Q_OBJECT
-private:
+
+public:
     MessagesDialog( qt_intf_t * );
     virtual ~MessagesDialog();
 
+private:
     Ui::messagesPanelWidget ui;
     static void sinkMessage( void *, vlc_log_t *, unsigned );
     void customEvent( QEvent * );
@@ -65,7 +66,6 @@ private slots:
 private:
     void buildTree( QTreeWidgetItem *, vlc_object_t * );
 
-    friend class    Singleton<MessagesDialog>;
     QToolButton *updateButton;
     QMutex messageLocker;
 #ifndef NDEBUG


=====================================
modules/gui/qt/dialogs/open/open.cpp
=====================================
@@ -40,39 +40,9 @@
 # define DEBUG_QT 1
 #endif
 
-OpenDialog* OpenDialog::getInstance(  qt_intf_t *p_intf,
-        bool b_rawInstance, int _action_flag, bool b_selectMode )
-{
-    const auto instance = Singleton<OpenDialog>::getInstance(nullptr,
-                                                             p_intf,
-                                                             b_selectMode,
-                                                             _action_flag);
-
-    if( !b_rawInstance )
-    {
-        /* Request the instance but change small details:
-           - Button menu */
-        if( b_selectMode )
-            _action_flag = SELECT; /* This should be useless, but we never know
-                                      if the call is correct */
-        instance->setWindowModality( Qt::WindowModal );
-        instance->i_action_flag = _action_flag;
-        instance->setMenuAction();
-    }
-    return instance;
-}
-
-OpenDialog::OpenDialog( QWindow *parent,
-                        qt_intf_t *_p_intf,
-                        bool b_selectMode,
-                        int _action_flag )
+OpenDialog::OpenDialog(qt_intf_t *_p_intf, QWindow* parent )
     :  QVLCDialog( parent, _p_intf )
 {
-    i_action_flag = _action_flag;
-
-    if( b_selectMode ) /* Select mode */
-        i_action_flag = SELECT;
-
     /* Basic Creation of the Window */
     ui.setupUi( this );
     setWindowTitle( qtr( "Open Media" ) );
@@ -188,6 +158,14 @@ OpenDialog::OpenDialog( QWindow *parent,
     resize( getSettings()->value( "OpenDialog/size", QSize( 500, 400 ) ).toSize() );
 }
 
+void OpenDialog::setActionFlag(OpenDialog::ActionFlag flag)
+{
+    if (i_action_flag == flag)
+        return;
+    i_action_flag = flag;
+    setMenuAction();
+}
+
 /* Finish the dialog and decide if you open another one after */
 void OpenDialog::setMenuAction()
 {
@@ -245,8 +223,9 @@ QString OpenDialog::getOptions()
     return ui.advancedLineInput->text();
 }
 
-void OpenDialog::showTab( int i_tab )
+void OpenDialog::showTab( OpenDialog::OpenTab i_tab, OpenDialog::ActionFlag i_action )
 {
+    setActionFlag(i_action);
     if( i_tab == OPEN_CAPTURE_TAB ) captureOpenPanel->initialize();
     ui.Tab->setCurrentIndex( i_tab );
     show();
@@ -282,10 +261,10 @@ void OpenDialog::browseInputSlave()
 {
     QWidget* windowWidget = window();
     QWindow* parentWindow = windowWidget ? windowWidget->windowHandle() : nullptr;
-    OpenDialog *od = new OpenDialog( parentWindow, p_intf, true, SELECT );
-    od->exec();
-    ui.slaveText->setText( od->getMRL( false ) );
-    delete od;
+    OpenDialog od( p_intf, parentWindow );
+    od.setActionFlag(SELECT);
+    od.exec();
+    ui.slaveText->setText( od.getMRL( false ) );
 }
 
 /* Function called on signal currentChanged triggered */


=====================================
modules/gui/qt/dialogs/open/open.hpp
=====================================
@@ -36,41 +36,42 @@
 /* Auto-generated from .ui files */
 #include "ui_open.h"
 
-enum {
-    OPEN_FILE_TAB,
-    OPEN_DISC_TAB,
-    OPEN_NETWORK_TAB,
-    OPEN_CAPTURE_TAB,
-    OPEN_TAB_MAX
-};
-
-enum {
-    OPEN_AND_PLAY,
-    OPEN_AND_ENQUEUE,
-    OPEN_AND_STREAM,
-    OPEN_AND_SAVE,
-    SELECT              /* Special mode to select a MRL (for VLM or similar */
-};
-
-
 class QString;
 
-class OpenDialog : public QVLCDialog, public Singleton<OpenDialog>
+class OpenDialog : public QVLCDialog
 {
-    friend Singleton<OpenDialog>;
-
     Q_OBJECT
+
 public:
-    static OpenDialog * getInstance(qt_intf_t *p_intf,
-                                bool b_rawInstance = false, int _action_flag = 0,
-                                bool b_selectMode = false );
+    enum OpenTab {
+        OPEN_FILE_TAB,
+        OPEN_DISC_TAB,
+        OPEN_NETWORK_TAB,
+        OPEN_CAPTURE_TAB,
+        OPEN_TAB_MAX
+    };
+
+    enum ActionFlag {
+        OPEN_AND_PLAY,
+        OPEN_AND_ENQUEUE,
+        OPEN_AND_STREAM,
+        OPEN_AND_SAVE,
+        SELECT              /* Special mode to select a MRL (for VLM or similar */
+    };
 
-    void showTab( int = OPEN_FILE_TAB );
+
+public:
+    OpenDialog(qt_intf_t * , QWindow *parent = nullptr);
+    virtual ~OpenDialog();
+
+    void showTab( OpenDialog::OpenTab tab, OpenDialog::ActionFlag action );
     QString getMRL( bool b = true );
 
     QStringList getMRLs();
     QString getOptions();
 
+    void setActionFlag(ActionFlag action_flag);
+
 public slots:
     void selectSlots();
     void play();
@@ -79,10 +80,6 @@ public slots:
     void transcode();
 
 private:
-    OpenDialog( QWindow *parent, qt_intf_t *, bool b_selectMode,
-                int _action_flag = 0 );
-    virtual ~OpenDialog();
-
     QString optionsMRL;
     QString storedMethod;
     QStringList itemsMRL;
@@ -93,7 +90,7 @@ private:
     DiscOpenPanel *discOpenPanel;
     CaptureOpenPanel *captureOpenPanel;
 
-    int i_action_flag;
+    ActionFlag i_action_flag = OPEN_AND_PLAY;
     QStringList SeparateEntries( const QString& );
 
     QPushButton *cancelButton, *selectButton;


=====================================
modules/gui/qt/dialogs/playlists/playlists.hpp
=====================================
@@ -25,7 +25,6 @@
 
 // VLC includes
 #include <widgets/native/qvlcframe.hpp>
-#include <util/singleton.hpp>
 
 // Forward declarations
 class MLPlaylistListModel;
@@ -34,11 +33,11 @@ class QLineEdit;
 class QLabel;
 class QPushButton;
 
-class PlaylistsDialog : public QVLCFrame, public Singleton<PlaylistsDialog>
+class PlaylistsDialog : public QVLCFrame
 {
     Q_OBJECT
 
-private: // Ctor / dtor
+public: // Ctor / dtor
     PlaylistsDialog(qt_intf_t *);
 
     ~PlaylistsDialog() override;
@@ -70,9 +69,6 @@ private:
     QLabel * m_label;
 
     QPushButton * m_button;
-
-private:
-    friend class Singleton<PlaylistsDialog>;
 };
 
 #endif


=====================================
modules/gui/qt/dialogs/plugins/plugins.hpp
=====================================
@@ -24,7 +24,6 @@
 #define QVLC_PLUGIN_DIALOG_H_ 1
 
 #include "widgets/native/qvlcframe.hpp"
-#include "util/singleton.hpp"
 
 #include <QStringList>
 #include <QTreeWidgetItem>
@@ -60,20 +59,19 @@ extern "C" {
     typedef struct extension_t extension_t;
 };
 
-class PluginDialog : public QVLCFrame, public Singleton<PluginDialog>
+class PluginDialog : public QVLCFrame
 {
     Q_OBJECT
 
-private:
+public:
     PluginDialog( qt_intf_t * );
     virtual ~PluginDialog();
 
+private:
     QTabWidget *tabs;
     PluginTab *pluginTab;
     ExtensionTab *extensionTab;
     AddonsTab *addonsTab;
-
-    friend class Singleton<PluginDialog>;
 };
 
 class PluginTab : public QVLCFrame


=====================================
modules/gui/qt/dialogs/podcast/podcast_configuration.hpp
=====================================
@@ -29,21 +29,21 @@
 /* Auto-generated from .ui files */
 #include "ui_podcast_configuration.h"
 
-class PodcastConfigDialog : public QVLCDialog, public Singleton<PodcastConfigDialog>
+class PodcastConfigDialog : public QVLCDialog
 {
     Q_OBJECT
 
-private:
+public:
     PodcastConfigDialog( qt_intf_t * );
     virtual ~PodcastConfigDialog();
 
-    Ui::PodcastConfiguration ui;
 public slots:
     void accept();
     void add();
     void remove();
 
-    friend class    Singleton<PodcastConfigDialog>;
+private:
+    Ui::PodcastConfiguration ui;
 };
 
 #endif


=====================================
modules/gui/qt/dialogs/preferences/preferences.cpp
=====================================
@@ -26,11 +26,12 @@
 #endif
 
 #include "dialogs/preferences/preferences.hpp"
-#include "dialogs/errors/errors.hpp"
 
 #include "expert_view.hpp"
 #include "dialogs/preferences/complete_preferences.hpp"
 #include "dialogs/preferences/simple_preferences.hpp"
+#include "dialogs/dialogs/dialogmodel.hpp"
+#include "dialogs/dialogs_provider.hpp"
 #include "widgets/native/searchlineedit.hpp"
 #include "widgets/native/qvlcframe.hpp"
 #include "maininterface/mainctx.hpp"
@@ -353,8 +354,18 @@ void PrefsDialog::save()
     /* Save to file */
     if( config_SaveConfigFile( p_intf ) != 0 )
     {
-        ErrorsDialog::getInstance (p_intf)->addError( qtr( "Cannot save Configuration" ),
-            qtr("Preferences file could not be saved") );
+        DialogErrorModel::getInstance(p_intf)->pushError(
+            qtr( "Cannot save Configuration" ),
+            qtr("Preferences file could not be saved")
+        );
+        if (p_intf->b_isDialogProvider)
+        {
+            //at this point we are closing the preference dialog which is modal,
+            //we need to postpone the dialog raising up
+            QMetaObject::invokeMethod(DialogsProvider::getInstance(), [](){
+                DialogsProvider::getInstance()->messagesDialog(1);
+            }, Qt::QueuedConnection);
+        }
     }
 
     if( p_intf->p_mi )


=====================================
modules/gui/qt/dialogs/vlm/vlm.cpp
=====================================
@@ -342,21 +342,24 @@ void VLMDialog::clearWidgets()
 
 void VLMDialog::selectInput()
 {
-    OpenDialog *o = OpenDialog::getInstance( p_intf, false, SELECT, true );
-    o->exec();
-    ui.inputLedit->setText( o->getMRL( false ) );
-    inputOptions = o->getOptions();
+    QWidget* windowWidget = window();
+    QWindow* parentWindow = windowWidget ? windowWidget->windowHandle() : nullptr;
+    OpenDialog o( p_intf, parentWindow );
+    o.setActionFlag(OpenDialog::SELECT);
+    o.exec();
+    ui.inputLedit->setText( o.getMRL( false ) );
+    inputOptions = o.getOptions();
 }
 
 void VLMDialog::selectOutput()
 {
     QWidget* windowWidget = window();
     QWindow* parentWindow = windowWidget ? windowWidget->windowHandle() : nullptr;
-    SoutDialog *s = new SoutDialog( parentWindow, p_intf );
-    if( s->exec() == QDialog::Accepted )
+    SoutDialog s( parentWindow, p_intf );
+    if( s.exec() == QDialog::Accepted )
     {
-        int i = s->getChain().indexOf( " " );
-        ui.outputLedit->setText( s->getChain().left( i ) );
+        int i = s.getChain().indexOf( " " );
+        ui.outputLedit->setText( s.getChain().left( i ) );
     }
 }
 


=====================================
modules/gui/qt/dialogs/vlm/vlm.hpp
=====================================
@@ -34,7 +34,6 @@
 #include "ui_vlm.h"
 
 #include "widgets/native/qvlcframe.hpp"
-#include "util/singleton.hpp"
 #include <QDateTime>
 
 enum{
@@ -61,19 +60,20 @@ class VLMAWidget;
 class VLMWrapper;
 
 
-class VLMDialog : public QVLCFrame, public Singleton<VLMDialog>
+class VLMDialog : public QVLCFrame
 {
     Q_OBJECT
 
 public:
+    VLMDialog( qt_intf_t * );
+    virtual ~VLMDialog();
+
     void toggleVisible();
 
+
 private:
     VLMWrapper *vlm;
 
-    VLMDialog( qt_intf_t * );
-    virtual ~VLMDialog();
-
     Ui::Vlm ui;
 
     QString inputOptions;
@@ -102,8 +102,6 @@ private slots:
     void selectOutput();
     bool exportVLMConf();
     bool importVLMConf();
-
-    friend class    Singleton<VLMDialog>;
 };
 
 class VLMWrapper


=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -52,6 +52,7 @@
 #include "menus/menus.hpp"                            // Menu creation
 
 #include "dialogs/toolbar/controlbar_profile_model.hpp"
+#include "dialogs/help/help.hpp"
 
 #include <QKeyEvent>
 
@@ -216,6 +217,40 @@ MainCtx::MainCtx(qt_intf_t *_p_intf)
     {
         QMetaObject::invokeMethod(m_medialib, &MediaLib::reload, Qt::QueuedConnection);
     }
+
+
+#ifdef UPDATE_CHECK
+    /* Checking for VLC updates */
+    if( var_InheritBool( p_intf, "qt-updates-notif" ) &&
+        !var_InheritBool( p_intf, "qt-privacy-ask" ) )
+    {
+        int interval = var_InheritInteger( p_intf, "qt-updates-days" );
+        if( QDate::currentDate() >
+            getSettings()->value( "updatedate" ).toDate().addDays( interval ) )
+        {
+            /* check for update at startup */
+            m_updateModel = std::make_unique<UpdateModel>(p_intf);
+            connect(m_updateModel.get(), &UpdateModel::updateStatusChanged, this, [this](){
+                switch (m_updateModel->updateStatus())
+                {
+                case UpdateModel::Checking:
+                case UpdateModel::Unchecked:
+                    break;
+                case UpdateModel::NeedUpdate:
+                    qWarning() << "Need Udpate";
+                    THEDP->updateDialog();
+                    [[fallthrough]];
+                case UpdateModel::UpToDate:
+                case UpdateModel::CheckFailed:
+                    disconnect(m_updateModel.get(), nullptr, this, nullptr);
+                    break;
+                }
+            });
+            m_updateModel->checkUpdate();
+            getSettings()->setValue( "updatedate", QDate::currentDate() );
+        }
+    }
+#endif
 }
 
 MainCtx::~MainCtx()
@@ -926,3 +961,12 @@ void MainCtx::setArtistAlbumsWidthFactor(double newArtistAlbumsWidthFactor)
     m_artistAlbumsWidthFactor = newArtistAlbumsWidthFactor;
     emit artistAlbumsWidthFactorChanged( m_artistAlbumsWidthFactor );
 }
+
+#ifdef UPDATE_CHECK
+UpdateModel* MainCtx::getUpdateModel() const
+{
+    if (!m_updateModel)
+        m_updateModel = std::make_unique<UpdateModel>(p_intf);
+    return m_updateModel.get();
+}
+#endif


=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -46,6 +46,9 @@ Q_MOC_INCLUDE( "util/csdbuttonmodel.hpp" )
 Q_MOC_INCLUDE( "playlist/playlist_controller.hpp" )
 Q_MOC_INCLUDE( "maininterface/mainctx_submodels.hpp" )
 Q_MOC_INCLUDE( "maininterface/videosurface.hpp" )
+#ifdef UPDATE_CHECK
+Q_MOC_INCLUDE( "dialogs/help/help.hpp" )
+#endif
 
 class CSDButtonModel;
 class QSettings;
@@ -69,6 +72,9 @@ class SearchCtx;
 class SortCtx;
 class WorkerThreadSet;
 class VLCSystray;
+#ifdef UPDATE_CHECK
+class UpdateModel;
+#endif
 
 namespace vlc {
 namespace playlist {
@@ -144,6 +150,10 @@ class MainCtx : public QObject
     Q_PROPERTY(SearchCtx* search MEMBER m_search CONSTANT FINAL)
     Q_PROPERTY(SortCtx* sort MEMBER m_sort CONSTANT FINAL)
 
+#ifdef UPDATE_CHECK
+    Q_PROPERTY(UpdateModel* updateModel READ getUpdateModel CONSTANT FINAL)
+#endif
+
 public:
     /* tors */
     MainCtx(qt_intf_t *);
@@ -295,6 +305,10 @@ public:
     double artistAlbumsWidthFactor() const;
     void setArtistAlbumsWidthFactor(double newArtistAlbumsWidthFactor);
 
+#ifdef UPDATE_CHECK
+    UpdateModel* getUpdateModel() const;
+#endif
+
 protected:
     /* Systray */
     void initSystray();
@@ -371,6 +385,11 @@ protected:
     SearchCtx* m_search = nullptr;
     SortCtx* m_sort = nullptr;
 
+#ifdef UPDATE_CHECK
+    //m_updateModel is created on first access
+    mutable std::unique_ptr<UpdateModel> m_updateModel;
+#endif
+
     mutable std::unique_ptr<WorkerThreadSet> m_workersThreads;
 
 public slots:


=====================================
modules/gui/qt/meson.build
=====================================
@@ -32,7 +32,6 @@ moc_headers = files(
     'dialogs/epg/EPGView.hpp',
     'dialogs/epg/EPGWidget.hpp',
     'dialogs/epg/epg.hpp',
-    'dialogs/errors/errors.hpp',
     'dialogs/extended/extended.hpp',
     'dialogs/extended/extended_panels.hpp',
     'dialogs/extensions/extensions.hpp',
@@ -206,8 +205,6 @@ some_sources = files(
     'dialogs/epg/EPGWidget.hpp',
     'dialogs/epg/epg.cpp',
     'dialogs/epg/epg.hpp',
-    'dialogs/errors/errors.cpp',
-    'dialogs/errors/errors.hpp',
     'dialogs/extended/extended.cpp',
     'dialogs/extended/extended.hpp',
     'dialogs/extended/extended_panels.cpp',


=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -1045,22 +1045,6 @@ static void *Thread( void *obj )
     /* Explain how to show a dialog :D */
     p_intf->pf_show_dialog = ShowDialog;
 
-#ifdef UPDATE_CHECK
-    /* Checking for VLC updates */
-    if( var_InheritBool( p_intf, "qt-updates-notif" ) &&
-        !var_InheritBool( p_intf, "qt-privacy-ask" ) )
-    {
-        int interval = var_InheritInteger( p_intf, "qt-updates-days" );
-        if( QDate::currentDate() >
-             getSettings()->value( "updatedate" ).toDate().addDays( interval ) )
-        {
-            /* The constructor of the update Dialog will do the 1st request */
-            UpdateDialog::getInstance( p_intf );
-            getSettings()->setValue( "updatedate", QDate::currentDate() );
-        }
-    }
-#endif
-
     /* Tell the main LibVLC thread we are ready */
     {
         vlc::threads::mutex_locker locker (lock);


=====================================
po/POTFILES.in
=====================================
@@ -684,8 +684,6 @@ modules/gui/qt/dialogs/epg/EPGWidget.cpp
 modules/gui/qt/dialogs/epg/EPGWidget.hpp
 modules/gui/qt/dialogs/epg/epg.cpp
 modules/gui/qt/dialogs/epg/epg.hpp
-modules/gui/qt/dialogs/errors/errors.cpp
-modules/gui/qt/dialogs/errors/errors.hpp
 modules/gui/qt/dialogs/extended/extended.cpp
 modules/gui/qt/dialogs/extended/extended.hpp
 modules/gui/qt/dialogs/extended/extended_panels.cpp



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ac0545c6c51e18d7b5faf5a1d55bdab7e0bd6ac9...cf2df44353e148cf39286d06ed78225091289cbf

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ac0545c6c51e18d7b5faf5a1d55bdab7e0bd6ac9...cf2df44353e148cf39286d06ed78225091289cbf
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list