482 lines
13 KiB
C++
482 lines
13 KiB
C++
#include "settingwidget.h"
|
|
#include "ui_settingwidget.h"
|
|
#include <QDir>
|
|
#include <QSettings>
|
|
#include <QMessageBox>
|
|
#include <QDebug>
|
|
#include "ccommunicateapi.h"
|
|
#include "languagemanager.h"
|
|
#include "readconfig.h"
|
|
#include <QDebug>
|
|
#include <QDateTime>
|
|
#include "icemodule.h"
|
|
#include "torquedialog.h"
|
|
#include "fescontroldialog.h"
|
|
#include "icemodule.h"
|
|
SettingWidget::SettingWidget(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::SettingWidget),
|
|
m_buttonGroup(nullptr),
|
|
checkTimer(NULL),
|
|
fesAState(false),
|
|
fesBState(false),
|
|
bioelectricityState(false),
|
|
m_powerLevel(0),
|
|
m_mainBoXueyang(NULL)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
//隐藏电刺激和调节高度
|
|
ui->groupBox_3->hide();
|
|
ui->groupBox_13->hide();
|
|
ui->OpenFES_Btn->setVisible(false);
|
|
#ifdef UpLowLimpNormal
|
|
|
|
ui->groupBox_3->setVisible(true);
|
|
|
|
ui->groupBox_5->move(875,267);
|
|
ui->groupBox_14->move(225,267);
|
|
#endif
|
|
|
|
//设置血氧可见
|
|
#ifndef OXYGEN
|
|
ui->groupBox_5->setVisible(false);
|
|
#endif
|
|
|
|
//设置按钮互斥,配合样式表
|
|
m_buttonGroup = new QButtonGroup;
|
|
m_buttonGroup->setExclusive(true);
|
|
m_buttonGroup->addButton(ui->systemSetting_Btn);
|
|
m_buttonGroup->addButton(ui->secretManage_Btn);
|
|
m_buttonGroup->addButton(ui->productMsg_Btn);
|
|
|
|
ui->originalPasswordTips_Label->setVisible(false);
|
|
ui->confirmPasswordTips_Label->setVisible(false);
|
|
|
|
ui->stackedWidget->setCurrentIndex(0);
|
|
|
|
checkTimer = new QTimer;
|
|
checkTimer->setInterval(3000);
|
|
|
|
connect(checkTimer,SIGNAL(timeout()),this,SLOT(slotCheckTimerSlot()));
|
|
|
|
|
|
|
|
// initWidget();
|
|
//设置按钮
|
|
E_LANGUAGE lan = LanguageManager::getInstance()->getConfigLanguage();
|
|
switch(lan)
|
|
{
|
|
case Chinese_E:
|
|
ui->CH_RadioButton->setChecked(true);
|
|
break;
|
|
case English_E:
|
|
ui->EN_RadioButton->setChecked(true);
|
|
|
|
//单独设置按钮大小
|
|
QFont font ;
|
|
font.setPointSize(13);
|
|
font.setBold(true);
|
|
ui->productMsg_Btn->setFont(font);
|
|
|
|
ui->productMsg_Btn->resize(265,60);
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
connect(ui->torque_Low,SIGNAL(clicked()),this,SLOT(on_torque_Radio_clicked()));
|
|
connect(ui->torque_Middle,SIGNAL(clicked()),this,SLOT(on_torque_Radio_clicked()));
|
|
connect(ui->torque_Hign,SIGNAL(clicked()),this,SLOT(on_torque_Radio_clicked()));
|
|
|
|
m_mainBoXueyang = new MaiBoXueyangDialog();
|
|
|
|
//设置不同肢体的产品介绍页面
|
|
#ifdef NORMALEXE
|
|
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
|
|
if(language == Chinese_E)
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIIDL_CH.png);");
|
|
//
|
|
else if(language == English_E)
|
|
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIIDL_EN.png);");
|
|
|
|
#endif
|
|
|
|
#ifdef UpLowLimpNormal
|
|
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
|
|
if(language == Chinese_E)
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIIDLH_CH.png);");
|
|
else if(language == English_E)
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIIDLH_EN.png);");
|
|
|
|
#endif
|
|
//单上肢
|
|
|
|
#ifdef ONLYUPLIMP
|
|
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
|
|
if(language == Chinese_E)
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IDL_CH.png);");
|
|
else if(language == English_E)
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IDL_EN.png);");
|
|
|
|
#endif
|
|
//单下肢
|
|
#ifdef ONLYDOWNLIMP
|
|
E_LANGUAGE language = LanguageManager::getInstance()->getCurrentLanguage();
|
|
if(language == Chinese_E)
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIDL_CH.png);");
|
|
else if(language == English_E)
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIDL_EN.png);");
|
|
|
|
#endif
|
|
}
|
|
|
|
SettingWidget::~SettingWidget()
|
|
{
|
|
if(m_buttonGroup != nullptr)
|
|
delete m_buttonGroup;
|
|
delete ui;
|
|
}
|
|
|
|
|
|
void SettingWidget::on_resetPassword_Btn_clicked()
|
|
{
|
|
QString dirPath = "./DependFile/conf/";
|
|
QDir confdir(dirPath);
|
|
if(!confdir.exists())
|
|
confdir.mkdir(dirPath);
|
|
QString confFile(dirPath + "IDconf.ini");
|
|
QSettings iniSetting(confFile, QSettings::IniFormat);
|
|
QString password("666666");
|
|
iniSetting.setValue("password",password);
|
|
iniSetting.setValue("user","xyyl");
|
|
QMessageBox::warning(NULL,tr("提示"),tr("密码重置成功"));
|
|
}
|
|
|
|
void SettingWidget::on_bioelectricity_Btn_clicked()
|
|
{
|
|
/***
|
|
QMessageBox::warning(NULL,tr("提示"),tr("未检测到脉搏血氧设备"));
|
|
return;
|
|
if(ui->bioelectricity_Btn->text() == tr("启用"))
|
|
{
|
|
ui->bioelectricity_Btn->setText(tr("断开"));
|
|
ui->bioelectricityState_Label->setText(tr("已连接"));
|
|
}
|
|
else if(ui->bioelectricity_Btn->text() == tr("断开"))
|
|
{
|
|
ui->bioelectricity_Btn->setText(tr("启用"));
|
|
ui->bioelectricityState_Label->setText(tr("未连接"));
|
|
}
|
|
***/
|
|
|
|
if(!m_mainBoXueyang)
|
|
m_mainBoXueyang = new MaiBoXueyangDialog();
|
|
|
|
m_mainBoXueyang->show();
|
|
|
|
}
|
|
|
|
|
|
void SettingWidget::on_systemSetting_Btn_clicked()
|
|
{
|
|
//系统设置界面
|
|
ui->stackedWidget->setCurrentIndex(0);
|
|
}
|
|
|
|
|
|
void SettingWidget::on_secretManage_Btn_clicked()
|
|
{
|
|
//密码管理界面
|
|
ui->stackedWidget->setCurrentIndex(1);
|
|
ui->originalPasswordTips_Label->setVisible(false);
|
|
ui->confirmPasswordTips_Label->setVisible(false);
|
|
}
|
|
|
|
|
|
void SettingWidget::on_productMsg_Btn_clicked()
|
|
{
|
|
ui->stackedWidget->setCurrentIndex(2);
|
|
}
|
|
|
|
|
|
void SettingWidget::on_cancelPassword_Btn_clicked()
|
|
{
|
|
ui->originalPassword_LineEdit->clear();
|
|
ui->newPassword_LineEdit->clear();
|
|
ui->confirmPassword_LineEdit->clear();
|
|
}
|
|
|
|
|
|
void SettingWidget::on_savePassword_Btn_clicked()
|
|
{
|
|
QString originalPassword = ui->originalPassword_LineEdit->text();
|
|
QString dirPath = "./DependFile/conf/";
|
|
QDir confdir(dirPath);
|
|
if(!confdir.exists())
|
|
confdir.mkdir(dirPath);
|
|
QString confFile(dirPath + "IDconf.ini");
|
|
QSettings iniSetting(confFile, QSettings::IniFormat);
|
|
QString password = iniSetting.value("password").toString();
|
|
if(password != originalPassword)
|
|
{
|
|
ui->originalPasswordTips_Label->setText(tr("原密码输入错误"));
|
|
ui->originalPasswordTips_Label->setVisible(true);
|
|
return;
|
|
}
|
|
|
|
if(ui->newPassword_LineEdit->text() != ui->confirmPassword_LineEdit->text())
|
|
{
|
|
ui->confirmPasswordTips_Label->setText(tr("两次输入的密码不同"));
|
|
ui->confirmPasswordTips_Label->setVisible(true);
|
|
return;
|
|
}
|
|
|
|
iniSetting.setValue("password",ui->confirmPassword_LineEdit->text());
|
|
|
|
ui->confirmPasswordTips_Label->setVisible(false);
|
|
ui->originalPasswordTips_Label->setVisible(false);
|
|
ui->confirmPassword_LineEdit->clear();
|
|
ui->newPassword_LineEdit->clear();
|
|
ui->originalPassword_LineEdit->clear();
|
|
|
|
QMessageBox::warning(NULL,tr("提示"),tr("密码更新成功"));
|
|
}
|
|
|
|
|
|
void SettingWidget::slotCheckTimerSlot()
|
|
{
|
|
if(!fesAState)
|
|
{
|
|
ui->FESConfig_Btn->setEnabled(false);
|
|
ui->FESConfig_Btn->setStyleSheet("background: #E1E1E1;border-radius: 8px;color:white;");
|
|
// ui->FESAState_Label->setText(tr("未连接"));
|
|
}
|
|
else
|
|
{
|
|
ui->FESConfig_Btn->setEnabled(true);
|
|
ui->FESConfig_Btn->setStyleSheet("background: #0D9DDB;border-radius: 8px;color:white;");
|
|
}
|
|
|
|
if(!fesBState)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
if(!bioelectricityState)
|
|
{
|
|
ui->bioelectricity_Btn->setEnabled(false);
|
|
ui->bioelectricity_Btn->setStyleSheet("background: #E1E1E1;border-radius: 8px;color:white;");
|
|
ui->bioelectricityState_Label->setText(tr("未连接"));
|
|
}
|
|
else
|
|
{
|
|
ui->bioelectricity_Btn->setEnabled(true);
|
|
ui->bioelectricity_Btn->setStyleSheet("background: #0D9DDB;border-radius: 8px;color:white;");
|
|
}
|
|
}
|
|
|
|
void SettingWidget::initWidget()
|
|
{
|
|
ui->FESConfig_Btn->setEnabled(false);
|
|
ui->bioelectricity_Btn->setEnabled(false);
|
|
}
|
|
|
|
void SettingWidget::getVersion()
|
|
{
|
|
//读取上位机版本号
|
|
//获取下位机版本号
|
|
QByteArray array(4,0);
|
|
array[0] = GET_VERSION_CMD;
|
|
CCommunicateAPI::getInstance()->sendData(array);
|
|
|
|
QTimer::singleShot(1000,this,[this](){
|
|
QString version = IceModule::getInstance()->getVersion();
|
|
ui->lowVersion_Label->setText(version);
|
|
});
|
|
}
|
|
|
|
void SettingWidget::on_reset_Btn_clicked()
|
|
{
|
|
CCommunicateAPI::getInstance()->setConfigParam();
|
|
}
|
|
|
|
void SettingWidget::on_CH_RadioButton_toggled(bool checked)
|
|
{
|
|
if(checked)
|
|
{
|
|
LanguageManager::getInstance()->setCurrentLanguage(Chinese_E);
|
|
//单独设置按钮大小
|
|
QFont font ;
|
|
font.setPointSize(15);
|
|
font.setBold(true);
|
|
ui->productMsg_Btn->setFont(font);
|
|
|
|
ui->productMsg_Btn->resize(230,60);
|
|
|
|
#ifdef NORMALEXE
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIIDL_CH.png);");
|
|
#endif
|
|
#ifdef UpLowLimpNormal
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIIDLH_CH.png);");
|
|
#endif
|
|
//单上肢
|
|
|
|
#ifdef ONLYUPLIMP
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IDL_CH.png);");
|
|
#endif
|
|
//单下肢
|
|
#ifdef ONLYDOWNLIMP
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIDL_CH.png);");
|
|
#endif
|
|
}
|
|
}
|
|
|
|
void SettingWidget::on_EN_RadioButton_toggled(bool checked)
|
|
{
|
|
if(checked)
|
|
{
|
|
LanguageManager::getInstance()->setCurrentLanguage(English_E);
|
|
//单独设置按钮大小
|
|
QFont font ;
|
|
font.setPointSize(13);
|
|
font.setBold(true);
|
|
ui->productMsg_Btn->setFont(font);
|
|
|
|
ui->productMsg_Btn->resize(265,60);
|
|
#ifdef NORMALEXE
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIIDL_EN.png);");
|
|
#endif
|
|
#ifdef UpLowLimpNormal
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIIDLH_EN.png);");
|
|
#endif
|
|
|
|
#ifdef ONLYUPLIMP
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IDL_EN.png);");
|
|
#endif
|
|
//单下肢
|
|
#ifdef ONLYDOWNLIMP
|
|
ui->label_9->setStyleSheet("border-image: url(:/DependFile/Source/channel/IIDL_EN.png);");
|
|
#endif
|
|
}
|
|
}
|
|
|
|
void SettingWidget::changeEvent(QEvent* event)
|
|
{
|
|
switch (event->type())
|
|
{
|
|
case QEvent::LanguageChange:
|
|
ui->retranslateUi(this);
|
|
break;
|
|
default:
|
|
QWidget::changeEvent(event);
|
|
break;
|
|
}
|
|
}
|
|
|
|
void SettingWidget::showEvent(QShowEvent *event)
|
|
{
|
|
Q_UNUSED(event)
|
|
getVersion();
|
|
}
|
|
|
|
void SettingWidget::on_Up_Btn_clicked()
|
|
{
|
|
if(!IceModule::getInstance()->getEmergencyState())
|
|
CCommunicateAPI::getInstance()->sendRealTimeParam(TUIGAN_UPDOWN,1);
|
|
}
|
|
|
|
|
|
void SettingWidget::on_down_Btn_clicked()
|
|
{
|
|
if(!IceModule::getInstance()->getEmergencyState())
|
|
CCommunicateAPI::getInstance()->sendRealTimeParam(TUIGAN_UPDOWN,2);
|
|
}
|
|
|
|
void SettingWidget::on_torque_Radio_clicked()
|
|
{
|
|
TorqueDialog torqueDialog;
|
|
torqueDialog.setWindowModality(Qt::WindowModal);
|
|
torqueDialog.exec();
|
|
bool isConfirmed = torqueDialog.getConfirmState();
|
|
|
|
if(!isConfirmed)
|
|
{
|
|
switch(m_powerLevel)
|
|
{
|
|
case 0:
|
|
ui->torque_Low->setChecked(true);
|
|
break;
|
|
case 1:
|
|
ui->torque_Middle->setChecked(true);
|
|
break;
|
|
case 2:
|
|
ui->torque_Hign->setChecked(true);
|
|
break;
|
|
}
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if(QObject::sender()->objectName() == "torque_Low")
|
|
{
|
|
m_powerLevel = 0;
|
|
}
|
|
else if(QObject::sender()->objectName() == "torque_Middle")
|
|
{
|
|
m_powerLevel = 1;
|
|
}
|
|
else if(QObject::sender()->objectName() == "torque_Hign")
|
|
{
|
|
m_powerLevel = 2;
|
|
}
|
|
IceModule::getInstance()->setPower(m_powerLevel);
|
|
switch(m_powerLevel)
|
|
{
|
|
case 0:
|
|
ui->torque_Low->setChecked(true);
|
|
break;
|
|
case 1:
|
|
ui->torque_Middle->setChecked(true);
|
|
break;
|
|
case 2:
|
|
ui->torque_Hign->setChecked(true);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//配置电刺激盒
|
|
void SettingWidget::on_FESConfig_Btn_clicked()
|
|
{
|
|
FesControlDialog::getInstance()->show();
|
|
}
|
|
|
|
|
|
void SettingWidget::on_OpenFES_Btn_clicked()
|
|
{
|
|
if(ui->OpenFES_Btn->text() == tr("启用"))
|
|
{
|
|
if(FesControlDialog::getInstance()->openFESDevice())
|
|
{
|
|
ui->OpenFES_Btn->setText("已启用");
|
|
}
|
|
}
|
|
else if(ui->OpenFES_Btn->text() == tr("已启用"))
|
|
{
|
|
//关闭设备
|
|
ui->OpenFES_Btn->setText(tr("启用"));
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|