summaryrefslogtreecommitdiffstats
path: root/examples/multimedia/video/recorder/MediaList.qml
blob: 5fa65393a2882dbdca14bf3ae468aaa7a2aba839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls
import QtMultimedia
import QtQuick.Layouts

Item {
    id: root

    required property Playback playback

    property string mediaThumbnail
    property string mediaUrl

    function append() {
        if (mediaUrl !== "")
            mediaList.append({"thumbnail": root.mediaThumbnail, "url": root.mediaUrl})
        mediaThumbnail = ""
        mediaUrl = ""
    }

    ListModel { id: mediaList }

    ListView {
        id: listView
        anchors.fill: parent
        model:  mediaList
        orientation: ListView.Horizontal
        spacing: Style.intraSpacing

        delegate: Frame {
            padding: Style.intraSpacing
            width: root.height
            height: root.height
            background: StyleRectangle { anchors.fill: parent }

            required property string url
            required property string thumbnail

            ColumnLayout {
                anchors.fill: parent
                Image {
                    id: image
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                    source: thumbnail
                    fillMode: Image.PreserveAspectFit
                }

                Text {
                    Layout.fillWidth: true
                    elide: Text.ElideLeft
                    text: url
                }
            }
            RoundButton {
                anchors.centerIn: parent
                width: 30
                height: 30
                text: "\u25B6";
                onClicked: { playback.playUrl(url) }
            }
        }
    }
}