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()
177 Component.onDestruction: videoItem.stop()
182 NumberAnimation {duration: Kirigami.Units.longDuration; easing.type: Easing.InOutCubic}
185 NumberAnimation {duration:
Kirigami.Units.longDuration; easing.type: Easing.InOutCubic}
190 anchors.centerIn: parent
191 width: root.sourceWidth > 0 || (videoItem.metaData.resolution && videoItem.metaData.resolution.width > 0) ? root.sourceWidth : tempImage.sourceSize.width
192 height: root.sourceHeight > 0 || (videoItem.metaData.resolution && videoItem.metaData.resolution.height > 0) ? root.sourceHeight : tempImage.sourceSize.height
193 visible: source &&
status === Image.Ready && !videoItem.source.
toString().length > 0
195 source: root.tempSource
199 anchors.centerIn: parent
200 visible: root.downloadAction.started && !root.downloadAction.completed
201 width: videoItem.width * 0.8
205 value: root.downloadAction.progress
209 anchors.centerIn: parent
212 visible: !videoItem.source.
toString().length > 0 && !root.downloadAction.started
213 display: QQC2.AbstractButton.IconOnly
214 action: root.downloadAction
219 origin.x: videoItem.width / 2
220 origin.y: videoItem.height / 2
221 xScale: root.scaleFactor
222 yScale: root.scaleFactor
225 NumberAnimation {duration:
Kirigami.
Units.longDuration; easing.type: Easing.InOutCubic}
228 NumberAnimation {duration:
Kirigami.Units.longDuration; easing.type: Easing.InOutCubic}
235 anchors.bottom: videoItem.bottom
236 anchors.left: videoItem.left
237 anchors.right: videoItem.right
238 visible: videoArea.hovered || volumePopupHoverHandler.hovered || volumeSlider.hovered || videoControlTimer.running
240 contentItem: RowLayout {
245 icon.name: videoItem.playbackState === MediaPlayer.PlayingState ?
"media-playback-pause" :
"media-playback-start"
246 action: videoItem.playbackState === MediaPlayer.PlayingState ? root.pauseAction : root.playAction
249 Layout.fillWidth:
true
251 to: videoItem.duration
252 value: videoItem.position
253 onMoved: videoItem.seek(value)
256 text: root.getTimeString(videoItem.position) +
"/" + root.getTimeString(videoItem.duration)
260 property var unmuteVolume: videoItem.volume
262 icon.name: videoItem.volume <= 0 ?
"player-volume-muted" :
"player-volume"
264 QQC2.ToolTip.visible: hovered
265 QQC2.ToolTip.delay:
Kirigami.Units.toolTipDelay
266 QQC2.ToolTip.timeout:
Kirigami.Units.toolTipDelay
267 QQC2.ToolTip.text:
i18ndc(
"kirigami-addons6",
"@action:button",
"Volume")
270 if (videoItem.volume > 0) {
273 if (unmuteVolume === 0) {
276 videoItem.volume = unmuteVolume
282 videoControlTimer.restart()
283 volumePopupTimer.restart()
290 width: volumeButton.width
291 visible: volumeButton.hovered || volumePopupHoverHandler.hovered || volumeSlider.hovered || volumePopupTimer.running
294 padding:
Kirigami.Units.smallSpacing
295 closePolicy: QQC2.Popup.NoAutoClose
299 anchors.centerIn: parent
300 implicitHeight:
Kirigami.Units.gridUnit * 7
301 orientation:
Qt.Vertical
305 value: videoItem.volume
307 videoItem.volume = value
308 volumeButton.unmuteVolume = value
312 videoControlTimer.restart()
313 volumePopupTimer.restart()
322 id: volumePopupHoverHandler
325 videoControlTimer.restart()
326 volumePopupTimer.restart()
330 background:
Kirigami.ShadowedRectangle {
332 color:
Kirigami.Theme.backgroundColor
340 shadow.color:
Qt.rgba(0, 0, 0, 0.3)
346 background:
Kirigami.ShadowedRectangle {
348 color:
Kirigami.Theme.backgroundColor
356 shadow.color:
Qt.rgba(0, 0, 0, 0.3)
361 id: videoControlTimer
366 acceptedButtons:
Qt.RightButton
367 onTapped: root.itemRightClicked()
373 videoControlTimer.restart()
379 acceptedButtons:
Qt.LeftButton
380 onTapped: root.backgroundClicked()
383 function formatTimer(time){
384 return (time < 10 ?
"0" :
"") + time
387 function getTimeString(timeMilliseconds){
388 let hours = root.formatTimer(Math.floor(timeMilliseconds/3600000));
389 let minutes = root.formatTimer(Math.floor(timeMilliseconds%3600000/60000));
390 let seconds = root.formatTimer(Math.floor(timeMilliseconds%60000/1000));
392 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)