commit before modify

This commit is contained in:
xueyan hu
2021-12-13 17:01:17 +08:00
parent e3ffa9bd88
commit faa69197f3
10 changed files with 65 additions and 18 deletions

View File

@@ -11,9 +11,10 @@
#include <QToolButton>
#include "json/jsonobject.h"
#include "SelectDialog.h"
#include "components/ImageSwitch.h"
#include "components/imageswitch.h"
#include "components/ipaddress.h"
#include <QProcess>
systemSettingForm::systemSettingForm(QWidget* parent) : QWidget(parent)
{
@@ -399,6 +400,13 @@ systemSettingForm::systemSettingForm(QWidget* parent) : QWidget(parent)
loadServersInfo();
//connection
connect(swt_verify, &ImageSwitch::clicked, [=]() {
if(swt_verify->getChecked())
{
autoDHCP();
}
});
connect(btnCancel, &QToolButton::clicked, [=]() {
loadServersInfo();
});
@@ -471,7 +479,32 @@ void systemSettingForm::loadServersInfo()
local_Mask->setIP(lhost.mask);
local_Gate->setIP(lhost.gateway);
qIfConfig(lhost);
}
void systemSettingForm::qIfConfig(const localhost &lhost)
{
QProcess *myProcess = new QProcess;
//QString cmd = QString("echo %1 | sudo -S ifconfig eth0 %2 up").;
QString cmd = QString("echo %1 | sudo -S ifconfig eth0 %2 netmask %3 up; sudo -S route del default dev eth0; \
sudo -S route add default gw %4").arg("klxts4047").arg(lhost.ip).arg(lhost.mask).arg(lhost.gateway);
QStringList args;
args<<"-c"<<cmd;
myProcess->start("/bin/sh",args);
}
void systemSettingForm::autoDHCP()
{
QProcess *myProcess = new QProcess;
//QString cmd = QString("echo %1 | sudo -S cp cfgs/ifcfg-eth0 /etc/sysconfig/network/ifcfg-eth0; sudo -S rcnetwork restart eth0").arg("klxts4047");
//we propose that the default config is DHCP
QString cmd = QString("echo %1 | sudo -S rcnetwork restart eth0").arg("klxts4047");
QStringList args;
args<<"-c"<<cmd;
myProcess->start("/bin/sh",args);
}
void systemSettingForm::saveServersInfo()
{
@@ -508,4 +541,6 @@ void systemSettingForm::saveServersInfo()
lhost.gateway = local_Gate->getIP();
JsonObject::Instance()->setLocalHost(lhost);
}
qIfConfig(lhost);
}