vlc | branch: master | Adrien Maglo <[email protected]> | Tue Jun 18 15:11:15 2019 +0200| [72d205abec9b7742a763ff96bc9c653e8a170c15] | committer: Jean-Baptiste Kempf
QML: implement keyboard navigation to the mini player Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=72d205abec9b7742a763ff96bc9c653e8a170c15 --- modules/gui/qt/qml/mediacenter/MCMainDisplay.qml | 161 ++++++++++++++--------- modules/gui/qt/qml/mediacenter/MiniPlayer.qml | 12 +- 2 files changed, 110 insertions(+), 63 deletions(-) diff --git a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml index d5d07e9f2e..3e74cf9a4d 100644 --- a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml +++ b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml @@ -130,82 +130,121 @@ Utils.NavigableFocusScope { contentModel = stackView.currentItem.contentModel } - onActionDown: stackView.focus = true + onActionDown: stackViewZone.focus = true onActionLeft: root.actionLeft(index) onActionRight: root.actionRight(index) onActionUp: root.actionUp(index) onActionCancel: root.actionCancel(index) } - Utils.StackViewExt { - id: stackView + Item { Layout.fillWidth: true Layout.fillHeight: true - Component.onCompleted: { - var found = stackView.loadView(root.pageModel, root.view, root.viewProperties) - sourcesBanner.subTabModel = stackView.currentItem.tabModel - sourcesBanner.sortModel = stackView.currentItem.sortModel - sourcesBanner.contentModel = stackView.currentItem.contentModel - // Restore sourcesBanner state - sourcesBanner.selectedIndex = pageModel.findIndex(function (e) { - return e.name === root.view - }) - if (stackView.currentItem.pageModel !== undefined) - sourcesBanner.subSelectedIndex = stackView.currentItem.pageModel.findIndex(function (e) { - return e.name === stackView.currentItem.view - }) - } - Utils.Drawer { - z: 1 - id: playlist - anchors { - top: parent.top - right: parent.right - bottom: parent.bottom + Utils.NavigableFocusScope { + id: stackViewZone + anchors.fill: parent + + Rectangle { + visible: parent.focus + anchors.fill: parent + color: "transparent" + border.width: VLCStyle.selectedBorder + border.color: VLCStyle.colors.accent } - focus: false - expandHorizontally: true - state: (rootWindow.playlistDocked && rootWindow.playlistVisible) ? "visible" : "hidden" - onVisibleChanged: { - if (playlist.visible) - playlist.forceActiveFocus() + onActionUp: sourcesBanner.focus = true + onActionDown: { + if (miniPlayer.expanded) + miniPlayer.focus = true + } + + Keys.onPressed: { + if (!event.accepted) + defaultKeyAction(event, 0) + } + Keys.onReleased: { + if (!event.accepted && (event.key === Qt.Key_Return || event.key === Qt.Key_Space)) { + event.accepted = true + stackView.focus = true + } + } + } + + Utils.StackViewExt { + id: stackView + anchors.fill: parent + + Component.onCompleted: { + var found = stackView.loadView(root.pageModel, root.view, root.viewProperties) + sourcesBanner.subTabModel = stackView.currentItem.tabModel + sourcesBanner.sortModel = stackView.currentItem.sortModel + sourcesBanner.contentModel = stackView.currentItem.contentModel + // Restore sourcesBanner state + sourcesBanner.selectedIndex = pageModel.findIndex(function (e) { + return e.name === root.view + }) + if (stackView.currentItem.pageModel !== undefined) + sourcesBanner.subSelectedIndex = stackView.currentItem.pageModel.findIndex(function (e) { + return e.name === stackView.currentItem.view + }) } - component: Rectangle { - color: VLCStyle.colors.setColorAlpha(VLCStyle.colors.banner, 0.9) - width: root.width/3 - height: playlist.height - - MouseArea { - anchors.fill: parent - propagateComposedEvents: false - hoverEnabled: true - preventStealing: true - onWheel: event.accepted = true - - PL.PlaylistListView { - id: playlistView - focus: true + + Utils.Drawer { + z: 1 + id: playlist + anchors { + top: parent.top + right: parent.right + bottom: parent.bottom + } + focus: false + expandHorizontally: true + + state: (rootWindow.playlistDocked && rootWindow.playlistVisible) ? "visible" : "hidden" + onVisibleChanged: { + if (playlist.visible) + playlist.forceActiveFocus() + } + component: Rectangle { + color: VLCStyle.colors.setColorAlpha(VLCStyle.colors.banner, 0.9) + width: root.width/3 + height: playlist.height + + MouseArea { anchors.fill: parent - onActionLeft: playlist.closeAndFocus(stackView.currentItem) - onActionCancel: playlist.closeAndFocus(stackView.currentItem) - onActionUp: playlist.closeAndFocus(sourcesBanner) + propagateComposedEvents: false + hoverEnabled: true + preventStealing: true + onWheel: event.accepted = true + + PL.PlaylistListView { + id: playlistView + focus: true + anchors.fill: parent + onActionLeft: playlist.closeAndFocus(stackView.currentItem) + onActionCancel: playlist.closeAndFocus(stackView.currentItem) + onActionUp: playlist.closeAndFocus(sourcesBanner) + } } } - } - function closeAndFocus(item){ - if (!item) - return + function closeAndFocus(item){ + if (!item) + return - rootWindow.playlistVisible = false - item.forceActiveFocus() + rootWindow.playlistVisible = false + item.forceActiveFocus() + } } } } MiniPlayer { id: miniPlayer + + onActionUp: stackViewZone.focus = true + onActionCancel: sourcesBanner.focus = true + onActionDown: medialibId.actionDown(index) } } @@ -214,11 +253,15 @@ Utils.NavigableFocusScope { ignoreUnknownSignals: true onActionUp: sourcesBanner.focus = true - onActionCancel: sourcesBanner.focus = true - - onActionLeft: medialibId.actionLeft(index) - onActionRight: medialibId.actionRight(index) - onActionDown: medialibId.actionDown(index) + onActionCancel: stackViewZone.focus = true + onActionLeft: medialibId.actionLeft(index) + onActionRight: medialibId.actionRight(index) + onActionDown: { + if (miniPlayer.expanded) + miniPlayer.focus = true + else + medialibId.actionDown(index) + } } } diff --git a/modules/gui/qt/qml/mediacenter/MiniPlayer.qml b/modules/gui/qt/qml/mediacenter/MiniPlayer.qml index b302b53063..f9c953be2e 100644 --- a/modules/gui/qt/qml/mediacenter/MiniPlayer.qml +++ b/modules/gui/qt/qml/mediacenter/MiniPlayer.qml @@ -13,6 +13,8 @@ Utils.NavigableFocusScope { Layout.fillWidth: true + readonly property bool expanded: root.implicitHeight === root.childrenRect.height + Component.onCompleted : { if (player.playingState === PlayerController.PLAYING_STATE_STOPPED) root.implicitHeight = 0; @@ -90,10 +92,7 @@ Utils.NavigableFocusScope { } Row { - focus: true - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - rightPadding: VLCStyle.margin_normal Utils.IconToolButton { @@ -137,7 +136,7 @@ Utils.NavigableFocusScope { id: repeatBtn size: VLCStyle.icon_normal checked: mainPlaylistController.repeatMode !== PlaylistControllerModel.PLAYBACK_REPEAT_NONE - text: (mainPlaylistController.repeatMode == PlaylistControllerModel.PLAYBACK_REPEAT_CURRENT) + text: (mainPlaylistController.repeatMode === PlaylistControllerModel.PLAYBACK_REPEAT_CURRENT) ? VLCIcons.repeat_one : VLCIcons.repeat_all onClicked: mainPlaylistController.toggleRepeatMode() @@ -145,4 +144,9 @@ Utils.NavigableFocusScope { } } } + + Keys.onPressed: { + if (!event.accepted) + defaultKeyAction(event, 0) + } } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
