Compare commits

..

No commits in common. "46831412fd7ff200f07670418b9fd72dae12b888" and "56ece09e5b576e40b46b32793175a03029ab0076" have entirely different histories.

6 changed files with 26 additions and 181 deletions

View File

@ -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,19 +18,7 @@ AutoStart::AutoStart(bool hmiAuto, bool sysAuto, QWidget *parent) :
{ {
ui->hmiCheckBox->setEnabled(false); ui->hmiCheckBox->setEnabled(false);
} }
QButtonGroup *buttonGroup = new QButtonGroup(this); setWindowTitle(tr("自启动设置"));
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()
@ -53,10 +41,6 @@ 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);

View File

@ -17,7 +17,6 @@ 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;

View File

@ -7,26 +7,26 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>234</width> <width>234</width>
<height>217</height> <height>166</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>234</width> <width>234</width>
<height>217</height> <height>166</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>234</width> <width>234</width>
<height>217</height> <height>166</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 resource="resource.qrc"> <iconset>
<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,74 +54,7 @@
</item> </item>
</layout> </layout>
</item> </item>
</layout>
</widget>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>系统语言</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBox">
<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>
<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>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="layoutDirection"> <property name="layoutDirection">
<enum>Qt::LeftToRight</enum> <enum>Qt::LeftToRight</enum>
@ -139,9 +72,10 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> </item>
<include location="resource.qrc"/> </layout>
</resources> </widget>
<resources/>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>

View File

@ -19,8 +19,7 @@
#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):
@ -29,7 +28,6 @@ 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);
} }
@ -230,61 +228,6 @@ 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;

View File

@ -130,21 +130,6 @@
<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"/>
@ -163,8 +148,8 @@
</message> </message>
<message> <message>
<location filename="AutoStart.cpp" line="35"/> <location filename="AutoStart.cpp" line="35"/>
<source></source> <source></source>
<translation >System setting</translation> <translation >Auto start setting</translation>
</message> </message>
</context> </context>
<context> <context>