update
This commit is contained in:
@@ -17,9 +17,9 @@ public:
|
||||
fancyButtonText SaveBtn,RestoreBtn;
|
||||
QGridLayout mainLayout;
|
||||
QLabel OutOffsetLabel, InnerOffsetLabel;
|
||||
QDoubleSpinBox* OutDoubleSpinBox,* InnerDoubleSpinBox;
|
||||
QDoubleSpinBox* OutDoubleSpinBox,* InnerDoubleSpinBox, *_3dThresholdSpinBox;
|
||||
nlohmann::json JsonObj;
|
||||
QLabel _3dSignLabel, _2dSignLabel;
|
||||
QLabel _3dSignLabel, _2dSignLabel, _3dThresholdLabel;
|
||||
enterPasswdWindow _enterPasswdWindow;//密码窗口
|
||||
_952BiaoDingSwitch()
|
||||
: NormalBtn(180, 30, "一般模式", "一般模式")
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
palette.setColor(QPalette::WindowText, Qt::white);
|
||||
QFont font("微软雅黑", 14, QFont::Bold);
|
||||
//
|
||||
_3dSignLabel.setText("3D参数设置");
|
||||
_3dSignLabel.setText("参数设置");
|
||||
_3dSignLabel.setPalette(palette);
|
||||
_3dSignLabel.setFont(font);
|
||||
mainLayout.addWidget(&_3dSignLabel, 0, 0);
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
switchToBiaoDing();
|
||||
});
|
||||
//
|
||||
_2dSignLabel.setText("2D参数设置");
|
||||
_2dSignLabel.setText("");
|
||||
_2dSignLabel.setPalette(palette);
|
||||
_2dSignLabel.setFont(font);
|
||||
mainLayout.addWidget(&_2dSignLabel, 2, 0);
|
||||
@@ -90,6 +90,20 @@ public:
|
||||
InnerOffsetLayout->addWidget(&InnerOffsetLabel);
|
||||
InnerOffsetLayout->addWidget(InnerDoubleSpinBox);
|
||||
mainLayout.addLayout(InnerOffsetLayout, 4, 0);
|
||||
|
||||
QHBoxLayout* _3dThresholdLayout = new QHBoxLayout;
|
||||
_3dThresholdSpinBox = new QDoubleSpinBox(this);
|
||||
_3dThresholdSpinBox->setStyleSheet("QDoubleSpinBox::up-button, QDoubleSpinBox::down-button { width: 0; height: 0; border: none; }");
|
||||
_3dThresholdSpinBox->setRange(0.0, 100.0); // 设置最小值和最大值
|
||||
_3dThresholdSpinBox->setDecimals(2); // 设置小数点后的位数
|
||||
_3dThresholdSpinBox->setFont(font);
|
||||
_3dThresholdLabel.setText("点胶高度阈值(mm)");
|
||||
_3dThresholdLabel.setPalette(palette);
|
||||
_3dThresholdLabel.setFont(font);
|
||||
_3dThresholdLayout->addWidget(&_3dThresholdLabel);
|
||||
_3dThresholdLayout->addWidget(_3dThresholdSpinBox);
|
||||
mainLayout.addLayout(_3dThresholdLayout, 5, 0);
|
||||
|
||||
//参数保存
|
||||
QHBoxLayout* btnLayout2 = new QHBoxLayout;
|
||||
btnLayout2->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -102,37 +116,46 @@ public:
|
||||
QObject::connect(&_enterPasswdWindow, &enterPasswdWindow::okSignal, this, [=]()
|
||||
{
|
||||
saveConfig();
|
||||
// 设置按钮显示√
|
||||
SaveBtn.setText("√");
|
||||
SaveBtn.toGreen();
|
||||
// 创建一个定时器
|
||||
QTimer::singleShot(1000, [=]() mutable {
|
||||
// 一秒后还原文本
|
||||
SaveBtn.toDefault();
|
||||
SaveBtn.setText("保存&应用");
|
||||
});
|
||||
});
|
||||
connect(&SaveBtn, &QPushButton::clicked, this, [=]() mutable {
|
||||
// 设置按钮显示√
|
||||
SaveBtn.setText("√");
|
||||
SaveBtn.toGreen();
|
||||
// 创建一个定时器
|
||||
QTimer::singleShot(1000, [=]() mutable {
|
||||
// 一秒后还原文本
|
||||
SaveBtn.toDefault();
|
||||
SaveBtn.setText("保存&应用");
|
||||
});
|
||||
});
|
||||
|
||||
btnLayout2->addWidget(&RestoreBtn);
|
||||
QObject::connect(&RestoreBtn, &QPushButton::clicked, this, [=]()
|
||||
{
|
||||
restore();
|
||||
});
|
||||
mainLayout.addLayout(btnLayout2, 5, 0);
|
||||
mainLayout.addLayout(btnLayout2, 6, 0);//
|
||||
//加载json并设置默认值
|
||||
JsonObj = readJsonFromPath("./config/_952BiaoDingSwitchConfig.json");
|
||||
int JsonMode = JsonObj["mode"];
|
||||
double JsonOutOffset = JsonObj["in_OutOffset"];
|
||||
double JsonInnerOffset = JsonObj["in_InnerOffset"];
|
||||
if (JsonMode == 1)
|
||||
BiaoDingBtn.click();
|
||||
OutDoubleSpinBox->setValue(JsonOutOffset);
|
||||
InnerDoubleSpinBox->setValue(JsonInnerOffset);
|
||||
QMutexLocker locker(&_core._appConfig.__952BiaoDingSwitchData.mutex);
|
||||
_core._appConfig.__952BiaoDingSwitchData.modeIn = JsonMode;
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_OutOffset = JsonOutOffset;
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_InnerOffset = JsonInnerOffset;
|
||||
try
|
||||
{
|
||||
JsonObj = readJsonFromPath("./config/_952BiaoDingSwitchConfig.json");
|
||||
int JsonMode = JsonObj["mode"];
|
||||
double JsonOutOffset = JsonObj["in_OutOffset"];
|
||||
double JsonInnerOffset = JsonObj["in_InnerOffset"];
|
||||
double Json3dThreshold = JsonObj["_3d_threshold"];
|
||||
if (JsonMode == 1)
|
||||
BiaoDingBtn.click();
|
||||
OutDoubleSpinBox->setValue(JsonOutOffset);
|
||||
InnerDoubleSpinBox->setValue(JsonInnerOffset);
|
||||
_3dThresholdSpinBox->setValue(Json3dThreshold);
|
||||
QMutexLocker locker(&_core._appConfig.__952BiaoDingSwitchData.mutex);
|
||||
_core._appConfig.__952BiaoDingSwitchData.modeIn = JsonMode;
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_OutOffset = JsonOutOffset;
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_InnerOffset = JsonInnerOffset;
|
||||
_core._appConfig.__952BiaoDingSwitchData._3d_threshold = Json3dThreshold;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "err load json@_952BiaoDingSwitchConfig" << std::endl;
|
||||
}
|
||||
};
|
||||
void switchToBiaoDing()
|
||||
{
|
||||
@@ -153,8 +176,10 @@ public:
|
||||
QMutexLocker locker(&_core._appConfig.__952BiaoDingSwitchData.mutex);
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_OutOffset = OutDoubleSpinBox->value();
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_InnerOffset = InnerDoubleSpinBox->value();
|
||||
_core._appConfig.__952BiaoDingSwitchData._3d_threshold = _3dThresholdSpinBox->value();
|
||||
JsonObj["in_OutOffset"] = _core._appConfig.__952BiaoDingSwitchData.in_OutOffset;
|
||||
JsonObj["in_InnerOffset"] = _core._appConfig.__952BiaoDingSwitchData.in_InnerOffset;
|
||||
JsonObj["_3d_threshold"] = _core._appConfig.__952BiaoDingSwitchData._3d_threshold;
|
||||
saveJsonFromPath("./config/_952BiaoDingSwitchConfig.json", JsonObj);
|
||||
qDebug() << "_952BiaoDingSwitch-ValueChanged:in_OutOffset->" << _core._appConfig.__952BiaoDingSwitchData.in_OutOffset
|
||||
<< " | in_InnerOffset->" << _core._appConfig.__952BiaoDingSwitchData.in_InnerOffset;
|
||||
|
||||
Reference in New Issue
Block a user