2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2022-03-21 07:49:12 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.5
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: uploadPopup
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
2023-06-02 02:45:24 +03:00
|
|
|
Layout.preferredHeight: 200
|
|
|
|
clip: true
|
2022-03-21 07:49:12 +03:00
|
|
|
padding: Nheko.paddingMedium
|
2023-06-02 02:45:24 +03:00
|
|
|
visible: room && room.input.uploads.length > 0
|
2022-03-21 07:49:12 +03:00
|
|
|
|
2023-06-02 02:45:24 +03:00
|
|
|
background: Rectangle {
|
|
|
|
color: palette.base
|
|
|
|
}
|
2022-03-21 07:49:12 +03:00
|
|
|
contentItem: ListView {
|
|
|
|
id: uploadsList
|
2023-06-02 02:45:24 +03:00
|
|
|
|
2024-06-12 23:24:53 +03:00
|
|
|
Loader {
|
|
|
|
source: NHEKO_USE_KIRIGAMI ? "components/KirigamiWheelHandler.qml" : ""
|
|
|
|
}
|
|
|
|
|
2022-03-21 07:49:12 +03:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
2023-06-02 02:45:24 +03:00
|
|
|
model: room ? room.input.uploads : undefined
|
|
|
|
orientation: ListView.Horizontal
|
|
|
|
spacing: Nheko.paddingMedium
|
|
|
|
width: Math.min(contentWidth, parent.availableWidth)
|
2022-03-21 07:49:12 +03:00
|
|
|
|
|
|
|
ScrollBar.horizontal: ScrollBar {
|
|
|
|
id: scr
|
|
|
|
|
2023-06-02 02:45:24 +03:00
|
|
|
}
|
2022-03-21 07:49:12 +03:00
|
|
|
delegate: Pane {
|
2023-06-04 03:44:41 +03:00
|
|
|
id: pane
|
2023-06-08 02:51:27 +03:00
|
|
|
|
2023-06-02 02:45:24 +03:00
|
|
|
height: uploadPopup.availableHeight - buttons.height - (scr.visible ? scr.height : 0)
|
2022-03-21 07:49:12 +03:00
|
|
|
padding: Nheko.paddingSmall
|
|
|
|
width: uploadPopup.availableHeight - buttons.height
|
|
|
|
|
|
|
|
background: Rectangle {
|
2023-06-02 02:29:05 +03:00
|
|
|
color: palette.window
|
2022-03-21 07:49:12 +03:00
|
|
|
radius: Nheko.paddingMedium
|
|
|
|
}
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
Image {
|
2023-06-02 02:45:24 +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";
|
|
|
|
}
|
|
|
|
|
2022-03-21 07:49:12 +03:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
mipmap: true
|
2023-06-02 02:45:24 +03:00
|
|
|
smooth: true
|
|
|
|
source: (modelData.thumbnail != "") ? modelData.thumbnail : ("image://colorimage/:/icons/icons/ui/" + typeStr + ".svg?" + palette.buttonText)
|
2023-06-04 03:44:41 +03:00
|
|
|
sourceSize.height: pane.availableHeight - namefield.height
|
|
|
|
sourceSize.width: pane.availableWidth
|
2022-03-21 07:49:12 +03:00
|
|
|
}
|
|
|
|
MatrixTextField {
|
2022-10-24 18:31:15 +03:00
|
|
|
id: namefield
|
2023-06-02 02:45:24 +03:00
|
|
|
|
2022-03-21 07:49:12 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
text: modelData.filename
|
2023-06-02 02:45:24 +03:00
|
|
|
|
2022-03-21 07:49:12 +03:00
|
|
|
onTextEdited: modelData.filename = text
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
footer: DialogButtonBox {
|
|
|
|
id: buttons
|
|
|
|
|
|
|
|
standardButtons: DialogButtonBox.Cancel
|
2023-06-02 02:45:24 +03:00
|
|
|
|
2022-03-21 07:49:12 +03:00
|
|
|
onAccepted: room.input.acceptUploads()
|
|
|
|
onRejected: room.input.declineUploads()
|
|
|
|
|
2023-06-02 02:45:24 +03:00
|
|
|
Button {
|
|
|
|
DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole
|
|
|
|
text: qsTr("Upload %n file(s)", "", (room ? room.input.uploads.length : 0))
|
|
|
|
}
|
2022-03-21 07:49:12 +03:00
|
|
|
}
|
|
|
|
}
|