|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/***************************************************************************** |
|
|
|
* Copyright (C) 2021 VLC authors and VideoLAN |
|
|
|
* Copyright (C) 2021-23 VLC authors and VideoLAN |
|
|
|
* |
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
|
@ -27,9 +27,10 @@ import org.videolan.vlc 0.1 |
|
|
|
import "qrc:///widgets/" as Widgets |
|
|
|
import "qrc:///main/" as MainInterface |
|
|
|
import "qrc:///util/" as Util |
|
|
|
import "qrc:///util/Helpers.js" as Helpers |
|
|
|
import "qrc:///style/" |
|
|
|
|
|
|
|
FocusScope { |
|
|
|
MainInterface.MainViewLoader { |
|
|
|
id: root |
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
@ -38,9 +39,7 @@ FocusScope { |
|
|
|
|
|
|
|
property bool isMusic: false |
|
|
|
|
|
|
|
readonly property int currentIndex: _currentView.currentIndex |
|
|
|
|
|
|
|
property int initialIndex: 0 |
|
|
|
readonly property int currentIndex: Helpers.get(currentItem, "currentIndex", -1) |
|
|
|
|
|
|
|
property var sortModel: [{ text: I18n.qtr("Alphabetic"), criteria: "title" }] |
|
|
|
|
|
|
|
@ -62,16 +61,8 @@ FocusScope { |
|
|
|
property string _placeHolder: (isMusic) ? VLCStyle.noArtAlbumCover |
|
|
|
: VLCStyle.noArtVideoCover |
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
// Alias |
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
property alias leftPadding: view.leftPadding |
|
|
|
property alias rightPadding: view.rightPadding |
|
|
|
|
|
|
|
property alias model: model |
|
|
|
|
|
|
|
property alias _currentView: view.currentItem |
|
|
|
// FIXME: remove this |
|
|
|
property var _currentView: currentItem |
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
// Signals |
|
|
|
@ -84,75 +75,44 @@ FocusScope { |
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
// NOTE: Define the initial position and selection. This is done on activeFocus rather than |
|
|
|
// Component.onCompleted because modelSelect.selectedGroup update itself after this |
|
|
|
// Component.onCompleted because selectionModel.selectedGroup update itself after this |
|
|
|
// event. |
|
|
|
onActiveFocusChanged: { |
|
|
|
if (activeFocus == false || model.count === 0 || modelSelect.hasSelection) |
|
|
|
if (activeFocus == false || model.count === 0 || selectionModel.hasSelection) |
|
|
|
return; |
|
|
|
|
|
|
|
var initialIndex = 0; |
|
|
|
|
|
|
|
if (_currentView.currentIndex !== -1) { |
|
|
|
initialIndex = _currentView.currentIndex; |
|
|
|
} |
|
|
|
|
|
|
|
modelSelect.select(model.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect); |
|
|
|
|
|
|
|
_currentView.currentIndex = initialIndex; |
|
|
|
resetFocus() |
|
|
|
} |
|
|
|
|
|
|
|
onInitialIndexChanged: resetFocus() |
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
// Connections |
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
Connections { |
|
|
|
target: MainCtx |
|
|
|
|
|
|
|
onGridViewChanged: { |
|
|
|
if (MainCtx.gridView) view.replace(grid); |
|
|
|
else view.replace(table); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
// Functions |
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
function resetFocus() { |
|
|
|
if (model.count === 0) |
|
|
|
return; |
|
|
|
// Private |
|
|
|
|
|
|
|
var initialIndex = root.initialIndex; |
|
|
|
grid: grid |
|
|
|
list: table |
|
|
|
emptyLabel: emptyLabel |
|
|
|
|
|
|
|
if (initialIndex >= model.count) |
|
|
|
initialIndex = 0; |
|
|
|
model: MLPlaylistListModel { |
|
|
|
ml: MediaLib |
|
|
|
|
|
|
|
modelSelect.select(model.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect); |
|
|
|
coverSize: (isMusic) ? Qt.size(512, 512) |
|
|
|
: Qt.size(1024, 640) |
|
|
|
|
|
|
|
if (_currentView) |
|
|
|
_currentView.positionViewAtIndex(initialIndex, ItemView.Contain); |
|
|
|
} |
|
|
|
coverDefault: root._placeHolder |
|
|
|
|
|
|
|
function setCurrentItemFocus(reason) { |
|
|
|
_currentView.setCurrentItemFocus(reason); |
|
|
|
coverPrefix: (isMusic) ? "playlist-music" : "playlist-video" |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
// Private |
|
|
|
|
|
|
|
function _actionAtIndex() { |
|
|
|
if (modelSelect.selectedIndexes.length > 1) { |
|
|
|
MediaLib.addAndPlay(model.getIdsForIndexes(modelSelect.selectedIndexes)); |
|
|
|
} else if (modelSelect.selectedIndexes.length === 1) { |
|
|
|
var index = modelSelect.selectedIndexes[0]; |
|
|
|
if (root.selectionModel.selectedIndexes.length > 1) { |
|
|
|
MediaLib.addAndPlay(model.getIdsForIndexes(selectionModel.selectedIndexes)); |
|
|
|
} else if (root.selectionModel.selectedIndexes.length === 1) { |
|
|
|
var index = selectionModel.selectedIndexes[0]; |
|
|
|
showList(model.getDataAt(index), Qt.TabFocusReason); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function _getCount(model) |
|
|
|
{ |
|
|
|
function _getCount(model) { |
|
|
|
var count = model.count; |
|
|
|
|
|
|
|
if (count < 100) |
|
|
|
@ -174,42 +134,13 @@ FocusScope { |
|
|
|
// Childs |
|
|
|
//--------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
MLPlaylistListModel { |
|
|
|
id: model |
|
|
|
|
|
|
|
ml: MediaLib |
|
|
|
|
|
|
|
coverSize: (isMusic) ? Qt.size(512, 512) |
|
|
|
: Qt.size(1024, 640) |
|
|
|
|
|
|
|
coverDefault: root._placeHolder |
|
|
|
|
|
|
|
coverPrefix: (isMusic) ? "playlist-music" : "playlist-video" |
|
|
|
|
|
|
|
onCountChanged: { |
|
|
|
if (count === 0 || modelSelect.hasSelection) |
|
|
|
return; |
|
|
|
|
|
|
|
resetFocus(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Widgets.StackViewExt { |
|
|
|
id: view |
|
|
|
|
|
|
|
anchors.fill: parent |
|
|
|
|
|
|
|
initialItem: (MainCtx.gridView) ? grid : table |
|
|
|
|
|
|
|
focus: (model.count !== 0) |
|
|
|
} |
|
|
|
|
|
|
|
Widgets.MLDragItem { |
|
|
|
id: dragItemPlaylist |
|
|
|
|
|
|
|
mlModel: model |
|
|
|
|
|
|
|
indexes: modelSelect.selectedIndexes |
|
|
|
indexes: selectionModel.selectedIndexes |
|
|
|
|
|
|
|
coverRole: "thumbnail" |
|
|
|
|
|
|
|
@ -218,12 +149,6 @@ FocusScope { |
|
|
|
titleRole: "name" |
|
|
|
} |
|
|
|
|
|
|
|
Util.SelectableDelegateModel { |
|
|
|
id: modelSelect |
|
|
|
|
|
|
|
model: root.model |
|
|
|
} |
|
|
|
|
|
|
|
PlaylistListContextMenu { |
|
|
|
id: contextMenu |
|
|
|
|
|
|
|
@ -247,7 +172,7 @@ FocusScope { |
|
|
|
|
|
|
|
model: root.model |
|
|
|
|
|
|
|
selectionDelegateModel: modelSelect |
|
|
|
selectionDelegateModel: selectionModel |
|
|
|
|
|
|
|
Navigation.parentItem: root |
|
|
|
|
|
|
|
@ -288,7 +213,7 @@ FocusScope { |
|
|
|
onContextMenuButtonClicked: { |
|
|
|
gridView.rightClickOnItem(index); |
|
|
|
|
|
|
|
contextMenu.popup(modelSelect.selectedIndexes, globalMousePos); |
|
|
|
contextMenu.popup(selectionModel.selectedIndexes, globalMousePos); |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------- |
|
|
|
@ -301,13 +226,13 @@ FocusScope { |
|
|
|
// Events |
|
|
|
|
|
|
|
// NOTE: Define the initial position and selection. This is done on activeFocus rather |
|
|
|
// than Component.onCompleted because modelSelect.selectedGroup update itself |
|
|
|
// than Component.onCompleted because selectionModel.selectedGroup update itself |
|
|
|
// after this event. |
|
|
|
onActiveFocusChanged: { |
|
|
|
if (activeFocus == false || model.count === 0 || modelSelect.hasSelection) |
|
|
|
if (activeFocus == false || model.count === 0 || selectionModel.hasSelection) |
|
|
|
return; |
|
|
|
|
|
|
|
modelSelect.select(model.index(0,0), ItemSelectionModel.ClearAndSelect) |
|
|
|
selectionModel.select(model.index(0,0), ItemSelectionModel.ClearAndSelect) |
|
|
|
} |
|
|
|
|
|
|
|
onActionAtIndex: _actionAtIndex() |
|
|
|
@ -383,7 +308,7 @@ FocusScope { |
|
|
|
sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall |
|
|
|
: _modelMedium |
|
|
|
|
|
|
|
selectionDelegateModel: modelSelect |
|
|
|
selectionDelegateModel: selectionModel |
|
|
|
|
|
|
|
dragItem: dragItemPlaylist |
|
|
|
|
|
|
|
@ -397,10 +322,10 @@ FocusScope { |
|
|
|
|
|
|
|
onItemDoubleClicked: showList(model, Qt.MouseFocusReason) |
|
|
|
|
|
|
|
onContextMenuButtonClicked: contextMenu.popup(modelSelect.selectedIndexes, |
|
|
|
onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, |
|
|
|
globalMousePos) |
|
|
|
|
|
|
|
onRightClick: contextMenu.popup(modelSelect.selectedIndexes, globalMousePos) |
|
|
|
onRightClick: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos) |
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------- |
|
|
|
// Childs |
|
|
|
@ -435,16 +360,18 @@ FocusScope { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
EmptyLabelHint { |
|
|
|
anchors.fill: parent |
|
|
|
Component { |
|
|
|
id: emptyLabel |
|
|
|
|
|
|
|
visible: (model.count === 0) |
|
|
|
EmptyLabelHint { |
|
|
|
visible: (model.count === 0) |
|
|
|
|
|
|
|
focus: visible |
|
|
|
focus: true |
|
|
|
|
|
|
|
text: I18n.qtr("No playlists found") |
|
|
|
hint: I18n.qtr("Right click on a media to add it to a playlist") |
|
|
|
text: I18n.qtr("No playlists found") |
|
|
|
hint: I18n.qtr("Right click on a media to add it to a playlist") |
|
|
|
|
|
|
|
cover: VLCStyle.noArtAlbumCover |
|
|
|
cover: VLCStyle.noArtAlbumCover |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|