[vlc-commits] [Git][videolan/vlc][master] 6 commits: qt: rename role "album_id" to "album_id_serialized" in `MLAudioModel`

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Apr 29 03:26:57 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a0349660 by Fatih Uzunoglu at 2026-04-28T16:59:08+00:00
qt: rename role "album_id" to "album_id_serialized" in `MLAudioModel`

- - - - -
d298d7fe by Fatih Uzunoglu at 2026-04-28T16:59:08+00:00
qt: introduce role "album_id" in `MLAudioModel`

- - - - -
c1281d01 by Fatih Uzunoglu at 2026-04-28T16:59:08+00:00
qml: add action "Play as album" in `MLContextMenu`

- - - - -
ff38326f by Fatih Uzunoglu at 2026-04-28T16:59:08+00:00
qml: add action "Enqueue as album" in `MLContextMenu`

- - - - -
0402c27c by Fatih Uzunoglu at 2026-04-28T16:59:08+00:00
qml: disable enqueue and play as album actions when there is album header in `MusicArtist`

- - - - -
471e6c6c by Fatih Uzunoglu at 2026-04-28T16:59:08+00:00
qml: do not display album header if album sections is enabled in `MusicArtist`

This was shown even if the sections is turned off, because it
was the only way of playing or enqueuing the album.

Now that there are "Play as album" and "Enqueue as album"
actions in the context menu, we do not need to display the
album header.

Since the header is already too big, this releases some space
so that the user sees more view content at once.

- - - - -


4 changed files:

- modules/gui/qt/medialibrary/mlaudiomodel.cpp
- modules/gui/qt/medialibrary/mlaudiomodel.hpp
- modules/gui/qt/medialibrary/qml/MusicArtist.qml
- modules/gui/qt/util/qml/MLContextMenu.qml


Changes:

=====================================
modules/gui/qt/medialibrary/mlaudiomodel.cpp
=====================================
@@ -45,6 +45,8 @@ QVariant MLAudioModel::itemRoleData(const MLItem *item, const int role) const
     case AUDIO_ALBUM_FIRST_SYMBOL:
         return QVariant::fromValue(getFirstSymbol(audio->getAlbumTitle()));
     case AUDIO_ALBUM_ID:
+        return QVariant::fromValue(audio->getAlbumId());
+    case AUDIO_ALBUM_ID_SERIALIZED:
         return QVariant::fromValue(audio->getAlbumId().toString());
     default:
         return MLMediaModel::itemRoleData(item, role);
@@ -66,6 +68,7 @@ QHash<int, QByteArray> MLAudioModel::roleNames() const
         {AUDIO_ALBUM, "album_title"},
         {AUDIO_ALBUM_FIRST_SYMBOL, "album_title_first_symbol"},
         {AUDIO_ALBUM_ID, "album_id"},
+        {AUDIO_ALBUM_ID_SERIALIZED, "album_id_serialized"},
     });
 
     return hash;


=====================================
modules/gui/qt/medialibrary/mlaudiomodel.hpp
=====================================
@@ -40,6 +40,7 @@ public:
         AUDIO_ALBUM,
         AUDIO_ALBUM_FIRST_SYMBOL,
         AUDIO_ALBUM_ID,
+        AUDIO_ALBUM_ID_SERIALIZED,
     }
     ;
 


=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -214,7 +214,7 @@ FocusScope {
                 anchors.left: parent.left
                 anchors.right: parent.right
 
-                active: (root._currentView instanceof Widgets.TableViewExt)
+                active: (root._currentView instanceof Widgets.TableViewExt) && MainCtx.albumSections
                 visible: active
 
                 sourceComponent: MusicAlbumSectionDelegate {
@@ -508,6 +508,8 @@ FocusScope {
         id: trackContextMenu
 
         model: trackModel
+
+        showPlayAsAlbumAction: MainCtx.albumSections ? false : implicitShowPlayAsAlbumAction
     }
 
     Component {
@@ -632,7 +634,7 @@ FocusScope {
 
             property bool albumSections: true
 
-            section.property: "album_id"
+            section.property: "album_id_serialized"
             section.delegate: albumSections ? musicAlbumSectionDelegateComponent : null
 
             readonly property var _artistId: root.artistId


=====================================
modules/gui/qt/util/qml/MLContextMenu.qml
=====================================
@@ -33,9 +33,14 @@ NativeMenu {
     required property MLBaseModel model
 
     property string idDataRole: "id"
+    property string albumIdDataRole: "album_id"
 
     property bool showPlayAsAudioAction: false
 
+    // This is only applicable when the model is `MLAudioModel`:
+    property bool showPlayAsAlbumAction: implicitShowPlayAsAlbumAction
+    property bool implicitShowPlayAsAlbumAction: !showPlayAsAudioAction
+
     // Signals
 
     signal showMediaInformation(int index)
@@ -55,9 +60,19 @@ NativeMenu {
             "text": qsTr("Play as audio"),
             "action": playAsAudio,
             "visible": root.showPlayAsAudioAction
+        }, {
+            "text": qsTr("Play as album"),
+            "action": playAsAlbum,
+            "visible": root.showPlayAsAlbumAction &&
+                       (root.model instanceof MLAudioModel)
         }, {
             "text": qsTr("Enqueue"),
             "action": enqueue
+        }, {
+            "text": qsTr("Enqueue as album"),
+            "action": enqueueAsAlbum,
+            "visible": root.showPlayAsAlbumAction &&
+                       (root.model instanceof MLAudioModel)
         }, {
             "text": qsTr("Add to favorites"),
             "action": addFavorite,
@@ -126,10 +141,18 @@ NativeMenu {
         model.ml.addAndPlay(_mlIDList(dataList), _playerOptions(options, ":no-video"))
     }
 
+    function playAsAlbum(dataList, options, indexes) {
+        model.ml.addAndPlay(_mlIDList(dataList, root.albumIdDataRole), _playerOptions(options))
+    }
+
     function enqueue(dataList, options, indexes) {
         model.ml.addToPlaylist(_mlIDList(dataList), _playerOptions(options))
     }
 
+    function enqueueAsAlbum(dataList, options, indexes) {
+        model.ml.addToPlaylist(_mlIDList(dataList, root.albumIdDataRole), _playerOptions(options))
+    }
+
     function addToAudioOnlyPlaylist(dataList, options, indexes) {
         addToAPlaylist(dataList, options, indexes, MLPlaylistListModel.PLAYLIST_TYPE_AUDIO_ONLY)
     }
@@ -236,10 +259,11 @@ NativeMenu {
         return playerOpts.concat(extraOptions)
     }
 
-    function _mlIDList(dataList) {
+    function _mlIDList(dataList, role = root.idDataRole) {
         const idList = []
         for (let i in dataList) {
-            idList.push(dataList[i][idDataRole])
+            console.assert(dataList[i][role] !== undefined)
+            idList.push(dataList[i][role])
         }
 
         return idList



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ec5601c05a8cc5600f177efb474339be3ffe87f0...471e6c6c5840ad1f26d041c8e26dcfeffaa07f11

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ec5601c05a8cc5600f177efb474339be3ffe87f0...471e6c6c5840ad1f26d041c8e26dcfeffaa07f11
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list