[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt/MLVideo: Add the 'fileName' property

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Oct 24 10:40:27 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
14a3c95f by Benjamin Arnaud at 2021-10-24T08:45:22+00:00
qt/MLVideo: Add the 'fileName' property

- - - - -
e265edd1 by Benjamin Arnaud at 2021-10-24T08:45:22+00:00
qt/MLVideoModel: Add the 'getVariantList' function

- - - - -
14014510 by Benjamin Arnaud at 2021-10-24T08:45:22+00:00
qml/VideoInfoExpandPanel: Fix behavior and content

- - - - -


7 changed files:

- modules/gui/qt/medialibrary/mlvideo.cpp
- modules/gui/qt/medialibrary/mlvideo.hpp
- modules/gui/qt/medialibrary/mlvideomodel.cpp
- modules/gui/qt/medialibrary/mlvideomodel.hpp
- modules/gui/qt/medialibrary/qml/MediaGroupList.qml
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml


Changes:

=====================================
modules/gui/qt/medialibrary/mlvideo.cpp
=====================================
@@ -93,6 +93,9 @@ MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data)
         {
             //FIXME should we store every mrl
             m_mrl = QUrl::fromEncoded(file.psz_mrl);
+
+            m_fileName = QUrl(m_mrl).fileName();
+
             break;
         }
 
@@ -160,6 +163,11 @@ void MLVideo::onMlEvent( const vlc_ml_event_t* event )
     vlc_ml_event_unregister_from_callback( m_ml, m_ml_event_handle.release() );
 }
 
