[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: add `inputItem()` method to PlaylistItem

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sat Jun 1 17:11:48 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
95d26c79 by Fatih Uzunoglu at 2024-06-01T16:58:54+00:00
qt: add `inputItem()` method to PlaylistItem

- - - - -
0d83ffab by Fatih Uzunoglu at 2024-06-01T16:58:54+00:00
qt: accept `PlaylistItem` in `vlc::playlist::toMediaList()`

- - - - -
29cde5f9 by Fatih Uzunoglu at 2024-06-01T16:58:54+00:00
qml: make ArtworkInfoWidget draggable

Dragging this toolbar control is now
possible and is equivalent to dragging
the current playlist item.

- - - - -


4 changed files:

- modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml
- modules/gui/qt/playlist/playlist_controller.cpp
- modules/gui/qt/playlist/playlist_item.cpp
- modules/gui/qt/playlist/playlist_item.hpp


Changes:

=====================================
modules/gui/qt/player/qml/controlbarcontrols/ArtworkInfoWidget.qml
=====================================
@@ -84,13 +84,42 @@ AbstractButton {
 
     onClicked: History.push(["player"])
 
+    // Children
+
+    Widgets.DragItem {
+        id: dragItem
+
+        onRequestData: (_, resolve, reject) => {
+            resolve([{
+                "title": Player.title,
+                "cover": (!!Player.artwork && Player.artwork.toString() !== "") ? Player.artwork
+                                                                                : VLCStyle.noArtAlbumCover
+            }])
+        }
+
+        onRequestInputItems: (indexes, data, resolve, reject) => {
+            resolve([MainPlaylistController.currentItem])
+        }
+
+        indexes: [0]
+    }
+
+    DragHandler {
+        target: null
+        onActiveChanged: {
+            if (active) {
+                dragItem.Drag.active = true
+            } else {
+                dragItem.Drag.drop()
+            }
+        }
+    }
+
     background: Widgets.AnimatedBackground {
         enabled: theme.initialized
         border.color: visualFocus ? theme.visualFocus : "transparent"
     }
 
-    // Children
-
     contentItem: RowLayout {
         spacing: VLCStyle.margin_xsmall
 


=====================================
modules/gui/qt/playlist/playlist_controller.cpp
=====================================
@@ -80,10 +80,15 @@ QVector<Media> toMediaList(const QVariantList &sources)
                 mrl = resolveWinSymlinks(mrl);
 
             return Media(mrl.toString(QUrl::FullyEncoded), mrl.fileName());
-        } else if (value.canConvert<SharedInputItem>())
+        }
+        else if (value.canConvert<SharedInputItem>())
         {
             return Media(value.value<SharedInputItem>().get());
         }
+        else if (value.canConvert<PlaylistItem>())
+        {
+            return Media(value.value<PlaylistItem>().inputItem());
+        }
         return Media{};
     });
 


=====================================
modules/gui/qt/playlist/playlist_item.cpp
=====================================
@@ -72,7 +72,8 @@ QUrl PlaylistItem::getUrl() const
 }
 
 void PlaylistItem::sync() {
-    input_item_t *media = vlc_playlist_item_GetMedia(d->item.get());
+    input_item_t *media = inputItem();
+    assert(media);
     vlc_mutex_locker locker(&media->lock);
     d->duration = media->i_duration;
     d->url      = media->psz_uri;


=====================================
modules/gui/qt/playlist/playlist_item.hpp
=====================================
@@ -64,6 +64,13 @@ public:
         return d ? d->item.get() : nullptr;
     }
 
+    input_item_t *inputItem() const {
+        if (const auto item = raw())
+            return vlc_playlist_item_GetMedia(item);
+        else
+            return nullptr;
+    }
+
     bool isSelected() const;
     void setSelected(bool selected);
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8fffc6e248d88104f338d26c64ef3a3c0c5e82bc...29cde5f95dc4bcac0c57a9f09a128768754a0253

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8fffc6e248d88104f338d26c64ef3a3c0c5e82bc...29cde5f95dc4bcac0c57a9f09a128768754a0253
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list