[vlc-devel] [PATCH 18/19] qt: add explore function to playlist controller
Fatih Uzunoglu
fuzun54 at outlook.com
Wed Aug 12 23:17:25 CEST 2020
---
.../gui/qt/playlist/playlist_controller.cpp | 28 +++++++++++++++++++
.../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);
--
2.25.1
More information about the vlc-devel
mailing list