Move Chat/ dir under Pages/

This commit is contained in:
miruka
2019-12-18 04:53:08 -04:00
parent 2bdf21d528
commit f4d7636df6
30 changed files with 38 additions and 38 deletions

View File

@@ -0,0 +1,192 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../../Base"
HColumnLayout {
id: transfer
property bool paused: false
property int msLeft: model.time_left || 0
property int uploaded: model.uploaded
readonly property int speed: model.speed
readonly property int totalSize: model.total_size
readonly property string status: model.status
function cancel() {
// Python might take a sec to cancel, but we want
// immediate visual feedback
transfer.height = 0
// Python will delete this model item on cancel
py.call(py.getattr(model.task, "cancel"))
}
function pause() {
transfer.paused = ! transfer.paused
py.setattr(model.monitor, "pause", transfer.paused)
}
Behavior on height { HNumberAnimation {} }
HRowLayout {
HIcon {
svgName: "uploading"
colorize:
transfer.status === "Error" ? theme.colors.negativeBackground :
transfer.paused ? theme.colors.middleBackground :
theme.icons.colorize
Layout.preferredWidth: theme.baseElementsHeight
}
HLabel {
id: statusLabel
elide: expand ? Text.ElideNone : Text.ElideRight
wrapMode: expand ? Text.Wrap : Text.NoWrap
text:
status === "Uploading" ? fileName :
status === "Caching" ?
qsTr("Caching %1...").arg(fileName) :
model.error === "MatrixForbidden" ?
qsTr("Forbidden file type or quota exceeded: %1")
.arg(fileName) :
model.error === "MatrixTooLarge" ?
qsTr("Too large for this server: %1").arg(fileName) :
model.error === "IsADirectoryError" ?
qsTr("Can't upload folders, need a file: %1").arg(filePath) :
model.error === "FileNotFoundError" ?
qsTr("Non-existant file: %1").arg(filePath) :
model.error === "PermissionError" ?
qsTr("No permission to read this file: %1").arg(filePath) :
qsTr("Unknown error for %1: %2 - %3")
.arg(filePath).arg(model.error).arg(model.error_args)
topPadding: theme.spacing / 2
bottomPadding: topPadding
leftPadding: theme.spacing / 1.5
rightPadding: leftPadding
Layout.fillWidth: true
property bool expand: status === "Error"
readonly property string fileName:
model.filepath.split("/").slice(-1)[0]
readonly property string filePath:
model.filepath.replace(/^file:\/\//, "")
HoverHandler { id: statusLabelHover }
HToolTip {
text: parent.truncated ? parent.text : ""
visible: text && statusLabelHover.hovered
}
}
HSpacer {}
Repeater {
model: [
msLeft ? qsTr("-%1").arg(utils.formatDuration(msLeft)) : "",
speed ? qsTr("%1/s").arg(CppUtils.formattedBytes(speed)) : "",
qsTr("%1/%2").arg(CppUtils.formattedBytes(uploaded))
.arg(CppUtils.formattedBytes(totalSize)),
]
HLabel {
text: modelData
visible: text && Layout.preferredWidth > 0
leftPadding: theme.spacing / 1.5
rightPadding: leftPadding
Layout.preferredWidth:
status === "Uploading" ? implicitWidth : 0
Behavior on Layout.preferredWidth { HNumberAnimation {} }
}
}
HButton {
visible: Layout.preferredWidth > 0
padded: false
icon.name: transfer.paused ?
"upload-resume" : "upload-pause"
icon.color: transfer.paused ?
theme.colors.positiveBackground :
theme.colors.middleBackground
toolTip.text: transfer.paused ?
qsTr("Resume") : qsTr("Pause")
onClicked: transfer.pause()
Layout.preferredWidth:
status === "Uploading" ?
theme.baseElementsHeight : 0
Layout.fillHeight: true
Behavior on Layout.preferredWidth { HNumberAnimation {} }
}
HButton {
icon.name: "upload-cancel"
icon.color: theme.colors.negativeBackground
padded: false
onClicked: transfer.cancel()
Layout.preferredWidth: theme.baseElementsHeight
Layout.fillHeight: true
}
TapHandler {
onTapped: {
if (status === "Error") { transfer.cancel() }
else { statusLabel.expand = ! statusLabel.expand }
}
}
}
HProgressBar {
id: progressBar
visible: Layout.maximumHeight !== 0
indeterminate: status !== "Uploading"
value: uploaded
to: totalSize
// TODO: bake this in hprogressbar
foregroundColor:
status === "Error" ?
theme.controls.progressBar.errorForeground :
transfer.paused ?
theme.controls.progressBar.pausedForeground :
theme.controls.progressBar.foreground
Layout.fillWidth: true
Layout.maximumHeight:
status === "Error" && indeterminate ? 0 : -1
Behavior on value { HNumberAnimation { duration: 1200 } }
Behavior on Layout.maximumHeight { HNumberAnimation {} }
}
}

View File

@@ -0,0 +1,33 @@
import QtQuick 2.12
import "../../../Base"
Rectangle {
implicitWidth: 800
implicitHeight: firstDelegate ? firstDelegate.height : 0
color: theme.chat.fileTransfer.background
opacity: implicitHeight ? 1 : 0
clip: true
property int delegateHeight: 0
readonly property var firstDelegate:
transferList.contentItem.visibleChildren[0]
readonly property alias transferCount: transferList.count
Behavior on implicitHeight { HNumberAnimation {} }
HListView {
id: transferList
anchors.fill: parent
model: HListModel {
keyField: "uuid"
source: modelSources[["Upload", chat.roomId]] || []
}
delegate: Transfer { width: transferList.width }
}
}