Commit 42f964bd authored by Benjamin Arnaud's avatar Benjamin Arnaud Committed by Jean-Baptiste Kempf
Browse files

qml/PlaylistMediaList: Revamp implementation based on design guidelines

parent 54c0ecc8
......@@ -37,6 +37,8 @@ Widgets.NavigableFocusScope {
readonly property int currentIndex: currentItem.currentIndex
property bool isMusic: false
property int initialIndex: 0
property var sortModel: [{ text: i18n.qtr("Alphabetic"), criteria: "title" }]
......@@ -44,15 +46,23 @@ Widgets.NavigableFocusScope {
//---------------------------------------------------------------------------------------------
// Private
property int _width: VLCStyle.colWidth(2)
property int _width: (isMusic) ? VLCStyle.gridItem_music_width
: VLCStyle.gridItem_video_width
property int _height: Math.round(_width / 2)
property int _height: (isMusic) ? VLCStyle.gridItem_music_height
: VLCStyle.gridItem_video_height
property int _widthColumn:
Math.max(VLCStyle.gridColumnsForWidth(tableView.availableRowWidth
- VLCStyle.listAlbumCover_width
- VLCStyle.column_margin_width) - 1, 1)
property int _widthCover: (isMusic) ? VLCStyle.gridCover_music_width
: VLCStyle.gridCover_video_width
property int _heightCover: (isMusic) ? VLCStyle.gridCover_music_height
: VLCStyle.gridCover_video_height
//---------------------------------------------------------------------------------------------
// Alias
//---------------------------------------------------------------------------------------------
......@@ -145,6 +155,16 @@ Widgets.NavigableFocusScope {
}
}
function _getCount(model)
{
var count = model.count;
if (count < 100)
return count;
else
return i18n.qtr("99+");
}
//---------------------------------------------------------------------------------------------
// Childs
//---------------------------------------------------------------------------------------------
......@@ -154,6 +174,13 @@ Widgets.NavigableFocusScope {
ml: medialib
coverSize: (isMusic) ? Qt.size(512, 512)
: Qt.size(1024, 640)
coverDefault: (isMusic) ? ":/noart_album.svg" : ":/noart_videoCover.svg"
coverPrefix: (isMusic) ? "playlist-music" : "playlist-video"
onCountChanged: {
if (count === 0 || modelSelect.hasSelection) return;
......@@ -183,7 +210,7 @@ Widgets.NavigableFocusScope {
})
var covers = items.map(function (item) {
return { artwork: item.cover || VLCStyle.noArtCover };
return { artwork: item.thumbnail || VLCStyle.noArtCover };
})
var title = items.map(function (item) {
......@@ -237,21 +264,7 @@ Widgets.NavigableFocusScope {
focus: true
//-------------------------------------------------------------------------------------
// Events
onSelectAll: modelSelect.selectAll()
onSelectionUpdated: modelSelect.updateSelection(keyModifiers, oldIndex, newIndex)
onActionAtIndex: _actionAtIndex()
//-------------------------------------------------------------------------------------
// Childs
delegate: Widgets.GridItem {
id: item
delegate: VideoGridItem {
//---------------------------------------------------------------------------------
// Properties
......@@ -262,76 +275,70 @@ Widgets.NavigableFocusScope {
//---------------------------------------------------------------------------------
// Settings
width : _width
height: _height
pictureWidth : _widthCover
pictureHeight: _heightCover
title: (model.name) ? model.name
: i18n.qtr("Unknown title")
pictureWidth : width
pictureHeight: height
labels: (model.count > 1) ? [ i18n.qtr("%1 Tracks").arg(_getCount(model)) ]
: [ i18n.qtr("%1 Track") .arg(_getCount(model)) ]
image: VLCStyle.noArtAlbum
// NOTE: We don't want to show the new indicator for a playlist.
showNewIndicator: false
dragItem: dragItemPlaylist
selectedUnderlay : shadows.selected
unselectedUnderlay: shadows.unselected
selectedUnderlay: shadows.selected
pictureOverlay: Item {
Column {
anchors.centerIn: parent
Label {
width: item.width
horizontalAlignment: Text.AlignHCenter
text: model.name
elide: Text.ElideRight
//---------------------------------------------------------------------------------
// Events
color: "white"
onItemClicked: gridView.leftClickOnItem(modifier, index)
font.pixelSize: VLCStyle.fontSize_large
font.weight : Font.DemiBold
}
onItemDoubleClicked: showList(model)
Widgets.CaptionLabel {
width: item.width
onPlayClicked: if (model.id) medialib.addAndPlay(model.id)
horizontalAlignment: Text.AlignHCenter
onContextMenuButtonClicked: {
gridView.rightClickOnItem(index);
opacity: 0.7
contextMenu.popup(modelSelect.selectedIndexes, globalMousePos);
}
text: (model.count > 1) ? i18n.qtr("%1 Tracks").arg(model.count)
: i18n.qtr("%1 Track") .arg(model.count)
//---------------------------------------------------------------------------------
// Animations
color: "white"
}
}
}
Behavior on opacity { NumberAnimation { duration: 100 } }
}
playCoverBorderWidth: VLCStyle.dp(3, VLCStyle.scale)
//-------------------------------------------------------------------------------------
// Events
//---------------------------------------------------------------------------------
// Events
// NOTE: Define the initial position and selection. This is done on activeFocus rather
// than Component.onCompleted because modelSelect.selectedGroup update itself
// after this event.
onActiveFocusChanged: {
if (activeFocus == false || model.count === 0 || modelSelect.hasSelection) return;
onItemDoubleClicked: showList(model)
modelSelect.select(model.index(0,0), ItemSelectionModel.ClearAndSelect)
}
onItemClicked: gridView.leftClickOnItem(modifier, index)
onSelectAll: modelSelect.selectAll()
onPlayClicked: if (model.id) medialib.addAndPlay(model.id)
onSelectionUpdated: modelSelect.updateSelection(keyModifiers, oldIndex, newIndex)
onContextMenuButtonClicked: {
gridView.rightClickOnItem(index);
onActionAtIndex: _actionAtIndex()
contextMenu.popup(modelSelect.selectedIndexes, globalMousePos);
}
}
//-------------------------------------------------------------------------------------
// Childs
Widgets.GridShadows {
id: shadows
coverWidth: root._width
coverHeight: root._height
coverWidth : _widthCover
coverHeight: _heightCover
}
}
}
......@@ -371,7 +378,7 @@ Widgets.NavigableFocusScope {
sortModel: [{
isPrimary: true,
criteria: "cover",
criteria: "thumbnail",
width: VLCStyle.listAlbumCover_width,
......@@ -409,9 +416,24 @@ Widgets.NavigableFocusScope {
showTitleText: false
titleCover_width : VLCStyle.listAlbumCover_width
titleCover_height: VLCStyle.listAlbumCover_height
titleCover_radius: VLCStyle.listAlbumCover_radius
//---------------------------------------------------------------------------------
// NOTE: When it's music we want the cover to be square
titleCover_width: (isMusic) ? VLCStyle.trackListAlbumCover_width
: VLCStyle.listAlbumCover_width
titleCover_height: (isMusic) ? VLCStyle.trackListAlbumCover_heigth
: VLCStyle.listAlbumCover_height
titleCover_radius: (isMusic) ? VLCStyle.trackListAlbumCover_radius
: VLCStyle.listAlbumCover_radius
//---------------------------------------------------------------------------------
// NOTE: This makes sure we display the playlist count on the item.
function titlecoverLabels(model) {
return [ _getCount(model) ];
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment