[vlc-devel] [PATCH 01/18] qt: clean MainUI

Pierre Lamot pierre at videolabs.io
Wed Sep 23 14:27:35 CEST 2020


From: Fatih Uzunoglu <fuzun54 at outlook.com>

+ add mediaLibraryAvailable property to MainInterface
---
 .../gui/qt/maininterface/main_interface.cpp   |  4 ++
 .../gui/qt/maininterface/main_interface.hpp   |  2 +
 modules/gui/qt/maininterface/mainui.cpp       | 37 +------------------
 modules/gui/qt/maininterface/mainui.hpp       | 33 -----------------
 4 files changed, 8 insertions(+), 68 deletions(-)

diff --git a/modules/gui/qt/maininterface/main_interface.cpp b/modules/gui/qt/maininterface/main_interface.cpp
index 8e4d2f7baf..bfe239e4e1 100644
--- a/modules/gui/qt/maininterface/main_interface.cpp
+++ b/modules/gui/qt/maininterface/main_interface.cpp
@@ -48,6 +48,8 @@
 
 #include "menus/menus.hpp"                            // Menu creation
 
+#include "vlc_media_library.h"
+
 #include <QCloseEvent>
 #include <QKeyEvent>
 
@@ -136,6 +138,8 @@ MainInterface::MainInterface(intf_thread_t *_p_intf , QWidget* parent, Qt::Windo
     /* Get the available interfaces */
     m_extraInterfaces = new VLCVarChoiceModel(p_intf, "intf-add", this);
 
+    b_hasMedialibrary = (vlc_ml_instance_get( p_intf ) != NULL);
+
     /* Set the other interface settings */
     settings = getSettings();
 
diff --git a/modules/gui/qt/maininterface/main_interface.hpp b/modules/gui/qt/maininterface/main_interface.hpp
index 5739af44ee..e9c834c120 100644
--- a/modules/gui/qt/maininterface/main_interface.hpp
+++ b/modules/gui/qt/maininterface/main_interface.hpp
@@ -148,6 +148,7 @@ class MainInterface : public QVLCMW
     Q_PROPERTY(bool showRemainingTime READ isShowRemainingTime WRITE setShowRemainingTime NOTIFY showRemainingTimeChanged)
     Q_PROPERTY(VLCVarChoiceModel* extraInterfaces READ getExtraInterfaces CONSTANT)
     Q_PROPERTY(float intfScaleFactor READ getIntfScaleFactor NOTIFY intfScaleFactorChanged)
+    Q_PROPERTY(bool mediaLibraryAvailable READ hasMediaLibrary CONSTANT)
 
 public:
     /* tors */
@@ -181,6 +182,7 @@ public:
     inline bool isHideAfterCreation() const { return b_hideAfterCreation; }
     inline bool isShowRemainingTime() const  { return m_showRemainingTime; }
     inline float getIntfScaleFactor() const { return m_intfScaleFactor; }
+    inline bool hasMediaLibrary() const { return b_hasMedialibrary; }
 
     bool hasEmbededVideo() const;
     VideoSurfaceProvider* getVideoSurfaceProvider() const;
diff --git a/modules/gui/qt/maininterface/mainui.cpp b/modules/gui/qt/maininterface/mainui.cpp
index f371e4321e..da026c1408 100644
--- a/modules/gui/qt/maininterface/mainui.cpp
+++ b/modules/gui/qt/maininterface/mainui.cpp
@@ -68,19 +68,6 @@ MainUI::MainUI(intf_thread_t *p_intf, MainInterface *mainInterface,  QObject *pa
     assert(m_intf);
     assert(m_mainInterface);
 
-    m_settings = getSettings();
-
-    m_hasMedialibrary = (vlc_ml_instance_get( p_intf ) != NULL);
-
-    /* Get the available interfaces */
-    m_extraInterfaces = new VLCVarChoiceModel(p_intf, "intf-add", this);
-
-    /* playlist settings */
-    m_playlistDocked   = m_settings->value( "MainWindow/pl-dock-status", true ).toBool();
-    m_playlistVisible  = m_settings->value( "MainWindow/playlist-visible", false ).toBool();
-
-    m_showRemainingTime = m_settings->value( "MainWindow/ShowRemainingTime", false ).toBool();
-
     registerQMLTypes();
 }
 
@@ -107,7 +94,7 @@ bool MainUI::setup(QQmlEngine* engine)
     rootCtx->setContextProperty( "settings",  new Settings( m_intf, this ));
     rootCtx->setContextProperty( "systemPalette", new SystemPalette(this));
 
-    if (m_hasMedialibrary)
+    if (m_mainInterface->hasMediaLibrary())
         rootCtx->setContextProperty( "medialib", new MediaLib(m_intf, this) );
     else
         rootCtx->setContextProperty( "medialib", nullptr );
@@ -166,7 +153,7 @@ void MainUI::registerQMLTypes()
 
     qmlRegisterType<VideoSurface>("org.videolan.vlc", 0, 1, "VideoSurface");
 
-    if (m_hasMedialibrary)
+    if (m_mainInterface->hasMediaLibrary())
     {
         qRegisterMetaType<MLParentId>();
         qmlRegisterType<MLAlbumModel>( "org.videolan.medialib", 0, 1, "MLAlbumModel" );
@@ -219,23 +206,3 @@ void MainUI::onQmlWarning(const QList<QQmlError>& qmlErrors)
         msg_Warn( m_intf, "qml error %s:%i %s", qtu(error.url().toString()), error.line(), qtu(error.description()) );
     }
 }
