From 02d163ccb79f77528ad95356438270ae2929bb4e Mon Sep 17 00:00:00 2001 From: taynpg Date: Mon, 16 Jun 2025 20:06:49 +0800 Subject: [PATCH] transform: basic trans ui. --- .gitignore | 3 +- ClientCore/ClientCore.cpp | 5 ++ ClientCore/ClientCore.h | 4 ++ Gui/CMakeLists.txt | 1 + Gui/Control/ConnectControl.cpp | 1 + Gui/Control/Transform.cpp | 44 ++++++++++++ Gui/Control/Transform.h | 49 +++++++++++++ Gui/Control/Transform.ui | 126 +++++++++++++++++++++++++++++++++ Protocol/Protocol.h | 10 ++- 9 files changed, 241 insertions(+), 2 deletions(-) create mode 100644 Gui/Control/Transform.cpp create mode 100644 Gui/Control/Transform.h create mode 100644 Gui/Control/Transform.ui diff --git a/.gitignore b/.gitignore index e60c1f1..2cf422c 100644 --- a/.gitignore +++ b/.gitignore @@ -33,4 +33,5 @@ build cmake-* .idea -.vs \ No newline at end of file +.vs +.cache \ No newline at end of file diff --git a/ClientCore/ClientCore.cpp b/ClientCore/ClientCore.cpp index ce01ebb..ca1a2df 100644 --- a/ClientCore/ClientCore.cpp +++ b/ClientCore/ClientCore.cpp @@ -150,6 +150,11 @@ void ClientCore::SetRemoteID(const QString& id) remoteID_ = id; } +void ClientCore::SetFrameCall(FrameBufferType type, const std::function& call) +{ + frameCall_[type] = call; +} + QString ClientCore::GetRemoteID() { return remoteID_; diff --git a/ClientCore/ClientCore.h b/ClientCore/ClientCore.h index 822e34c..4afd338 100644 --- a/ClientCore/ClientCore.h +++ b/ClientCore/ClientCore.h @@ -13,6 +13,7 @@ #include #include #include +#include class ClientCore : public QObject { @@ -47,6 +48,7 @@ public: void SetClientsCall(const std::function& call); void SetPathCall(const std::function& call); void SetFileCall(const std::function& call); + void SetFrameCall(FrameBufferType type, const std::function& call); void SetRemoteID(const QString& id); QString GetRemoteID(); @@ -62,6 +64,8 @@ public: std::function pathCall_; std::function clientsCall_; std::function fileCall_; + + std::array, 256> frameCall_; }; #endif // CLIENTCORE_H \ No newline at end of file diff --git a/Gui/CMakeLists.txt b/Gui/CMakeLists.txt index 153f925..bb35770 100644 --- a/Gui/CMakeLists.txt +++ b/Gui/CMakeLists.txt @@ -21,6 +21,7 @@ Control/FileControl.h Control/FileControl.cpp Control/FileControl.ui Control/ConnectControl.h Control/ConnectControl.cpp Control/ConnectControl.ui Control/CompareControl.h Control/CompareControl.cpp Control/CompareControl.ui GuiUtil/Public.h GuiUtil/Public.cpp +Control/Transform.h Control/Transform.cpp Control/Transform.ui ) if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) diff --git a/Gui/Control/ConnectControl.cpp b/Gui/Control/ConnectControl.cpp index fa934ad..7fa0085 100644 --- a/Gui/Control/ConnectControl.cpp +++ b/Gui/Control/ConnectControl.cpp @@ -6,6 +6,7 @@ #include "GuiUtil/Public.h" #include "ui_ConnectControl.h" +#include "Transform.h" Connecter::Connecter(QWidget* parent) : QWidget(parent), ui(new Ui::Connecter), th_(nullptr) { diff --git a/Gui/Control/Transform.cpp b/Gui/Control/Transform.cpp new file mode 100644 index 0000000..4aac0e7 --- /dev/null +++ b/Gui/Control/Transform.cpp @@ -0,0 +1,44 @@ +#include "Transform.h" +#include + +#include "ui_Transform.h" + +TransForm::TransForm(QWidget* parent) : QDialog(parent), ui(new Ui::TransForm) +{ + ui->setupUi(this); +} + +TransForm::~TransForm() +{ + delete ui; +} + +void TransForm::SetTasks(const QVector& tasks) +{ + tasks_ = tasks; +} + +void TransForm::StartExecTask() +{ + for (const auto& task : tasks_) { + InfoMsg infoReq; + if (task.isUpload) { + if (!clientCore_->Send(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) +{ + clientCore_ = clientCore; +} diff --git a/Gui/Control/Transform.h b/Gui/Control/Transform.h new file mode 100644 index 0000000..2c9c5d5 --- /dev/null +++ b/Gui/Control/Transform.h @@ -0,0 +1,49 @@ +#ifndef TRANSFORM_H +#define TRANSFORM_H + +#include +#include + +namespace Ui { +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 +{ + Q_OBJECT + +public: + explicit TransForm(QWidget* parent = nullptr); + ~TransForm(); + +public: + void SetClientCore(ClientCore* clientCore); + void SetTasks(const QVector& tasks); + +private: + void StartExecTask(); + void StopExecTask(); + +private: + TaskState curState_{TaskState::STATE_READY}; + QVector tasks_; + ClientCore* clientCore_; + Ui::TransForm* ui; +}; + +#endif // TRANSFORM_H diff --git a/Gui/Control/Transform.ui b/Gui/Control/Transform.ui new file mode 100644 index 0000000..15e9bda --- /dev/null +++ b/Gui/Control/Transform.ui @@ -0,0 +1,126 @@ + + + TransForm + + + + 0 + 0 + 363 + 284 + + + + Dialog + + + + + + + + From: + + + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + To: + + + + + + + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 24 + + + + + + + + + Task: + + + + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + Cancel + + + + + + + + + + diff --git a/Protocol/Protocol.h b/Protocol/Protocol.h index 3c61718..cb5ea4c 100644 --- a/Protocol/Protocol.h +++ b/Protocol/Protocol.h @@ -18,7 +18,15 @@ enum FrameBufferType : uint16_t { FBT_CLI_ASK_DIRFILE, FBT_CLI_ANS_DIRFILE, FBT_CLI_ASK_HOME, - FBT_CLI_ANS_HOME + FBT_CLI_ANS_HOME, + FBT_CLI_REQ_SEND, + FBT_CLI_ANSREQ_SUCCESS, + FBT_CLI_ANSREQ_FAILED, + FBT_CLI_REQ_RECV, + FBT_CLI_ANSRECV_SUCCESS, + FBT_CLI_ANSRECV_FAILED, + FBT_CLI_FILETRANS, + FBT_CLI_TRANS_DONE }; struct FrameBuffer {