Debian Codegraph @

resources/qml/UploadBox.qml

raw
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 import QtQuick 2.9
6 import QtQuick.Controls 2.5
7 import QtQuick.Layouts 1.3
8 import im.nheko 1.0
9
10 Page {
11 id: uploadPopup
12
13 Layout.fillWidth: true
14 Layout.preferredHeight: 200
15 clip: true
16 padding: Nheko.paddingMedium
17 visible: room && room.input.uploads.length > 0
18
19 background: Rectangle {
20 color: palette.base
21 }
22 contentItem: ListView {
23 id: uploadsList
24
25 anchors.horizontalCenter: parent.horizontalCenter
26 boundsBehavior: Flickable.StopAtBounds
27 model: room ? room.input.uploads : undefined
28 orientation: ListView.Horizontal
29 spacing: Nheko.paddingMedium
30 width: Math.min(contentWidth, parent.availableWidth)
31
32 ScrollBar.horizontal: ScrollBar {
33 id: scr
34
35 }
36 delegate: Pane {
37 id: pane
38
39 height: uploadPopup.availableHeight - buttons.height - (scr.visible ? scr.height : 0)
40 padding: Nheko.paddingSmall
41 width: uploadPopup.availableHeight - buttons.height
42
43 background: Rectangle {
44 color: palette.window
45 radius: Nheko.paddingMedium
46 }
47 contentItem: ColumnLayout {
48 Image {
49 property string typeStr: switch (modelData.mediaType) {
50 case MediaUpload.Video:
51 return "video-file";
52 case MediaUpload.Audio:
53 return "music";
54 case MediaUpload.Image:
55 return "image";
56 default:
57 return "zip";
58 }
59
60 Layout.fillHeight: true
61 Layout.fillWidth: true
62 fillMode: Image.PreserveAspectFit
63 mipmap: true
64 smooth: true
65 source: (modelData.thumbnail != "") ? modelData.thumbnail : ("image://colorimage/:/icons/icons/ui/" + typeStr + ".svg?" + palette.buttonText)
66 sourceSize.height: pane.availableHeight - namefield.height
67 sourceSize.width: pane.availableWidth
68 }
69 MatrixTextField {
70 id: namefield
71
72 Layout.fillWidth: true
73 text: modelData.filename
74
75 onTextEdited: modelData.filename = text
76 }
77 }
78 }
79 }
80 footer: DialogButtonBox {
81 id: buttons
82
83 standardButtons: DialogButtonBox.Cancel
84
85 onAccepted: room.input.acceptUploads()
86 onRejected: room.input.declineUploads()
87
88 Button {
89 DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
90 text: qsTr("Upload %n file(s)", "", (room ? room.input.uploads.length : 0))
91 }
92 }
93 }