summary refs log tree commit diff
path: root/resources/qml
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-03-21 05:49:12 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-03-21 05:49:12 +0100
commita9486ec89616a1e944d325c99d87173742a2de33 (patch)
tree70a494e3abcfc6f085f64d5497afa86373faacb9 /resources/qml
parentShow some previews in upload window (diff)
downloadnheko-a9486ec89616a1e944d325c99d87173742a2de33.tar.xz
Fix thumbnails for encrypted files and factor upload box out
Diffstat (limited to 'resources/qml')
-rw-r--r--resources/qml/TimelineView.qml70
-rw-r--r--resources/qml/UploadBox.qml89
2 files changed, 90 insertions, 69 deletions
diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml

index 7421d594..c4820077 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml
@@ -125,75 +125,7 @@ Item { } - Page { - id: uploadPopup - visible: room && room.input.uploads.length > 0 - Layout.preferredHeight: 200 - clip: true - - Layout.fillWidth: true - - padding: Nheko.paddingMedium - - contentItem: ListView { - id: uploadsList - anchors.horizontalCenter: parent.horizontalCenter - boundsBehavior: Flickable.StopAtBounds - - orientation: ListView.Horizontal - width: Math.min(contentWidth, parent.width) - model: room ? room.input.uploads : undefined - spacing: Nheko.paddingMedium - - delegate: Pane { - padding: Nheko.paddingSmall - height: uploadPopup.availableHeight - buttons.height - width: uploadPopup.availableHeight - buttons.height - - background: Rectangle { - color: Nheko.colors.window - radius: Nheko.paddingMedium - } - contentItem: ColumnLayout { - Image { - Layout.fillHeight: true - Layout.fillWidth: true - - sourceSize.height: height - sourceSize.width: width - - 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"; - } - source: "image://colorimage/:/icons/icons/ui/"+typeStr+".svg?" + Nheko.colors.buttonText - } - MatrixTextField { - Layout.fillWidth: true - text: modelData.filename - onTextEdited: modelData.filename = text - } - } - } - } - - footer: DialogButtonBox { - id: buttons - - standardButtons: DialogButtonBox.Cancel - Button { - text: qsTr("Upload %n file(s)", "", (room ? room.input.uploads.length : 0)) - DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole - } - onAccepted: room.input.acceptUploads() - onRejected: room.input.declineUploads() - } - - background: Rectangle { - color: Nheko.colors.base - } + UploadBox { } NotificationWarning { diff --git a/resources/qml/UploadBox.qml b/resources/qml/UploadBox.qml new file mode 100644
index 00000000..ba00f205 --- /dev/null +++ b/resources/qml/UploadBox.qml
@@ -0,0 +1,89 @@ +// SPDX-FileCopyrightText: 2022 Nheko Contributors +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import "./components" +import "./ui" + +import QtQuick 2.9 +import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.3 +import im.nheko 1.0 + +Page { + id: uploadPopup + visible: room && room.input.uploads.length > 0 + Layout.preferredHeight: 200 + clip: true + + Layout.fillWidth: true + + padding: Nheko.paddingMedium + + contentItem: ListView { + id: uploadsList + anchors.horizontalCenter: parent.horizontalCenter + boundsBehavior: Flickable.StopAtBounds + + ScrollBar.horizontal: ScrollBar { + id: scr + } + + orientation: ListView.Horizontal + width: Math.min(contentWidth, parent.availableWidth) + model: room ? room.input.uploads : undefined + spacing: Nheko.paddingMedium + + delegate: Pane { + padding: Nheko.paddingSmall + height: uploadPopup.availableHeight - buttons.height - (scr.visible? scr.height : 0) + width: uploadPopup.availableHeight - buttons.height + + background: Rectangle { + color: Nheko.colors.window + radius: Nheko.paddingMedium + } + contentItem: ColumnLayout { + Image { + Layout.fillHeight: true + Layout.fillWidth: true + + sourceSize.height: height + sourceSize.width: width + fillMode: Image.PreserveAspectFit + smooth: true + mipmap: true + + 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"; + } + source: (modelData.thumbnail != "") ? modelData.thumbnail : ("image://colorimage/:/icons/icons/ui/"+typeStr+".svg?" + Nheko.colors.buttonText) + } + MatrixTextField { + Layout.fillWidth: true + text: modelData.filename + onTextEdited: modelData.filename = text + } + } + } + } + + footer: DialogButtonBox { + id: buttons + + standardButtons: DialogButtonBox.Cancel + Button { + text: qsTr("Upload %n file(s)", "", (room ? room.input.uploads.length : 0)) + DialogButtonBox.buttonRole: DialogButtonBox.AcceptRole + } + onAccepted: room.input.acceptUploads() + onRejected: room.input.declineUploads() + } + + background: Rectangle { + color: Nheko.colors.base + } +}