From ec4484f81f9bb1c6d126231c8b9f2c59f65cb651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Sun, 10 Dec 2017 16:45:11 -0200 Subject: [PATCH] Add video popup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- qgcresources.qrc | 1 + src/FlightDisplay/FlightDisplayView.qml | 72 ++++++++++++++++++++- src/FlightDisplay/VideoManager.h | 3 + src/FlightMap/Images/PiP.svg | 73 ++++++++++++++++++--- src/FlightMap/Images/pipHide.svg | 84 +++++++++++++++++++++++++ src/QmlControls/QGCPipable.qml | 28 ++++++++- 6 files changed, 248 insertions(+), 13 deletions(-) create mode 100644 src/FlightMap/Images/pipHide.svg diff --git a/qgcresources.qrc b/qgcresources.qrc index e638acf3f..5b6fa54b5 100644 --- a/qgcresources.qrc +++ b/qgcresources.qrc @@ -109,6 +109,7 @@ src/FlightMap/Images/compassInstrumentDial.svg src/FlightMap/Images/crossHair.svg src/FlightMap/Images/PiP.svg + src/FlightMap/Images/pipHide.svg src/FlightMap/Images/pipResize.svg src/FlightMap/Images/rollDialWhite.svg src/FlightMap/Images/rollPointerWhite.svg diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index e2ff0b234..9daed693e 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -16,6 +16,7 @@ import QtLocation 5.3 import QtPositioning 5.3 import QtMultimedia 5.5 import QtQuick.Layouts 1.2 +import QtQuick.Window 2.2 import QGroundControl 1.0 import QGroundControl.FlightDisplay 1.0 @@ -182,6 +183,24 @@ QGCView { } } + Window { + id: videoWindow + width: !_mainIsMap ? _panel.width : _pipSize + height: !_mainIsMap ? _panel.height : _pipSize * (9/16) + visible: false + + Item { + id: videoItem + anchors.fill: parent + } + + onClosing: { + _flightVideo.state = "unpopup" + videoWindow.visible = false + } + + } + QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true } QGCViewPanel { @@ -242,7 +261,11 @@ QGCView { name: "pipMode" PropertyChanges { target: _flightVideo - anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.margins: ScreenTools.defaultFontPixelHeight + } + PropertyChanges { + target: _flightVideoPipControl + inPopup: false } }, State { @@ -251,10 +274,53 @@ QGCView { target: _flightVideo anchors.margins: 0 } + PropertyChanges { + target: _flightVideoPipControl + inPopup: false + } + }, + State { + name: "popup" + StateChangeScript { + script: QGroundControl.videoManager.stopVideo() + } + ParentChange { + target: _flightVideo + parent: videoItem + x: 0 + y: 0 + width: videoWindow.width + height: videoWindow.height + } + PropertyChanges { + target: _flightVideoPipControl + inPopup: true + } + }, + State { + name: "unpopup" + StateChangeScript { + script: QGroundControl.videoManager.stopVideo() + } + ParentChange { + target: _flightVideo + parent: _panel + } + PropertyChanges { + target: _flightVideo + anchors.left: _panel.left + anchors.bottom: _panel.bottom + anchors.margins: ScreenTools.defaultFontPixelHeight + } + PropertyChanges { + target: _flightVideoPipControl + inPopup: false + } } ] //-- Video Streaming FlightDisplayViewVideo { + id: videoStreaming anchors.fill: parent visible: QGroundControl.videoManager.isGStreamer } @@ -285,6 +351,10 @@ QGCView { onHideIt: { setPipVisibility(!state) } + onPopup: { + videoWindow.visible = true + _flightVideo.state = "popup" + } onNewWidth: { _pipSize = newWidth } diff --git a/src/FlightDisplay/VideoManager.h b/src/FlightDisplay/VideoManager.h index 2db9e8aa1..f419af90a 100644 --- a/src/FlightDisplay/VideoManager.h +++ b/src/FlightDisplay/VideoManager.h @@ -56,6 +56,9 @@ public: // Override from QGCTool void setToolbox (QGCToolbox *toolbox); + Q_INVOKABLE void startVideo() {_videoReceiver->stop();}; + Q_INVOKABLE void stopVideo() {_videoReceiver->stop();}; + signals: void hasVideoChanged (); void isGStreamerChanged (); diff --git a/src/FlightMap/Images/PiP.svg b/src/FlightMap/Images/PiP.svg index f73f1e577..84739056b 100644 --- a/src/FlightMap/Images/PiP.svg +++ b/src/FlightMap/Images/PiP.svg @@ -1,10 +1,63 @@ - - - - - - - - - + + + +image/svg+xml \ No newline at end of file diff --git a/src/FlightMap/Images/pipHide.svg b/src/FlightMap/Images/pipHide.svg new file mode 100644 index 000000000..73200628f --- /dev/null +++ b/src/FlightMap/Images/pipHide.svg @@ -0,0 +1,84 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/QmlControls/QGCPipable.qml b/src/QmlControls/QGCPipable.qml index 3a84d47b8..dfcd10be1 100644 --- a/src/QmlControls/QGCPipable.qml +++ b/src/QmlControls/QGCPipable.qml @@ -26,9 +26,12 @@ Item { property real maxSize: 0.75 property real minSize: 0.10 + property bool inPopup: false + signal activated() signal hideIt(bool state) signal newWidth(real newWidth) + signal popup() MouseArea { id: pipMouseArea @@ -87,7 +90,7 @@ Item { mipmap: true anchors.right: parent.right anchors.top: parent.top - visible: !isHidden && (ScreenTools.isMobile || pipMouseArea.containsMouse) + visible: !isHidden && (ScreenTools.isMobile || pipMouseArea.containsMouse) && !inPopup height: ScreenTools.defaultFontPixelHeight * 2.5 width: ScreenTools.defaultFontPixelHeight * 2.5 sourceSize.height: height @@ -116,10 +119,31 @@ Item { } } + //-- PIP Popup Indicator + Image { + id: popupPIP + source: "/qmlimages/PiP.svg" + mipmap: true + fillMode: Image.PreserveAspectFit + anchors.left: parent.left + anchors.top: parent.top + visible: !isHidden && (ScreenTools.isMobile || pipMouseArea.containsMouse) && !inPopup && !ScreenTools.isMobile + height: ScreenTools.defaultFontPixelHeight * 2.5 + width: ScreenTools.defaultFontPixelHeight * 2.5 + sourceSize.height: height + MouseArea { + anchors.fill: parent + onClicked: { + inPopup = true + pip.popup() + } + } + } + //-- PIP Corner Indicator Image { id: closePIP - source: "/qmlimages/PiP.svg" + source: "/qmlimages/pipHide.svg" mipmap: true fillMode: Image.PreserveAspectFit anchors.left: parent.left -- 2.22.0