Files
GUI/src/systemsettingform.cpp

527 lines
15 KiB
C++
Raw Normal View History

2021-12-07 14:13:55 +08:00
#include "systemsettingform.h"
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QDebug>
#include <QLabel>
#include <QLineEdit>
#include <QEvent>
2021-12-09 10:00:01 +08:00
#include <QToolButton>
2021-12-07 14:13:55 +08:00
#include "json/jsonobject.h"
#include "SelectDialog.h"
2021-12-13 17:01:17 +08:00
#include "components/imageswitch.h"
2021-12-09 10:00:01 +08:00
#include "components/ipaddress.h"
#include "network/networkcfgdialog.h"
2021-12-07 14:13:55 +08:00
systemSettingForm::systemSettingForm(QWidget* parent) : QWidget(parent)
{
2021-12-09 10:00:01 +08:00
QVBoxLayout* verticalLayout;
QWidget* block1;
QHBoxLayout* horizontalLayout;
QWidget* block10;
QGridLayout* gridLayout_2;
QSpacerItem* horizontalSpacer_7;
QLabel* lbl_verify;
QSpacerItem* horizontalSpacer_8;
QPushButton* btnFlt;
QPushButton* btnPro;
QSpacerItem* horizontalSpacer_2;
QLabel* lbl_filter;
QLabel* lbl_protocal;
ImageSwitch* swt_verify;
QSpacerItem* verticalSpacer_2;
QLabel* label_2;
QSpacerItem* horizontalSpacer_6;
QFrame* line;
QWidget* block2;
QGridLayout* gridLayout;
QLabel* lbl_local_gate;
QLabel* lbl_Recon;
QLabel* lbl_local_mask;
//IPAddress* local_Mask;
QLabel* lbl_Name;
QLabel* lbl_PACS;
//IPAddress* local_IP;
QLabel* lbl_list;
QLabel* lbl_AE;
QLabel* lbl_local_IP;
QLabel* lbl_IP;
QLabel* lbl_Local;
QLabel* label;
QLabel* lbl_Port;
QLabel* lbl_DAQ;
//IPAddress* local_Gate;
QWidget* widget;
QHBoxLayout* horizontalLayout_2;
QSpacerItem* horizontalSpacer;
QToolButton* btnCancel;
QToolButton* btnAccept;
QSpacerItem* verticalSpacer;
QWidget* centralWidget = this;
verticalLayout = new QVBoxLayout(centralWidget);
verticalLayout->setSpacing(6);
verticalLayout->setContentsMargins(11, 11, 11, 11);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
block1 = new QWidget(centralWidget);
block1->setObjectName(QString::fromUtf8("block1"));
horizontalLayout = new QHBoxLayout(block1);
horizontalLayout->setSpacing(6);
horizontalLayout->setContentsMargins(11, 11, 11, 11);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
block10 = new QWidget(block1);
block10->setObjectName(QString::fromUtf8("block10"));
gridLayout_2 = new QGridLayout(block10);
gridLayout_2->setSpacing(6);
gridLayout_2->setContentsMargins(11, 11, 11, 11);
gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
horizontalSpacer_7 = new QSpacerItem(40, 20, QSizePolicy::Fixed, QSizePolicy::Minimum);
gridLayout_2->addItem(horizontalSpacer_7, 0, 1, 1, 1);
lbl_verify = new QLabel(block10);
lbl_verify->setObjectName(QString::fromUtf8("lbl_verify"));
lbl_verify->setMinimumSize(QSize(100, 0));
gridLayout_2->addWidget(lbl_verify, 3, 0, 1, 1);
horizontalSpacer_8 = new QSpacerItem(40, 20, QSizePolicy::Fixed, QSizePolicy::Minimum);
gridLayout_2->addItem(horizontalSpacer_8, 1, 1, 1, 1);
btnFlt = new QPushButton(block10);
btnFlt->setObjectName(QString::fromUtf8("btnFlt"));
btnFlt->setMinimumSize(QSize(100, 0));
gridLayout_2->addWidget(btnFlt, 1, 2, 1, 1);
btnPro = new QPushButton(block10);
btnPro->setObjectName(QString::fromUtf8("btnPro"));
btnPro->setMinimumSize(QSize(100, 0));
gridLayout_2->addWidget(btnPro, 0, 2, 1, 1);
horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Fixed, QSizePolicy::Minimum);
gridLayout_2->addItem(horizontalSpacer_2, 3, 1, 1, 1);
lbl_filter = new QLabel(block10);
lbl_filter->setObjectName(QString::fromUtf8("lbl_filter"));
gridLayout_2->addWidget(lbl_filter, 1, 0, 1, 1);
lbl_protocal = new QLabel(block10);
lbl_protocal->setObjectName(QString::fromUtf8("lbl_protocal"));
gridLayout_2->addWidget(lbl_protocal, 0, 0, 1, 1);
swt_verify = new ImageSwitch(block10);
swt_verify->setObjectName(QString::fromUtf8("swt_verify"));
gridLayout_2->addWidget(swt_verify, 3, 2, 1, 1);
verticalSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
gridLayout_2->addItem(verticalSpacer_2, 2, 2, 1, 1);
label_2 = new QLabel(block10);
label_2->setObjectName(QString::fromUtf8("label_2"));
gridLayout_2->addWidget(label_2, 2, 0, 1, 1);
horizontalLayout->addWidget(block10);
horizontalSpacer_6 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout->addItem(horizontalSpacer_6);
verticalLayout->addWidget(block1);
line = new QFrame(centralWidget);
line->setObjectName(QString::fromUtf8("line"));
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
verticalLayout->addWidget(line);
block2 = new QWidget(centralWidget);
block2->setObjectName(QString::fromUtf8("block2"));
gridLayout = new QGridLayout(block2);
gridLayout->setSpacing(6);
gridLayout->setContentsMargins(11, 11, 11, 11);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
gridLayout->setHorizontalSpacing(25);
gridLayout->setVerticalSpacing(10);
wl_Port = new QLineEdit(block2);
wl_Port->setObjectName(QString::fromUtf8("wl_Port"));
gridLayout->addWidget(wl_Port, 2, 4, 1, 1);
daq_AE = new QLineEdit(block2);
daq_AE->setObjectName(QString::fromUtf8("daq_AE"));
gridLayout->addWidget(daq_AE, 4, 2, 1, 1);
lbl_local_gate = new QLabel(block2);
lbl_local_gate->setObjectName(QString::fromUtf8("lbl_local_gate"));
gridLayout->addWidget(lbl_local_gate, 7, 3, 1, 1);
lbl_Recon = new QLabel(block2);
lbl_Recon->setObjectName(QString::fromUtf8("lbl_Recon"));
gridLayout->addWidget(lbl_Recon, 5, 0, 1, 1);
daq_Port = new QLineEdit(block2);
daq_Port->setObjectName(QString::fromUtf8("daq_Port"));
gridLayout->addWidget(daq_Port, 4, 4, 1, 1);
recon_Port = new QLineEdit(block2);
recon_Port->setObjectName(QString::fromUtf8("recon_Port"));
gridLayout->addWidget(recon_Port, 5, 4, 1, 1);
lbl_local_mask = new QLabel(block2);
lbl_local_mask->setObjectName(QString::fromUtf8("lbl_local_mask"));
gridLayout->addWidget(lbl_local_mask, 7, 2, 1, 1);
local_Mask = new IPAddress(block2);
local_Mask->setObjectName(QString::fromUtf8("local_Mask"));
gridLayout->addWidget(local_Mask, 8, 2, 1, 1);
lbl_Name = new QLabel(block2);
lbl_Name->setObjectName(QString::fromUtf8("lbl_Name"));
gridLayout->addWidget(lbl_Name, 1, 1, 1, 1);
lbl_PACS = new QLabel(block2);
lbl_PACS->setObjectName(QString::fromUtf8("lbl_PACS"));
gridLayout->addWidget(lbl_PACS, 3, 0, 1, 1);
local_IP = new IPAddress(block2);
local_IP->setObjectName(QString::fromUtf8("local_IP"));
gridLayout->addWidget(local_IP, 8, 1, 1, 1);
recon_Name = new QLineEdit(block2);
recon_Name->setObjectName(QString::fromUtf8("recon_Name"));
gridLayout->addWidget(recon_Name, 5, 1, 1, 1);
lbl_list = new QLabel(block2);
lbl_list->setObjectName(QString::fromUtf8("lbl_list"));
lbl_list->setMinimumSize(QSize(100, 0));
gridLayout->addWidget(lbl_list, 2, 0, 1, 1);
pacs_Port = new QLineEdit(block2);
pacs_Port->setObjectName(QString::fromUtf8("pacs_Port"));
gridLayout->addWidget(pacs_Port, 3, 4, 1, 1);
pacs_Name = new QLineEdit(block2);
pacs_Name->setObjectName(QString::fromUtf8("pacs_Name"));
gridLayout->addWidget(pacs_Name, 3, 1, 1, 1);
pacs_IP = new QLineEdit(block2);
pacs_IP->setObjectName(QString::fromUtf8("pacs_IP"));
gridLayout->addWidget(pacs_IP, 3, 3, 1, 1);
lbl_AE = new QLabel(block2);
lbl_AE->setObjectName(QString::fromUtf8("lbl_AE"));
gridLayout->addWidget(lbl_AE, 1, 2, 1, 1);
2021-12-07 14:13:55 +08:00
2021-12-09 10:00:01 +08:00
lbl_local_IP = new QLabel(block2);
lbl_local_IP->setObjectName(QString::fromUtf8("lbl_local_IP"));
2021-12-07 14:13:55 +08:00
2021-12-09 10:00:01 +08:00
gridLayout->addWidget(lbl_local_IP, 7, 1, 1, 1);
2021-12-07 14:13:55 +08:00
2021-12-09 10:00:01 +08:00
daq_IP = new QLineEdit(block2);
daq_IP->setObjectName(QString::fromUtf8("daq_IP"));
2021-12-07 14:13:55 +08:00
2021-12-09 10:00:01 +08:00
gridLayout->addWidget(daq_IP, 4, 3, 1, 1);
2021-12-07 14:13:55 +08:00
2021-12-09 10:00:01 +08:00
wl_Name = new QLineEdit(block2);
wl_Name->setObjectName(QString::fromUtf8("wl_Name"));
gridLayout->addWidget(wl_Name, 2, 1, 1, 1);
lbl_IP = new QLabel(block2);
lbl_IP->setObjectName(QString::fromUtf8("lbl_IP"));
gridLayout->addWidget(lbl_IP, 1, 3, 1, 1);
pacs_AE = new QLineEdit(block2);
pacs_AE->setObjectName(QString::fromUtf8("pacs_AE"));
gridLayout->addWidget(pacs_AE, 3, 2, 1, 1);
wl_AE = new QLineEdit(block2);
wl_AE->setObjectName(QString::fromUtf8("wl_AE"));
gridLayout->addWidget(wl_AE, 2, 2, 1, 1);
daq_Name = new QLineEdit(block2);
daq_Name->setObjectName(QString::fromUtf8("daq_Name"));
gridLayout->addWidget(daq_Name, 4, 1, 1, 1);
lbl_Local = new QLabel(block2);
lbl_Local->setObjectName(QString::fromUtf8("lbl_Local"));
gridLayout->addWidget(lbl_Local, 8, 0, 1, 1);
label = new QLabel(block2);
label->setObjectName(QString::fromUtf8("label"));
gridLayout->addWidget(label, 6, 0, 1, 1);
recon_IP = new QLineEdit(block2);
recon_IP->setObjectName(QString::fromUtf8("recon_IP"));
gridLayout->addWidget(recon_IP, 5, 3, 1, 1);
lbl_Port = new QLabel(block2);
lbl_Port->setObjectName(QString::fromUtf8("lbl_Port"));
gridLayout->addWidget(lbl_Port, 1, 4, 1, 1);
wl_IP = new QLineEdit(block2);
wl_IP->setObjectName(QString::fromUtf8("wl_IP"));
gridLayout->addWidget(wl_IP, 2, 3, 1, 1);
lbl_DAQ = new QLabel(block2);
lbl_DAQ->setObjectName(QString::fromUtf8("lbl_DAQ"));
gridLayout->addWidget(lbl_DAQ, 4, 0, 1, 1);
recon_AE = new QLineEdit(block2);
recon_AE->setObjectName(QString::fromUtf8("recon_AE"));
gridLayout->addWidget(recon_AE, 5, 2, 1, 1);
local_Gate = new IPAddress(block2);
local_Gate->setObjectName(QString::fromUtf8("local_Gate"));
gridLayout->addWidget(local_Gate, 8, 3, 1, 1);
verticalLayout->addWidget(block2);
widget = new QWidget(centralWidget);
widget->setObjectName(QString::fromUtf8("widget"));
horizontalLayout_2 = new QHBoxLayout(widget);
horizontalLayout_2->setSpacing(6);
horizontalLayout_2->setContentsMargins(11, 11, 11, 11);
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout_2->addItem(horizontalSpacer);
btnCancel = new QToolButton(widget);
btnCancel->setObjectName(QString::fromUtf8("btnCancel"));
horizontalLayout_2->addWidget(btnCancel);
btnAccept = new QToolButton(widget);
btnAccept->setObjectName(QString::fromUtf8("btnAccept"));
horizontalLayout_2->addWidget(btnAccept);
verticalLayout->addWidget(widget);
verticalSpacer = new QSpacerItem(20, 278, QSizePolicy::Minimum, QSizePolicy::Expanding);
verticalLayout->addItem(verticalSpacer);
/************************************************************************/
//text init
lbl_list->setText(tr("Worklist"));
lbl_protocal->setText(tr("Protocal"));
lbl_filter->setText(tr("Worklist Filter"));
lbl_PACS->setText(tr("PACS"));
lbl_AE->setText(tr("AE"));
lbl_Port->setText(tr("Port"));
lbl_Name->setText(tr("Name"));
lbl_DAQ->setText(tr("DAQ"));
lbl_IP->setText(tr("IP"));
lbl_Local->setText(tr("Local"));
lbl_Recon->setText(tr("3D Recon"));
lbl_verify->setText(tr("Auto Verify"));
lbl_Local->setText(tr("Local"));
lbl_local_IP->setText(tr("IP"));
lbl_local_gate->setText(tr("Default Gateway"));
lbl_local_mask->setText(tr("Subnet Mask"));
//style init
btnCancel->setToolButtonStyle(Qt::ToolButtonIconOnly);
btnCancel->setIcon(QIcon(":/icons/close_circle.png"));
btnCancel->setIconSize(QSize(50, 50));
btnAccept->setToolButtonStyle(Qt::ToolButtonIconOnly);
btnAccept->setIcon(QIcon(":/icons/selected.png"));
btnAccept->setIconSize(QSize(50, 50));
swt_verify->setChecked(true);
swt_verify->setButtonStyle(ImageSwitch::ButtonStyle_1);
btnFlt->setFixedWidth(200);
btnPro->setFixedWidth(200);
lbl_protocal->setFixedWidth(100);
//lbl_filter
lbl_list->setFixedWidth(100);
lbl_verify->setFixedWidth(100);
lbl_Local->setFixedHeight(50);
//data init
2021-12-07 14:13:55 +08:00
btnPro->setText(JsonObject::Instance()->defaultProtocal());
btnFlt->setText(JsonObject::Instance()->defaultFilter());
2021-12-09 10:00:01 +08:00
loadServersInfo();
2021-12-07 14:13:55 +08:00
2021-12-09 10:00:01 +08:00
//connection
connect(swt_verify, &ImageSwitch::clicked, [=]() {
if (swt_verify->getChecked())
{
//autoDHCP();
networkCfgDialog dia(this);
dia.setWindowModality(Qt::WindowModal);
dia.exec();
}
});
2021-12-13 17:01:17 +08:00
2021-12-09 10:00:01 +08:00
connect(btnCancel, &QToolButton::clicked, [=]() {
loadServersInfo();
});
connect(btnAccept, &QToolButton::clicked, [=]() {
saveServersInfo();
});
2021-12-07 14:13:55 +08:00
connect(btnPro, &QPushButton::clicked, [=]() {
2021-12-09 10:00:01 +08:00
if (!sd_protocal) {
sd_protocal = new SelectDialog(this);
sd_protocal->setWindowModality(Qt::WindowModal);
2021-12-07 14:13:55 +08:00
}
2021-12-09 10:00:01 +08:00
sd_protocal->setAvailableDates(JsonObject::Instance()->protocals());
sd_protocal->setSelectedValue(JsonObject::Instance()->defaultProtocal());
if (sd_protocal->exec() == QDialog::Accepted)
2021-12-07 14:13:55 +08:00
{
2021-12-09 10:00:01 +08:00
QString pro = sd_protocal->getSelectedValue();
2021-12-07 14:13:55 +08:00
//take effect
JsonObject::Instance()->setDefaultProtocal(pro);
btnPro->setText(JsonObject::Instance()->defaultProtocal());
}
});
connect(btnFlt, &QPushButton::clicked, [=]() {
2021-12-09 10:00:01 +08:00
if (!sd_filter) {
sd_filter = new SelectDialog(this);
sd_filter->setWindowModality(Qt::WindowModal);
2021-12-07 14:13:55 +08:00
}
2021-12-09 10:00:01 +08:00
sd_filter->setAvailableDates(JsonObject::Instance()->worklistFilters());
sd_filter->setSelectedValue(JsonObject::Instance()->defaultFilter());
if (sd_filter->exec() == QDialog::Accepted)
2021-12-07 14:13:55 +08:00
{
2021-12-09 10:00:01 +08:00
QString flt = sd_filter->getSelectedValue();
2021-12-07 14:13:55 +08:00
//take effect
2021-12-09 10:00:01 +08:00
JsonObject::Instance()->setDefaultFilter(flt);
2021-12-07 14:13:55 +08:00
btnFlt->setText(JsonObject::Instance()->defaultFilter());
}
});
}
2021-12-09 10:00:01 +08:00
void systemSettingForm::loadServersInfo()
{
host h;
h = JsonObject::Instance()->getServer(JsonObject::RECON);
recon_AE->setText(h.ae);
recon_IP->setText(h.ip);
recon_Name->setText(h.name);
recon_Port->setText(h.port);
h = JsonObject::Instance()->getServer(JsonObject::PACS);
pacs_AE->setText(h.ae);
pacs_IP->setText(h.ip);
pacs_Name->setText(h.name);
pacs_Port->setText(h.port);
h = JsonObject::Instance()->getServer(JsonObject::DAQ);
daq_AE->setText(h.ae);
daq_IP->setText(h.ip);
daq_Name->setText(h.name);
daq_Port->setText(h.port);
h = JsonObject::Instance()->getServer(JsonObject::WORKLIST);
wl_AE->setText(h.ae);
wl_IP->setText(h.ip);
wl_Name->setText(h.name);
wl_Port->setText(h.port);
//localhost lhost = JsonObject::Instance()->getLocalHost();
//local_IP->setIP(lhost.ip);
//local_Mask->setIP(lhost.mask);
//local_Gate->setIP(lhost.gateway);
2021-12-09 10:00:01 +08:00
//qIfConfig(lhost);
2021-12-13 17:01:17 +08:00
2021-12-09 10:00:01 +08:00
}
2021-12-13 17:01:17 +08:00
2021-12-09 10:00:01 +08:00
void systemSettingForm::saveServersInfo()
{
host h;
h.ae = recon_AE->text();
h.ip = recon_IP->text();
h.name = recon_Name->text();
h.port = recon_Port->text();
JsonObject::Instance()->setServer(JsonObject::RECON, h);
h.ae = pacs_AE->text();
h.ip = pacs_IP->text();
h.name = pacs_Name->text();
h.port = pacs_Port->text();
JsonObject::Instance()->setServer(JsonObject::PACS, h);
h.ip = wl_IP->text();
h.ae = wl_AE->text();
h.name = wl_Name->text();
h.port = wl_Port->text();
JsonObject::Instance()->setServer(JsonObject::WORKLIST, h);
h.ip = daq_IP->text();
h.ae = daq_AE->text();
h.name = daq_Name->text();
h.port = daq_Port->text();
JsonObject::Instance()->setServer(JsonObject::DAQ, h);
//localhost lhost;
//lhost.ip = local_IP->getIP();
//lhost.mask = local_Mask->getIP();
//lhost.gateway = local_Gate->getIP();
//JsonObject::Instance()->setLocalHost(lhost);
2021-12-07 14:13:55 +08:00
//qIfConfig(lhost);
2021-12-13 17:01:17 +08:00
}