[vlc-commits] qt: move the MediaLib instance to the MainInterface
Pierre Lamot
git at videolan.org
Thu Oct 29 09:08:31 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Oct 14 15:52:45 2020 +0200| [8d81679b1088c58f13c910d1aa2421935ceb0277] | committer: Pierre Lamot
qt: move the MediaLib instance to the MainInterface
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8d81679b1088c58f13c910d1aa2421935ceb0277
---
modules/gui/qt/maininterface/main_interface.cpp | 6 +++++-
modules/gui/qt/maininterface/main_interface.hpp | 4 ++++
modules/gui/qt/maininterface/mainui.cpp | 2 +-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/modules/gui/qt/maininterface/main_interface.cpp b/modules/gui/qt/maininterface/main_interface.cpp
index 1216e28902..287cee774d 100644
--- a/modules/gui/qt/maininterface/main_interface.cpp
+++ b/modules/gui/qt/maininterface/main_interface.cpp
@@ -138,7 +138,11 @@ 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);
+ vlc_medialibrary_t* ml = vlc_ml_instance_get( p_intf );
+ b_hasMedialibrary = (ml != NULL);
+ if (b_hasMedialibrary) {
+ m_medialib = new MediaLib(p_intf, this);
+ }
/* 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 1522bd4f3d..4ec9c3a04e 100644
--- a/modules/gui/qt/maininterface/main_interface.hpp
+++ b/modules/gui/qt/maininterface/main_interface.hpp
@@ -29,6 +29,7 @@
#include "widgets/native/qvlcframe.hpp"
#include "player/player_controller.hpp"
#include "util/color_scheme_model.hpp"
+#include "medialibrary/medialib.hpp"
#include <QSystemTrayIcon>
#include <QStackedWidget>
@@ -150,6 +151,7 @@ class MainInterface : public QVLCMW
Q_PROPERTY(VLCVarChoiceModel* extraInterfaces READ getExtraInterfaces CONSTANT)
Q_PROPERTY(float intfScaleFactor READ getIntfScaleFactor NOTIFY intfScaleFactorChanged)
Q_PROPERTY(bool mediaLibraryAvailable READ hasMediaLibrary CONSTANT)
+ Q_PROPERTY(MediaLib* mediaLibrary READ getMediaLibrary CONSTANT)
Q_PROPERTY(bool gridView READ hasGridView WRITE setGridView NOTIFY gridViewChanged)
Q_PROPERTY(ColorSchemeModel* colorScheme READ getColorScheme CONSTANT)
Q_PROPERTY(bool hasVLM READ hasVLM CONSTANT)
@@ -189,6 +191,7 @@ public:
inline bool isShowRemainingTime() const { return m_showRemainingTime; }
inline float getIntfScaleFactor() const { return m_intfScaleFactor; }
inline bool hasMediaLibrary() const { return b_hasMedialibrary; }
+ inline MediaLib* getMediaLibrary() const { return m_medialib; }
inline bool hasGridView() const { return m_gridView; }
inline ColorSchemeModel* getColorScheme() const { return m_colorScheme; }
bool hasVLM() const;
@@ -255,6 +258,7 @@ protected:
bool b_hasWayland;
#endif
bool b_hasMedialibrary;
+ MediaLib* m_medialib = nullptr;
bool m_gridView;
ColorSchemeModel* m_colorScheme;
bool m_clientSideDecoration = false;
diff --git a/modules/gui/qt/maininterface/mainui.cpp b/modules/gui/qt/maininterface/mainui.cpp
index a9b911ed5d..d17992484e 100644
--- a/modules/gui/qt/maininterface/mainui.cpp
+++ b/modules/gui/qt/maininterface/mainui.cpp
@@ -99,7 +99,7 @@ bool MainUI::setup(QQmlEngine* engine)
rootCtx->setContextProperty( "systemPalette", new SystemPalette(this));
if (m_mainInterface->hasMediaLibrary())
- rootCtx->setContextProperty( "medialib", new MediaLib(m_intf, this) );
+ rootCtx->setContextProperty( "medialib", m_mainInterface->getMediaLibrary() );
else
rootCtx->setContextProperty( "medialib", nullptr );
More information about the vlc-commits
mailing list