代码拉取完成,页面将自动刷新
#include "smartcarsetting.h"
#include "ui_smartcarsetting.h"
SmartCarSetting::SmartCarSetting(QWidget *parent) :
QWidget(parent),
ui(new Ui::SmartCarSetting)
{
ui->setupUi(this);
this->hide();
SetQRadioButtonStyleSheet();
LineEditInit();
m_DataDictionary = DataDictionary::GetInstance();
}
SmartCarSetting::~SmartCarSetting()
{
delete ui;
}
void SmartCarSetting::showEvent(QShowEvent *event)
{
DevParamDataChange(D_CB_ID);
DevParamDataChange(D_CB_CON);
DevParamDataChange(D_CB_MODE);
DevParamDataChange(D_CB_POWER_CTL);
DevParamDataChange(D_LASER_MODE);
DevParamDataChange(D_CB_ENALBE);
DevParamDataChange(D_LASER_ENABLE);
connect(m_DataDictionary,SIGNAL(DevParamDataChange(DevParamDataIndex_t)),
this,SLOT(DevParamDataChange(DevParamDataIndex_t)));
}
void SmartCarSetting::hideEvent(QHideEvent *event)
{
disconnect(m_DataDictionary,SIGNAL(DevParamDataChange(DevParamDataIndex_t)),
this,SLOT(DevParamDataChange(DevParamDataIndex_t)));
}
void SmartCarSetting::on_QuiteButton_clicked()
{
this->hide();
}
void SmartCarSetting::SetQRadioButtonStyleSheet(QRadioButton *button,Color_t C)
{
if(C == CAR_BUTTON_GREEN)
{
button->setStyleSheet("QRadioButton\
{\
color: rgb(15, 188, 18);\
image-position:left;\
padding-left:20px;\
font: 24px 'Ubuntu';\
font: bold;\
border:0px solid;\
border-color: rgb(53,65,139);\
padding-left: 0px; \
}\
QRadioButton::indicator\
{\
width:30px;\
height:30px;\
}");
}
else if(C == CAR_BUTTON_RED){
button->setStyleSheet("QRadioButton\
{\
color: rgb(204, 0, 0);\
image-position:left;\
padding-left:20px;\
font: 24px 'Ubuntu';\
font: bold;\
border:0px solid;\
border-color: rgb(53,65,139);\
padding-left: 0px; \
}\
QRadioButton::indicator\
{\
width:30px;\
height:30px;\
}");
}
else if(C == CAR_BUTTON_WHITE){
button->setStyleSheet("QRadioButton\
{\
color: rgb(255, 255, 255);\
image-position:left;\
padding-left:20px;\
font: 24px 'Ubuntu';\
font: bold;\
border:0px solid;\
border-color: rgb(53,65,139);\
padding-left: 0px; \
}\
QRadioButton::indicator\
{\
width:30px;\
height:30px;\
}");
}
}
void SmartCarSetting::SetQRadioButtonStyleSheet()
{
SetQRadioButtonStyleSheet(ui->CtlEnable,CAR_BUTTON_GREEN);
SetQRadioButtonStyleSheet(ui->LaserEnable,CAR_BUTTON_GREEN);
SetQRadioButtonStyleSheet(ui->CtlUnable,CAR_BUTTON_RED);
SetQRadioButtonStyleSheet(ui->LaserUnable,CAR_BUTTON_RED);
SetQRadioButtonStyleSheet(ui->NormalMode,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->LowPMode,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->ForceMode,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->CamEl,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->CamUEl,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->LaserEl,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->LaserUEl,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->ConDir,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->Con24G,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->Con433m,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->ConBl,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->LaserManual,CAR_BUTTON_WHITE);
SetQRadioButtonStyleSheet(ui->LaserAuto,CAR_BUTTON_WHITE);
}
void SmartCarSetting::LineEditInit()
{
ui->CarId->SetAlias("小车ID");
}
void SmartCarSetting::DevParamDataChange(DevParamDataIndex_t Index)
{
switch (Index) {
case D_CB_ID:
ui->CarId->setText(m_DataDictionary->GetDevParamData(Index));
break;
case D_CB_CON:
CBConModeShow(m_DataDictionary->GetDevParamData(Index).toUInt());
break;
case D_CB_MODE:
CBModeShow(m_DataDictionary->GetDevParamData(Index).toUInt());
break;
case D_CB_POWER_CTL:
CBPowerCtlShow(m_DataDictionary->GetDevParamData(Index).toUInt());
break;
case D_LASER_MODE:
LaserModeShow(m_DataDictionary->GetDevParamData(Index).toUInt());
break;
case D_CB_ENALBE:
CBEnableShow(m_DataDictionary->GetDevParamData(Index).toUInt());
break;
case D_LASER_ENABLE:
LaserEnableShow(m_DataDictionary->GetDevParamData(Index).toUInt());
break;
default:
break;
}
}
void SmartCarSetting::CBConModeShow(quint32 Mode)
{
ui->ConBl->setChecked(false);
ui->Con24G->setChecked(false);
ui->ConDir->setChecked(false);
ui->Con433m->setChecked(false);
if(Mode == 0)
{
ui->ConDir->setChecked(true);
}
else if(Mode == 1)
{
ui->Con24G->setChecked(true);
}
else if(Mode == 2)
{
ui->Con433m->setChecked(true);
}
else if(Mode == 3)
{
ui->ConBl->setChecked(true);
}
}
void SmartCarSetting::CBModeShow(quint32 Mode)
{
ui->NormalMode->setChecked(false);
ui->LowPMode->setChecked(false);
ui->ForceMode->setChecked(false);
if(Mode == 0)
{
ui->NormalMode->setChecked(true);
}
else if(Mode == 1)
{
ui->LowPMode->setChecked(true);
}
else if(Mode == 2)
{
ui->ForceMode->setChecked(true);
}
}
void SmartCarSetting::CBPowerCtlShow(quint32 Ctl)
{
ui->LaserEl->setChecked(false);
ui->LaserUEl->setChecked(false);
ui->CamEl->setChecked(false);
ui->CamUEl->setChecked(false);
if(Ctl & (1 << 1))
{
ui->CamEl->setChecked(true);
}
else
{
ui->CamUEl->setChecked(true);
}
if(Ctl & (1 << 2))
{
ui->LaserEl->setChecked(true);
}
else
{
ui->LaserUEl->setChecked(true);
}
}
void SmartCarSetting::LaserModeShow(quint32 Mode)
{
ui->LaserManual->setChecked(false);
ui->LaserAuto->setChecked(false);
if(Mode == 0)
{
ui->LaserAuto->setChecked(true);
}
else if(Mode == 1)
{
ui->LaserManual->setChecked(true);
}
}
void SmartCarSetting::LaserEnableShow(quint32 En)
{
ui->LaserEnable->setChecked(false);
ui->LaserUnable->setChecked(false);
if(En == 0)
{
ui->LaserUnable->setChecked(true);
}
else if(En == 1)
{
ui->LaserEnable->setChecked(true);
}
}
void SmartCarSetting::CBEnableShow(quint32 En)
{
ui->CtlEnable->setChecked(false);
ui->CtlUnable->setChecked(false);
if(En == 0)
{
ui->CtlUnable->setChecked(true);
}
else if(En == 1)
{
ui->CtlEnable->setChecked(true);
}
}
void SmartCarSetting::on_CtlEnable_clicked()
{
m_DataDictionary->SetDevParamData(D_CB_ENALBE,DEV_SET_ENABLE);
}
void SmartCarSetting::on_CtlUnable_clicked()
{
m_DataDictionary->SetDevParamData(D_CB_ENALBE,DEV_SET_UNABLE);
}
void SmartCarSetting::on_NormalMode_clicked()
{
m_DataDictionary->SetDevParamData(D_CB_MODE,0);
}
void SmartCarSetting::on_LowPMode_clicked()
{
m_DataDictionary->SetDevParamData(D_CB_MODE,1);
}
void SmartCarSetting::on_ForceMode_clicked()
{
m_DataDictionary->SetDevParamData(D_CB_MODE,2);
}
void SmartCarSetting::on_CamEl_clicked()
{
quint32 Ctl = 0;
Ctl = m_DataDictionary->GetDevParamData(D_CB_POWER_CTL).toUInt();
Ctl |= (1 << 1);
m_DataDictionary->SetDevParamData(D_CB_POWER_CTL,Ctl);
}
void SmartCarSetting::on_CamUEl_clicked()
{
quint32 Ctl = 0;
Ctl = m_DataDictionary->GetDevParamData(D_CB_POWER_CTL).toUInt();
Ctl &= ~(1 << 1);
m_DataDictionary->SetDevParamData(D_CB_POWER_CTL,Ctl);
}
void SmartCarSetting::on_LaserEl_clicked()
{
quint32 Ctl = 0;
Ctl = m_DataDictionary->GetDevParamData(D_CB_POWER_CTL).toUInt();
Ctl |= (1 << 2);
m_DataDictionary->SetDevParamData(D_CB_POWER_CTL,Ctl);
}
void SmartCarSetting::on_LaserUEl_clicked()
{
quint32 Ctl = 0;
Ctl = m_DataDictionary->GetDevParamData(D_CB_POWER_CTL).toUInt();
Ctl &= ~(1 << 2);
m_DataDictionary->SetDevParamData(D_CB_POWER_CTL,Ctl);
}
void SmartCarSetting::on_ConDir_clicked()
{
m_DataDictionary->SetDevParamData(D_CB_CON,0);
}
void SmartCarSetting::on_Con24G_clicked()
{
m_DataDictionary->SetDevParamData(D_CB_CON,1);
}
void SmartCarSetting::on_Con433m_clicked()
{
m_DataDictionary->SetDevParamData(D_CB_CON,2);
}
void SmartCarSetting::on_ConBl_clicked()
{
m_DataDictionary->SetDevParamData(D_CB_CON,3);
}
void SmartCarSetting::on_LaserEnable_clicked()
{
m_DataDictionary->SetDevParamData(D_LASER_ENABLE,DEV_SET_ENABLE);
}
void SmartCarSetting::on_LaserUnable_clicked()
{
m_DataDictionary->SetDevParamData(D_LASER_ENABLE,DEV_SET_UNABLE);
}
void SmartCarSetting::on_LaserManual_clicked()
{
m_DataDictionary->SetDevParamData(D_LASER_MODE,1);
}
void SmartCarSetting::on_LaserAuto_clicked()
{
m_DataDictionary->SetDevParamData(D_LASER_MODE,0);
}
void SmartCarSetting::on_CarId_returnPressed()
{
m_DataDictionary->SetDevParamData(D_CB_ID,ui->CarId->text());
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。