ready: trans file ready code.

This commit is contained in:
2025-06-16 23:41:35 +08:00
parent 02d163ccb7
commit 33b8a37719
11 changed files with 169 additions and 58 deletions

View File

@@ -1,8 +1,8 @@
BasedOnStyle: LLVM BasedOnStyle: LLVM
IndentWidth: 4 IndentWidth: 4
PointerAlignment: Left PointerAlignment: Left
AccessModifierOffset: -4 AccessModifierOffset: -4
ReflowComments: Always ReflowComments: true
SpacesBeforeTrailingComments: 3 SpacesBeforeTrailingComments: 3
AllowShortFunctionsOnASingleLine: None AllowShortFunctionsOnASingleLine: None
BreakBeforeBraces: Custom BreakBeforeBraces: Custom

3
.gitignore vendored
View File

@@ -1,4 +1,4 @@
# Prerequisites # Prerequisites
*.d *.d
# Compiled Object files # Compiled Object files
@@ -6,6 +6,7 @@
*.lo *.lo
*.o *.o
*.obj *.obj
out
# Precompiled Headers # Precompiled Headers
*.gch *.gch

22
CMakePresets.json Normal file
View File

@@ -0,0 +1,22 @@
{
"version": 3,
"configurePresets": [
{
"hidden": true,
"name": "Qt",
"cacheVariables": {
"CMAKE_PREFIX_PATH": "$env{QTDIR}"
},
"vendor": {
"qt-project.org/Qt": {
"checksum": "wVa86FgEkvdCTVp1/nxvrkaemJc="
}
}
}
],
"vendor": {
"qt-project.org/Presets": {
"checksum": "67SmY24ZeVbebyKD0fGfIzb/bGI="
}
}
}

60
CMakeUserPresets.json Normal file
View File

@@ -0,0 +1,60 @@
{
"version": 3,
"configurePresets": [
{
"name": "Debug-x64",
"displayName": "Debug (x64)",
"binaryDir": "${sourceDir}/out/build/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"inherits": [
"Qt-Default"
]
},
{
"name": "Release-x64",
"displayName": "Release (x64)",
"binaryDir": "${sourceDir}/out/build/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
},
"inherits": [
"Qt-Default"
]
},
{
"hidden": true,
"name": "Qt-Default",
"inherits": "Qt6_msvc2022_64",
"vendor": {
"qt-project.org/Default": {
"checksum": "976Pn2eYm5E5Y4HL6Z+8qkbnJAs="
}
}
},
{
"hidden": true,
"name": "Qt6_msvc2022_64",
"inherits": "Qt",
"environment": {
"QTDIR": "D:/Dev/Qt6/msvc2022_64"
},
"architecture": {
"strategy": "external",
"value": "x64"
},
"generator": "Ninja",
"vendor": {
"qt-project.org/Version": {
"checksum": "ymjJj8izmTr4fYiat3sCfIwY424="
}
}
}
],
"vendor": {
"qt-project.org/Presets": {
"checksum": "e87AwgwSE1IKoagovHrM8pEnc+U="
}
}
}

View File

@@ -17,6 +17,8 @@ ClientCore.cpp
ClientCore.h ClientCore.h
RemoteFile.h RemoteFile.h
RemoteFile.cpp RemoteFile.cpp
FileTrans.h
FileTrans.cpp
) )
add_library(ClientCore STATIC ${SOURCES}) add_library(ClientCore STATIC ${SOURCES})

View File

@@ -1,4 +1,4 @@
#include "ClientCore.h" #include "ClientCore.h"
#include <QDebug> #include <QDebug>
@@ -99,7 +99,7 @@ void ClientCore::UseFrame(QSharedPointer<FrameBuffer> frame)
break; break;
} }
default: default:
qWarning() << QString(tr("unknown frame type: %1")).arg(frame->type); frameCall_[static_cast<uint32_t>(frame->type)](frame);
break; break;
} }
} }
@@ -150,7 +150,7 @@ void ClientCore::SetRemoteID(const QString& id)
remoteID_ = id; remoteID_ = id;
} }
void ClientCore::SetFrameCall(FrameBufferType type, const std::function<void(FrameBuffer*)>& call) void ClientCore::SetFrameCall(FrameBufferType type, const std::function<void(QSharedPointer<FrameBuffer>)>& call)
{ {
frameCall_[type] = call; frameCall_[type] = call;
} }

View File

