AicsKnowledgeBase_client/AicsKnowledgeBase/qml/component/TransferListPopup.qml

125 lines
4.8 KiB
QML
Raw Normal View History

2023-07-02 15:58:02 +08:00
import QtQuick
import QtQuick.Controls
import QtQuick.Window
import QtQuick.Layouts
2023-07-05 21:14:33 +08:00
import Qt5Compat.GraphicalEffects
2023-07-02 15:58:02 +08:00
import FluentUI
2023-07-05 21:14:33 +08:00
import AicsKB.FileTransferManager
2023-07-02 15:58:02 +08:00
Popup {
id: transfer_popup
x: parent ? (parent.width - implicitWidth) / 2 : 0
y: parent ? parent.height : 0
background: FluArea {
implicitWidth: 300
implicitHeight: 200
color: "#f8f8f8"
radius: 5
FluShadow {}
}
2023-07-03 17:13:47 +08:00
contentItem: FluScrollablePage {
anchors.fill: parent
anchors.topMargin: 10
ColumnLayout {
Layout.fillWidth: true
2023-07-05 21:14:33 +08:00
spacing: 0
2023-07-03 17:13:47 +08:00
Repeater {
model: FileTransferListModel
2023-07-05 21:14:33 +08:00
delegate: Item {
Layout.fillWidth: true
height: 50
ColumnLayout {
anchors.fill: parent
anchors.margins: 5
spacing: 2
Text {
text: name
}
FluProgressBar {
Layout.fillWidth: true
progress: completedSize / totalSize
indeterminate: false
}
Text {
color: FluColors.Grey130
text: formatSize(speed) + "/s - " + formatSize(
completedSize) + "/" + formatSize(
totalSize)
/**
* ,
* @param {Number} size
* @param {Number} [pointLength=1]
* @param {Array} [units=[ 'B', 'K', 'M', 'G', 'TB' ]]
* K()M, K.
*/
function formatSize(size, pointLength, units) {
var unit
units = units || ['B', 'KB', 'MB', 'GB', 'TB']
while ((unit = units.shift()) && size > 1024) {
size = size / 1024
}
return (unit === 'B' ? size : size.toFixed(
pointLength === undefined ? 1 : pointLength)) + ' ' + unit
}
}
2023-07-03 17:13:47 +08:00
}
2023-07-05 21:14:33 +08:00
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: file_buttons.visible = true
onExited: file_buttons.visible = false
LinearGradient {
anchors.fill: file_buttons
visible: file_buttons.visible
start: Qt.point(0, 0)
end: Qt.point(20, 0)
gradient: Gradient {
GradientStop {
position: 0.0
color: "transparent"
}
GradientStop {
position: 1.0
color: "#f8f8f8"
}
}
}
RowLayout {
id: file_buttons
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
layoutDirection: Qt.RightToLeft
visible: false
FluIconButton {
iconSource: FluentIcons.Cancel
}
FluIconButton {
Layout.leftMargin: 20
iconSource: paused ? FluentIcons.Play : FluentIcons.Pause
onClicked: {
if (!paused) {
console.log("pause")
FileTransferManager.pause(fileId)
}
}
}
}
2023-07-03 17:13:47 +08:00
}
2023-07-02 15:58:02 +08:00
}
}
}
}
}