More file previews

This adds previews for downloaded pdfs and code files.

![image](/uploads/9c199e91a1b4ea296c9b82a76e11038b/image.png)

![image](/uploads/17ea3869469417ee78e650ce750dbeb7/image.png)
This commit is contained in:
James Graham
2024-03-19 20:06:32 +00:00
committed by Tobias Fella
parent 33c55d1563
commit 1671e05d12
13 changed files with 195 additions and 36 deletions

View File

@@ -0,0 +1,44 @@
// SPDX-FileCopyrightText: 2024 Tobias Fella <tobias.fella@kde.org>
// SPDX-FileCopyrightText: 2024 James Graham <james.h.graham@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
import QtQuick
import QtQuick.Layouts
import org.kde.neochat
Rectangle {
id: root
/**
* @brief FileTransferInfo for any downloading files.
*/
required property var fileTransferInfo
/**
* @brief The attributes of the component.
*/
required property var componentAttributes
/**
* @brief The maximum width that the bubble's content can be.
*/
property real maxContentWidth: -1
Layout.preferredWidth: mediaSizeHelper.currentSize.width
Layout.preferredHeight: mediaSizeHelper.currentSize.height
color: "white"
Image {
anchors.fill: root
source: root?.fileTransferInfo.localPath ?? ""
MediaSizeHelper {
id: mediaSizeHelper
contentMaxWidth: root.maxContentWidth
mediaWidth: root.componentAttributes.size.width
mediaHeight: root.componentAttributes.size.height
}
}
}