|
|
|
@ -16,31 +16,31 @@ |
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|
|
|
*****************************************************************************/ |
|
|
|
import QtQuick 2.11 |
|
|
|
import QtQuick.Controls 2.4 |
|
|
|
import QtQuick.Layouts 1.11 |
|
|
|
import QtQml.Models 2.2 |
|
|
|
|
|
|
|
import org.videolan.medialib 0.1 |
|
|
|
import org.videolan.vlc 0.1 |
|
|
|
|
|
|
|
import "qrc:///util/" as Util |
|
|
|
import "qrc:///widgets/" as Widgets |
|
|
|
import "qrc:///main/" as MainInterface |
|
|
|
import "qrc:///util/Helpers.js" as Helpers |
|
|
|
import "qrc:///style/" |
|
|
|
|
|
|
|
FocusScope { |
|
|
|
MainInterface.MainViewLoader { |
|
|
|
id: root |
|
|
|
|
|
|
|
// Properties |
|
|
|
|
|
|
|
//the index to "go to" when the view is loaded |
|
|
|
property int initialIndex: 0 |
|
|
|
property int gridViewMarginTop: VLCStyle.margin_large |
|
|
|
property var gridViewRowX: MainCtx.gridView ? _currentView.rowX : undefined |
|
|
|
property var gridViewRowX: Helpers.get(currentItem, "rowX", 0) |
|
|
|
|
|
|
|
readonly property var currentIndex: Helpers.get(currentItem, "currentIndex", - 1) |
|
|
|
|
|
|
|
readonly property var currentIndex: _currentView.currentIndex |
|
|
|
property Component header: Item {} |
|
|
|
readonly property Item headerItem: Helpers.get(currentItem, "headerItem", null) |
|
|
|
|
|
|
|
property Component header: Item{} |
|
|
|
readonly property Item headerItem: _currentView ? _currentView.headerItem : null |
|
|
|
readonly property int contentLeftMargin: Helpers.get(currentItem, "contentLeftMargin", 0) |
|
|
|
readonly property int contentRightMargin: Helpers.get(currentItem, "contentRightMargin", 0) |
|
|
|
|
|
|
|
property var sortModel: [ |
|
|
|
{ text: I18n.qtr("Alphabetic"), criteria: "title"}, |
|
|
|
@ -49,39 +49,16 @@ FocusScope { |
|
|
|
{ text: I18n.qtr("Artist"), criteria: "main_artist" }, |
|
|
|
] |
|
|
|
|
|
|
|
// Aliases |
|
|
|
|
|
|
|
property alias leftPadding: view.leftPadding |
|
|
|
property alias rightPadding: view.rightPadding |
|
|
|
|
|
|
|
property alias model: albumModelId |
|
|
|
property alias parentId: albumModelId.parentId |
|
|
|
|
|
|
|
readonly property int contentLeftMargin: _currentView ? _currentView.contentLeftMargin : 0 |
|
|
|
readonly property int contentRightMargin: _currentView ? _currentView.contentRightMargin : 0 |
|
|
|
model: albumModelId |
|
|
|
|
|
|
|
property alias _currentView: view.currentItem |
|
|
|
grid: gridComponent |
|
|
|
list: tableComponent |
|
|
|
emptyLabel: emptyLabelComponent |
|
|
|
|
|
|
|
onInitialIndexChanged: resetFocus() |
|
|
|
onModelChanged: resetFocus() |
|
|
|
onParentIdChanged: resetFocus() |
|
|
|
|
|
|
|
function resetFocus() { |
|
|
|
if (albumModelId.count === 0) { |
|
|
|
return |
|
|
|
} |
|
|
|
var initialIndex = root.initialIndex |
|
|
|
if (initialIndex >= albumModelId.count) |
|
|
|
initialIndex = 0 |
|
|
|
selectionModel.select(model.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect) |
|
|
|
if (_currentView) |
|
|
|
_currentView.positionViewAtIndex(initialIndex, ItemView.Contain) |
|
|
|
} |
|
|
|
|
|
|
|
function setCurrentItemFocus(reason) { |
|
|
|
_currentView.setCurrentItemFocus(reason); |
|
|
|
} |
|
|
|
|
|
|
|
function _actionAtIndex(index) { |
|
|
|
if (selectionModel.selectedIndexes.length > 1) { |
|
|
|
MediaLib.addAndPlay( model.getIdsForIndexes( selectionModel.selectedIndexes ) ) |
|
|
|
@ -91,29 +68,19 @@ FocusScope { |
|
|
|
} |
|
|
|
|
|
|
|
function _onNavigationCancel() { |
|
|
|
if (_currentView.currentIndex <= 0) { |
|
|
|
if (currentIndex <= 0) { |
|
|
|
root.Navigation.defaultNavigationCancel() |
|
|
|
} else { |
|
|
|
_currentView.currentIndex = 0; |
|
|
|
_currentView.positionViewAtIndex(0, ItemView.Contain) |
|
|
|
} else if (model.count > 0) { |
|
|
|
currentItem.currentIndex = 0; |
|
|
|
currentItem.positionViewAtIndex(0, ItemView.Contain) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MLAlbumModel { |
|
|
|
id: albumModelId |
|
|
|
ml: MediaLib |
|
|
|
|
|
|
|
onCountChanged: { |
|
|
|
if (albumModelId.count > 0 && !selectionModel.hasSelection) { |
|
|
|
root.resetFocus() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Util.SelectableDelegateModel { |
|
|
|
id: selectionModel |
|
|
|
model: albumModelId |
|
|
|
ml: MediaLib |
|
|
|
} |
|
|
|
|
|
|
|
Widgets.MLDragItem { |
|
|
|
@ -310,32 +277,13 @@ FocusScope { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Widgets.StackViewExt { |
|
|
|
id: view |
|
|
|
|
|
|
|
anchors.fill: parent |
|
|
|
|
|
|
|
focus: albumModelId.count !== 0 |
|
|
|
|
|
|
|
initialItem: MainCtx.gridView ? gridComponent : tableComponent |
|
|
|
Component { |
|
|
|
id: emptyLabelComponent |
|
|
|
|
|
|
|
Connections { |
|
|
|
target: MainCtx |
|
|
|
onGridViewChanged: { |
|
|
|
if (MainCtx.gridView) |
|
|
|
view.replace(gridComponent) |
|
|
|
else |
|
|
|
view.replace(tableComponent) |
|
|
|
} |
|
|
|
EmptyLabelButton { |
|
|
|
text: I18n.qtr("No albums found\nPlease try adding sources, by going to the Browse tab") |
|
|
|
Navigation.parentItem: root |
|
|
|
cover: VLCStyle.noArtAlbumCover |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
EmptyLabelButton { |
|
|
|
anchors.fill: parent |
|
|
|
visible: albumModelId.isReady && (albumModelId.count <= 0) |
|
|
|
focus: visible |
|
|
|
text: I18n.qtr("No albums found\nPlease try adding sources, by going to the Browse tab") |
|
|
|
Navigation.parentItem: root |
|
|
|
cover: VLCStyle.noArtAlbumCover |
|
|
|
} |
|
|
|
} |
|
|
|
|