[vlc-devel] [PATCH 5/5] qml: use cached shadows in GridItem
Pierre Lamot
pierre at videolabs.io
Mon Apr 12 10:03:13 UTC 2021
On 09/04/2021 16:47, Prince Gupta wrote:
> improves creation time of GridItem
> ---
> .../gui/qt/medialibrary/qml/MusicAlbums.qml | 9 +++++++++
> .../gui/qt/medialibrary/qml/MusicArtist.qml | 18 ++++++++++++++++++
> .../medialibrary/qml/MusicArtistsDisplay.qml | 12 ++++++++++++
> .../gui/qt/medialibrary/qml/MusicGenres.qml | 12 +++++++++++-
> .../qt/medialibrary/qml/PlaylistMediaList.qml | 10 ++++++++++
> modules/gui/qt/medialibrary/qml/VideoAll.qml | 12 ++++++++++++
> .../qml/VideoDisplayRecentVideos.qml | 10 ++++++++++
> .../qt/network/qml/NetworkBrowseDisplay.qml | 9 +++++++++
> .../network/qml/NetworkHomeDeviceListView.qml | 9 +++++++++
> .../gui/qt/network/qml/ServicesHomeDisplay.qml | 9 +++++++++
> 10 files changed, 109 insertions(+), 1 deletion(-)
>
> diff --git a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
> index 8deb707e65..e375c7ffbe 100644
> --- a/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
> +++ b/modules/gui/qt/medialibrary/qml/MusicAlbums.qml
> @@ -139,11 +139,20 @@ Widgets.NavigableFocusScope {
> delegateModel: selectionModel
> model: albumModelId
>
> + Widgets.GridShadow {
you named your Qml file GridShadows.qml (with an s), this doesn't load
properly
> + id: shadows
> +
> + coverWidth: VLCStyle.gridCover_music_width
> + coverHeight: VLCStyle.gridCover_music_height
> + }
> +
> delegate: AudioGridItem {
> id: audioGridItem
>
> opacity: gridView_id.expandIndex !== -1 && gridView_id.expandIndex !== audioGridItem.index ? .7 : 1
> dragItem: albumDragItem
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
>
> onItemClicked : gridView_id.leftClickOnItem(modifier, index)
>
> diff --git a/modules/gui/qt/medialibrary/qml/MusicArtist.qml b/modules/gui/qt/medialibrary/qml/MusicArtist.qml
> index bd40ed6ec6..c915474583 100644
> --- a/modules/gui/qt/medialibrary/qml/MusicArtist.qml
> +++ b/modules/gui/qt/medialibrary/qml/MusicArtist.qml
> @@ -118,6 +118,8 @@ Widgets.NavigableFocusScope {
> pictureHeight: VLCStyle.gridCover_music_height
> playCoverBorder.width: VLCStyle.gridCover_music_border
> dragItem: albumDragItem
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
>
> onPlayClicked: play()
> onItemDoubleClicked: play()
> @@ -144,6 +146,13 @@ Widgets.NavigableFocusScope {
> onSelectAll: albumSelectionModel.selectAll()
> onSelectionUpdated: albumSelectionModel.updateSelection( keyModifiers, oldIndex, newIndex )
> onActionAtIndex: medialib.addAndPlay( albumModel.getIdForIndex( index ) )
> +
> + Widgets.GridShadow {
> + id: shadows
> +
> + coverWidth: VLCStyle.gridCover_music_width
> + coverHeight: VLCStyle.gridCover_music_height
> + }
> }
>
> Widgets.SubtitleLabel {
> @@ -283,6 +292,8 @@ Widgets.NavigableFocusScope {
>
> opacity: gridView_id.expandIndex !== -1 && gridView_id.expandIndex !== audioGridItem.index ? .7 : 1
> dragItem: albumDragItem
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
>
> onItemClicked : gridView_id.leftClickOnItem(modifier, index)
>
> @@ -330,6 +341,13 @@ Widgets.NavigableFocusScope {
> target: contextMenu
> onShowMediaInformation: gridView_id.switchExpandItem( index )
> }
> +
> + Widgets.GridShadow {
> + id: shadows
> +
> + coverWidth: VLCStyle.gridCover_music_width
> + coverHeight: VLCStyle.gridCover_music_height
> + }
> }
>
> }
> diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
> index 7a1b7c9516..5b548a4f51 100644
> --- a/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
> +++ b/modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml
> @@ -160,6 +160,15 @@ Widgets.PageLoader {
> }
> }
>
> + Widgets.GridShadow {
> + id: shadows
> +
> + leftPadding: (VLCStyle.colWidth(1) - shadows.coverWidth) / 2 // GridItem's rect is horizontally centered
> + coverWidth: VLCStyle.artistGridCover_radius
> + coverHeight: VLCStyle.artistGridCover_radius
> + coverRadius: VLCStyle.artistGridCover_radius
> + }
> +
> delegate: AudioGridItem {
> id: gridItem
>
> @@ -174,6 +183,9 @@ Widgets.PageLoader {
> textHorizontalAlignment: Text.AlignHCenter
> width: VLCStyle.colWidth(1)
> dragItem: artistsDragItem
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
> +
>
> onItemClicked: artistGrid.leftClickOnItem(modifier, index)
>
> diff --git a/modules/gui/qt/medialibrary/qml/MusicGenres.qml b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
> index d12230a5c2..6b14a526e4 100644
> --- a/modules/gui/qt/medialibrary/qml/MusicGenres.qml
> +++ b/modules/gui/qt/medialibrary/qml/MusicGenres.qml
> @@ -149,7 +149,15 @@ Widgets.NavigableFocusScope {
> model: genreModel
> topMargin: VLCStyle.margin_large
>
> - delegate: Widgets.GridItem {
> + Widgets.GridShadow {
> + id: shadows
> +
> + leftPadding: 0
> + coverWidth: VLCStyle.colWidth(2)
> + coverHeight: shadows.coverWidth / 2
> + }
> +
> + delegate: Widgets.GridItem {
> id: item
>
> property var model: ({})
> @@ -162,6 +170,8 @@ Widgets.NavigableFocusScope {
> image: model.cover || VLCStyle.noArtAlbum
> playCoverBorder.width: VLCStyle.dp(3, VLCStyle.scale)
> dragItem: genreDragItem
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
>
> onItemDoubleClicked: root.showAlbumView(model)
> onItemClicked: gridView_id.leftClickOnItem(modifier, item.index)
> diff --git a/modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml b/modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
> index 1bbdec00e4..0ca250e2b3 100644
> --- a/modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
> +++ b/modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
> @@ -272,6 +272,9 @@ Widgets.NavigableFocusScope {
>
> dragItem: dragItemPlaylist
>
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
> +
> pictureOverlay: Item {
> Column {
> anchors.centerIn: parent
> @@ -323,6 +326,13 @@ Widgets.NavigableFocusScope {
> contextMenu.popup(modelSelect.selectedIndexes, globalMousePos);
> }
> }
> +
> + Widgets.GridShadow {
> + id: shadows
> +
> + coverWidth: root._width
> + coverHeight: root._height
> + }
> }
> }
>
> diff --git a/modules/gui/qt/medialibrary/qml/VideoAll.qml b/modules/gui/qt/medialibrary/qml/VideoAll.qml
> index 56e7ff9334..a895a4d05a 100644
> --- a/modules/gui/qt/medialibrary/qml/VideoAll.qml
> +++ b/modules/gui/qt/medialibrary/qml/VideoAll.qml
> @@ -238,6 +238,16 @@ Widgets.NavigableFocusScope {
> onRetract: gridView.retract()
> }
>
> + //---------------------------------------------------------------------------------
> + // Shadows
> +
> + Widgets.GridShadow {
> + id: shadows
> +
> + coverWidth: VLCStyle.gridCover_video_width
> + coverHeight: VLCStyle.gridCover_video_height
> + }
> +
> delegate: VideoGridItem {
> id: gridItem
>
> @@ -249,6 +259,8 @@ Widgets.NavigableFocusScope {
> gridView.expandIndex !== gridItem.index) ? 0.7 : 1
>
> dragItem: root.dragItem
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
>
> //---------------------------------------------------------------------------------
> // Events
> diff --git a/modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml b/modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
> index 4223796189..2cce91eb86 100644
> --- a/modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
> +++ b/modules/gui/qt/medialibrary/qml/VideoDisplayRecentVideos.qml
> @@ -113,6 +113,9 @@ Widgets.NavigableFocusScope {
> playCoverBorder.width: VLCStyle.gridCover_video_border
> titleMargin: VLCStyle.margin_xxsmall
> showNewIndicator: true
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
> +
> onItemDoubleClicked: {
> if ( model.id !== undefined ) {
> g_mainDisplay.showPlayer()
> @@ -155,6 +158,13 @@ Widgets.NavigableFocusScope {
> g_mainDisplay.showPlayer()
> medialib.addAndPlay( model.getIdsForIndexes( recentVideoSelection.selectedIndexes ) )
> }
> +
> + Widgets.GridShadow {
> + id: shadows
> +
> + coverWidth: VLCStyle.gridCover_video_width_large
> + coverHeight: VLCStyle.gridCover_video_height_large
> + }
> }
> }
> }
> diff --git a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
> index db9d413946..754e2c7a2f 100644
> --- a/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
> +++ b/modules/gui/qt/network/qml/NetworkBrowseDisplay.qml
> @@ -190,6 +190,8 @@ Widgets.NavigableFocusScope {
> subtitle: ""
> height: VLCStyle.gridCover_network_height + VLCStyle.margin_xsmall + VLCStyle.fontHeight_normal
> dragItem: networkDragItem
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
>
> onPlayClicked: playAt(index)
> onItemClicked : gridView.leftClickOnItem(modifier, index)
> @@ -216,6 +218,13 @@ Widgets.NavigableFocusScope {
> navigationCancel: function() {
> history.previous()
> }
> +
> + Widgets.GridShadow {
> + id: shadows
> +
> + coverWidth: VLCStyle.gridCover_network_width
> + coverHeight: VLCStyle.gridCover_network_height
> + }
> }
> }
>
> diff --git a/modules/gui/qt/network/qml/NetworkHomeDeviceListView.qml b/modules/gui/qt/network/qml/NetworkHomeDeviceListView.qml
> index 5063963975..937d321a8e 100644
> --- a/modules/gui/qt/network/qml/NetworkHomeDeviceListView.qml
> +++ b/modules/gui/qt/network/qml/NetworkHomeDeviceListView.qml
> @@ -66,6 +66,13 @@ Widgets.NavigableFocusScope {
> model: deviceModel
> }
>
> + Widgets.GridShadow {
> + id: shadows
> +
> + coverWidth: VLCStyle.gridCover_network_width
> + coverHeight: VLCStyle.gridCover_network_height
> + }
> +
> Widgets.KeyNavigableListView {
> id: deviceListView
>
> @@ -87,6 +94,8 @@ Widgets.NavigableFocusScope {
> focus: true
> x: selectedBorderWidth
> y: selectedBorderWidth
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
>
> onItemClicked : {
> deviceSelection.updateSelection( modifier , deviceSelection.currentIndex, index)
> diff --git a/modules/gui/qt/network/qml/ServicesHomeDisplay.qml b/modules/gui/qt/network/qml/ServicesHomeDisplay.qml
> index 461c50c519..ad499e99d0 100644
> --- a/modules/gui/qt/network/qml/ServicesHomeDisplay.qml
> +++ b/modules/gui/qt/network/qml/ServicesHomeDisplay.qml
> @@ -305,6 +305,8 @@ Widgets.PageLoader {
> playCoverBorder.width: VLCStyle.gridCover_network_border
> playCoverOnlyBorders: true
> pictureOverlay: overlay
> + unselectedUnderlay: shadows.unselected
> + selectedUnderlay: shadows.selected
>
> onItemDoubleClicked: {
> if (is_dummy)
> @@ -408,6 +410,13 @@ Widgets.PageLoader {
> sourceModel: sourcesModel
> searchRole: "name"
> }
> +
> + Widgets.GridShadow {
> + id: shadows
> +
> + coverWidth: VLCStyle.colWidth(1)
> + coverHeight: VLCStyle.gridCover_network_height
> + }
> }
> }
> }
More information about the vlc-devel
mailing list