-
-void MainUI::setPlaylistDocked( bool docked )
-{
-    m_playlistDocked = docked;
-
-    emit playlistDockedChanged(docked);
-}
-
-void MainUI::setPlaylistVisible( bool visible )
-{
-    m_playlistVisible = visible;
-
-    emit playlistVisibleChanged(visible);
-}
-
-void MainUI::setShowRemainingTime( bool show )
-{
-    m_showRemainingTime = show;
-    emit showRemainingTimeChanged(show);
-}
diff --git a/modules/gui/qt/maininterface/mainui.hpp b/modules/gui/qt/maininterface/mainui.hpp
index 3f18c25f70..08807d6550 100644
--- a/modules/gui/qt/maininterface/mainui.hpp
+++ b/modules/gui/qt/maininterface/mainui.hpp
@@ -18,12 +18,6 @@ class MainUI : public QObject
 {
     Q_OBJECT
 
-    Q_PROPERTY(bool playlistDocked READ isPlaylistDocked WRITE setPlaylistDocked NOTIFY playlistDockedChanged)
-    Q_PROPERTY(bool playlistVisible READ isPlaylistVisible WRITE setPlaylistVisible NOTIFY playlistVisibleChanged)
-    Q_PROPERTY(bool showRemainingTime READ isShowRemainingTime WRITE setShowRemainingTime NOTIFY showRemainingTimeChanged)
-
-    Q_PROPERTY(VLCVarChoiceModel* extraInterfaces READ getExtraInterfaces CONSTANT)
-
 public:
     explicit MainUI(intf_thread_t *_p_intf, MainInterface* mainInterface, QObject *parent = nullptr);
     ~MainUI();
@@ -34,22 +28,6 @@ public:
     VLC_USED
     QQuickItem* createRootItem();
 
-public slots:
-    inline bool isPlaylistDocked() const { return m_playlistDocked; }
-    inline bool isPlaylistVisible() const { return m_playlistVisible; }
-    inline bool isShowRemainingTime() const  { return m_showRemainingTime; }
-    inline VLCVarChoiceModel* getExtraInterfaces() const { return m_extraInterfaces; };
-
-    void setPlaylistDocked( bool );
-    void setPlaylistVisible( bool );
-    void setShowRemainingTime( bool );
-
-
-signals:
-    void playlistDockedChanged(bool);
-    void playlistVisibleChanged(bool);
-    void showRemainingTimeChanged(bool);
-
 private slots:
     void onQmlWarning(const QList<QQmlError>& errors);
 
@@ -59,19 +37,8 @@ private:
     intf_thread_t* m_intf = nullptr;
     MainInterface* m_mainInterface = nullptr;
 
-    QQmlEngine* m_engine = nullptr;
     QQmlComponent* m_component = nullptr;
     QQuickItem* m_rootItem = nullptr;
-
-    QSettings* m_settings = nullptr;
-
-    bool m_hasMedialibrary;
-
-    bool m_playlistDocked = false;
-    bool m_playlistVisible = false;
-    bool m_showRemainingTime = false;
-    VLCVarChoiceModel* m_extraInterfaces = nullptr;
-
 };
 
 #endif // MAINUI_HPP
-- 
2.25.1



More information about the vlc-devel mailing list