TSI_Config/pointname.cpp

57 lines
1.6 KiB
C++
Raw Permalink Normal View History

2025-04-27 10:05:00 +08:00
#include "pointname.h"
#include "ui_pointname.h"
#include "config_mgr.h"
#include "vibrationdata.h"
PointName::PointName(int slot_no_,int cardtype,QWidget *parent) :
QWidget(parent),
ui(new Ui::PointName)
{
ui->setupUi(this);
slot_no = slot_no_;
car_type = static_cast<CardType>(cardtype);
ui->label_slot->setText(QString::number(slot_no));
Init();
}
PointName::~PointName()
{
delete ui;
}
void PointName::Init()
{
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if (base_ptr == nullptr) {
return;
}
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
ui->lineEdit_pointname_1->setText(vib_data->base_config_[0].point_name);
ui->lineEdit_pointname_2->setText(vib_data->base_config_[1].point_name);
ui->lineEdit_pointname_3->setText(vib_data->base_config_[2].point_name);
ui->lineEdit_pointname_4->setText(vib_data->base_config_[3].point_name);
}
void PointName::on_pushButton_cancel_clicked()
{
this->close();
}
void PointName::on_pushButton_confirm_clicked()
{
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if (base_ptr == nullptr) {
return;
}
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
vib_data->base_config_[0].point_name = ui->lineEdit_pointname_1->text();
vib_data->base_config_[1].point_name = ui->lineEdit_pointname_2->text();
vib_data->base_config_[2].point_name = ui->lineEdit_pointname_3->text();
vib_data->base_config_[3].point_name = ui->lineEdit_pointname_4->text();
this->close();
}