Merge branch 'master' of http://47.103.159.168:10012/GZHM/HM-SPMS
This commit is contained in:
commit
82e405212a
@ -1,6 +1,6 @@
|
|||||||
#include "AutoStart.h"
|
#include "AutoStart.h"
|
||||||
#include "ui_AutoStart.h"
|
#include "ui_AutoStart.h"
|
||||||
|
#include "pub_utility_api/I18N.h"
|
||||||
AutoStart::AutoStart(bool hmiAuto, bool sysAuto, QWidget *parent) :
|
AutoStart::AutoStart(bool hmiAuto, bool sysAuto, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::AutoStart)
|
ui(new Ui::AutoStart)
|
||||||
@ -18,7 +18,19 @@ AutoStart::AutoStart(bool hmiAuto, bool sysAuto, QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->hmiCheckBox->setEnabled(false);
|
ui->hmiCheckBox->setEnabled(false);
|
||||||
}
|
}
|
||||||
setWindowTitle(tr("自启动设置"));
|
QButtonGroup *buttonGroup = new QButtonGroup(this);
|
||||||
|
buttonGroup->setExclusive(true); // 设置为互斥模式
|
||||||
|
|
||||||
|
// 将复选框添加到按钮组
|
||||||
|
buttonGroup->addButton(ui->checkBox);
|
||||||
|
buttonGroup->addButton(ui->checkBox_2);
|
||||||
|
const std::string strLanguage = std::move( iot_public::getCurLanguage());
|
||||||
|
if(strLanguage =="zh")
|
||||||
|
{
|
||||||
|
ui->checkBox->setChecked(true);
|
||||||
|
}else
|
||||||
|
ui->checkBox_2->setChecked(true);
|
||||||
|
setWindowTitle(tr("系统设置"));
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoStart::~AutoStart()
|
AutoStart::~AutoStart()
|
||||||
@ -41,6 +53,10 @@ bool AutoStart::isSysAutoStart()
|
|||||||
return ui->sysCheckBox->isChecked();
|
return ui->sysCheckBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AutoStart::isZh()
|
||||||
|
{
|
||||||
|
return ui->checkBox->isChecked();
|
||||||
|
}
|
||||||
void AutoStart::showEvent(QShowEvent *)
|
void AutoStart::showEvent(QShowEvent *)
|
||||||
{
|
{
|
||||||
ui->sysCheckBox->setChecked(m_sysAuto);
|
ui->sysCheckBox->setChecked(m_sysAuto);
|
||||||
|
|||||||
@ -17,6 +17,7 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
bool isHmiAutoStart();
|
bool isHmiAutoStart();
|
||||||
bool isSysAutoStart();
|
bool isSysAutoStart();
|
||||||
|
bool isZh();
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *) override;
|
void showEvent(QShowEvent *) override;
|
||||||
|
|
||||||
|
|||||||
@ -7,26 +7,26 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>234</width>
|
<width>234</width>
|
||||||
<height>166</height>
|
<height>217</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>234</width>
|
<width>234</width>
|
||||||
<height>166</height>
|
<height>217</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>234</width>
|
<width>234</width>
|
||||||
<height>166</height>
|
<height>217</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset>
|
<iconset resource="resource.qrc">
|
||||||
<normaloff>:/auto_start.ico</normaloff>:/auto_start.ico</iconset>
|
<normaloff>:/auto_start.ico</normaloff>:/auto_start.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
@ -54,28 +54,94 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
</layout>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
</widget>
|
||||||
<property name="layoutDirection">
|
</item>
|
||||||
<enum>Qt::LeftToRight</enum>
|
<item row="1" column="0">
|
||||||
</property>
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<property name="orientation">
|
<property name="title">
|
||||||
<enum>Qt::Horizontal</enum>
|
<string>系统语言</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<item row="0" column="0">
|
||||||
</property>
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="centerButtons">
|
<item>
|
||||||
<bool>true</bool>
|
<widget class="QCheckBox" name="checkBox">
|
||||||
</property>
|
<property name="minimumSize">
|
||||||
</widget>
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>中文</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBox_2">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>英文</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="layoutDirection">
|
||||||
|
<enum>Qt::LeftToRight</enum>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
<property name="centerButtons">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="resource.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
|
|||||||
@ -19,7 +19,8 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include "pub_utility_api/FileUtil.h"
|
#include "pub_utility_api/FileUtil.h"
|
||||||
#include "../include/sys/sys_login_api/CLoginDlg.h"
|
#include "../include/sys/sys_login_api/CLoginDlg.h"
|
||||||
|
#include <QDomDocument>
|
||||||
|
#include <QFile>
|
||||||
using namespace sys_startup;
|
using namespace sys_startup;
|
||||||
|
|
||||||
ButtonForm::ButtonForm(int mode,bool isZh, QWidget *parent):
|
ButtonForm::ButtonForm(int mode,bool isZh, QWidget *parent):
|
||||||
@ -28,6 +29,7 @@ ButtonForm::ButtonForm(int mode,bool isZh, QWidget *parent):
|
|||||||
m_mode(mode),
|
m_mode(mode),
|
||||||
m_bIsZh(isZh)
|
m_bIsZh(isZh)
|
||||||
{
|
{
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ void ButtonForm::addToolButtons(QVector<QString> &buttonVec)
|
|||||||
//toolBtn->setIcon(icon);
|
//toolBtn->setIcon(icon);
|
||||||
toolBtn->setText(m_bIsZh?buttonInfo.m_zh:buttonInfo.m_en);
|
toolBtn->setText(m_bIsZh?buttonInfo.m_zh:buttonInfo.m_en);
|
||||||
#ifdef Q_PROCESSOR_ARM_64
|
#ifdef Q_PROCESSOR_ARM_64
|
||||||
toolBtn->setEnabled(buttonInfo.m_enable);
|
toolBtn->setEnabled(buttonInfo.m_enable);
|
||||||
#endif
|
#endif
|
||||||
connect(toolBtn,&QToolButton::clicked,[=](){
|
connect(toolBtn,&QToolButton::clicked,[=](){
|
||||||
executeTask(buttonInfo.m_cmd,buttonInfo.m_param);
|
executeTask(buttonInfo.m_cmd,buttonInfo.m_param);
|
||||||
@ -228,6 +230,61 @@ void ButtonForm::autoStartDlg()
|
|||||||
{
|
{
|
||||||
setHmiAuto(!isHmi,text);
|
setHmiAuto(!isHmi,text);
|
||||||
}
|
}
|
||||||
|
QString language ="en";
|
||||||
|
if(dlg->isZh())
|
||||||
|
{
|
||||||
|
language ="zh";
|
||||||
|
}
|
||||||
|
const std::string strCurDir = iot_public::CFileUtil::getCurModuleDir();
|
||||||
|
|
||||||
|
std::string objFullPath = strCurDir;
|
||||||
|
objFullPath = objFullPath+"/../../" + "platform" + "/common/sysconfig/language.xml";
|
||||||
|
|
||||||
|
qDebug()<<QString::fromStdString(objFullPath);
|
||||||
|
QFile file(QString::fromStdString(objFullPath));
|
||||||
|
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
|
||||||
|
qWarning() << "Cannot open config file";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomDocument doc;
|
||||||
|
if (!doc.setContent(&file)) {
|
||||||
|
qWarning() << "Cannot parse XML file";
|
||||||
|
file.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
QDomElement root = doc.documentElement();
|
||||||
|
// 查找 module 元素
|
||||||
|
QDomNodeList moduleList = root.elementsByTagName("module");
|
||||||
|
for (int i = 0; i < moduleList.size(); ++i) {
|
||||||
|
QDomElement moduleElem = moduleList.at(i).toElement();
|
||||||
|
if (moduleElem.isNull()) continue;
|
||||||
|
|
||||||
|
// 检查 module 的 name 属性
|
||||||
|
if (moduleElem.attribute("name") == "language") {
|
||||||
|
// 查找 param 元素
|
||||||
|
QDomNodeList paramList = moduleElem.elementsByTagName("param");
|
||||||
|
for (int j = 0; j < paramList.size(); ++j) {
|
||||||
|
QDomElement paramElem = paramList.at(j).toElement();
|
||||||
|
if (paramElem.isNull()) continue;
|
||||||
|
|
||||||
|
// 检查 param 的 key 属性
|
||||||
|
if (paramElem.attribute("key") == "language") {
|
||||||
|
// 修改 value 属性
|
||||||
|
paramElem.setAttribute("value", language);
|
||||||
|
|
||||||
|
// 保存修改
|
||||||
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
stream.setCodec("UTF-8");
|
||||||
|
doc.save(stream, 4); // 缩进4个空格
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
emit sigLogText(text);
|
emit sigLogText(text);
|
||||||
}
|
}
|
||||||
delete dlg;
|
delete dlg;
|
||||||
|
|||||||
Binary file not shown.
@ -130,6 +130,21 @@
|
|||||||
<location filename="AutoStart.ui" line="39"/>
|
<location filename="AutoStart.ui" line="39"/>
|
||||||
<source>HMI 开机自启动</source>
|
<source>HMI 开机自启动</source>
|
||||||
<translation >HMI auto start</translation>
|
<translation >HMI auto start</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="AutoStart.ui" line="24"/>
|
||||||
|
<source>系统语言</source>
|
||||||
|
<translation >System language</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="AutoStart.ui" line="32"/>
|
||||||
|
<source>中文</source>
|
||||||
|
<translation >Chinese</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="AutoStart.ui" line="39"/>
|
||||||
|
<source>英文</source>
|
||||||
|
<translation >English</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="AutoStart.ui" line="57"/>
|
<location filename="AutoStart.ui" line="57"/>
|
||||||
@ -148,8 +163,8 @@
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="AutoStart.cpp" line="35"/>
|
<location filename="AutoStart.cpp" line="35"/>
|
||||||
<source>自启动设置</source>
|
<source>系统设置</source>
|
||||||
<translation >Auto start setting</translation>
|
<translation >System setting</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user