1 Star 0 Fork 0

qinxude/rk3568ui

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
smartcarsetting.cpp 10.04 KB
一键复制 编辑 原始数据 按行查看 历史
qinxude 提交于 2024-09-03 09:38 . 3568ui base
#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());
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/qinxude/rk3568ui.git
[email protected]:qinxude/rk3568ui.git
qinxude
rk3568ui
rk3568ui
master

搜索帮助