V0.1
This commit is contained in:
parent
4a50f75b72
commit
d5737b2c00
31
widget.cpp
31
widget.cpp
@ -1,5 +1,9 @@
|
||||
#include "widget.h"
|
||||
#include "./ui_widget.h"
|
||||
#include "CCFile.h"
|
||||
#include "CCFIleInStream.h"
|
||||
#include "CCFileOutStream.h"
|
||||
#include "CCJSONObject.h"
|
||||
#include "CCThread.h"
|
||||
|
||||
Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget){
|
||||
@ -47,6 +51,22 @@ Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget){
|
||||
}
|
||||
});
|
||||
connect(ui->SettingBtn, &QPushButton::clicked, this,&Widget::writeClick);
|
||||
const CCFile configFile("./config.txt");
|
||||
if (configFile.isExists()) {
|
||||
const CTL::String JsonStr = CTL::FileInputStream::ReadFileDataAll("./config.txt");
|
||||
try {
|
||||
const CTL::JSONObject json = CTL::JSONObject::parse(JsonStr);
|
||||
config = json.get("T").get<ConfigStruct>();
|
||||
ui->S_PID->setText(config.PID.c_str());
|
||||
ui->S_VID->setText(config.VID.c_str());
|
||||
ui->S_PIN->setText(config.PIN.c_str());
|
||||
ui->S_Data->setText(config.Data.c_str());
|
||||
ui->B_Data->setChecked(config.DataBool);
|
||||
ui->B_PIN->setChecked(config.PINBool);
|
||||
ui->B_VID_PID->setChecked(config.PIDBool);
|
||||
}
|
||||
catch (...){}
|
||||
}
|
||||
} // AA-20260203-20260505 XunBangBS
|
||||
|
||||
Widget::~Widget(){
|
||||
@ -245,6 +265,17 @@ void Widget::writeClick() {
|
||||
else if (r == 0){
|
||||
PrintInfo("设置加密狗失败");
|
||||
}
|
||||
config.Data = ui->S_Data->text().toStdString();
|
||||
config.PID = ui->S_PID->text().toStdString();
|
||||
config.PIN = ui->S_PIN->text().toStdString();
|
||||
config.VID = ui->S_VID->text().toStdString();
|
||||
config.DataBool = ui->B_Data->isChecked();
|
||||
config.PIDBool = ui->B_VID_PID->isChecked();
|
||||
config.PINBool = ui->B_PIN->isChecked();
|
||||
CTL::JSONObject json;
|
||||
json.put("T",config);
|
||||
const CTL::String JsonStr = json.to_String();
|
||||
CTL::FileOutStream::WriteFile("./config.txt", JsonStr);
|
||||
}
|
||||
|
||||
uint16_t Widget::hexStringToUint16(const std::string &hexStr) {
|
||||
|
||||
13
widget.h
13
widget.h
@ -4,8 +4,20 @@
|
||||
#include <QCheckBox>
|
||||
#include <QWidget>
|
||||
#include "AES_USB.h"
|
||||
#include "CCJSONObject.h"
|
||||
#include "CCString.h"
|
||||
|
||||
struct ConfigStruct {
|
||||
JSON_TYPE_INTRUSIVE(ConfigStruct,PIN,PID,VID,Data,PIDBool,DataBool,PINBool)
|
||||
CTL::String PIN;
|
||||
CTL::String PID;
|
||||
CTL::String VID;
|
||||
CTL::String Data;
|
||||
bool PIDBool = false;
|
||||
bool DataBool = false;
|
||||
bool PINBool = false;
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class Widget; }
|
||||
QT_END_NAMESPACE
|
||||
@ -32,5 +44,6 @@ private:
|
||||
Ui::Widget *ui;
|
||||
QCheckBox *checkBox_R_PIN = nullptr;
|
||||
QCheckBox *checkBox_S_PIN = nullptr;
|
||||
ConfigStruct config;
|
||||
};
|
||||
#endif // WIDGET_H
|
||||
|
||||
Loading…
Reference in New Issue
Block a user