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

@@ -28,7 +28,7 @@ source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_cxx})
source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_cc})
source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${project_c})
find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL Sql VirtualKeyboard REQUIRED)
find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL Sql VirtualKeyboard Network REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
file(GLOB project_uis ./src/*.ui)
@@ -40,9 +40,9 @@ file(GLOB project_res ./src/*.qrc)
add_executable(${PROJECT_NAME} ${project_headers} ${project_cpps} ${project_cxx} ${project_res} ${project_cc} ${project_c} ${ui_FILES} )
if(UNIX AND USE_SHIMLIB)
link_directories(/usr/local/lib64)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard pthread usct_shim dmapi log4c cunit ctomat hdf5 matio m)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard Qt5::Network pthread usct_shim dmapi log4c cunit ctomat hdf5 matio m)
else()
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard Qt5::Network)
endif()
if(MSVC)

View File

@@ -5,7 +5,7 @@
#ifndef GUI_ADMINSETTINGFORM_H
#define GUI_ADMINSETTINGFORM_H
#include "TabFormWidget.h"
#include "tabformwidget.h"
class AdminSettingForm:public TabFormWidget {
Q_OBJECT

View File

@@ -15,7 +15,7 @@
#include "guimacros.h"
#include "event/EventCenter.h"
#include "AccountFormDialog.h"
#include <qDebug>
#include <QDebug>
#include "log/UserOperationLog.h"
#define ADD_CENTER_ITEM(row,col,text)\
@@ -252,4 +252,4 @@ SelectFormWidget::SelectFormWidget(QWidget *parent) :
SelectFormWidget::~SelectFormWidget()
{
}
}

View File

@@ -1,4 +1,4 @@
#pragma execution_character_set("utf-8")
#pragma execution_character_set("utf-8")
#include "imageswitch.h"
#include "qpainter.h"
@@ -19,6 +19,7 @@ void ImageSwitch::mousePressEvent(QMouseEvent*)
imgFile = isChecked ? imgOffFile : imgOnFile;
isChecked = !isChecked;
this->update();
emit clicked();
}
void ImageSwitch::paintEvent(QPaintEvent*)

View File

@@ -1,4 +1,4 @@
#ifndef IMAGESWITCH_H
#ifndef IMAGESWITCH_H
#define IMAGESWITCH_H
/**
@@ -48,7 +48,8 @@ public:
ButtonStyle getButtonStyle() const;
QSize sizeHint() const;
QSize minimumSizeHint() const;
signals:
void clicked();
public Q_SLOTS:
//设置是否选中
void setChecked(bool isChecked);

View File

@@ -291,11 +291,20 @@ void JsonObject::setServer(ServerType type, const host& list)
localhost JsonObject::getLocalHost()
{
localhost lhost;
//lhost.ip = IPConfig::getDeviceIP();
lhost.ip = QString(getJsonString("localhost", "ip"));
lhost.mask = QString(getJsonString("localhost", "mask"));
lhost.gateway = QString(getJsonString("localhost", "gateway"));
return lhost;
// localhost lhost;
// lhost.ip = QString(getJsonString("localhost", "ip"));
// lhost.mask = QString(getJsonString("localhost", "mask"));
// lhost.gateway = QString(getJsonString("localhost", "gateway"));
// return lhost;
}
@@ -306,4 +315,4 @@ void JsonObject::setLocalHost(const localhost& lh)
setJsonString("localhost", "gateway", lh.gateway.toStdString().c_str(), false);
savecfg();
}
}

View File

@@ -2,7 +2,7 @@
#define JSONOBJECT_H
//#include <QObject>
#include <QString>
class QStringList;
class QTranslator;

View File

@@ -5,7 +5,7 @@
#include <QtCore/QFile>
#include <QtCore/QTextStream>
#include "LogFileTableModel.h"
#include <qDebug>
#include <QDebug>
LogFileTableModel::LogFileTableModel(QObject *parent) : QAbstractTableModel(parent) {

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);
}

View File

@@ -8,7 +8,7 @@ class SelectDialog;
class QLineEdit;
class ImageSwitch;
class IPAddress;
class localhost;
class systemSettingForm : public QWidget
{
Q_OBJECT
@@ -25,8 +25,9 @@ private:
SelectDialog* sd_filter = nullptr;
void loadServersInfo();
void saveServersInfo();
void saveServersInfo();
void qIfConfig(const localhost &lhost);
void autoDHCP();
QLineEdit* pacs_Name;
QLineEdit* recon_IP;
QLineEdit* daq_AE;
@@ -52,4 +53,4 @@ private:
ImageSwitch* swt_verify;
};
#endif // SYSTEMSETTINGFORM_H
#endif // SYSTEMSETTINGFORM_H