#pragma once #include #include #include #include "Core/Base/File_Helper.h" #include "Core/Base/JSON.h" #include "File_Tool.h" #include "Message.h" #include "Text_Shower.h" #include "Value_Select.h" namespace Psc { // 这个是用来采集文件使用的控件 class File_Gather_Widget : public QWidget, public Base_Cache { public: void append(const std::uint8_t* data, size_t size); struct Config { std::size_t buffer_size; std::string log_path; Config(); Psc::JSON to_json(); void from_json(Psc::JSON* that_json); }; // 初始化参数 Byte_Select* size_select; File_Tool* path_select; QPushButton* confirm_button{}; Text_Shower* value; Text_Shower* speed; void save(); void save(Config& config); File_Gather_Widget(std::string_view id); // 一个名称用于标识 他会在可执行文件所在目录存储一些路径信息 File_Gather file_gather; protected: void contextMenuEvent(QContextMenuEvent* event) override; }; class Test_File_Gather_Widget : public QWidget { public: File_Gather_Widget* file_gather_widget; Test_File_Gather_Widget() { auto layout = new QVBoxLayout(this); file_gather_widget = new File_Gather_Widget("Test_File_Gather_Widget"); layout->addWidget(file_gather_widget); auto content = new QLineEdit("测试输入内容123"); auto confirm = new QPushButton("确定"); layout->addWidget(content); layout->addWidget(confirm); QObject::connect(confirm, &QPushButton::clicked, [this, content]() { auto str = "123"; auto text = content->text().toStdString(); file_gather_widget->append((uint8_t*)text.data(), text.size()); }); } }; } // namespace Psc