5import QtQuick.Controls as QQC2
9import org.kde.kirigami as Kirigami
17 required property string source
25 required property string tempSource
32 required property real sourceWidth
39 required property real sourceHeight
49 required property string caption
57 readonly property int type: AlbumModelItem.Video
66 property bool autoLoad
71 property bool autoPlay
79 property DownloadAction downloadAction: DownloadAction {
80 onTriggered: videoItem.play()
89 property Kirigami.Action playAction: Kirigami.Action {
90 onTriggered: videoItem.play()
99 property Kirigami.Action pauseAction: Kirigami.Action {
100 onTriggered: videoItem.pause()
106 property alias playbackState: videoItem.playbackState
114 property var padding: Kirigami.Units.largeSpacing
119 property var scaleFactor: 1
124 signal backgroundClicked()
129 signal itemRightClicked()
150 anchors.centerIn: parent
152 if (root.sourceWidth > 0 ) {
153 return Math.min(root.sourceWidth, root.width - root.padding * 2)
154 } else if (metaData.resolution && metaData.resolution.width) {
155 return Math.min(metaData.resolution.width, root.width - root.padding * 2)
161 if (root.sourceHeight > 0 ) {
162 return Math.min(root.sourceHeight, root.height - root.padding * 2)
163 } else if (metaData.resolution && metaData.resolution.height) {
164 return Math.min(metaData.resolution.height, root.height - root.padding * 2)
172 if (source.toString().length > 0 && root.autoPlay && root.index === root.ListView.view.currentIndex) {
173 root.playAction.trigger()
180 NumberAnimation {duration: Kirigami.Units.longDuration; easing.type: Easing.InOutCubic}
183 NumberAnimation {duration:
Kirigami.Units.longDuration; easing.type: Easing.InOutCubic}
188 anchors.centerIn: parent
189 width: root.sourceWidth > 0 || (videoItem.metaData.resolution && videoItem.metaData.resolution.width > 0) ? root.sourceWidth : tempImage.sourceSize.width
190 height: root.sourceHeight > 0 || (videoItem.metaData.resolution && videoItem.metaData.resolution.height > 0) ? root.sourceHeight : tempImage.sourceSize.height
191 visible: source &&
status === Image.Ready && !videoItem.source.
toString().length > 0
193 source: root.tempSource
197 anchors.centerIn: parent
198 visible: root.downloadAction.started && !root.downloadAction.completed
199 width: videoItem.width * 0.8
203 value: root.downloadAction.progress
207 anchors.centerIn: parent
210 visible: !videoItem.source.
toString().length > 0 && !root.downloadAction.started
211 display: QQC2.AbstractButton.IconOnly
212 action: root.downloadAction
217 origin.x: videoItem.width / 2
218 origin.y: videoItem.height / 2
219 xScale: root.scaleFactor
220 yScale: root.scaleFactor
223 NumberAnimation {duration:
Kirigami.
Units.longDuration; easing.type: Easing.InOutCubic}
226 NumberAnimation {duration:
Kirigami.Units.longDuration; easing.type: Easing.InOutCubic}
233 anchors.bottom: videoItem.bottom
236 visible: videoArea.hovered || volumePopupHoverHandler.hovered || volumeSlider.hovered || videoControlTimer.running
238 contentItem: RowLayout {
243 icon.name: videoItem.playbackState === MediaPlayer.PlayingState ?
"media-playback-pause" :
"media-playback-start"
244 action: videoItem.playbackState === MediaPlayer.PlayingState ? root.pauseAction : root.playAction
247 Layout.fillWidth:
true
249 to: videoItem.duration
250 value: videoItem.position
251 onMoved: videoItem.seek(value)
254 text: root.getTimeString(videoItem.position) +
"/" + root.getTimeString(videoItem.duration)
258 property var unmuteVolume: videoItem.volume
260 icon.name: videoItem.volume <= 0 ?
"player-volume-muted" :
"player-volume"
262 QQC2.ToolTip.visible: hovered
263 QQC2.ToolTip.delay:
Kirigami.Units.toolTipDelay
264 QQC2.ToolTip.timeout:
Kirigami.Units.toolTipDelay
265 QQC2.ToolTip.text:
i18ndc(
"kirigami-addons6",
"@action:button",
"Volume")
268 if (videoItem.volume > 0) {
271 if (unmuteVolume === 0) {
274 videoItem.volume = unmuteVolume
280 videoControlTimer.restart()
281 volumePopupTimer.restart()
288 width: volumeButton.width
289 visible: volumeButton.hovered || volumePopupHoverHandler.hovered || volumeSlider.hovered || volumePopupTimer.running
292 padding:
Kirigami.Units.smallSpacing
293 closePolicy: QQC2.Popup.NoAutoClose
297 anchors.centerIn: parent
298 implicitHeight:
Kirigami.Units.gridUnit * 7
299 orientation:
Qt.Vertical
303 value: videoItem.volume
305 videoItem.volume = value
306 volumeButton.unmuteVolume = value
310 videoControlTimer.restart()
311 volumePopupTimer.restart()
320 id: volumePopupHoverHandler
323 videoControlTimer.restart()
324 volumePopupTimer.restart()
328 background:
Kirigami.ShadowedRectangle {
330 color:
Kirigami.Theme.backgroundColor
338 shadow.color:
Qt.rgba(0, 0, 0, 0.3)
344 background:
Kirigami.ShadowedRectangle {
346 color:
Kirigami.Theme.backgroundColor
354 shadow.color:
Qt.rgba(0, 0, 0, 0.3)
359 id: videoControlTimer
364 acceptedButtons:
Qt.RightButton
365 onTapped: root.itemRightClicked()
371 videoControlTimer.restart()
377 acceptedButtons:
Qt.LeftButton
378 onTapped: root.backgroundClicked()
381 function formatTimer(time){
382 return (time < 10 ?
"0" :
"") + time
385 function getTimeString(timeMilliseconds){
386 let hours = root.formatTimer(Math.floor(timeMilliseconds/3600000));
387 let minutes = root.formatTimer(Math.floor(timeMilliseconds%3600000/60000));
388 let seconds = root.formatTimer(Math.floor(timeMilliseconds%60000/1000));
390 return (hours +
":" + minutes +
":" + seconds);
Q_SCRIPTABLE CaptureState status()
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
char * toString(const EngineQuery &query)
QString left(qsizetype n) const const
QString right(qsizetype n) const const