[vlc-commits] qml: add PIP player
Pierre Lamot
git at videolan.org
Mon Dec 7 12:31:53 UTC 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Oct 16 10:05:57 2020 +0200| [7f6f993b209966c496e325c397bf33baa79e23b6] | committer: Pierre Lamot
qml: add PIP player
A floating player that can be dragged around while browsing the ML
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7f6f993b209966c496e325c397bf33baa79e23b6
---
modules/gui/qt/Makefile.am | 2 +
modules/gui/qt/player/qml/PIPPlayer.qml | 138 ++++++++++++++++++++++++++++++
modules/gui/qt/vlc.qrc | 2 +
modules/gui/qt/widgets/qml/IconButton.qml | 46 ++++++++++
4 files changed, 188 insertions(+)
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 668af1f625..83a8eb8b45 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -663,6 +663,7 @@ libqt_plugin_la_QML = \
gui/qt/player/qml/ControlButtons.qml \
gui/qt/player/qml/LanguageMenu.qml \
gui/qt/player/qml/MiniPlayer.qml \
+ gui/qt/player/qml/PIPPlayer.qml \
gui/qt/player/qml/Player.qml \
gui/qt/player/qml/PlayerButtonsLayout.qml \
gui/qt/player/qml/PlayerMenu.qml \
@@ -701,6 +702,7 @@ libqt_plugin_la_QML = \
gui/qt/widgets/qml/GridItem.qml \
gui/qt/widgets/qml/HorizontalResizeHandle.qml \
gui/qt/widgets/qml/IconLabel.qml \
+ gui/qt/widgets/qml/IconButton.qml \
gui/qt/widgets/qml/IconToolButton.qml \
gui/qt/widgets/qml/ImageToolButton.qml \
gui/qt/widgets/qml/KeyNavigableGridView.qml \
diff --git a/modules/gui/qt/player/qml/PIPPlayer.qml b/modules/gui/qt/player/qml/PIPPlayer.qml
new file mode 100644
index 0000000000..23509db361
--- /dev/null
+++ b/modules/gui/qt/player/qml/PIPPlayer.qml
@@ -0,0 +1,138 @@
+/*****************************************************************************
+ * 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 org.videolan.vlc 0.1
+import "qrc:///style/"
+import "qrc:///widgets/" as Widgets
+
+Item {
+ id: root
+ width: VLCStyle.dp(320, VLCStyle.scale)
+ height: VLCStyle.dp(180, VLCStyle.scale)
+
+ //VideoSurface x,y won't update
+ onXChanged: videoSurface.onSurfacePositionChanged()
+ onYChanged: videoSurface.onSurfacePositionChanged()
+
+ property real dragXMin: 0
+ property real dragXMax: 0
+ property real dragYMin: undefined
+ property real dragYMax: undefined
+
+ Connections {
+ target: mouseArea.drag
+ onActiveChanged: {
+ root.anchors.left = undefined;
+ root.anchors.right = undefined
+ root.anchors.top = undefined
+ root.anchors.bottom = undefined
+ root.anchors.verticalCenter = undefined;
+ root.anchors.horizontalCenter = undefined
+ }
+ }
+ Drag.active: mouseArea.drag.active
+
+ VideoSurface {
+ id: videoSurface
+
+ anchors.fill: parent
+
+ enabled: root.enabled
+ visible: root.visible
+
+ ctx: mainctx
+
+ //punch a transparent hole in the interface
+ layer.enabled: true
+ layer.effect: ShaderEffect {
+ blending: false
+ fragmentShader: "void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); }"
+ }
+ }
+
+ MouseArea {
+ id: mouseArea
+
+ anchors.fill: videoSurface
+ z: 1
+
+ hoverEnabled: true
+ onClicked: mainPlaylistController.togglePlayPause()
+
+ enabled: root.enabled
+ visible: root.visible
+
+ cursorShape: drag.active ? Qt.DragMoveCursor : undefined
+ drag.target: root
+ drag.minimumX: root.dragXMin
+ drag.minimumY: root.dragYMin
+ drag.maximumX: root.dragXMax
+ drag.maximumY: root.dragYMax
+
+ onWheel: wheel.accept()
+
+ Rectangle {
+ color: "#10000000"
+ anchors.fill: parent
+ visible: parent.containsMouse
+
+ Widgets.IconButton {
+ anchors.centerIn: parent
+
+ font.pixelSize: VLCStyle.dp(60, VLCStyle.scale)
+ text: (player.playingState !== PlayerController.PLAYING_STATE_PAUSED
+ && player.playingState !== PlayerController.PLAYING_STATE_STOPPED)
+ ? VLCIcons.pause
+ : VLCIcons.play
+
+ onClicked: mainPlaylistController.togglePlayPause()
+ }
+
+ Widgets.IconButton {
+ anchors {
+ top: parent.top
+ topMargin: VLCStyle.margin_small
+ right: parent.right
+ rightMargin: VLCStyle.margin_small
+ }
+
+ font.pixelSize: VLCStyle.dp(20, VLCStyle.scale)
+ text: VLCIcons.close
+
+ onClicked: mainPlaylistController.stop()
+ }
+
+
+ Widgets.IconButton {
+ anchors {
+ top: parent.top
+ topMargin: VLCStyle.margin_small
+ left: parent.left
+ leftMargin: VLCStyle.margin_small
+ }
+
+ font.pixelSize: VLCStyle.dp(20, VLCStyle.scale)
+ text: VLCIcons.fullscreen
+
+ onClicked: history.push(["player"])
+ }
+ }
+ }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 6a1a413f34..1200fe382b 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -239,6 +239,7 @@
<file alias="CheckedDelegate.qml">widgets/qml/CheckedDelegate.qml</file>
<file alias="PageLoader.qml">widgets/qml/PageLoader.qml</file>
<file alias="LocalTabBar.qml">widgets/qml/LocalTabBar.qml</file>
+ <file alias="IconButton.qml">widgets/qml/IconButton.qml</file>
</qresource>
<qresource prefix="/network">
<file alias="AddressbarButton.qml">network/qml/AddressbarButton.qml</file>
@@ -304,6 +305,7 @@
<file alias="TeletextWidget.qml">player/qml/TeletextWidget.qml</file>
<file alias="MiniPlayer.qml">player/qml/MiniPlayer.qml</file>
<file alias="TopBar.qml">player/qml/TopBar.qml</file>
+ <file alias="PIPPlayer.qml">player/qml/PIPPlayer.qml</file>
<file alias="PlayerButtonsLayout.qml">player/qml/PlayerButtonsLayout.qml</file>
<file alias="PlayerMenu.qml">player/qml/PlayerMenu.qml</file>
<file alias="PlayerMenuItem.qml">player/qml/PlayerMenuItem.qml</file>
diff --git a/modules/gui/qt/widgets/qml/IconButton.qml b/modules/gui/qt/widgets/qml/IconButton.qml
new file mode 100644
index 0000000000..90df21ad6e
--- /dev/null
+++ b/modules/gui/qt/widgets/qml/IconButton.qml
@@ -0,0 +1,46 @@
+/*****************************************************************************
+ * 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 QtQuick.Templates 2.4 as T
+import "qrc:///style/"
+
+T.Button {
+ id: control
+
+ width: content.implicitWidth
+ height: content.implicitHeight
+
+ property color color: "white"
+ font.family: VLCIcons.fontFamily
+
+ contentItem: Item {
+ Label {
+ id: content
+ anchors.centerIn: parent
+ text: control.text
+ color: control.color
+ font: control.font
+ }
+ }
+
+ background: Item {
+ implicitWidth: 10
+ implicitHeight: 10
+ }
+}
More information about the vlc-commits
mailing list