Merge branch 'main' of http://101.34.228.45:3000/auto/AicsKnowledgeBase_client
commit
5928e49884
|
@ -102,6 +102,7 @@ FluWindow {
|
|||
target: SignalFileOperation
|
||||
function onOpen(file) {
|
||||
stack_view.clear()
|
||||
UserData.viewHistory.push(file)
|
||||
stack_view.push(file_view, {
|
||||
"knowledgeFileId": file
|
||||
})
|
||||
|
|
|
@ -5,6 +5,7 @@ import QtQuick.Layouts
|
|||
import Qt5Compat.GraphicalEffects
|
||||
import FluentUI
|
||||
import AicsKB.FileTransferManager
|
||||
import "qrc:///AicsKnowledgeBase/qml/global"
|
||||
|
||||
Popup {
|
||||
id: transfer_popup
|
||||
|
@ -18,6 +19,15 @@ Popup {
|
|||
FluShadow {}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: FileTransferManager
|
||||
onTransferComplete: (download, fileId, fileName) => {
|
||||
console.log("onTransferComplete")
|
||||
UserData.downloadedFiles.push(fileId)
|
||||
console.log(UserData.downloadedFiles)
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: FluScrollablePage {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 10
|
||||
|
@ -30,21 +40,41 @@ Popup {
|
|||
Layout.fillWidth: true
|
||||
height: 50
|
||||
|
||||
ColumnLayout {
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 5
|
||||
anchors.topMargin: 5
|
||||
anchors.bottomMargin: 5
|
||||
anchors.leftMargin: 0
|
||||
Image {
|
||||
id: icon
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 32
|
||||
height: 32
|
||||
source: download ? "qrc:/AicsKnowledgeBase/res/download.png" : "qrc:/AicsKnowledgeBase/res/upload.png"
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.left: icon.right
|
||||
anchors.right: parent.right
|
||||
anchors.leftMargin: 5
|
||||
spacing: 2
|
||||
Text {
|
||||
text: name
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: completedSize >= totalSize
|
||||
text: "已完成"
|
||||
color: FluColors.Grey130
|
||||
}
|
||||
FluProgressBar {
|
||||
Layout.fillWidth: true
|
||||
progress: completedSize / totalSize
|
||||
indeterminate: false
|
||||
visible: completedSize < totalSize
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: completedSize < totalSize
|
||||
color: FluColors.Grey130
|
||||
text: formatSize(speed) + "/s - " + formatSize(
|
||||
completedSize) + "/" + formatSize(
|
||||
|
@ -60,8 +90,10 @@ Popup {
|
|||
*/
|
||||
function formatSize(size, pointLength, units) {
|
||||
var unit
|
||||
units = units || ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
while ((unit = units.shift()) && size > 1024) {
|
||||
units = units
|
||||
|| ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
while ((unit = units.shift())
|
||||
&& size > 1024) {
|
||||
size = size / 1024
|
||||
}
|
||||
return (unit === 'B' ? size : size.toFixed(
|
||||
|
@ -69,11 +101,15 @@ Popup {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: file_buttons.visible = true
|
||||
onEntered: {
|
||||
if (completedSize < totalSize)
|
||||
file_buttons.visible = true
|
||||
}
|
||||
onExited: file_buttons.visible = false
|
||||
|
||||
LinearGradient {
|
||||
|
|
|
@ -5,4 +5,6 @@ import QtQuick
|
|||
QtObject {
|
||||
property string username
|
||||
property string userId
|
||||
property var viewHistory: []
|
||||
property var downloadedFiles: []
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
|
@ -10,6 +10,8 @@ FileTransferListModel::FileTransferListModel(QObject *parent)
|
|||
m_roleName.insert(kTotalSizeRole, "totalSize");
|
||||
m_roleName.insert(kSpeedRole, "speed");
|
||||
m_roleName.insert(kPausedRole, "paused");
|
||||
|
||||
m_data.append({true, "id", "name", 30, 100, 30});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,8 +73,8 @@ static int xferinfo(void *p, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ul
|
|||
fileTrans->completedSize += dlnow;
|
||||
|
||||
fileTrans->speed = speed;
|
||||
qDebug() << std::format("Downloading: {} / {}, Speed: {}", fileTrans->completedSize, fileTrans->totalSize,
|
||||
speed).c_str();
|
||||
//qDebug() << std::format("Downloading: {} / {}, Speed: {}", fileTrans->completedSize, fileTrans->totalSize,
|
||||
// speed).c_str();
|
||||
|
||||
auto item = static_cast<FileItem>(*fileTrans);
|
||||
QTimer::singleShot(0, qApp, [item]() {
|
||||
|
@ -96,8 +96,8 @@ static int uploadInfo(void *p, curl_off_t dltotal, curl_off_t dlnow, curl_off_t
|
|||
curl_easy_getinfo(fileTrans->curlHandle, CURLINFO_SPEED_UPLOAD_T, &speed);
|
||||
fileTrans->completedSize += ulnow;
|
||||
fileTrans->speed = speed;
|
||||
qDebug() << std::format("Uploading: {} / {}, Speed: {}", fileTrans->completedSize, fileTrans->totalSize,
|
||||
speed).c_str();
|
||||
//qDebug() << std::format("Uploading: {} / {}, Speed: {}", fileTrans->completedSize, fileTrans->totalSize,
|
||||
// speed).c_str();
|
||||
|
||||
auto item = static_cast<FileItem>(*fileTrans);
|
||||
QTimer::singleShot(0, qApp, [item]() {
|
||||
|
@ -359,6 +359,10 @@ void FileTransferManager::download(const QString &fileId, const QString &fileNam
|
|||
|
||||
auto fileUrl = std::format("File/{}?rangeStart={}&rangeEnd={}", fileId.toStdString(), completedSize, size);
|
||||
auto res = httpDownload(fileUrl, savePath, item);
|
||||
|
||||
if (QFileInfo(QString::fromLocal8Bit(savePath.c_str())).size() == size)
|
||||
emit transferComplete(true, fileId, fileName);
|
||||
|
||||
qDebug() << "End Get" << res;
|
||||
});
|
||||
}
|
||||
|
@ -398,8 +402,6 @@ QString FileTransferManager::getFileName(const QUrl &fileUrl)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void FileTransferManager::getMarkdown(const QString &fileId)
|
||||
{
|
||||
QtConcurrent::run([fileId, this] {
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
Q_INVOKABLE void getMarkdown(const QString &fileId);
|
||||
|
||||
signals:
|
||||
void transferComplete(bool download, QString fileId, QString fileName);
|
||||
void markdownData(QString data);
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in New Issue