[vlc-commits] qml: display user friendy url in Video detailed informations

Pierre Lamot git at videolan.org
Thu Feb 20 13:56:45 CET 2020


vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Feb 17 13:54:17 2020 +0100| [b053e60abda58aa42b5dac806e63cf80c586d8db] | committer: Jean-Baptiste Kempf

qml: display user friendy url in Video detailed informations

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b053e60abda58aa42b5dac806e63cf80c586d8db
---

 modules/gui/qt/medialibrary/mlvideo.cpp                  | 10 ++++++++--
 modules/gui/qt/medialibrary/mlvideo.hpp                  |  4 +++-
 modules/gui/qt/medialibrary/mlvideomodel.cpp             |  4 ++++
 modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml |  2 +-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/medialibrary/mlvideo.cpp b/modules/gui/qt/medialibrary/mlvideo.cpp
index df2968578b..a4452aac51 100644
--- a/modules/gui/qt/medialibrary/mlvideo.cpp
+++ b/modules/gui/qt/medialibrary/mlvideo.cpp
@@ -68,7 +68,7 @@ MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data, QObject* pa
         if( file.i_type == VLC_ML_FILE_TYPE_MAIN )
         {
             //FIXME should we store every mrl
-            m_mrl = QString::fromUtf8(file.psz_mrl);
+            m_mrl = QUrl::fromEncoded(file.psz_mrl);
             break;
         }
     char *psz_progress;
@@ -183,8 +183,14 @@ QString MLVideo::getDuration() const
 
 QString MLVideo::getMRL() const
 {
-    return m_mrl;
+    return m_mrl.toEncoded();
 }
+
+QString MLVideo::getDisplayMRL() const
+{
+    return m_mrl.toString(QUrl::PrettyDecoded | QUrl::RemoveUserInfo | QUrl::PreferLocalFile | QUrl::NormalizePathSegments);
+}
+
 QString MLVideo::getResolutionName() const
 {
     return m_resolution;
diff --git a/modules/gui/qt/medialibrary/mlvideo.hpp b/modules/gui/qt/medialibrary/mlvideo.hpp
index e42546644a..4644e3177a 100644
--- a/modules/gui/qt/medialibrary/mlvideo.hpp
+++ b/modules/gui/qt/medialibrary/mlvideo.hpp
@@ -41,6 +41,7 @@ class MLVideo : public QObject
     Q_PROPERTY(QString thumbnail READ getThumbnail NOTIFY onThumbnailChanged);
     Q_PROPERTY(QString duration READ getDuration CONSTANT);
     Q_PROPERTY(QString mrl READ getMRL CONSTANT);
+    Q_PROPERTY(QString displayMrl READ getDisplayMRL CONSTANT)
     Q_PROPERTY(float progress READ getProgress CONSTANT);
     Q_PROPERTY(unsigned int playCount READ getPlayCount CONSTANT);
     Q_PROPERTY(QString resolution_name READ getResolutionName CONSTANT);
@@ -59,6 +60,7 @@ public:
     QString getResolutionName() const;
     QString getChannel() const;
     QString getMRL() const;
+    QString getDisplayMRL() const;
     float getProgress() const;
     unsigned int getPlayCount() const;
     QString getProgressTime() const;
@@ -82,7 +84,7 @@ private:
     QString m_title;
     QString m_thumbnail;
     int64_t m_duration;
-    QString m_mrl;
+    QUrl m_mrl;
     QString m_resolution;
     QString m_channel;
     float m_progress;
diff --git a/modules/gui/qt/medialibrary/mlvideomodel.cpp b/modules/gui/qt/medialibrary/mlvideomodel.cpp
index 3338970730..4f303c6487 100644
--- a/modules/gui/qt/medialibrary/mlvideomodel.cpp
+++ b/modules/gui/qt/medialibrary/mlvideomodel.cpp
@@ -30,6 +30,7 @@ enum Role {
     VIDEO_RESOLUTION,
     VIDEO_CHANNEL,
     VIDEO_MRL,
+    VIDEO_DISPLAY_MRL,
     VIDEO_VIDEO_TRACK,
     VIDEO_AUDIO_TRACK,
 
@@ -75,6 +76,8 @@ QVariant MLVideoModel::data(const QModelIndex& index, int role) const
             return QVariant::fromValue( video->getChannel() );
         case VIDEO_MRL:
             return QVariant::fromValue( video->getMRL() );
+        case VIDEO_DISPLAY_MRL:
+            return QVariant::fromValue( video->getDisplayMRL() );
         case VIDEO_VIDEO_TRACK:
             return QVariant::fromValue( video->getVideoDesc() );
         case VIDEO_AUDIO_TRACK:
@@ -99,6 +102,7 @@ QHash<int, QByteArray> MLVideoModel::roleNames() const
         { VIDEO_RESOLUTION, "resolution_name" },
         { VIDEO_CHANNEL, "channel" },
         { VIDEO_MRL, "mrl" },
+        { VIDEO_DISPLAY_MRL, "display_mrl" },
         { VIDEO_AUDIO_TRACK, "audioDesc" },
         { VIDEO_VIDEO_TRACK, "videoDesc" },
         { VIDEO_TITLE_FIRST_SYMBOL, "title_first_symbol"},
diff --git a/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml b/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
index 845662edec..45e8002124 100644
--- a/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoInfoExpandPanel.qml
@@ -195,7 +195,7 @@ Widgets.NavigableFocusScope {
                             spacing: VLCStyle.margin_xsmall
                             model: [
                                 {text: i18n.qtr("File Name"),    data: expandRect.model.title, bold: true},
-                                {text: i18n.qtr("Path"),         data: expandRect.model.mrl},
+                                {text: i18n.qtr("Path"),         data: expandRect.model.display_mrl},
                                 {text: i18n.qtr("Length"),       data: expandRect.model.duration},
                                 {text: i18n.qtr("File size"),    data: ""},
                                 {text: i18n.qtr("Times played"), data: expandRect.model.playcount},



More information about the vlc-commits mailing list