matrixion/qml/UploadBox.qml

86 lines
2.8 KiB
QML
Raw Permalink Normal View History

// SPDX-FileCopyrightText: 2022 Nheko Contributors
// SPDX-License-Identifier: GPL-3.0-or-later
2022-04-16 03:13:01 +03:00
import "components"
import "ui"
import QtQuick 2.9
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import im.nheko
Page {
id: uploadPopup
2022-04-16 03:13:01 +03:00
Layout.fillWidth: true
Layout.preferredHeight: 200
clip: true
padding: Nheko.paddingMedium
2022-04-16 03:13:01 +03:00
visible: room && room.input.uploads.length > 0
2022-04-16 03:13:01 +03:00
background: Rectangle {
color: timelineRoot.palette.base
}
contentItem: ListView {
id: uploadsList
anchors.horizontalCenter: parent.horizontalCenter
boundsBehavior: Flickable.StopAtBounds
2022-04-16 03:13:01 +03:00
model: room ? room.input.uploads : undefined
orientation: ListView.Horizontal
spacing: Nheko.paddingMedium
width: Math.min(contentWidth, parent.availableWidth)
ScrollBar.horizontal: ScrollBar {
id: scr
}
delegate: Pane {
2022-04-16 03:13:01 +03:00
height: uploadPopup.availableHeight - buttons.height - (scr.visible ? scr.height : 0)
padding: Nheko.paddingSmall
width: uploadPopup.availableHeight - buttons.height
background: Rectangle {
2022-04-11 05:18:16 +03:00
color: timelineRoot.palette.window
radius: Nheko.paddingMedium
}
contentItem: ColumnLayout {
Image {
2022-04-16 03:13:01 +03:00
property string typeStr: switch (modelData.mediaType) {
case MediaUpload.Video:
return "video-file";
case MediaUpload.Audio:
return "music";
case MediaUpload.Image:
return "image";
default:
return "zip";
}
Layout.fillHeight: true
Layout.fillWidth: true
fillMode: Image.PreserveAspectFit
mipmap: true
2022-04-16 03:13:01 +03:00
smooth: true
source: (modelData.thumbnail != "") ? modelData.thumbnail : ("image://colorimage/:/icons/icons/ui/" + typeStr + ".svg?" + timelineRoot.palette.placeholderText)
sourceSize.height: height
sourceSize.width: width
}
MatrixTextField {
Layout.fillWidth: true
text: modelData.filename
2022-04-16 03:13:01 +03:00
onTextEdited: modelData.filename = text
}
}
}
}
footer: DialogButtonBox {
id: buttons
standardButtons: DialogButtonBox.Cancel
2022-04-16 03:13:01 +03:00
onAccepted: room.input.acceptUploads()
onRejected: room.input.declineUploads()
2022-04-16 03:13:01 +03:00
Button {
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
text: qsTr("Upload %n file(s)", "", (room ? room.input.uploads.length : 0))
}
}
}