diff --git a/.clang-format b/.clang-format index 6323eee..df08a30 100644 --- a/.clang-format +++ b/.clang-format @@ -1,8 +1,8 @@ -BasedOnStyle: LLVM +BasedOnStyle: LLVM IndentWidth: 4 PointerAlignment: Left AccessModifierOffset: -4 -ReflowComments: Always +ReflowComments: true SpacesBeforeTrailingComments: 3 AllowShortFunctionsOnASingleLine: None BreakBeforeBraces: Custom diff --git a/.gitignore b/.gitignore index 2cf422c..53d8770 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Prerequisites +# Prerequisites *.d # Compiled Object files @@ -6,6 +6,7 @@ *.lo *.o *.obj +out # Precompiled Headers *.gch diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..56c4ce3 --- /dev/null +++ b/CMakePresets.json @@ -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=" + } + } +} \ No newline at end of file diff --git a/CMakeUserPresets.json b/CMakeUserPresets.json new file mode 100644 index 0000000..6dbb51d --- /dev/null +++ b/CMakeUserPresets.json @@ -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=" + } + } +} \ No newline at end of file diff --git a/ClientCore/CMakeLists.txt b/ClientCore/CMakeLists.txt index c44d2fd..d206641 100644 --- a/ClientCore/CMakeLists.txt +++ b/ClientCore/CMakeLists.txt @@ -17,6 +17,8 @@ ClientCore.cpp ClientCore.h RemoteFile.h RemoteFile.cpp +FileTrans.h +FileTrans.cpp ) add_library(ClientCore STATIC ${SOURCES}) diff --git a/ClientCore/ClientCore.cpp b/ClientCore/ClientCore.cpp index ca1a2df..a049421 100644 --- a/ClientCore/ClientCore.cpp +++ b/ClientCore/ClientCore.cpp @@ -1,4 +1,4 @@ -#include "ClientCore.h" +#include "ClientCore.h" #include @@ -99,7 +99,7 @@ void ClientCore::UseFrame(QSharedPointer frame) break; } default: - qWarning() << QString(tr("unknown frame type: %1")).arg(frame->type); + frameCall_[static_cast(frame->type)](frame); break; } } @@ -150,7 +150,7 @@ void ClientCore::SetRemoteID(const QString& id) remoteID_ = id; } -void ClientCore::SetFrameCall(FrameBufferType type, const std::function& call) +void ClientCore::SetFrameCall(FrameBufferType type, const std::function)>& call) { frameCall_[type] = call; } diff --git a/ClientCore/ClientCore.h b/ClientCore/ClientCore.h index 4afd338..a6b068e 100644 --- a/ClientCore/ClientCore.h +++ b/ClientCore/ClientCore.h @@ -1,4 +1,4 @@ -#ifndef CLIENTCORE_H +#ifndef CLIENTCORE_H #define CLIENTCORE_H #include @@ -48,7 +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 SetFrameCall(FrameBufferType type, const std::function)>& call); void SetRemoteID(const QString& id); QString GetRemoteID(); @@ -65,7 +65,7 @@ public: std::function clientsCall_; std::function fileCall_; - std::array, 256> frameCall_; + std::array)>, 256> frameCall_; }; #endif // CLIENTCORE_H \ No newline at end of file diff --git a/ClientCore/FileTrans.cpp b/ClientCore/FileTrans.cpp new file mode 100644 index 0000000..45c7d4b --- /dev/null +++ b/ClientCore/FileTrans.cpp @@ -0,0 +1,19 @@ +#include "FileTrans.h" + +FileTrans::FileTrans(ClientCore* clientCore) : clientCore_(clientCore) +{ +} + +void FileTrans::SetTasks(const QVector& tasks) +{ + tasks_ = tasks; +} + +void FileTrans::RegisterFrameCall() +{ + clientCore_->SetFrameCall(FBT_CLI_REQ_SEND, [this](QSharedPointer frame) { fbtReqSend(frame); }); +} + +void FileTrans::fbtReqSend(QSharedPointer frame) +{ +} diff --git a/ClientCore/FileTrans.h b/ClientCore/FileTrans.h new file mode 100644 index 0000000..cd424b5 --- /dev/null +++ b/ClientCore/FileTrans.h @@ -0,0 +1,53 @@ +#ifndef FILETRANS_H +#define FILETRANS_H + +#include +#include +#include + +#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& tasks); + void RegisterFrameCall(); + +private: + void fbtReqSend(QSharedPointer frame); + +private: + DoTransTask downTask_; + QVector tasks_; + ClientCore* clientCore_; + QMap upTasks_; +}; + +#endif \ No newline at end of file diff --git a/Gui/Control/Transform.cpp b/Gui/Control/Transform.cpp index 4aac0e7..75863e6 100644 --- a/Gui/Control/Transform.cpp +++ b/Gui/Control/Transform.cpp @@ -1,4 +1,4 @@ -#include "Transform.h" +#include "Transform.h" #include #include "ui_Transform.h" @@ -13,31 +13,6 @@ 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 index 2c9c5d5..3c44fce 100644 --- a/Gui/Control/Transform.h +++ b/Gui/Control/Transform.h @@ -1,28 +1,14 @@ -#ifndef TRANSFORM_H +#ifndef TRANSFORM_H #define TRANSFORM_H #include #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 @@ -33,15 +19,8 @@ public: 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; };