+QString MLVideo::getFileName() const
+{
+    return m_fileName;
+}
+
 QString MLVideo::getTitle() const
 {
     return m_title;


=====================================
modules/gui/qt/medialibrary/mlvideo.hpp
=====================================
@@ -90,6 +90,7 @@ class MLVideo : public MLItem
 public:
     MLVideo(vlc_medialibrary_t *ml, const vlc_ml_media_t *data);
 
+    QString getFileName() const;
     QString getTitle() const;
     QString getThumbnail();
     int64_t getDuration() const;
@@ -108,6 +109,7 @@ private:
     void onMlEvent( const vlc_ml_event_t* event );
 
     vlc_medialibrary_t* m_ml;
+    QString m_fileName;
     QString m_title;
     QString m_thumbnail;
     int64_t m_duration;


=====================================
modules/gui/qt/medialibrary/mlvideomodel.cpp
=====================================
@@ -18,6 +18,19 @@
 
 #include "mlvideomodel.hpp"
 
+template<typename T>
+QVariantList getVariantList(const QList<T> & desc)
+{
+    QVariantList list;
+
+    for (const T & item : desc)
+    {
+        list.append(QVariant::fromValue(item));
+    }
+
+    return list;
+}
+
 QHash<QByteArray, vlc_ml_sorting_criteria_t> MLVideoModel::M_names_to_criteria = {
     {"id", VLC_ML_SORTING_DEFAULT},
     {"title", VLC_ML_SORTING_ALPHA},
@@ -39,6 +52,8 @@ QVariant MLVideoModel::data(const QModelIndex& index, int role) const
     {
         case VIDEO_ID:
             return QVariant::fromValue( video->getId() );
+        case VIDEO_FILENAME:
+            return QVariant::fromValue( video->getFileName() );
         case VIDEO_TITLE:
             return QVariant::fromValue( video->getTitle() );
         case VIDEO_THUMBNAIL:
@@ -58,9 +73,9 @@ QVariant MLVideoModel::data(const QModelIndex& index, int role) const
         case VIDEO_DISPLAY_MRL:
             return QVariant::fromValue( video->getDisplayMRL() );
         case VIDEO_VIDEO_TRACK:
-            return QVariant::fromValue( video->getVideoDesc() );
+            return getVariantList( video->getVideoDesc() );
         case VIDEO_AUDIO_TRACK:
-            return QVariant::fromValue( video->getAudioDesc() );
+            return getVariantList( video->getAudioDesc() );
         case VIDEO_TITLE_FIRST_SYMBOL:
             return QVariant::fromValue( getFirstSymbol( video->getTitle() ) );
 
@@ -73,6 +88,7 @@ QHash<int, QByteArray> MLVideoModel::roleNames() const
 {
     return {
         { VIDEO_ID, "id" },
+        { VIDEO_FILENAME, "fileName" },
         { VIDEO_TITLE, "title" },
         { VIDEO_THUMBNAIL, "thumbnail" },
         { VIDEO_DURATION, "duration" },


=====================================
modules/gui/qt/medialibrary/mlvideomodel.hpp
=====================================
@@ -38,6 +38,7 @@ class MLVideoModel : public MLBaseModel
 public:
     enum Role {
         VIDEO_ID = Qt::UserRole + 1,
+        VIDEO_FILENAME,
         VIDEO_TITLE,
         VIDEO_THUMBNAIL,
         VIDEO_DURATION,


=====================================
modules/gui/qt/medialibrary/qml/MediaGroupList.qml
=====================================
@@ -252,6 +252,8 @@ FocusScope {
 
                 x: 0
 
+                model: root.model
+
                 Navigation.parentItem: gridView
 
                 Navigation.upAction    : function() { gridView.retract() }


=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -210,6 +210,8 @@ FocusScope {
 
                 x: 0
 
+                model: root.model
+
                 Navigation.parentItem: gridView
 
                 Navigation.cancelAction: function() { gridView.retract() }


=====================================
modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
=====================================
@@ -139,7 +139,6 @@ FocusScope {
                 }
             }
 
-
             Column {
                 id: expand_infos_id
 
@@ -173,86 +172,92 @@ FocusScope {
                     width: parent.width
                 }
 
-                Row {
-                    width: parent.width
-                    topPadding: VLCStyle.margin_normal
-                    spacing: VLCStyle.margin_xlarge
+                Column {
+                    width: expand_infos_id.width
 
-                    Column {
-                        width: audioTrackInfo.visible ? expand_infos_id.width / 2 : expand_infos_id.width
+                    topPadding: VLCStyle.margin_normal
 
-                        Widgets.MenuCaption {
-                            text: "<b>" + i18n.qtr("File Name:") + "</b> " + expandRect.model.title
-                            width: parent.width
-                        }
+                    Widgets.MenuCaption {
+                        text: "<b>" + i18n.qtr("File Name:") + "</b> " + expandRect.model.fileName
+                        width: parent.width
+                    }
 
-                        Widgets.MenuCaption {
-                            text: "<b>" + i18n.qtr("Path:") + "</b> " + expandRect.model.display_mrl
-                            topPadding: VLCStyle.margin_xsmall
-                            width: parent.width
-                        }
+                    Widgets.MenuCaption {
+                        text: "<b>" + i18n.qtr("Path:") + "</b> " + expandRect.model.display_mrl
+                        topPadding: VLCStyle.margin_xsmall
+                        width: parent.width
+                    }
 
-                        MouseArea {
-                            width: childrenRect.width
-                            height: childrenRect.height
+                    MouseArea {
+                        width: childrenRect.width
+                        height: childrenRect.height
 
-                            onClicked: _showMoreInfo = !_showMoreInfo
+                        onClicked: _showMoreInfo = !_showMoreInfo
 
-                            Row {
-                                topPadding: VLCStyle.margin_large
-                                spacing: VLCStyle.margin_xsmall
+                        Row {
+                            topPadding: VLCStyle.margin_large
+                            spacing: VLCStyle.margin_xsmall
 
-                                Widgets.IconLabel {
-                                    text: VLCIcons.back
-                                    rotation: _showMoreInfo ? 270 : 90
+                            Widgets.IconLabel {
+                                text: VLCIcons.back
+                                rotation: _showMoreInfo ? 90 : 270
 
-                                    Behavior on rotation {
-                                        NumberAnimation {
-                                            duration: VLCStyle.duration_faster
-                                        }
+                                Behavior on rotation {
+                                    NumberAnimation {
+                                        duration: VLCStyle.duration_faster
                                     }
                                 }
+                            }
 
-                                Widgets.CaptionLabel {
-                                    text: _showMoreInfo ? i18n.qtr("View Less") : i18n.qtr("View More")
-                                    color: VLCStyle.colors.text
-                                }
+                            Widgets.CaptionLabel {
+                                text: _showMoreInfo ? i18n.qtr("View Less") : i18n.qtr("View More")
+                                color: VLCStyle.colors.text
                             }
                         }
+                    }
+                }
 
-                        Column {
-                            topPadding: VLCStyle.margin_xxlarge
-                            visible: _showMoreInfo && expandRect.model.videoDesc.length > 0
-                            opacity: visible ? 1 : 0
+                Row {
+                    width: parent.width
 
-                            Behavior on opacity {
-                                NumberAnimation {
-                                    duration: VLCStyle.duration_faster
-                                }
-                            }
+                    topPadding: VLCStyle.margin_normal
+
+                    spacing: VLCStyle.margin_xlarge
 
-                            Widgets.MenuCaption {
-                                text: i18n.qtr("Video track:")
-                                font.bold: true
-                                bottomPadding: VLCStyle.margin_small
+                    Column {
+                        id: videoTrackInfo
+
+                        visible: (_showMoreInfo && expandRect.model.videoDesc.length > 0)
+
+                        opacity: (visible) ? 1.0 : 0.0
+
+                        Behavior on opacity {
+                            NumberAnimation {
+                                duration: VLCStyle.duration_faster
                             }
+                        }
 
-                            Repeater {
-                                model: expandRect.model.videoDesc
+                        Widgets.MenuCaption {
+                            text: i18n.qtr("Video track")
+                            font.bold: true
+                            bottomPadding: VLCStyle.margin_small
+                        }
 
-                                delegate: Repeater {
-                                    model: [
-                                        {text: i18n.qtr("Codec:"), data: modelData.codec },
-                                        {text: i18n.qtr("Language:"), data: modelData.language },
-                                        {text: i18n.qtr("FPS:"), data: modelData.fps }
-                                    ]
+                        Repeater {
+                            model: expandRect.model.videoDesc
 
-                                    delegate: Widgets.MenuCaption {
-                                        text: modelData.text + " " + modelData.data
-                                        bottomPadding: VLCStyle.margin_xsmall
-                                    }
+                            delegate: Repeater {
+                                model: [
+                                    {text: i18n.qtr("Codec:"), data: modelData.codec },
+                                    {text: i18n.qtr("Language:"), data: modelData.language },
+                                    {text: i18n.qtr("FPS:"), data: modelData.fps }
+                                ]
 
+                                delegate: Widgets.MenuCaption {
+                                    text: modelData.text + " " + modelData.data
+                                    bottomPadding: VLCStyle.margin_xsmall
                                 }
+
                             }
                         }
                     }
@@ -260,8 +265,9 @@ FocusScope {
                     Column {
                         id: audioTrackInfo
 
-                        visible: _showMoreInfo && expandRect.model.audioDesc.length > 0
-                        opacity: visible ? 1 : 0
+                        visible: (_showMoreInfo && expandRect.model.audioDesc.length > 0)
+
+                        opacity: (visible) ? 1.0 : 0.0
 
                         Behavior on opacity {
                             NumberAnimation {
@@ -270,7 +276,7 @@ FocusScope {
                         }
 
                         Widgets.MenuCaption {
-                            text: i18n.qtr("Audio track:")
+                            text: i18n.qtr("Audio track")
                             font.bold: true
                             bottomPadding: VLCStyle.margin_small
                         }
@@ -291,7 +297,6 @@ FocusScope {
                                 }
                             }
                         }
-
                     }
                 }
             }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/44c2aa7bcb0804880ecd499393034b3185082b8a...1401451005828f94e7ab452780990079f14b386b

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




More information about the vlc-commits mailing list