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


Commits:
5f1e80b1 by Prince Gupta at 2024-03-23T14:35:07+00:00
qt: rename variable

- - - - -
69a44986 by Prince Gupta at 2024-03-23T14:35:07+00:00
qt: add 'currentIndex' property to PlaylistController

- - - - -
4cd7e935 by Prince Gupta at 2024-03-23T14:35:07+00:00
qml: add option to jump to playing in Playlist

- - - - -


5 changed files:

- modules/gui/qt/menus/qml_menu_wrapper.cpp
- modules/gui/qt/menus/qml_menu_wrapper.hpp
- modules/gui/qt/playlist/playlist_controller.cpp
- modules/gui/qt/playlist/playlist_controller.hpp
- modules/gui/qt/playlist/qml/PlaylistListView.qml


Changes:

=====================================
modules/gui/qt/menus/qml_menu_wrapper.cpp
=====================================
@@ -848,7 +848,7 @@ PlaylistContextMenu::PlaylistContextMenu(QObject* parent)
     : QObject(parent)
 {}
 
-void PlaylistContextMenu::popup(int currentIndex, QPoint pos )
+void PlaylistContextMenu::popup(int selectedIndex, QPoint pos )
 {
     if (!m_controler || !m_model || !m_selectionModel)
         return;
@@ -860,20 +860,26 @@ void PlaylistContextMenu::popup(int currentIndex, QPoint 
pos )
     for (const int modelIndex : m_selectionModel->selectedIndexesFlat())
         selectedUrlList.push_back(m_model->itemAt(modelIndex).getUrl());
 
-    PlaylistItem currentItem;
-    if (currentIndex >= 0)
-        currentItem = m_model->itemAt(currentIndex);
+    PlaylistItem selectedItem;
+    if (selectedIndex >= 0)
+        selectedItem = m_model->itemAt(selectedIndex);
 
-    if (currentItem)
+    if (selectedItem)
     {
         action = m_menu->addAction( qtr("Play") );
-        connect(action, &QAction::triggered, [this, currentIndex]( ) {
-            m_controler->goTo(currentIndex, true);
+        connect(action, &QAction::triggered, [this, selectedIndex]( ) {
+            m_controler->goTo(selectedIndex, true);
         });
 
         m_menu->addSeparator();
     }
 
+    if (m_controler->currentIndex() != -1)
+    {
+        action = m_menu->addAction( qtr("Jump to current playing"));
+        connect(action, &QAction::triggered, this, 
&PlaylistContextMenu::jumpToCurrentPlaying);
+    }
+
     if (m_selectionModel->hasSelection()) {
         action = m_menu->addAction( qtr("Stream") );
         connect(action, &QAction::triggered, [selectedUrlList]( ) {
@@ -888,19 +894,19 @@ void PlaylistContextMenu::popup(int currentIndex, QPoint 
pos )
         m_menu->addSeparator();
     }
 
-    if (currentItem) {
+    if (selectedItem) {
         action = m_menu->addAction( qtr("Information") );
         action->setIcon(QIcon(":/menu/info.svg"));
-        connect(action, &QAction::triggered, [currentItem]( ) {
-            DialogsProvider::getInstance()->mediaInfoDialog(currentItem);
+        connect(action, &QAction::triggered, [selectedItem]( ) {
+            DialogsProvider::getInstance()->mediaInfoDialog(selectedItem);
         });
 
         m_menu->addSeparator();
 
         action = m_menu->addAction( qtr("Show Containing Directory...") );
         action->setIcon(QIcon(":/menu/folder.svg"));
-        connect(action, &QAction::triggered, [this, currentItem]( ) {
-            m_controler->explore(currentItem);
+        connect(action, &QAction::triggered, [this, selectedItem]( ) {
+            m_controler->explore(selectedItem);
         });
 
         m_menu->addSeparator();


=====================================
modules/gui/qt/menus/qml_menu_wrapper.hpp
=====================================
@@ -378,6 +378,9 @@ class PlaylistContextMenu : public QObject {
 public:
     PlaylistContextMenu(QObject* parent = nullptr);
 
+signals:
+    void jumpToCurrentPlaying();
+
 public slots:
     void popup(int currentIndex, QPoint pos );
 private:


=====================================
modules/gui/qt/playlist/playlist_controller.cpp
=====================================
@@ -554,6 +554,12 @@ void PlaylistController::explore(const PlaylistItem& pItem)
     }
 }
 
+int PlaylistController::currentIndex() const
+{
+    Q_D(const PlaylistController);
+    return d->m_currentIndex;
+}
+
 void PlaylistController::play()
 {
     Q_D(PlaylistController);


=====================================
modules/gui/qt/playlist/playlist_controller.hpp
=====================================
@@ -105,6 +105,7 @@ public:
     Q_PROPERTY(SortKey sortKey READ getSortKey WRITE setSortKey NOTIFY 
sortKeyChanged FINAL)
     Q_PROPERTY(SortOrder sortOrder READ getSortOrder WRITE setSortOrder NOTIFY 
sortOrderChanged FINAL)
     Q_PROPERTY(MediaStopAction mediaStopAction READ getMediaStopAction WRITE 
setMediaStopAction NOTIFY mediaStopActionChanged FINAL)
+    Q_PROPERTY(int currentIndex READ currentIndex NOTIFY currentIndexChanged 
FINAL)
 
 
 public:
@@ -162,6 +163,7 @@ public slots:
 
     bool isEmpty() const;
     int count() const;
+    int currentIndex() const;
 
     SortKey getSortKey() const;
     void setSortKey(SortKey sortKey);


=====================================
modules/gui/qt/playlist/qml/PlaylistListView.qml
=====================================
@@ -137,6 +137,8 @@ T.Pane {
         model: root.model
         selectionModel: root.selectionModel
         controler: MainPlaylistController
+
+        onJumpToCurrentPlaying: listView.positionViewAtIndex( 
MainPlaylistController.currentIndex, ItemView.Center)
     }
 
     background: Widgets.AcrylicBackground {



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/3d8fa03b17d45769ca866adb97598ee977cff467...4cd7e935253548370fb8a561fe607329621cdec8

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/3d8fa03b17d45769ca866adb97598ee977cff467...4cd7e935253548370fb8a561fe607329621cdec8
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to