1 /*****************************************************************************
2 * Copyright (C) 2019 VLC authors and VideoLAN
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * ( at your option ) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17 *****************************************************************************/
19 import QtQuick.Controls 2.4
20 import QtQuick.Layouts 1.3
21 import org.videolan.medialib 0.1
22 import org.videolan.vlc 0.1
24 import "qrc:///style/"
25 import "qrc:///main/" as Main
26 import "qrc:///widgets/" as Widgets
27 import "qrc:///util/KeyHelper.js" as KeyHelper
28 import "qrc:///playlist/" as PL
29 import "qrc:///player/" as Player
30 import "qrc:///network/" as Network
32 Widgets.NavigableFocusScope {
35 //name and properties of the tab to be initially loaded
36 property string view: ""
37 property var viewProperties: ({})
39 onViewChanged: loadView()
40 onViewPropertiesChanged: loadView()
41 Component.onCompleted: {
47 var found = stackView.loadView(root.pageModel, root.view, root.viewProperties)
49 sourcesBanner.subTabModel = stackView.currentItem.tabModel
50 sourcesBanner.sortModel = stackView.currentItem.sortModel
51 sourcesBanner.contentModel = stackView.currentItem.contentModel
52 sourcesBanner.extraLocalActions = stackView.currentItem.extraLocalActions
53 // Restore sourcesBanner state
54 sourcesBanner.selectedIndex = pageModel.findIndex(function (e) {
55 return e.name === root.view
57 if (stackView.currentItem.pageModel !== undefined)
58 sourcesBanner.subSelectedIndex = stackView.currentItem.pageModel.findIndex(function (e) {
59 return e.name === stackView.currentItem.view
63 navigationCancel: function() {
68 if (KeyHelper.matchSearch(event)) {
69 sourcesBanner.search()
72 //unhandled keys are forwarded as hotkeys
74 rootWindow.sendHotkey(event.key, event.modifiers);
80 navigationParent: medialibId
81 navigationUpItem: sourcesBanner
82 navigationRightItem: playlist
83 navigationDownItem: miniPlayer.expanded ? miniPlayer : medialibId
90 navigationParent: medialibId
91 navigationUpItem: sourcesBanner
92 navigationRightItem: playlist
93 navigationDownItem: miniPlayer.expanded ? miniPlayer : medialibId
99 Network.NetworkDisplay {
100 navigationParent: medialibId
101 navigationUpItem: sourcesBanner
102 navigationRightItem: playlist
103 navigationDownItem: miniPlayer.expanded ? miniPlayer : medialibId
107 readonly property var pageModel: [
109 displayText: i18n.qtr("Video"),
110 icon: VLCIcons.topbar_video,
114 displayText: i18n.qtr("Music"),
115 icon: VLCIcons.topbar_music,
119 displayText: i18n.qtr("Network"),
120 icon: VLCIcons.topbar_network,
122 component: networkComp
126 property var tabModel: ListModel {
128 Component.onCompleted: {
129 pageModel.forEach(function(e) {
131 displayText: e.displayText,
140 color: VLCStyle.colors.bg
143 Widgets.NavigableFocusScope {
148 navigationParent: root
154 Layout.minimumWidth: VLCStyle.minWindowWidth
157 /* Source selection*/
161 Layout.preferredHeight: height
162 Layout.minimumHeight: height
163 Layout.maximumHeight: height
164 Layout.fillWidth: true
170 sourcesBanner.subTabModel = undefined
171 var name = root.tabModel.get(index).name
172 selectedIndex = index
173 history.push(["mc", name])
177 subSelectedIndex = index
178 stackView.currentItem.loadIndex(index)
179 sortModel = stackView.currentItem.sortModel
180 contentModel = stackView.currentItem.contentModel
181 extraLocalActions = stackView.currentItem.extraLocalActions
184 navigationParent: medialibId
185 navigationDownItem: stackView
189 Layout.fillWidth: true
190 Layout.fillHeight: true
192 Widgets.StackViewExt {
197 bottom: parent.bottom
198 right: playlist.visible ? playlist.left : parent.right
199 rightMargin: (rootWindow.playlistDocked && rootWindow.playlistVisible)
201 : VLCStyle.applicationHorizontalMargin
202 leftMargin: VLCStyle.applicationHorizontalMargin
205 Widgets.ScanProgressBar {
210 bottom: parent.bottom
211 rightMargin: VLCStyle.margin_small
212 leftMargin: VLCStyle.margin_small
218 PL.PlaylistListView {
222 visible: rootWindow.playlistDocked && rootWindow.playlistVisible
226 bottom: parent.bottom
229 rightPadding: VLCStyle.applicationHorizontalMargin
231 navigationParent: medialibId
232 navigationLeftItem: stackView
233 navigationUpItem: sourcesBanner
234 navigationDownItem: miniPlayer.expanded ? miniPlayer : undefined
240 bottom: parent.bottom
242 width: VLCStyle.margin_xxsmall
243 color: VLCStyle.colors.banner
251 navigationParent: medialibId
252 navigationUpItem: stackView
253 navigationCancelItem:sourcesBanner
255 if (!expanded && miniPlayer.activeFocus)
256 stackView.forceActiveFocus()