| 1 |
// SPDX-FileCopyrightText: Nheko Contributors |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: GPL-3.0-or-later |
| 4 |
|
| 5 |
import QtQuick |
| 6 |
import QtQuick.Layouts |
| 7 |
import QtQuick.Controls |
| 8 |
import im.nheko |
| 9 |
|
| 10 |
Control { |
| 11 |
id: evRoot |
| 12 |
|
| 13 |
required property string eventId |
| 14 |
required property string filename |
| 15 |
required property string filesize |
| 16 |
|
| 17 |
padding: Settings.bubbles? 8 : 12 |
| 18 |
//Layout.preferredHeight: rowa.implicitHeight + padding |
| 19 |
//Layout.maximumWidth: rowa.Layout.maximumWidth + metadataWidth + padding |
| 20 |
property int metadataWidth: 0 |
| 21 |
property bool fitsMetadata: false |
| 22 |
|
| 23 |
Layout.maximumWidth: rowa.Layout.maximumWidth + padding * 2 |
| 24 |
|
| 25 |
contentItem: RowLayout { |
| 26 |
id: rowa |
| 27 |
|
| 28 |
spacing: 16 |
| 29 |
|
| 30 |
Rectangle { |
| 31 |
id: button |
| 32 |
|
| 33 |
color: palette.light |
| 34 |
radius: 22 |
| 35 |
Layout.preferredHeight: 44 |
| 36 |
Layout.preferredWidth: 44 |
| 37 |
|
| 38 |
Image { |
| 39 |
id: img |
| 40 |
|
| 41 |
height: 40 |
| 42 |
width: 40 |
| 43 |
sourceSize.height: 40 |
| 44 |
sourceSize.width: 40 |
| 45 |
|
| 46 |
anchors.centerIn: parent |
| 47 |
source: "qrc:/icons/icons/ui/download.svg" |
| 48 |
fillMode: Image.Pad |
| 49 |
} |
| 50 |
|
| 51 |
TapHandler { |
| 52 |
onSingleTapped: room.saveMedia(eventId) |
| 53 |
gesturePolicy: TapHandler.ReleaseWithinBounds |
| 54 |
} |
| 55 |
|
| 56 |
NhekoCursorShape { |
| 57 |
anchors.fill: parent |
| 58 |
cursorShape: Qt.PointingHandCursor |
| 59 |
} |
| 60 |
|
| 61 |
} |
| 62 |
|
| 63 |
ColumnLayout { |
| 64 |
id: col |
| 65 |
|
| 66 |
Text { |
| 67 |
id: filename_ |
| 68 |
|
| 69 |
Layout.fillWidth: true |
| 70 |
Layout.maximumWidth: implicitWidth + 1 |
| 71 |
text: evRoot.filename |
| 72 |
textFormat: Text.PlainText |
| 73 |
elide: Text.ElideRight |
| 74 |
color: palette.text |
| 75 |
} |
| 76 |
|
| 77 |
Text { |
| 78 |
id: filesize_ |
| 79 |
|
| 80 |
Layout.fillWidth: true |
| 81 |
Layout.maximumWidth: implicitWidth + 1 |
| 82 |
text: evRoot.filesize |
| 83 |
textFormat: Text.PlainText |
| 84 |
elide: Text.ElideRight |
| 85 |
color: palette.text |
| 86 |
} |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
} |
| 91 |
|
| 92 |
background: Rectangle { |
| 93 |
color: palette.alternateBase |
| 94 |
radius: fontMetrics.lineSpacing / 2 + 2 * Nheko.paddingSmall |
| 95 |
visible: !Settings.bubbles // the bubble in a bubble looks odd |
| 96 |
} |
| 97 |
|
| 98 |
} |