moment/src/qml/Chat/UploadsBar.qml

126 lines
4.0 KiB
QML
Raw Normal View History

import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../Base"
import "../utils.js" as Utils
Rectangle {
id: uploadsBar
implicitWidth: 800
implicitHeight: firstDelegate ? firstDelegate.height : 0
2019-11-07 07:14:48 +11:00
color: theme.chat.uploadsBar.background
opacity: implicitHeight ? 1 : 0
clip: true
property int delegateHeight: 0
readonly property var firstDelegate:
uploadsList.contentItem.visibleChildren[0]
readonly property alias uploadsCount: uploadsList.count
Behavior on implicitHeight { HNumberAnimation {} }
HListView {
id: uploadsList
anchors.fill: parent
model: HListModel {
keyField: "uuid"
source: modelSources[["Upload", chatPage.roomId]] || []
}
delegate: HColumnLayout {
id: delegate
width: uploadsList.width
HRowLayout {
HLabel {
id: filenameLabel
elide: Text.ElideRight
2019-12-02 17:57:47 +11:00
color: model.status === "Error" ?
theme.colors.errorText : theme.colors.text
text:
model.status === "Uploading" ?
qsTr("Uploading %1...").arg(fileName) :
model.status === "Caching" ?
qsTr("Caching %1...").arg(fileName) :
model.status === "UploadingThumbnail" ?
2019-12-02 17:57:47 +11:00
qsTr("Uploading thumbnail for %1...").arg(fileName) :
model.status === "CachingThumbnail" ?
2019-12-02 17:57:47 +11:00
qsTr("Caching thumbnail for %1...").arg(fileName) :
model.status === "Error" ? (
model.error === "MatrixForbidden" ?
qsTr("Forbidden file type or quota exceeded: %1")
.arg(fileName) :
2019-12-02 17:57:47 +11:00
model.error === "MatrixTooLarge" ?
qsTr("Too large for this server: %1")
.arg(fileName) :
qsTr("Unknown error for %1: %2 - %3")
.arg(fileName)
.arg(model.error)
.arg(model.error_args)
) :
qsTr("Invalid status for %1: %2")
.arg(fileName).arg(model.status)
topPadding: theme.spacing / 2
bottomPadding: topPadding
leftPadding: theme.spacing / 1.5
rightPadding: leftPadding
Layout.fillWidth: true
readonly property string fileName:
model.filepath.split("/").slice(-1)[0]
}
HSpacer {}
HLabel {
id: uploadCountLabel
visible: Layout.preferredWidth > 0
text: qsTr("%1")
.arg(CppUtils.formattedBytes(model.total_size))
topPadding: theme.spacing / 2
bottomPadding: topPadding
leftPadding: theme.spacing / 1.5
rightPadding: leftPadding
Layout.preferredWidth:
model.status === "Uploading" ? implicitWidth : 0
Behavior on Layout.preferredWidth { HNumberAnimation {} }
}
}
HProgressBar {
id: progressBar
2019-12-02 17:57:47 +11:00
visible: Layout.maximumHeight !== 0
2019-11-07 01:08:55 +11:00
indeterminate: true
2019-12-02 17:57:47 +11:00
foregroundColor:
model.status === "Error" ?
theme.controls.progressBar.errorForeground :
theme.controls.progressBar.foreground
Layout.fillWidth: true
2019-12-02 17:57:47 +11:00
Layout.maximumHeight:
model.status === "Error" && indeterminate ? 0 : -1
Behavior on Layout.maximumHeight { HNumberAnimation {} }
}
}
}
}