Warning, /network/neochat/src/qml/NeochatMaximizeComponent.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com>
0002 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0003
0004 import QtQuick
0005 import QtQuick.Controls as QQC2
0006 import QtQuick.Layouts
0007 import Qt.labs.platform as Platform
0008
0009 import org.kde.kirigami as Kirigami
0010 import org.kde.kirigamiaddons.labs.components as Components
0011
0012 import org.kde.neochat
0013 import org.kde.neochat.config
0014
0015 Components.AlbumMaximizeComponent {
0016 id: root
0017
0018 /**
0019 * @brief The current room that user is viewing.
0020 */
0021 required property NeoChatRoom currentRoom
0022
0023 readonly property string currentEventId: model.data(model.index(content.currentIndex, 0), MessageEventModel.EventIdRole)
0024
0025 readonly property var currentAuthor: model.data(model.index(content.currentIndex, 0), MessageEventModel.AuthorRole)
0026
0027 readonly property var currentTime: model.data(model.index(content.currentIndex, 0), MessageEventModel.TimeRole)
0028
0029 readonly property var currentDelegateType: model.data(model.index(content.currentIndex, 0), MessageEventModel.DelegateTypeRole)
0030
0031 readonly property string currentPlainText: model.data(model.index(content.currentIndex, 0), MessageEventModel.PlainText)
0032
0033 readonly property var currentMimeType: model.data(model.index(content.currentIndex, 0), MessageEventModel.MimeTypeRole)
0034
0035 readonly property var currentProgressInfo: model.data(model.index(content.currentIndex, 0), MessageEventModel.ProgressInfoRole)
0036
0037 downloadAction: Components.DownloadAction {
0038 id: downloadAction
0039 onTriggered: {
0040 currentRoom.downloadFile(root.currentEventId, Platform.StandardPaths.writableLocation(Platform.StandardPaths.CacheLocation) + "/" + root.currentEventId.replace(":", "_").replace("/", "_").replace("+", "_") + currentRoom.fileNameToDownload(root.currentEventId));
0041 }
0042 }
0043
0044 Connections {
0045 target: currentRoom
0046
0047 function onFileTransferProgress(id, progress, total) {
0048 if (id == root.currentEventId) {
0049 downloadAction.progress = progress / total * 100.0;
0050 }
0051 }
0052 }
0053
0054 Connections {
0055 target: content
0056
0057 function onCurrentIndexChanged() {
0058 downloadAction.progress = currentProgressInfo.progress / currentProgressInfo.total * 100.0;
0059 }
0060 }
0061
0062 leading: RowLayout {
0063 Components.Avatar {
0064 id: userAvatar
0065 implicitWidth: Kirigami.Units.iconSizes.medium
0066 implicitHeight: Kirigami.Units.iconSizes.medium
0067
0068 name: root.currentAuthor.name ?? root.currentAuthor.displayName
0069 source: root.currentAuthor.avatarSource
0070 color: root.currentAuthor.color
0071 }
0072 ColumnLayout {
0073 spacing: 0
0074 QQC2.Label {
0075 id: userLabel
0076
0077 text: root.currentAuthor.name ?? root.currentAuthor.displayName
0078 color: root.currentAuthor.color
0079 font.weight: Font.Bold
0080 elide: Text.ElideRight
0081 }
0082 QQC2.Label {
0083 id: dateTimeLabel
0084 text: root.currentTime.toLocaleString(Qt.locale(), Locale.ShortFormat)
0085 color: Kirigami.Theme.disabledTextColor
0086 elide: Text.ElideRight
0087 }
0088 }
0089 }
0090 onItemRightClicked: RoomManager.viewEventMenu(root.currentEventId, root.currentAuthor, root.currentDelegateType, root.currentPlainText, "", "", root.currentMimeType, root.currentProgressInfo)
0091
0092 onSaveItem: {
0093 var dialog = saveAsDialog.createObject(QQC2.ApplicationWindow.overlay);
0094 dialog.open();
0095 dialog.currentFile = dialog.folder + "/" + currentRoom.fileNameToDownload(root.currentEventId);
0096 }
0097
0098 Connections {
0099 target: RoomManager
0100 function onCloseFullScreen() {
0101 root.close();
0102 }
0103 }
0104
0105 Component {
0106 id: saveAsDialog
0107 Platform.FileDialog {
0108 fileMode: FileDialog.SaveFile
0109 folder: root.saveFolder
0110 onAccepted: {
0111 Config.lastSaveDirectory = folder;
0112 Config.save();
0113 if (!currentFile) {
0114 return;
0115 }
0116 currentRoom.downloadFile(rooteventId, currentFile);
0117 }
0118 }
0119 }
0120 }