diff --git a/modules/gui/qt/medialibrary/mlvideo.cpp b/modules/gui/qt/medialibrary/mlvideo.cpp index cd87a96c114842a52d09d79ca7f15c3850f28248..acedfd8f9be8a1f118128d455e8dc138d4df2f2b 100644 --- a/modules/gui/qt/medialibrary/mlvideo.cpp +++ b/modules/gui/qt/medialibrary/mlvideo.cpp @@ -22,9 +22,8 @@ #include <vlc_thumbnailer.h> -VideoDescription::VideoDescription(const QString &codec, const QString &language, const unsigned int fps, QObject *parent) - : QObject(parent) - , m_codec(codec) +VideoDescription::VideoDescription(const QString &codec, const QString &language, const unsigned int fps) + : m_codec(codec) , m_language(language) , m_fps(fps) { @@ -45,9 +44,8 @@ unsigned int VideoDescription::getFps() const return m_fps; } -AudioDescription::AudioDescription(const QString &codec, const QString &language, const unsigned int nbChannels, const unsigned int sampleRate, QObject *parent) - : QObject(parent) - , m_codec(codec) +AudioDescription::AudioDescription(const QString &codec, const QString &language, const unsigned int nbChannels, const unsigned int sampleRate) + : m_codec(codec) , m_language(language) , m_nbchannels(nbChannels) , m_sampleRate(sampleRate) @@ -105,22 +103,20 @@ MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data, QObject* pa if ( track.i_type == VLC_ML_TRACK_TYPE_AUDIO ) { numChannel = std::max( numChannel , track.a.i_nbChannels ); - m_audioDesc.push_back( new AudioDescription ( QString::fromUtf8( track.psz_codec ) , - QString::fromUtf8( track.psz_language ) , - track.a.i_nbChannels , - track.a.i_sampleRate , - this ) - ); + m_audioDesc.push_back( { QString::fromUtf8( track.psz_codec ) , + QString::fromUtf8( track.psz_language ) , + track.a.i_nbChannels , + track.a.i_sampleRate } + ); } else if ( track.i_type == VLC_ML_TRACK_TYPE_VIDEO ){ maxWidth = std::max( maxWidth, track.v.i_width ); maxHeight = std::max( maxHeight, track.v.i_height ); - m_videoDesc.push_back( new VideoDescription( QString::fromUtf8( track.psz_codec ) , - QString::fromUtf8( track.psz_language ) , - track.v.i_fpsNum, - this ) - ); + m_videoDesc.push_back( { QString::fromUtf8( track.psz_codec ) , + QString::fromUtf8( track.psz_language ) , + track.v.i_fpsNum } + ); } } @@ -228,12 +224,12 @@ QString MLVideo::getProgressTime() const return MsToString(m_duration * m_progress); } -QObjectList MLVideo::getVideoDesc() const +QList<VideoDescription> MLVideo::getVideoDesc() const { return m_videoDesc; } -QObjectList MLVideo::getAudioDesc() const +QList<AudioDescription> MLVideo::getAudioDesc() const { return m_audioDesc; } diff --git a/modules/gui/qt/medialibrary/mlvideo.hpp b/modules/gui/qt/medialibrary/mlvideo.hpp index 50c0712d745fa7459d794110d6029178ec12ce5b..58d105c3d33a06d8375bec00236ddb9dcc9e79e6 100644 --- a/modules/gui/qt/medialibrary/mlvideo.hpp +++ b/modules/gui/qt/medialibrary/mlvideo.hpp @@ -32,16 +32,17 @@ #include <functional> -class VideoDescription : public QObject +class VideoDescription { - Q_OBJECT + Q_GADGET Q_PROPERTY(QString codec READ getCodec CONSTANT) Q_PROPERTY(QString language READ getLanguage CONSTANT) Q_PROPERTY(unsigned int fps READ getFps CONSTANT) public: - VideoDescription(const QString& codec, const QString& language, unsigned int fps, QObject *parent = nullptr); + VideoDescription() = default; + VideoDescription(const QString& codec, const QString& language, unsigned int fps); QString getCodec() const; QString getLanguage() const; @@ -54,9 +55,11 @@ private: unsigned int m_fps; }; -class AudioDescription : public QObject +Q_DECLARE_METATYPE(VideoDescription) + +class AudioDescription { - Q_OBJECT + Q_GADGET Q_PROPERTY(QString codec READ getCodec CONSTANT) Q_PROPERTY(QString language READ getLanguage CONSTANT) @@ -64,7 +67,8 @@ class AudioDescription : public QObject Q_PROPERTY(unsigned int sampleRate READ getSampleRate CONSTANT) public: - AudioDescription(const QString& codec, const QString& language, unsigned int nbChannels, unsigned int sampleRate, QObject *parent = nullptr); + AudioDescription() = default; + AudioDescription(const QString& codec, const QString& language, unsigned int nbChannels, unsigned int sampleRate); QString getCodec() const; QString getLanguage() const; @@ -79,6 +83,8 @@ private: unsigned int m_sampleRate; }; +Q_DECLARE_METATYPE(AudioDescription) + class MLVideo : public QObject, public MLItem { Q_OBJECT @@ -97,8 +103,8 @@ public: float getProgress() const; unsigned int getPlayCount() const; QString getProgressTime() const; - QObjectList getAudioDesc() const; - QObjectList getVideoDesc() const; + QList<AudioDescription> getAudioDesc() const; + QList<VideoDescription> getVideoDesc() const; private: static void onMlEvent( void* data, const vlc_ml_event_t* event ); @@ -115,8 +121,8 @@ private: QString m_progressTime; unsigned int m_playCount; vlc_ml_thumbnail_status_t m_thumbnailStatus; - QObjectList m_audioDesc; - QObjectList m_videoDesc; + QList<AudioDescription> m_audioDesc; + QList<VideoDescription> m_videoDesc; std::unique_ptr<vlc_ml_event_callback_t, std::function<void(vlc_ml_event_callback_t*)>> m_ml_event_handle;