vlc | branch: master | Pierre Lamot <[email protected]> | Thu Oct 8 13:37:34 2020 +0200| [7b01c636ce7f0146f45aa095a61681089c4afeb0] | committer: Pierre Lamot
qml: split medialib dependant widgets from the Discover > Url page > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7b01c636ce7f0146f45aa095a61681089c4afeb0 --- modules/gui/qt/Makefile.am | 1 + modules/gui/qt/medialibrary/qml/UrlListDisplay.qml | 158 ++++++--------------- modules/gui/qt/network/qml/DiscoverDisplay.qml | 2 +- modules/gui/qt/network/qml/DiscoverUrlDisplay.qml | 90 ++++++++++++ modules/gui/qt/vlc.qrc | 9 +- 5 files changed, 139 insertions(+), 121 deletions(-) diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am index eae0de1cc7..dae227fbe1 100644 --- a/modules/gui/qt/Makefile.am +++ b/modules/gui/qt/Makefile.am @@ -638,6 +638,7 @@ libqt_plugin_la_QML = \ gui/qt/menus/qml/GlobalShortcuts.qml \ gui/qt/menus/qml/Menubar.qml \ gui/qt/network/qml/DiscoverDisplay.qml \ + gui/qt/network/qml/DiscoverUrlDisplay.qml \ gui/qt/network/qml/NetworkBrowseDisplay.qml \ gui/qt/network/qml/NetworkDisplay.qml \ gui/qt/network/qml/NetworkGridItem.qml \ diff --git a/modules/gui/qt/medialibrary/qml/UrlListDisplay.qml b/modules/gui/qt/medialibrary/qml/UrlListDisplay.qml index 3fee0a621f..496a9f5ff1 100644 --- a/modules/gui/qt/medialibrary/qml/UrlListDisplay.qml +++ b/modules/gui/qt/medialibrary/qml/UrlListDisplay.qml @@ -20,6 +20,7 @@ import QtQuick 2.11 import QtQuick.Controls 2.4 import QtQml.Models 2.2 +import org.videolan.vlc 0.1 import org.videolan.medialib 0.1 import "qrc:///util" as Util @@ -27,8 +28,45 @@ import "qrc:///widgets/" as Widgets import "qrc:///util/KeyHelper.js" as KeyHelper import "qrc:///style/" -Widgets.NavigableFocusScope { - id: root + +Widgets.KeyNavigableTableView { + id: listView_id + + readonly property int _nbCols: VLCStyle.gridColumnsForWidth( + listView_id.availableRowWidth) + property Component urlHeaderDelegate: Widgets.IconLabel { + text: VLCIcons.history + color: VLCStyle.colors.caption + } + + visible: urlModel.count > 0 + model: urlModel + selectionDelegateModel: selectionModel + + sortModel: [{ + "isPrimary": true, + "criteria": "url", + "width": VLCStyle.colWidth(Math.max(listView_id._nbCols - 1, + 1)), + "text": i18n.qtr("Url"), + "showSection": "url", + headerDelegate: urlHeaderDelegate + }, { + "criteria": "last_played_date", + "width": VLCStyle.colWidth(1), + "showSection": "", + "headerDelegate": tableColumns.timeHeaderDelegate, + "showContextButton": true + }] + + rowHeight: VLCStyle.listAlbumCover_height + VLCStyle.margin_xxsmall * 2 + headerColor: VLCStyle.colors.bg + + onActionForSelection: medialib.addAndPlay(model.getIdsForIndexes( + selection)) + + onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, menuParent.mapToGlobal(0,0)) + onRightClick: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos) MLUrlModel { id: urlModel @@ -46,118 +84,8 @@ Widgets.NavigableFocusScope { model: urlModel } - Column { - anchors.fill: parent - - Item { - id: searchFieldContainer - - width: root.width - height: searchField.height + VLCStyle.margin_normal * 2 - - TextField { - id: searchField - - focus: true - anchors.centerIn: parent - height: VLCStyle.dp(32, VLCStyle.scale) - width: VLCStyle.colWidth(Math.max(VLCStyle.gridColumnsForWidth(root.width * .6), 2)) - placeholderText: i18n.qtr("Paste or write the URL here") - color: VLCStyle.colors.text - font.pixelSize: VLCStyle.fontSize_large - background: Rectangle { - color: VLCStyle.colors.bg - border.width: VLCStyle.dp(2, VLCStyle.scale) - border.color: searchField.activeFocus || searchField.hovered - ? VLCStyle.colors.accent - : VLCStyle.colors.setColorAlpha(VLCStyle.colors.text, .4) - } - - onAccepted: { - urlModel.addAndPlay(text) - } - - Keys.onPressed: { - if (event.accepted) - return - if (KeyHelper.matchUp(event)) { - root.navigationUp() - event.accepted = true - } else if (KeyHelper.matchDown(event)) { - listView_id.forceActiveFocus() - event.accepted = true - } else if (KeyHelper.matchLeft(event)) { - root.navigationLeft() - event.accepted = true - } else if (KeyHelper.matchRight(event)) { - root.navigationRight() - event.accepted = true - } - } - } - } - - - Widgets.KeyNavigableTableView { - id: listView_id - - readonly property int _nbCols: VLCStyle.gridColumnsForWidth( - listView_id.availableRowWidth) - property Component urlHeaderDelegate: Widgets.IconLabel { - text: VLCIcons.history - color: VLCStyle.colors.caption - } - - visible: urlModel.count > 0 - width: parent.width - height: parent.height - searchFieldContainer.height - model: urlModel - selectionDelegateModel: selectionModel - - sortModel: [{ - "isPrimary": true, - "criteria": "url", - "width": VLCStyle.colWidth(Math.max(listView_id._nbCols - 1, - 1)), - "text": i18n.qtr("Url"), - "showSection": "url", - headerDelegate: urlHeaderDelegate - }, { - "criteria": "last_played_date", - "width": VLCStyle.colWidth(1), - "showSection": "", - "headerDelegate": tableColumns.timeHeaderDelegate, - "showContextButton": true - }] - - rowHeight: VLCStyle.listAlbumCover_height + VLCStyle.margin_xxsmall * 2 - headerColor: VLCStyle.colors.bg - navigationUpItem: searchField - navigationParent: root - - navigationLeft: function (index) { - if (isFocusOnContextButton) - isFocusOnContextButton = false - else - defaultNavigationLeft(index) - } - navigationRight: function (index) { - if (!isFocusOnContextButton) - isFocusOnContextButton = true - else - defaultNavigationRight(index) - } - - onActionForSelection: medialib.addAndPlay(model.getIdsForIndexes( - selection)) - - onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, menuParent.mapToGlobal(0,0)) - onRightClick: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos) - - - Widgets.TableColumns { - id: tableColumns - } - } + + Widgets.TableColumns { + id: tableColumns } } diff --git a/modules/gui/qt/network/qml/DiscoverDisplay.qml b/modules/gui/qt/network/qml/DiscoverDisplay.qml index f0fe939178..c5c733edbf 100644 --- a/modules/gui/qt/network/qml/DiscoverDisplay.qml +++ b/modules/gui/qt/network/qml/DiscoverDisplay.qml @@ -42,7 +42,7 @@ Widgets.PageLoader { }, { displayText: i18n.qtr("URL"), name: "url", - url: "qrc:/medialibrary/UrlListDisplay.qml" + url: "qrc:///network/DiscoverUrlDisplay.qml" } ] diff --git a/modules/gui/qt/network/qml/DiscoverUrlDisplay.qml b/modules/gui/qt/network/qml/DiscoverUrlDisplay.qml new file mode 100644 index 0000000000..07333b6e0a --- /dev/null +++ b/modules/gui/qt/network/qml/DiscoverUrlDisplay.qml @@ -0,0 +1,90 @@ +/***************************************************************************** + * Copyright (C) 2020 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 + * the Free Software Foundation; either version 2 of the License, or + * ( at your option ) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQml.Models 2.2 + +import org.videolan.vlc 0.1 + +import "qrc:///util" as Util +import "qrc:///widgets/" as Widgets +import "qrc:///util/KeyHelper.js" as KeyHelper +import "qrc:///style/" + +Widgets.NavigableFocusScope { + id: root + + Column { + anchors.fill: parent + + Widgets.NavigableFocusScope { + id: searchFieldContainer + + width: root.width + height: searchField.height + VLCStyle.margin_normal * 2 + focus: true + + navigationParent: root + navigationDownItem: !medialib ? undefined : urlListDisplay.item + + TextField { + id: searchField + + focus: true + anchors.centerIn: parent + height: VLCStyle.dp(32, VLCStyle.scale) + width: VLCStyle.colWidth(Math.max(VLCStyle.gridColumnsForWidth(root.width * .6), 2)) + placeholderText: i18n.qtr("Paste or write the URL here") + color: VLCStyle.colors.text + font.pixelSize: VLCStyle.fontSize_large + background: Rectangle { + color: VLCStyle.colors.bg + border.width: VLCStyle.dp(2, VLCStyle.scale) + border.color: searchField.activeFocus || searchField.hovered + ? VLCStyle.colors.accent + : VLCStyle.colors.setColorAlpha(VLCStyle.colors.text, .4) + } + + onAccepted: { + mainPlaylistController.append([text], true) + } + + Keys.priority: Keys.AfterItem + Keys.onPressed: { + if (event.accepted) + return + searchFieldContainer.defaultKeyAction(event, 0) + } + } + } + + Loader { + id: urlListDisplay + + width: parent.width + height: parent.height - searchFieldContainer.height + + active: !!medialib + source: "qrc:///medialibrary/UrlListDisplay.qml" + onLoaded: { + item.navigationUpItem = searchField + item.navigationParent = root + } + } + } +} diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc index 31fc199ebb..1bd998f2a3 100644 --- a/modules/gui/qt/vlc.qrc +++ b/modules/gui/qt/vlc.qrc @@ -24,6 +24,8 @@ <file alias="wait2.svg">pixmaps/util/wait2.svg</file> <file alias="wait3.svg">pixmaps/util/wait3.svg</file> <file alias="wait4.svg">pixmaps/util/wait4.svg</file> + <file alias="SelectableDelegateModel.qml">util/qml/SelectableDelegateModel.qml</file> + <file alias="KeyHelper.js">util/qml/KeyHelper.js</file> </qresource> <qresource prefix="/toolbar"> <file alias="faster.svg">pixmaps/faster.svg</file> @@ -228,14 +230,11 @@ <file alias="HorizontalResizeHandle.qml">widgets/qml/HorizontalResizeHandle.qml</file> <file alias="PointingTooltip.qml">widgets/qml/PointingTooltip.qml</file> <file alias="FrostedGlassEffect.qml">widgets/qml/FrostedGlassEffect.qml</file> - <file alias="PageLoader.qml">widgets/qml/PageLoader.qml</file> - </qresource> - <qresource prefix="/util"> - <file alias="SelectableDelegateModel.qml">util/qml/SelectableDelegateModel.qml</file> - <file alias="KeyHelper.js">util/qml/KeyHelper.js</file> + <file alias="PageLoader.qml">widgets/qml/PageLoader.qml</file> </qresource> <qresource prefix="/network"> <file alias="DiscoverDisplay.qml">network/qml/DiscoverDisplay.qml</file> + <file alias="DiscoverUrlDisplay.qml">network/qml/DiscoverUrlDisplay.qml</file> <file alias="NetworkDisplay.qml">network/qml/NetworkDisplay.qml</file> <file alias="NetworkHomeDeviceListView.qml">network/qml/NetworkHomeDeviceListView.qml</file> <file alias="NetworkHomeDisplay.qml">network/qml/NetworkHomeDisplay.qml</file> _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
