From 1fa94b683023b369d8242105e9563308a4743c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Wed, 19 Feb 2020 10:13:24 +0100 Subject: [videoplayer] add video player for IC window Change-Id: I98cd83f2975c551084b1e27954fa631d6306d148 Reviewed-by: Egor Nemtsev --- com.luxoft.videoplayer/ControlsOverlay.qml | 18 ++++++- com.luxoft.videoplayer/ICVideoPlayerView.qml | 60 +++++++++++++++++++++++ com.luxoft.videoplayer/Main.qml | 33 ++++++++++++- com.luxoft.videoplayer/OpenFilesPanel.qml | 2 +- com.luxoft.videoplayer/VideoPlayerPanel.qml | 38 +++++++++++--- com.luxoft.videoplayer/VideoPlayerView.qml | 16 +++++- com.luxoft.videoplayer/com.luxoft.videoplayer.pro | 1 + 7 files changed, 155 insertions(+), 13 deletions(-) create mode 100644 com.luxoft.videoplayer/ICVideoPlayerView.qml diff --git a/com.luxoft.videoplayer/ControlsOverlay.qml b/com.luxoft.videoplayer/ControlsOverlay.qml index 96947ca..15906c4 100644 --- a/com.luxoft.videoplayer/ControlsOverlay.qml +++ b/com.luxoft.videoplayer/ControlsOverlay.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2020 Luxoft Sweden AB ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the Neptune 3 IVI UI. +** This file is part of the Neptune 3 UI. ** ** $QT_BEGIN_LICENSE:GPL-QTAS$ ** Commercial License Usage @@ -53,6 +53,11 @@ Rectangle { } signal fileOpenRequested(url fileURL) + signal playRequested() + signal pauseRequested() + signal stopRequested() + signal muteRequested(bool muted) + signal seekRequested(int offset) Timer { id: hideTimer @@ -127,6 +132,7 @@ Rectangle { onMoved: { hideTimer.restart(); player.seek(value); + root.seekRequested(value); } } @@ -142,7 +148,13 @@ Rectangle { enabled: player.hasVideo onClicked: { hideTimer.restart(); - player.playbackState == MediaPlayer.PlayingState ? player.pause() : player.play(); + if (player.playbackState == MediaPlayer.PlayingState) { + player.pause(); + root.pauseRequested(); + } else { + player.play(); + root.playRequested(); + } } } ToolButton { @@ -154,6 +166,7 @@ Rectangle { onClicked: { hideTimer.restart(); player.stop(); + root.stopRequested(); } } ToolButton { @@ -167,6 +180,7 @@ Rectangle { onToggled: { hideTimer.restart(); player.muted = !player.muted; + root.muteRequested(player.muted); } } } diff --git a/com.luxoft.videoplayer/ICVideoPlayerView.qml b/com.luxoft.videoplayer/ICVideoPlayerView.qml new file mode 100644 index 0000000..7a908d3 --- /dev/null +++ b/com.luxoft.videoplayer/ICVideoPlayerView.qml @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.12 +import shared.utils 1.0 +import shared.Style 1.0 +import shared.Sizes 1.0 + +Item { + id: root + + property alias sourceUrl: videoplayer.sourceUrl + property alias player: videoplayer.player + + Image { + anchors.fill: parent + source: Style.image("instrument-cluster-bg") + fillMode: Image.Stretch + } + + VideoPlayerPanel { + id: videoplayer + width: Sizes.dp(800) + height: Sizes.dp(600) + anchors.centerIn: parent + anchors.verticalCenterOffset: Sizes.dp(60) + player.muted: true + + icWindow: true + } +} diff --git a/com.luxoft.videoplayer/Main.qml b/com.luxoft.videoplayer/Main.qml index d44ef3e..e507b3b 100644 --- a/com.luxoft.videoplayer/Main.qml +++ b/com.luxoft.videoplayer/Main.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2020 Luxoft Sweden AB ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the Neptune 3 IVI UI. +** This file is part of the Neptune 3 UI. ** ** $QT_BEGIN_LICENSE:GPL-QTAS$ ** Commercial License Usage @@ -33,6 +33,8 @@ import QtQuick 2.12 import application.windows 1.0 import shared.utils 1.0 +import shared.com.pelagicore.settings 1.0 + import "." ApplicationCCWindow { @@ -51,6 +53,7 @@ ApplicationCCWindow { } VideoPlayerView { + id: videoplayer x: root.exposedRect.x y: root.exposedRect.y width: root.exposedRect.width @@ -59,4 +62,32 @@ ApplicationCCWindow { state: root.neptuneState bottomWidgetHide: root.exposedRect.height === root.targetHeight } + + InstrumentCluster { + id: clusterSettings + } + + readonly property Loader applicationICWindowLoader: Loader { + asynchronous: true + active: clusterSettings.available + || Qt.platform.os !== "linux" // FIXME and then remove; remote settings doesn't really work outside of Linux + + sourceComponent: Component { + ApplicationICWindow { + ICVideoPlayerView { + id: icVideoPlayer + anchors.fill: parent + sourceUrl: videoplayer.sourceUrl + + Connections { + target: videoplayer + onPlayRequested: icVideoPlayer.player.play() + onPauseRequested: icVideoPlayer.player.pause() + onStopRequested: icVideoPlayer.player.stop() + onSeekRequested: icVideoPlayer.player.seek(offset) + } + } + } + } + } } diff --git a/com.luxoft.videoplayer/OpenFilesPanel.qml b/com.luxoft.videoplayer/OpenFilesPanel.qml index 0a2d184..e1e600f 100644 --- a/com.luxoft.videoplayer/OpenFilesPanel.qml +++ b/com.luxoft.videoplayer/OpenFilesPanel.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2020 Luxoft Sweden AB ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the Neptune 3 IVI UI. +** This file is part of the Neptune 3 UI. ** ** $QT_BEGIN_LICENSE:GPL-QTAS$ ** Commercial License Usage diff --git a/com.luxoft.videoplayer/VideoPlayerPanel.qml b/com.luxoft.videoplayer/VideoPlayerPanel.qml index 71be88f..d7f82a3 100644 --- a/com.luxoft.videoplayer/VideoPlayerPanel.qml +++ b/com.luxoft.videoplayer/VideoPlayerPanel.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2020 Luxoft Sweden AB ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the Neptune 3 IVI UI. +** This file is part of the Neptune 3 UI. ** ** $QT_BEGIN_LICENSE:GPL-QTAS$ ** Commercial License Usage @@ -36,9 +36,21 @@ import QtMultimedia 5.12 import "utils.js" as Utils Rectangle { + id: root implicitWidth: 800 implicitHeight: 600 - color: "black" + color: icWindow ? "transparent" : "black" + + property bool icWindow + property alias sourceUrl: videoplayer.source + property alias player: videoplayer + + signal fileOpenRequested(url fileURL) + signal playRequested() + signal pauseRequested() + signal stopRequested() + signal muteRequested(bool muted) + signal seekRequested(int offset) Video { id: videoplayer @@ -63,21 +75,23 @@ Rectangle { console.debug("Supported audio roles:", supportedAudioRoles()) } - focus: true + focus: !root.icWindow Keys.onLeftPressed: seek(position - 5000) Keys.onRightPressed: seek(position + 5000) Keys.onUpPressed: videoplayer.volume += .1 Keys.onDownPressed: videoplayer.volume -= .1 - Keys.enabled: videoplayer.seekable + Keys.enabled: videoplayer.seekable && !root.icWindow MouseArea { anchors.fill: parent + enabled: !root.icWindow + visible: enabled onClicked: controls.shouldShow = !controls.shouldShow } ToolButton { anchors.centerIn: parent - visible: !videoplayer.hasVideo && !controls.shouldShow + visible: !videoplayer.hasVideo && !controls.shouldShow && !root.icWindow text: qsTr("Open video...") onClicked: { controls.shouldShow = !controls.shouldShow; @@ -90,10 +104,18 @@ Rectangle { width: parent.width height: parent.height x: parent.x - y: shouldShow ? 0 : parent.height + y: shouldShow && !root.icWindow ? 0 : parent.height player: videoplayer - Behavior on y { NumberAnimation {}} - onFileOpenRequested: videoplayer.source = fileURL + Behavior on y { NumberAnimation {} } + onFileOpenRequested: { + videoplayer.source = ""; + videoplayer.source = fileURL; + } + onPlayRequested: root.playRequested() + onPauseRequested: root.pauseRequested() + onStopRequested: root.stopRequested() + onSeekRequested: root.seekRequested(offset) + onMuteRequested: root.muteRequested(muted) } } } diff --git a/com.luxoft.videoplayer/VideoPlayerView.qml b/com.luxoft.videoplayer/VideoPlayerView.qml index 50c5050..4e4b546 100644 --- a/com.luxoft.videoplayer/VideoPlayerView.qml +++ b/com.luxoft.videoplayer/VideoPlayerView.qml @@ -3,7 +3,7 @@ ** Copyright (C) 2020 Luxoft Sweden AB ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the Neptune 3 IVI UI. +** This file is part of the Neptune 3 UI. ** ** $QT_BEGIN_LICENSE:GPL-QTAS$ ** Commercial License Usage @@ -42,6 +42,14 @@ Item { id: root property bool bottomWidgetHide: false + property alias sourceUrl: videoplayer.sourceUrl + + signal fileOpenRequested(url fileURL) + signal playRequested() + signal pauseRequested() + signal stopRequested() + signal muteRequested(bool muted) + signal seekRequested(int offset) // Top content background Image { @@ -57,7 +65,13 @@ Item { ColumnLayout { anchors.fill: parent VideoPlayerPanel { + id: videoplayer anchors.fill: parent + onPlayRequested: root.playRequested() + onPauseRequested: root.pauseRequested() + onStopRequested: root.stopRequested() + onSeekRequested: root.seekRequested(offset) + onMuteRequested: root.muteRequested(muted) } } } diff --git a/com.luxoft.videoplayer/com.luxoft.videoplayer.pro b/com.luxoft.videoplayer/com.luxoft.videoplayer.pro index f0c6bb3..46f9788 100644 --- a/com.luxoft.videoplayer/com.luxoft.videoplayer.pro +++ b/com.luxoft.videoplayer/com.luxoft.videoplayer.pro @@ -7,6 +7,7 @@ FILES += info.yaml \ VideoPlayerPanel.qml \ ControlsOverlay.qml \ OpenFilesPanel.qml \ + ICVideoPlayerView.qml \ utils.js app.files = $$FILES -- cgit v1.2.3