@@ -1,4 +1,4 @@
#ifndef CLIENTCORE_H #ifndef CLIENTCORE_H
#define CLIENTCORE_H #define CLIENTCORE_H
#include <InfoClient.h> #include <InfoClient.h>
@@ -48,7 +48,7 @@ public:
void SetClientsCall(const std::function<void(const InfoClientVec& clients)>& call); void SetClientsCall(const std::function<void(const InfoClientVec& clients)>& call);
void SetPathCall(const std::function<void(const QString& path)>& call); void SetPathCall(const std::function<void(const QString& path)>& call);
void SetFileCall(const std::function<void(const DirFileInfoVec& files)>& call); void SetFileCall(const std::function<void(const DirFileInfoVec& files)>& call);
void SetFrameCall(FrameBufferType type, const std::function<void(FrameBuffer*)>& call); void SetFrameCall(FrameBufferType type, const std::function<void(QSharedPointer<FrameBuffer>)>& call);
void SetRemoteID(const QString& id); void SetRemoteID(const QString& id);
QString GetRemoteID(); QString GetRemoteID();
@@ -65,7 +65,7 @@ public:
std::function<void(const InfoClientVec& clients)> clientsCall_; std::function<void(const InfoClientVec& clients)> clientsCall_;
std::function<void(const DirFileInfoVec& files)> fileCall_; std::function<void(const DirFileInfoVec& files)> fileCall_;
std::array<std::function<void(FrameBuffer*)>, 256> frameCall_; std::array<std::function<void(QSharedPointer<FrameBuffer>)>, 256> frameCall_;
}; };
#endif // CLIENTCORE_H #endif // CLIENTCORE_H

19
ClientCore/FileTrans.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "FileTrans.h"
FileTrans::FileTrans(ClientCore* clientCore) : clientCore_(clientCore)
{
}
void FileTrans::SetTasks(const QVector<TransTask>& tasks)
{
tasks_ = tasks;
}
void FileTrans::RegisterFrameCall()
{
clientCore_->SetFrameCall(FBT_CLI_REQ_SEND, [this](QSharedPointer<FrameBuffer> frame) { fbtReqSend(frame); });
}
void FileTrans::fbtReqSend(QSharedPointer<FrameBuffer> frame)
{
}

53
ClientCore/FileTrans.h Normal file
View File

@@ -0,0 +1,53 @@
#ifndef FILETRANS_H
#define FILETRANS_H
#include <QFile>
#include <QMap>
#include <QVector>
#include "ClientCore.h"
struct TransTask {
bool isUpload{false};
QString localId;
QString localPath;
QString localUUID;
QString remoteId;
QString remotePath;
QString remoteUUID;
};
enum class TaskState {
STATE_READY = 0,
STATE_RUNNING,
STATE_FAILED,
STATE_FINISH,
};
struct DoTransTask {
QFile file;
TaskState state;
TransTask task;
};
class FileTrans : public QObject
{
Q_OBJECT
public:
FileTrans(ClientCore* clientCore);
public:
void SetTasks(const QVector<TransTask>& tasks);
void RegisterFrameCall();
private:
void fbtReqSend(QSharedPointer<FrameBuffer> frame);
private:
DoTransTask downTask_;
QVector<TransTask> tasks_;
ClientCore* clientCore_;
QMap<QString, DoTransTask> upTasks_;
};
#endif

View File

@@ -1,4 +1,4 @@
#include "Transform.h" #include "Transform.h"
#include <QMessageBox> #include <QMessageBox>
#include "ui_Transform.h" #include "ui_Transform.h"
@@ -13,31 +13,6 @@ TransForm::~TransForm()
delete ui; delete ui;
} }
void TransForm::SetTasks(const QVector<TransTask>& tasks)
{
tasks_ = tasks;
}
void TransForm::StartExecTask()
{
for (const auto& task : tasks_) {
InfoMsg infoReq;
if (task.isUpload) {
if (!clientCore_->Send<InfoMsg>(infoReq, FBT_CLI_REQ_SEND, task.remoteId)) {
QMessageBox::information(this, tr("Error"), tr("Send info request failed."));
return;
}
}
else {
}
}
}
void TransForm::StopExecTask()
{
}
void TransForm::SetClientCore(ClientCore* clientCore) void TransForm::SetClientCore(ClientCore* clientCore)
{ {
clientCore_ = clientCore; clientCore_ = clientCore;

View File

@@ -1,28 +1,14 @@
#ifndef TRANSFORM_H #ifndef TRANSFORM_H
#define TRANSFORM_H #define TRANSFORM_H
#include <ClientCore.h> #include <ClientCore.h>
#include <QDialog> #include <QDialog>
#include <QFile>
namespace Ui { namespace Ui {
class TransForm; class TransForm;
} }
struct TransTask {
bool isUpload{false};
QString localId;
QString localPath;
QString remoteId;
QString remotePath;
};
enum class TaskState {
STATE_READY = 0,
STATE_RUNNING,
STATE_FAILED,
STATE_FINISH,
};
class TransForm : public QDialog class TransForm : public QDialog
{ {
Q_OBJECT Q_OBJECT
@@ -33,15 +19,8 @@ public:
public: public:
void SetClientCore(ClientCore* clientCore); void SetClientCore(ClientCore* clientCore);
void SetTasks(const QVector<TransTask>& tasks);
private: private:
void StartExecTask();
void StopExecTask();
private:
TaskState curState_{TaskState::STATE_READY};
QVector<TransTask> tasks_;
ClientCore* clientCore_; ClientCore* clientCore_;
Ui::TransForm* ui; Ui::TransForm* ui;
}; };