diff --git a/CMakeLists.txt b/CMakeLists.txt index 577c597..471c13b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/AdminSettingForm.h b/src/AdminSettingForm.h index c0da07b..ccca0b0 100644 --- a/src/AdminSettingForm.h +++ b/src/AdminSettingForm.h @@ -5,7 +5,7 @@ #ifndef GUI_ADMINSETTINGFORM_H #define GUI_ADMINSETTINGFORM_H -#include "TabFormWidget.h" +#include "tabformwidget.h" class AdminSettingForm:public TabFormWidget { Q_OBJECT diff --git a/src/SelectFormWidget.cpp b/src/SelectFormWidget.cpp index c9f1bfa..b163804 100644 --- a/src/SelectFormWidget.cpp +++ b/src/SelectFormWidget.cpp @@ -15,7 +15,7 @@ #include "guimacros.h" #include "event/EventCenter.h" #include "AccountFormDialog.h" -#include +#include #include "log/UserOperationLog.h" #define ADD_CENTER_ITEM(row,col,text)\ @@ -252,4 +252,4 @@ SelectFormWidget::SelectFormWidget(QWidget *parent) : SelectFormWidget::~SelectFormWidget() { -} \ No newline at end of file +} diff --git a/src/components/imageswitch.cpp b/src/components/imageswitch.cpp index 09bb357..2241351 100644 --- a/src/components/imageswitch.cpp +++ b/src/components/imageswitch.cpp @@ -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*) diff --git a/src/components/imageswitch.h b/src/components/imageswitch.h index 385641d..f1f09d2 100644 --- a/src/components/imageswitch.h +++ b/src/components/imageswitch.h @@ -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); diff --git a/src/json/jsonobject.cpp b/src/json/jsonobject.cpp index 3c949c4..277948b 100644 --- a/src/json/jsonobject.cpp +++ b/src/json/jsonobject.cpp @@ -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(); -} \ No newline at end of file +} diff --git a/src/json/jsonobject.h b/src/json/jsonobject.h index 2194258..d04e1aa 100644 --- a/src/json/jsonobject.h +++ b/src/json/jsonobject.h @@ -2,7 +2,7 @@ #define JSONOBJECT_H //#include - +#include class QStringList; class QTranslator; diff --git a/src/log/LogFileTableModel.cpp b/src/log/LogFileTableModel.cpp index 8c3e6f7..0a81e19 100644 --- a/src/log/LogFileTableModel.cpp +++ b/src/log/LogFileTableModel.cpp @@ -5,7 +5,7 @@ #include #include #include "LogFileTableModel.h" -#include +#include LogFileTableModel::LogFileTableModel(QObject *parent) : QAbstractTableModel(parent) { diff --git a/src/systemsettingform.cpp b/src/systemsettingform.cpp index e2d0afb..257f165 100644 --- a/src/systemsettingform.cpp +++ b/src/systemsettingform.cpp @@ -11,9 +11,10 @@ #include #include "json/jsonobject.h" #include "SelectDialog.h" -#include "components/ImageSwitch.h" +#include "components/imageswitch.h" #include "components/ipaddress.h" +#include 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"<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"<start("/bin/sh",args); +} + void systemSettingForm::saveServersInfo() { @@ -508,4 +541,6 @@ void systemSettingForm::saveServersInfo() lhost.gateway = local_Gate->getIP(); JsonObject::Instance()->setLocalHost(lhost); -} \ No newline at end of file + qIfConfig(lhost); + +} diff --git a/src/systemsettingform.h b/src/systemsettingform.h index 37ab54c..2d8eadf 100644 --- a/src/systemsettingform.h +++ b/src/systemsettingform.h @@ -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 \ No newline at end of file +#endif // SYSTEMSETTINGFORM_H