vlc | branch: master | Abel Tesfaye <[email protected]> | Thu Jul 25 14:38:27 2019 +0300| [abe3929e5e0213060593ec098543a70bc2bc33d4] | committer: Jean-Baptiste Kempf
qml: add contextMenu > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=abe3929e5e0213060593ec098543a70bc2bc33d4 --- modules/gui/qt/qml/dialogs/ModalDialog.qml | 4 +- modules/gui/qt/qml/mediacenter/MCVideoDisplay.qml | 103 +++++++++++++++++----- modules/gui/qt/qml/utils/GridItem.qml | 44 +++++++-- 3 files changed, 122 insertions(+), 29 deletions(-) diff --git a/modules/gui/qt/qml/dialogs/ModalDialog.qml b/modules/gui/qt/qml/dialogs/ModalDialog.qml index 95178b6d7f..5e6ddcf317 100644 --- a/modules/gui/qt/qml/dialogs/ModalDialog.qml +++ b/modules/gui/qt/qml/dialogs/ModalDialog.qml @@ -31,8 +31,8 @@ Dialog { focus: true modal: true - x: (rootWindow.width - width) / 2 - y: (rootWindow.height - height) / 2 + x: (rootWindow.x + rootWindow.width - width) / 2 + y: (rootWindow.y + rootWindow.height - height) / 2 padding: VLCStyle.margin_normal margins: VLCStyle.margin_large diff --git a/modules/gui/qt/qml/mediacenter/MCVideoDisplay.qml b/modules/gui/qt/qml/mediacenter/MCVideoDisplay.qml index 6ffdb82e33..abf8807b3b 100644 --- a/modules/gui/qt/qml/mediacenter/MCVideoDisplay.qml +++ b/modules/gui/qt/qml/mediacenter/MCVideoDisplay.qml @@ -22,6 +22,7 @@ import QtQml.Models 2.2 import org.videolan.medialib 0.1 import "qrc:///utils/" as Utils +import "qrc:///dialogs/" as DG import "qrc:///style/" Utils.NavigableFocusScope { @@ -29,6 +30,58 @@ Utils.NavigableFocusScope { property alias model: delegateModel.model + DG.ModalDialog { + id: deleteDialog + rootWindow: root + title: qsTr("Are you sure you want to delete?") + standardButtons: Dialog.Yes | Dialog.No + + onAccepted: console.log("Ok clicked") + onRejected: console.log("Cancel clicked") + } + + Utils.MenuExt { + id: contextMenu + property var model: ({}) + closePolicy: Popup.CloseOnReleaseOutside | Popup.CloseOnEscape + + Utils.MenuItemExt { + id: playMenuItem + text: "Play from start" + onTriggered: medialib.addAndPlay( contextMenu.model.id ) + } + Utils.MenuItemExt { + text: "Play all" + onTriggered: console.log("not implemented") + } + Utils.MenuItemExt { + text: "Play as audio" + onTriggered: console.log("not implemented") + } + Utils.MenuItemExt { + text: "Enqueue" + onTriggered: medialib.addToPlaylist( contextMenu.model.id ) + } + Utils.MenuItemExt { + text: "Information" + onTriggered: console.log("not implemented") + } + Utils.MenuItemExt { + text: "Download subtitles" + onTriggered: console.log("not implemented") + } + Utils.MenuItemExt { + text: "Add to playlist" + onTriggered: console.log("not implemented") + } + Utils.MenuItemExt { + text: "Delete" + onTriggered: deleteDialog.open() + } + + onClosed: contextMenu.parent.forceActiveFocus() + + } Utils.SelectableDelegateModel { id: delegateModel model: MLVideoModel { @@ -50,14 +103,24 @@ Utils.NavigableFocusScope { progress: Math.max(model.saved_position,0) onItemClicked : { - delegateModel.updateSelection( modifier , view.currentItem.currentIndex, index) - view.currentItem.currentIndex = index - view.currentItem.forceActiveFocus() + if (key == Qt.RightButton){ + contextMenu.model = model + contextMenu.popup() + } + else { + delegateModel.updateSelection( modifier , view.currentItem.currentIndex, index) + view.currentItem.currentIndex = index + view.currentItem.forceActiveFocus() + } } onPlayClicked: medialib.addAndPlay( model.id ) onAddToPlaylistClicked : medialib.addToPlaylist( model.id ) - } + onContextMenuButtonClicked:{ + contextMenu.model = model; + contextMenu.popup(menuParent,contextMenu.width,0,playMenuItem) + } + } Utils.ListItem { Package.name: "list" width: root.width @@ -107,7 +170,6 @@ Utils.NavigableFocusScope { Component { id: gridComponent - Utils.KeyNavigableGridView { id: gridView_id @@ -194,27 +256,24 @@ Utils.NavigableFocusScope { } } - Utils.StackViewExt { - id: view - - anchors.fill: parent - anchors.margins: VLCStyle.margin_normal + Utils.StackViewExt { + id: view - focus: true + anchors.fill: root - initialItem: medialib.gridView ? gridComponent : listComponent - - Connections { - target: medialib - onGridViewChanged: { - if (medialib.gridView) - view.replace(gridComponent) - else - view.replace(listComponent) + focus: true + initialItem: medialib.gridView ? gridComponent : listComponent + Connections { + target: medialib + onGridViewChanged: { + if (medialib.gridView) + view.replace(gridComponent) + else + view.replace(listComponent) + } } - } - } + } Label { anchors.centerIn: parent visible: delegateModel.items.count === 0 diff --git a/modules/gui/qt/qml/utils/GridItem.qml b/modules/gui/qt/qml/utils/GridItem.qml index f6a5656a65..6bb90d9e3c 100644 --- a/modules/gui/qt/qml/utils/GridItem.qml +++ b/modules/gui/qt/qml/utils/GridItem.qml @@ -45,9 +45,11 @@ Rectangle { signal playClicked signal addToPlaylistClicked - signal itemClicked(int keys, int modifier) + signal itemClicked(int key, int modifier) signal itemDoubleClicked(int keys, int modifier) + signal contextMenuButtonClicked(Item menuParent) + Rectangle { id: gridItem x: shiftX @@ -58,12 +60,12 @@ Rectangle { MouseArea { id: mouseArea hoverEnabled: true - onClicked: { - root.itemClicked(mouse.buttons, mouse.modifiers) - } + onClicked: root.itemClicked(mouse.button, mouse.modifiers) onDoubleClicked: root.itemDoubleClicked(mouse.buttons, mouse.modifiers); width: childrenRect.width height: childrenRect.height + acceptedButtons: Qt.RightButton | Qt.LeftButton + Keys.onMenuPressed: root.contextMenuButtonClicked(cover_bg) Item { id: picture @@ -157,7 +159,6 @@ Rectangle { } } } - ProgressBar { id: progressBar value: root.progress @@ -181,6 +182,39 @@ Rectangle { } } + Button { + id: contextButton + visible: isVideo + anchors { + top:cover.top + right:cover.right + } + width: VLCStyle.icon_normal + height: VLCStyle.icon_normal + text: "\u22ef" //ellipsis icon + font.pointSize: VLCStyle.fontMetrics_normal + + hoverEnabled: true + onClicked: root.contextMenuButtonClicked(cover_bg) + background: Rectangle { + id: contextButtonRect + anchors.fill: contextButton + color: "transparent" + } + contentItem: Text { + id: btnTxt + text: contextButton.text + font: contextButton.font + color: "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + // layer.enabled: true + // layer.effect: DropShadow { + // color: VLCStyle.colors.text + // } + + } + } states: [ State { name: "visible" _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
