[vlc-commits] qt: add explore function to playlist controller

Fatih Uzunoglu git at videolan.org
Tue Aug 18 17:15:13 CEST 2020


vlc | branch: master | Fatih Uzunoglu <fuzun54 at outlook.com> | Thu Jul 30 20:42:50 2020 +0300| [1b95adaae51970753c10d929e9dba695ab6cfbbe] | committer: Pierre Lamot

qt: add explore function to playlist controller

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

 modules/gui/qt/playlist/playlist_controller.cpp | 28 +++++++++++++++++++++++++
 modules/gui/qt/playlist/playlist_controller.hpp |  1 +
 2 files changed, 29 insertions(+)

diff --git a/modules/gui/qt/playlist/playlist_controller.cpp b/modules/gui/qt/playlist/playlist_controller.cpp
index 9abc3725fe..4215e774e6 100644
--- a/modules/gui/qt/playlist/playlist_controller.cpp
+++ b/modules/gui/qt/playlist/playlist_controller.cpp
@@ -23,8 +23,10 @@
 #include "playlist_controller.hpp"
 #include "playlist_controller_p.hpp"
 #include "vlc_player.h"
+#include "vlc_url.h"
 #include <algorithm>
 #include <QVariant>
+#include <QDesktopServices>
 
 namespace vlc {
   namespace playlist {
@@ -461,6 +463,32 @@ void PlaylistControllerModel::sort(PlaylistControllerModel::SortKey key, Playlis
     sort( criteria );
 }
 
+void PlaylistControllerModel::explore(const PlaylistItem& pItem)
+{
+    vlc_playlist_item_t * const playlistItem = pItem.raw();
+    if( playlistItem )
+    {
+        input_item_t * const p_input = vlc_playlist_item_GetMedia(playlistItem);
+        char * const uri = input_item_GetURI(p_input);
+
+        if( uri && uri[0] != '\0')
+        {
+            char * const path = vlc_uri2path( uri );
+
+            if( !path )
+                return;
+
+            QUrl file = QUrl::fromLocalFile( QFileInfo(path).absolutePath() );
+            free( path );
+
+            if( !file.isLocalFile() )
+                return;
+
+            QDesktopServices::openUrl( file );
+        }
+    }
+}
+
 void PlaylistControllerModel::play()
 {
     Q_D(PlaylistControllerModel);
diff --git a/modules/gui/qt/playlist/playlist_controller.hpp b/modules/gui/qt/playlist/playlist_controller.hpp
index 238a26df8a..e411fcd747 100644
--- a/modules/gui/qt/playlist/playlist_controller.hpp
+++ b/modules/gui/qt/playlist/playlist_controller.hpp
@@ -108,6 +108,7 @@ public:
     Q_INVOKABLE void shuffle();
     void sort(const QVector<vlc_playlist_sort_criterion> &);
     Q_INVOKABLE void sort(SortKey key, SortOrder order);
+    Q_INVOKABLE void explore(const PlaylistItem& pItem);
 
 public:
     PlaylistControllerModel(QObject *parent = nullptr);



More information about the vlc-commits mailing list