Compare commits
2 Commits
56ece09e5b
...
46831412fd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46831412fd | ||
|
|
147b45e94f |
@ -1,6 +1,6 @@
|
||||
#include "AutoStart.h"
|
||||
#include "ui_AutoStart.h"
|
||||
|
||||
#include "pub_utility_api/I18N.h"
|
||||
AutoStart::AutoStart(bool hmiAuto, bool sysAuto, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AutoStart)
|
||||
@ -18,7 +18,19 @@ AutoStart::AutoStart(bool hmiAuto, bool sysAuto, QWidget *parent) :
|
||||
{
|
||||
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()
|
||||
@ -41,6 +53,10 @@ bool AutoStart::isSysAutoStart()
|
||||
return ui->sysCheckBox->isChecked();
|
||||
}
|
||||
|
||||
bool AutoStart::isZh()
|
||||
{
|
||||
return ui->checkBox->isChecked();
|
||||
}
|
||||
void AutoStart::showEvent(QShowEvent *)
|
||||
{
|
||||
ui->sysCheckBox->setChecked(m_sysAuto);
|
||||
|
||||
@ -17,6 +17,7 @@ public:
|
||||
void init();
|
||||
bool isHmiAutoStart();
|
||||
bool isSysAutoStart();
|
||||
bool isZh();
|
||||
protected:
|
||||
void showEvent(QShowEvent *) override;
|
||||
|
||||
|
||||
@ -7,26 +7,26 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>234</width>
|
||||
<height>166</height>
|
||||
<height>217</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>234</width>
|
||||
<height>166</height>
|
||||
<height>217</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>234</width>
|
||||
<height>166</height>
|
||||
<height>217</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<iconset resource="resource.qrc">
|
||||
<normaloff>:/auto_start.ico</normaloff>:/auto_start.ico</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
@ -54,28 +54,94 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" 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>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<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">
|
||||
<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>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="resource.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
|
||||
@ -19,7 +19,8 @@
|
||||
#include <QString>
|
||||
#include "pub_utility_api/FileUtil.h"
|
||||
#include "../include/sys/sys_login_api/CLoginDlg.h"
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QFile>
|
||||
using namespace sys_startup;
|
||||
|
||||
ButtonForm::ButtonForm(int mode,bool isZh, QWidget *parent):
|
||||
@ -28,6 +29,7 @@ ButtonForm::ButtonForm(int mode,bool isZh, QWidget *parent):
|
||||
m_mode(mode),
|
||||
m_bIsZh(isZh)
|
||||
{
|
||||
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
@ -74,7 +76,7 @@ void ButtonForm::addToolButtons(QVector<QString> &buttonVec)
|
||||
//toolBtn->setIcon(icon);
|
||||
toolBtn->setText(m_bIsZh?buttonInfo.m_zh:buttonInfo.m_en);
|
||||
#ifdef Q_PROCESSOR_ARM_64
|
||||
toolBtn->setEnabled(buttonInfo.m_enable);
|
||||
toolBtn->setEnabled(buttonInfo.m_enable);
|
||||
#endif
|
||||
connect(toolBtn,&QToolButton::clicked,[=](){
|
||||
executeTask(buttonInfo.m_cmd,buttonInfo.m_param);
|
||||
@ -228,6 +230,61 @@ void ButtonForm::autoStartDlg()
|
||||
{
|
||||
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);
|
||||
}
|
||||
delete dlg;
|
||||
|
||||
Binary file not shown.
@ -130,6 +130,21 @@
|
||||
<location filename="AutoStart.ui" line="39"/>
|
||||
<source>HMI 开机自启动</source>
|
||||
<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>
|
||||
<location filename="AutoStart.ui" line="57"/>
|
||||
@ -148,8 +163,8 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="AutoStart.cpp" line="35"/>
|
||||
<source>自启动设置</source>
|
||||
<translation >Auto start setting</translation>
|
||||
<source>系统设置</source>
|
||||
<translation >System setting</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user