[vlc-commits] qml: use AudioGridItem
Pierre Lamot
git at videolan.org
Fri Sep 6 18:02:01 CEST 2019
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Tue Aug 27 14:46:04 2019 +0200| [23ded2cc1f64026954859254ccd0977f308a4389] | committer: Jean-Baptiste Kempf
qml: use AudioGridItem
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=23ded2cc1f64026954859254ccd0977f308a4389
---
.../gui/qt/qml/mediacenter/MusicAlbumsDisplay.qml | 24 ++----
.../gui/qt/qml/mediacenter/MusicGenresDisplay.qml | 90 ++++++++++------------
2 files changed, 48 insertions(+), 66 deletions(-)
diff --git a/modules/gui/qt/qml/mediacenter/MusicAlbumsDisplay.qml b/modules/gui/qt/qml/mediacenter/MusicAlbumsDisplay.qml
index 7969f945d3..1a2d2a3781 100644
--- a/modules/gui/qt/qml/mediacenter/MusicAlbumsDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MusicAlbumsDisplay.qml
@@ -116,26 +116,14 @@ Utils.NavigableFocusScope {
cellWidth: VLCStyle.cover_normal + VLCStyle.margin_small
cellHeight: VLCStyle.cover_normal + VLCStyle.fontHeight_normal * 2
- delegate: Utils.GridItem {
- property variant delegateModelItem: ({
- model: ({}),
- itemsIndex: 0,
- inSelected: false
- })
-
- image: delegateModelItem.model.cover || VLCStyle.noArtAlbum
- title: delegateModelItem.model.title || qsTr("Unknown title")
- subtitle: delegateModelItem.model.main_artist || qsTr("Unknown artist")
- selected: delegateModelItem.inSelected
- onItemClicked : {
- delegateModel.updateSelection( modifier , view.currentItem.currentIndex, delegateModelItem.itemsIndex)
- view.currentItem.currentIndex = delegateModelItem.itemsIndex
- //view.currentItem.forceActiveFocus()
- view._switchExpandItem( delegateModelItem.itemsIndex )
+ delegate: AudioGridItem {
+ id: audioGridItem
+ onItemClicked : {
+ delegateModel.updateSelection( modifier , root.currentIndex, index)
+ root.currentIndex = index
+ view._switchExpandItem( index )
}
- onPlayClicked: medialib.addAndPlay( delegateModelItem.model.id )
- onAddToPlaylistClicked : medialib.addToPlaylist( delegateModelItem.model.id )
}
expandDelegate: Rectangle {
diff --git a/modules/gui/qt/qml/mediacenter/MusicGenresDisplay.qml b/modules/gui/qt/qml/mediacenter/MusicGenresDisplay.qml
index fdb783f479..0db49f0e31 100644
--- a/modules/gui/qt/qml/mediacenter/MusicGenresDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MusicGenresDisplay.qml
@@ -42,53 +42,9 @@ Utils.NavigableFocusScope {
}
delegate: Package {
- id: element
- Utils.GridItem {
- Package.name: "grid"
- id: gridItem
- image: VLCStyle.noArtAlbum
- title: model.name || "Unknown genre"
- selected: element.DelegateModel.inSelected
-
- onItemClicked: {
- delegateModel.updateSelection( modifier , view.currentItem.currentIndex, index)
- view.currentItem.currentIndex = index
- view.currentItem.forceActiveFocus()
- }
- onPlayClicked: {
- medialib.addAndPlay( model.id )
- }
- onItemDoubleClicked: {
- history.push(["mc", "music", "albums", { parentId: model.id } ], History.Go)
- }
- onAddToPlaylistClicked: {
- medialib.addToPlaylist( model.id );
- }
-
- //replace image with a mutlicovers preview
- Utils.MultiCoverPreview {
- id: multicover
- visible: false
- width: VLCStyle.cover_normal
- height: VLCStyle.cover_normal
-
- albums: MLAlbumModel {
- ml: medialib
- parentId: model.id
- }
- }
-
- Component.onCompleted: {
- multicover.grabToImage(function(result) {
- gridItem.sourceSize = undefined
- gridItem.image = result.url
- //multicover.destroy()
- })
- }
- }
-
Utils.ListItem {
Package.name: "list"
+
width: root.width
height: VLCStyle.icon_normal + VLCStyle.margin_small
@@ -153,11 +109,50 @@ Utils.NavigableFocusScope {
/* Grid View */
Component {
id: gridComponent
- Utils.KeyNavigableGridView {
+ Utils.ExpandGridView {
id: gridView_id
- model: delegateModel.parts.grid
+ model: delegateModel
modelCount: delegateModel.items.count
+ delegate: AudioGridItem {
+ id: gridItem
+
+ image: VLCStyle.noArtAlbum
+ title: modelData.name || "Unknown genre"
+ subtitle: ""
+ //selected: element.DelegateModel.inSelected
+
+ onItemClicked: {
+ delegateModel.updateSelection( modifier , view.currentItem.currentIndex, index)
+ view.currentItem.currentIndex = index
+ view.currentItem.forceActiveFocus()
+ }
+
+ onItemDoubleClicked: {
+ history.push(["mc", "music", "albums", { parentId: modelData.id } ], History.Go)
+ }
+
+ //replace image with a mutlicovers preview
+ Utils.MultiCoverPreview {
+ id: multicover
+ visible: false
+ width: VLCStyle.cover_normal
+ height: VLCStyle.cover_normal
+
+ albums: MLAlbumModel {
+ ml: medialib
+ parentId: modelData.id
+ }
+ }
+
+ Component.onCompleted: {
+ multicover.grabToImage(function(result) {
+ gridItem.sourceSize = undefined
+ gridItem.image = result.url
+ //multicover.destroy()
+ })
+ }
+ }
focus: true
@@ -176,7 +171,6 @@ Utils.NavigableFocusScope {
}
}
-
Component {
id: listComponent
/* List View */
More information about the vlc-commits
mailing list