From 37a79fae5d57afa9dc5e14869a7371f79956b9c6 Mon Sep 17 00:00:00 2001 From: xueyan hu <576627988@qq.com> Date: Thu, 9 Dec 2021 10:00:01 +0800 Subject: [PATCH] [add] system setting --- src/components/imageswitch.cpp | 93 +++++ src/components/imageswitch.h | 59 +++ src/components/ipaddress.cpp | 213 +++++++++++ src/components/ipaddress.h | 52 +++ src/editpatientform.cpp | 1 + src/icons/imageswitch/btncheckoff1.png | Bin 0 -> 3605 bytes src/icons/imageswitch/btncheckoff2.png | Bin 0 -> 1980 bytes src/icons/imageswitch/btncheckoff3.png | Bin 0 -> 638 bytes src/icons/imageswitch/btncheckon1.png | Bin 0 -> 3213 bytes src/icons/imageswitch/btncheckon2.png | Bin 0 -> 2282 bytes src/icons/imageswitch/btncheckon3.png | Bin 0 -> 696 bytes src/json/jsonobject.cpp | 89 ++++- src/json/jsonobject.h | 35 +- src/res.qrc | 6 + src/systemsettingform.cpp | 501 +++++++++++++++++++++++-- src/systemsettingform.h | 36 +- 16 files changed, 1034 insertions(+), 51 deletions(-) create mode 100644 src/components/imageswitch.cpp create mode 100644 src/components/imageswitch.h create mode 100644 src/components/ipaddress.cpp create mode 100644 src/components/ipaddress.h create mode 100644 src/icons/imageswitch/btncheckoff1.png create mode 100644 src/icons/imageswitch/btncheckoff2.png create mode 100644 src/icons/imageswitch/btncheckoff3.png create mode 100644 src/icons/imageswitch/btncheckon1.png create mode 100644 src/icons/imageswitch/btncheckon2.png create mode 100644 src/icons/imageswitch/btncheckon3.png diff --git a/src/components/imageswitch.cpp b/src/components/imageswitch.cpp new file mode 100644 index 0000000..09bb357 --- /dev/null +++ b/src/components/imageswitch.cpp @@ -0,0 +1,93 @@ +#pragma execution_character_set("utf-8") + +#include "imageswitch.h" +#include "qpainter.h" +#include "qdebug.h" + +ImageSwitch::ImageSwitch(QWidget* parent) : QWidget(parent) +{ + isChecked = false; + buttonStyle = ButtonStyle_2; + + imgOffFile = ":/image/imageswitch/btncheckoff2.png"; + imgOnFile = ":/image/imageswitch/btncheckon2.png"; + imgFile = imgOffFile; +} + +void ImageSwitch::mousePressEvent(QMouseEvent*) +{ + imgFile = isChecked ? imgOffFile : imgOnFile; + isChecked = !isChecked; + this->update(); +} + +void ImageSwitch::paintEvent(QPaintEvent*) +{ + QPainter painter(this); + painter.setRenderHints(QPainter::SmoothPixmapTransform); + QImage img(imgFile); + img = img.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + + //按照比例自动居中绘制 + int pixX = rect().center().x() - img.width() / 2; + int pixY = rect().center().y() - img.height() / 2; + QPoint point(pixX, pixY); + painter.drawImage(point, img); +} + +bool ImageSwitch::getChecked() const +{ + return isChecked; +} + +ImageSwitch::ButtonStyle ImageSwitch::getButtonStyle() const +{ + return this->buttonStyle; +} + +QSize ImageSwitch::sizeHint() const +{ + return QSize(87, 28); +} + +QSize ImageSwitch::minimumSizeHint() const +{ + return QSize(87, 28); +} + +void ImageSwitch::setChecked(bool isChecked) +{ + if (this->isChecked != isChecked) { + this->isChecked = isChecked; + imgFile = isChecked ? imgOnFile : imgOffFile; + this->update(); + } +} + +void ImageSwitch::setButtonStyle(const ImageSwitch::ButtonStyle& buttonStyle) +{ + if (this->buttonStyle != buttonStyle) { + this->buttonStyle = buttonStyle; + + if (buttonStyle == ButtonStyle_1) { + imgOffFile = ":/icons/imageswitch/btncheckoff1.png"; + imgOnFile = ":/icons/imageswitch/btncheckon1.png"; + this->resize(87, 28); + } + else if (buttonStyle == ButtonStyle_2) { + imgOffFile = ":/icons/imageswitch/btncheckoff2.png"; + imgOnFile = ":/icons/imageswitch/btncheckon2.png"; + this->resize(87, 28); + } + else if (buttonStyle == ButtonStyle_3) { + imgOffFile = ":/icons/imageswitch/btncheckoff3.png"; + imgOnFile = ":/icons/imageswitch/btncheckon3.png"; + this->resize(96, 38); + } + + imgFile = isChecked ? imgOnFile : imgOffFile; + setChecked(isChecked); + this->update(); + updateGeometry(); + } +} diff --git a/src/components/imageswitch.h b/src/components/imageswitch.h new file mode 100644 index 0000000..385641d --- /dev/null +++ b/src/components/imageswitch.h @@ -0,0 +1,59 @@ +#ifndef IMAGESWITCH_H +#define IMAGESWITCH_H + +/** + * 图片开关控件 作者:feiyangqingyun(QQ:517216493) 2016-11-25 + * 1. 自带三种开关按钮样式。 + * 2. 可自定义开关图片。 + */ + +#include + +#ifdef quc +class Q_DECL_EXPORT ImageSwitch : public QWidget +#else +class ImageSwitch : public QWidget +#endif + +{ + Q_OBJECT + Q_ENUMS(ButtonStyle) + + Q_PROPERTY(bool isChecked READ getChecked WRITE setChecked) + Q_PROPERTY(ButtonStyle buttonStyle READ getButtonStyle WRITE setButtonStyle) + +public: + enum ButtonStyle { + ButtonStyle_1 = 0, //开关样式1 + ButtonStyle_2 = 1, //开关样式2 + ButtonStyle_3 = 2 //开关样式3 + }; + + explicit ImageSwitch(QWidget *parent = 0); + +protected: + void mousePressEvent(QMouseEvent *); + void paintEvent(QPaintEvent *event); + +private: + bool isChecked; + ButtonStyle buttonStyle; + + QString imgOffFile; + QString imgOnFile; + QString imgFile; + +public: + bool getChecked() const; + ButtonStyle getButtonStyle() const; + QSize sizeHint() const; + QSize minimumSizeHint() const; + +public Q_SLOTS: + //设置是否选中 + void setChecked(bool isChecked); + //设置按钮样式 + void setButtonStyle(const ImageSwitch::ButtonStyle &buttonStyle); +}; + +#endif // IMAGESWITCH_H diff --git a/src/components/ipaddress.cpp b/src/components/ipaddress.cpp new file mode 100644 index 0000000..7a06588 --- /dev/null +++ b/src/components/ipaddress.cpp @@ -0,0 +1,213 @@ +#pragma execution_character_set("utf-8") + +#include "ipaddress.h" +#include +#include +#include +#include +#include +#include +#include + +IPAddress::IPAddress(QWidget* parent) : QWidget(parent) +{ + bgColor = "#515151"; + borderColor = "#3c3c3c"; + borderRadius = 3; + + //用于显示小圆点的标签,居中对齐 + labDot1 = new QLabel(this); + labDot1->setAlignment(Qt::AlignCenter); + labDot1->setText("."); + labDot1->setFixedHeight(36); + + labDot2 = new QLabel(this); + labDot2->setAlignment(Qt::AlignCenter); + labDot2->setText("."); + labDot2->setFixedHeight(36); + + labDot3 = new QLabel(this); + labDot3->setAlignment(Qt::AlignCenter); + labDot3->setText("."); + labDot3->setFixedHeight(36); + + //用于输入IP地址的文本框,居中对齐 + txtIP1 = new QLineEdit(this); + txtIP1->setObjectName("txtIP1"); + txtIP1->setAlignment(Qt::AlignCenter); + txtIP1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + connect(txtIP1, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); + + txtIP2 = new QLineEdit(this); + txtIP2->setObjectName("txtIP2"); + txtIP2->setAlignment(Qt::AlignCenter); + txtIP2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + connect(txtIP2, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); + + txtIP3 = new QLineEdit(this); + txtIP3->setObjectName("txtIP3"); + txtIP3->setAlignment(Qt::AlignCenter); + txtIP3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + connect(txtIP3, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); + + txtIP4 = new QLineEdit(this); + txtIP4->setObjectName("txtIP4"); + txtIP4->setAlignment(Qt::AlignCenter); + txtIP4->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + connect(txtIP4, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString))); + + //设置IP地址校验过滤 + QString pattern = "(2[0-5]{2}|2[0-4][0-9]|1?[0-9]{1,2})"; + //确切的说 QRegularExpression QRegularExpressionValidator 从5.0 5.1开始就有 +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) + QRegularExpression regExp(pattern); + QRegularExpressionValidator* validator = new QRegularExpressionValidator(regExp, this); +#else + QRegExp regExp(pattern); + QRegExpValidator* validator = new QRegExpValidator(regExp, this); +#endif + + txtIP1->setValidator(validator); + txtIP2->setValidator(validator); + txtIP3->setValidator(validator); + txtIP4->setValidator(validator); + + //绑定事件过滤器,识别键盘按下 + txtIP1->installEventFilter(this); + txtIP2->installEventFilter(this); + txtIP3->installEventFilter(this); + txtIP4->installEventFilter(this); + + QFrame* frame = new QFrame(this); + frame->setObjectName("frameIP"); + + QStringList qss; + qss.append(QString("QFrame#frameIP{border:1px solid %1;border-radius:%2px;}").arg(borderColor).arg(borderRadius)); + qss.append(QString("QLabel{background-color:%1;}").arg(bgColor)); + qss.append(QString("QLineEdit{background-color:%1;border:none;}").arg(bgColor)); + qss.append(QString("QLineEdit#txtIP1{border-top-left-radius:%1px;border-bottom-left-radius:%1px;}").arg(borderRadius)); + qss.append(QString("QLineEdit#txtIP4{border-top-right-radius:%1px;border-bottom-right-radius:%1px;}").arg(borderRadius)); + frame->setStyleSheet(qss.join("")); + + QVBoxLayout* verticalLayout = new QVBoxLayout(this); + verticalLayout->setContentsMargins(0, 0, 0, 0); + verticalLayout->setSpacing(0); + verticalLayout->addWidget(frame); + + //将控件按照横向布局排列 + QHBoxLayout* layout = new QHBoxLayout(frame); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + layout->addWidget(txtIP1); + layout->addWidget(labDot1); + layout->addWidget(txtIP2); + layout->addWidget(labDot2); + layout->addWidget(txtIP3); + layout->addWidget(labDot3); + layout->addWidget(txtIP4); +} + +bool IPAddress::eventFilter(QObject* watched, QEvent* event) +{ + if (event->type() == QEvent::KeyPress) { + QLineEdit* txt = (QLineEdit*)watched; + if (txt == txtIP1 || txt == txtIP2 || txt == txtIP3 || txt == txtIP4) { + QKeyEvent* key = (QKeyEvent*)event; + + //如果当前按下了小数点则移动焦点到下一个输入框 + if (key->text() == ".") { + this->focusNextChild(); + } + + //如果按下了退格键并且当前文本框已经没有了内容则焦点往前移 + if (key->key() == Qt::Key_Backspace) { + if (txt->text().length() <= 1) { + this->focusNextPrevChild(false); + } + } + } + } + + return QWidget::eventFilter(watched, event); +} + +void IPAddress::textChanged(const QString& text) +{ + int len = text.length(); + int value = text.toInt(); + + //判断当前是否输入完成一个网段,是的话则自动移动到下一个输入框 + if (len == 3) { + if (value >= 100 && value <= 255) { + this->focusNextChild(); + } + } + + //拼接成完整IP地址 + ip = QString("%1.%2.%3.%4").arg(txtIP1->text()).arg(txtIP2->text()).arg(txtIP3->text()).arg(txtIP4->text()); +} + +QString IPAddress::getIP() const +{ + return this->ip; +} + +QSize IPAddress::sizeHint() const +{ + return QSize(250, 20); +} + +QSize IPAddress::minimumSizeHint() const +{ + return QSize(30, 10); +} + +void IPAddress::setIP(const QString& ip) +{ + //先检测IP地址是否合法 + QRegExp regExp("((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"); + if (!regExp.exactMatch(ip)) { + return; + } + if (this->ip != ip) { + this->ip = ip; + + //将IP地址填入各个网段 + QStringList list = ip.split("."); + txtIP1->setText(list.at(0)); + txtIP2->setText(list.at(1)); + txtIP3->setText(list.at(2)); + txtIP4->setText(list.at(3)); + } +} + +void IPAddress::clear() +{ + txtIP1->clear(); + txtIP2->clear(); + txtIP3->clear(); + txtIP4->clear(); + txtIP1->setFocus(); +} + +void IPAddress::setBgColor(const QString& bgColor) +{ + if (this->bgColor != bgColor) { + this->bgColor = bgColor; + } +} + +void IPAddress::setBorderColor(const QString& borderColor) +{ + if (this->borderColor != borderColor) { + this->borderColor = borderColor; + } +} + +void IPAddress::setBorderRadius(int borderRadius) +{ + if (this->borderRadius != borderRadius) { + this->borderRadius = borderRadius; + } +} diff --git a/src/components/ipaddress.h b/src/components/ipaddress.h new file mode 100644 index 0000000..0e45924 --- /dev/null +++ b/src/components/ipaddress.h @@ -0,0 +1,52 @@ +#ifndef IPADDRESS_H +#define IPADDRESS_H + +#include +#include + +class QLabel; +class QLineEdit; + +class IPAddress : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QString ip READ getIP WRITE setIP) +public: + explicit IPAddress(QWidget* parent = 0); + //获取IP地址 + QString getIP() const; + QSize sizeHint() const; + QSize minimumSizeHint() const; + +public Q_SLOTS: + + void clear(); + void setIP(const QString& ip); + //设置背景颜色 + void setBgColor(const QString& bgColor); + //设置边框颜色 + void setBorderColor(const QString& borderColor); + //设置边框圆角角度 + void setBorderRadius(int borderRadius); +protected: + bool eventFilter(QObject* watched, QEvent* event); +private slots: + void textChanged(const QString& text); + +private: + QLabel* labDot1; //第一个小圆点 + QLabel* labDot2; //第二个小圆点 + QLabel* labDot3; //第三个小圆点 + + QLineEdit* txtIP1; //IP地址网段输入框1 + QLineEdit* txtIP2; //IP地址网段输入框2 + QLineEdit* txtIP3; //IP地址网段输入框3 + QLineEdit* txtIP4; //IP地址网段输入框4 + + QString ip; //IP地址 + QString bgColor; //背景颜色 + QString borderColor;//边框颜色 + int borderRadius; //边框圆角角度 +}; + +#endif // IPADDRESS_H diff --git a/src/editpatientform.cpp b/src/editpatientform.cpp index 9405748..4f36194 100644 --- a/src/editpatientform.cpp +++ b/src/editpatientform.cpp @@ -35,6 +35,7 @@ EditPatientForm::EditPatientForm(QWidget *parent) : btnFemale=btnF; btnMale=btnM; QHBoxLayout* layout =new QHBoxLayout(this->ui->editcmdWidget); + ADD_TOOL_BTN(Cancel,":/icons/close_circle.png"); ADD_TOOL_BTN(Accpet,":/icons/selected.png"); btnCancel->setEnabled(editEnable); diff --git a/src/icons/imageswitch/btncheckoff1.png b/src/icons/imageswitch/btncheckoff1.png new file mode 100644 index 0000000000000000000000000000000000000000..bfa8ebbb8bdfc2651de62c5cc1539a3dc4667752 GIT binary patch literal 3605 zcmV+w4(joVP)?Upnuedf&v3^ikdT2uAPhl*1OzRm zCudXUUu28{?+}ffAp`a?$uRY)!nvOrIrH}C7`GvAQp%=gCZ&r1`(Np zOaU_9d(J(>-u>ewkq99H=~b;?)=JjOJ$s+C-}CMFd%t&Ip|z&FxZ$?Dhs9#?+oWkt zK^P+uq8KgWLTH2#NCAcfLkfhDAVjxwelJ2tzcjd7Q?Hb&4a4v~KM0qvS^U!8?uLsC zfjf2fqZ4Dcd`uhm?07t#t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_iR8 z#gb=y&o}5UX%BATPvjMFJwg%0RQK_++T(O^wob#7mQO{+R(s<~D&D+1Nv=lIZ>HZR zi-xI4@4Alf<5z~+sR7SI_ohhAiW!~f>5+3Sb(sdUiv{A%o3JZ8Ji;h;?ais3Sm3(@ NA@ogQl~AXMzW|0Yoa_Jq literal 0 HcmV?d00001 diff --git a/src/icons/imageswitch/btncheckoff3.png b/src/icons/imageswitch/btncheckoff3.png new file mode 100644 index 0000000000000000000000000000000000000000..45bb93483deb84d77979fb1a2f737b5dc7184158 GIT binary patch literal 638 zcmeAS@N?(olHy`uVBq!ia0vp^2|%pI!3-pM-1Dk|6mzkYX9x!e$L)vy4}jd#0G|-o z|NsBb#0`M5-@bo;|Ng_PS8tv^d;ajzlY93cUb}Yh>ecHPFJ3uw=FH(E#}6Jpx_95f z-Fx=$*tK`-_FbE|?%23_`>NIJSFBpMWZCM)OIOTaxOC3E#Xw8?CQj?_o!r{qV=nA5 z9q0h{k|4ie1|^rY@{U!z&%6U#h8uiW?}`Cx;VkfoEM{Qf76M_$OLy!300resTq8uT1ux2If_$`s`IY5C({|BGuad~uy^D;^i<%`l#sXkTVNn{)Nm`U}n8OBo7g+jN?R zJIq^Vbd#fC^So8JUpCaRMEL8yuFX1dmnni_KEs1GTmPioT(Gg5ZGmP-MtxiJtx3~O z4^D8@VNmVdWcSvCsY~v4SE#k~@dru94$kiFauY(ncKNNh}Ytt!QNH?~uUK*U_QK81lTDKtUvXJXzVQ>1r$C=%xjpo{H*>f zM$_YgiBJ7FPX1=SyN@d|_oIaWKKA#db@aV$v2nOrY&dJMBz6G@YS@z>v0~ahndM&@m7~!)jAt7~BAEAQ%(N zw(yQE*#cSn^7P)j%Q^kyy(de^k|o8HPW{zf&3pHq`@6sMJ-_?g&K1TOE{0`)C+e&S zYn8=~Qn5$~s)Qf{fVk-8|8HO?uxneMDpThy7mkug@elvKJ;Pt_|8vv& zdD+9rUH*``I+kRIo8YQw66`1_t6;I>|JGs!5E{s7h$xU0t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UT+fm8i$PGH{$cjlO<)1Mu-WY1_?&p!&vA#8<1d3P35Pmg=jyVXsEEvD zd&6yf(sz`&HQZv;K|B3H7lFwQqsouWz4J)ji{){v`xm6tzQN?FM^YHJhpq%&we{>HljEGbFEA{=UHVb`JU zWGg;=>Xo%-Hw2=GVWS9&|pi6EnWJ8%!qzABaj{YwZDOG*?kbGDenpjpC^p^mpRG~k=ED3~cdR`U8-nHk{wQj zMV1Rva`|laejXNhtrbjb`xakWw3+#HW)M#b!Z5(|0z#t)+=Y+=r6i7RqlBWTOSA9r z0siaAztEg``k|J$mwpn!qc?m z_VbzdQO1-W|8Y=4NH_n?iAw6jV}to#`@yQTe`an1wKF zVSF2-6&SJx-DX7YKT`nBwQZ7D}DRzCkP(0f6nco&Cu00000NkvXXu0mjfyOSb- literal 0 HcmV?d00001 diff --git a/src/icons/imageswitch/btncheckon2.png b/src/icons/imageswitch/btncheckon2.png new file mode 100644 index 0000000000000000000000000000000000000000..4d5b59ac5f714a45e8d0c59940cf2b2f468b3864 GIT binary patch literal 2282 zcmYLJ2{e>#8-7!rhT=>1@Nlr;?|S%xf)UD0I8OnjKA zEMpzp3^B&oX2{GCGNj>u#rgm1oacSceLeSez2`mm^*#tQs6IcR2p<3d{DuZP7T|6R zE-}b{@Oc(7_#NE#!?g^pAP~sdq$v#mc(`W9R=V5U+qba*6ayIN0tP7HuVg?i3NUB` z^gaLxhosoA4}Zr)lJqKXPxt7o5k5;aJH7#=}W7eZyYL< zGeKV?O|Sf9FRf3lY)r29F0j8(ulCc~+Y^gx3rx-&bBXzFle*kBGtVAdSf(tseqC4{ zUc^t**;M-GAiHjuzBoQJ-^Y62%d8liWKgNgo!?6PCKt#wHknHAr83&)3R~vTePdIE z(ODvS0Y97COXl&xTtv4_VO3jL*SVs~rqIsw4>}}5J0-Fz-ehCygWH9J+Ky$G*JPJr{aS_mS_M+e zi+x%lX(crttpM^(p2uh2=cOeHr6`XkAm(*^Tyc`aM*xxk%B5~6KQ6TpSKQI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F?>7{&c24%akyp?>3-u5=<(uyxe{xYdx6Vkj(X1(@YkygGjD-so zBz58`qC+*ku!`xRw@Q-T>HAxFn=^n+B`vhD%cD71z!v(NvhY6rp0ShySz`}2jg4f= z;WurwFwM$|l$Q0WPZyvJ)uivq=%0_T*j(of3%l~d9TnVR;qx>PA%rNUrK~z2@WuD2 zHh28v0`$75ghuUJ9~P2P*jpz--8Oc)#5eUZsz~GJb^m3Om%jHlPwFTY_M~$>47@r4 NLtUs&g_djde*yajiDLi& literal 0 HcmV?d00001 diff --git a/src/icons/imageswitch/btncheckon3.png b/src/icons/imageswitch/btncheckon3.png new file mode 100644 index 0000000000000000000000000000000000000000..a8de834cbe4b658ea38ad72ba0156a1edc75179c GIT binary patch literal 696 zcmeAS@N?(olHy`uVBq!ia0vp^2|%pI!3-pM-1Dk|6mzkYX9x!e$L)vy4}jds0X`wF z|H0tLpPyfTeS81?qgyUoqwElI|08+KIZ94(lALVS zD{wRw=sd%cAirP+i2H~qUkNjD!649rIzOxWfv=0Y|Xe-!N9;6;_2cT;?eo`dTxG`fdG3!{-X(; zJcV87+I=@n-K{Nq|NrH+9s6PyJ^Ph(?7y^^@GtLb)lBwgcaB-tym{s^-qX+bD9oL< z)ROtF%$_9~`VNJM!(Z~p&a7s9Eqh?~Cl)zYh2*uVMZDQ7UqAS#$ZC=$*ZWx4@Z}p> z$%{FYx}Gv@mUo=wCZN6AEx@FujImmoZN}k(pqtao1Sa<}Xf^wO4C-P$VyUtH$(_1G zeaBv^q$M&mXNJcwv6>-!cu&jLsjMa<+va;sT49jAyfLq}F_k|+%KE@7h3TwWKQjEh zT^_IGGfv(fu+CxAiOd^sYjdZ-Y?z{enY02e3*JfL{#Q~#&!PC{xWt~$(699jgTABa= literal 0 HcmV?d00001 diff --git a/src/json/jsonobject.cpp b/src/json/jsonobject.cpp index 604cf92..3c949c4 100644 --- a/src/json/jsonobject.cpp +++ b/src/json/jsonobject.cpp @@ -19,7 +19,7 @@ JsonObject::~JsonObject() savecfg(); } -void JsonObject::setJsonString(const char* catergory, const char* stringName, const char* stringValue) +void JsonObject::setJsonString(const char* catergory, const char* stringName, const char* stringValue, bool save) { if (!loadcfg()) return; @@ -29,8 +29,10 @@ void JsonObject::setJsonString(const char* catergory, const char* stringName, co cJSON* Item = cJSON_CreateString(stringValue); cJSON_ReplaceItemInObject(first, stringName, Item); - - savecfg(); + if (save) + { + savecfg(); + } } char* JsonObject::getJsonString(const char* catergory, const char* stringName) @@ -74,8 +76,6 @@ void JsonObject::setDefaultProtocal(QString str) setJsonString("protocol", "default", str.toStdString().c_str()); } - - QString JsonObject::defaultFilter() { char* str = getJsonString("worklistfilter", "default"); @@ -227,4 +227,83 @@ bool JsonObject::savecfg() outFile.close(); m_bLoaded = false; return true; +} + +host JsonObject::getServer(ServerType type) +{ + QString typeName; + switch (type) + { + + case JsonObject::WORKLIST: + typeName = "worklist"; + break; + case JsonObject::PACS: + typeName = "pacs"; + break; + case JsonObject::DAQ: + typeName = "daq"; + break; + case JsonObject::RECON: + typeName = "recon"; + break; + default: + break; + } + host list; + list.ae = QString(getJsonString(typeName.toStdString().c_str(), "ae")); + list.ip = QString(getJsonString(typeName.toStdString().c_str(), "ip")); + list.name = QString(getJsonString(typeName.toStdString().c_str(), "name")); + list.port = QString(getJsonString(typeName.toStdString().c_str(), "port")); + return list; +} + +void JsonObject::setServer(ServerType type, const host& list) +{ + QString typeName; + switch (type) + { + + case JsonObject::WORKLIST: + typeName = "worklist"; + break; + case JsonObject::PACS: + typeName = "pacs"; + break; + case JsonObject::DAQ: + typeName = "daq"; + break; + case JsonObject::RECON: + typeName = "recon"; + break; + default: + break; + } + setJsonString(typeName.toStdString().c_str(), "ae", list.ae.toStdString().c_str(), false); + setJsonString(typeName.toStdString().c_str(), "ip", list.ip.toStdString().c_str(), false); + setJsonString(typeName.toStdString().c_str(), "name", list.name.toStdString().c_str(), false); + setJsonString(typeName.toStdString().c_str(), "port", list.port.toStdString().c_str(), false); + + savecfg(); +} + + +localhost JsonObject::getLocalHost() +{ + + localhost lhost; + lhost.ip = QString(getJsonString("localhost", "ip")); + lhost.mask = QString(getJsonString("localhost", "mask")); + lhost.gateway = QString(getJsonString("localhost", "gateway")); + return lhost; +} + + +void JsonObject::setLocalHost(const localhost& lh) +{ + setJsonString("localhost", "ip", lh.ip.toStdString().c_str(), false); + setJsonString("localhost", "mask", lh.mask.toStdString().c_str(), false); + 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 c6147ae..44385a8 100644 --- a/src/json/jsonobject.h +++ b/src/json/jsonobject.h @@ -6,24 +6,33 @@ class QString; class QStringList; class QTranslator; -//#define setJsonString(catergory,stringName,stringValue)\ -// if (!loadcfg())\ -// return;\ -// cJSON* first = cJSON_FindItemInObject(json_root, #catergory);\ -// if (first){\ -// cJSON* Item = cJSON_CreateString(#stringValue);\ -// cJSON_ReplaceItemInObject(first, #stringName, Item);\ -// }\ -// savecfg(); + +struct host { + QString name; + QString ae; + QString ip; + QString port; + //QString isDefault; +}; +struct localhost { + QString ip; + QString mask; + QString gateway; +}; class JsonObject { public: + static JsonObject* Instance() { static JsonObject obj; return &obj; } + enum ServerType + { + WORKLIST, PACS, DAQ, RECON + }; QStringList language(); void setDefaultLanguage(QString str); @@ -49,8 +58,14 @@ public: QString defaultFilter(); void setDefaultFilter(QString str); + host getServer(ServerType type); + void setServer(ServerType type, const host& list); + + localhost getLocalHost(); + void setLocalHost(const localhost& lh); + private: - void setJsonString(const char* catergory, const char* stringName, const char* stringValue); + void setJsonString(const char* catergory, const char* stringName, const char* stringValue, bool save = true); char* getJsonString(const char* catergory, const char* stringName); bool loadcfg(); diff --git a/src/res.qrc b/src/res.qrc index b7d926a..3315117 100644 --- a/src/res.qrc +++ b/src/res.qrc @@ -30,5 +30,11 @@ fonts/DroidSansFallback.ttf translations/en_US.qm translations/zh_CN.qm + icons/imageswitch/btncheckoff1.png + icons/imageswitch/btncheckoff2.png + icons/imageswitch/btncheckoff3.png + icons/imageswitch/btncheckon1.png + icons/imageswitch/btncheckon2.png + icons/imageswitch/btncheckon3.png diff --git a/src/systemsettingform.cpp b/src/systemsettingform.cpp index 98e6c12..e2d0afb 100644 --- a/src/systemsettingform.cpp +++ b/src/systemsettingform.cpp @@ -8,48 +8,413 @@ #include #include +#include #include "json/jsonobject.h" #include "SelectDialog.h" +#include "components/ImageSwitch.h" +#include "components/ipaddress.h" + systemSettingForm::systemSettingForm(QWidget* parent) : QWidget(parent) { - layout = new QVBoxLayout(this); + 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* protocalHeader = new QWidget(this); - layout->addWidget(protocalHeader); - QHBoxLayout* protocalHeaderLayout = new QHBoxLayout(protocalHeader); - protocalHeaderLayout->addWidget(new QLabel(tr("Default Protocal"))); - QPushButton* btnPro = new QPushButton(protocalHeader); - protocalHeaderLayout->addWidget(btnPro); - protocalHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); + QWidget* centralWidget = this; - QWidget* filterHeader = new QWidget(this); - layout->addWidget(filterHeader); - QHBoxLayout* filterHeaderLayout = new QHBoxLayout(filterHeader); - filterHeaderLayout->addWidget(new QLabel(tr("Default Worklist Filter"))); - QPushButton* btnFlt = new QPushButton(filterHeader); - filterHeaderLayout->addWidget(btnFlt); - filterHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); + 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); - layout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Expanding)); + horizontalLayout->addWidget(block10); - //init + 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); + + lbl_local_IP = new QLabel(block2); + lbl_local_IP->setObjectName(QString::fromUtf8("lbl_local_IP")); + + gridLayout->addWidget(lbl_local_IP, 7, 1, 1, 1); + + daq_IP = new QLineEdit(block2); + daq_IP->setObjectName(QString::fromUtf8("daq_IP")); + + gridLayout->addWidget(daq_IP, 4, 3, 1, 1); + + 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); + const QString style = "QLineEdit{min-height:36px;max-height:36px;border:0px}"; + this->setStyleSheet(style); + + + //data init btnPro->setText(JsonObject::Instance()->defaultProtocal()); btnFlt->setText(JsonObject::Instance()->defaultFilter()); + loadServersInfo(); - + //connection + connect(btnCancel, &QToolButton::clicked, [=]() { + loadServersInfo(); + }); + connect(btnAccept, &QToolButton::clicked, [=]() { + saveServersInfo(); + }); connect(btnPro, &QPushButton::clicked, [=]() { - if (!protocal) { - protocal = new SelectDialog(this); - protocal->setWindowModality(Qt::WindowModal); + if (!sd_protocal) { + sd_protocal = new SelectDialog(this); + sd_protocal->setWindowModality(Qt::WindowModal); } - protocal->setAvailableDates(JsonObject::Instance()->protocals()); - protocal->setSelectedValue(JsonObject::Instance()->defaultProtocal()); - if (protocal->exec() == QDialog::Accepted) + sd_protocal->setAvailableDates(JsonObject::Instance()->protocals()); + sd_protocal->setSelectedValue(JsonObject::Instance()->defaultProtocal()); + if (sd_protocal->exec() == QDialog::Accepted) { - QString pro = protocal->getSelectedValue(); + QString pro = sd_protocal->getSelectedValue(); //take effect JsonObject::Instance()->setDefaultProtocal(pro); btnPro->setText(JsonObject::Instance()->defaultProtocal()); @@ -57,20 +422,90 @@ systemSettingForm::systemSettingForm(QWidget* parent) : QWidget(parent) }); connect(btnFlt, &QPushButton::clicked, [=]() { - if (!protocal) { - filter = new SelectDialog(this); - filter->setWindowModality(Qt::WindowModal); + if (!sd_filter) { + sd_filter = new SelectDialog(this); + sd_filter->setWindowModality(Qt::WindowModal); } - filter->setAvailableDates(JsonObject::Instance()->worklistFilters()); - filter->setSelectedValue(JsonObject::Instance()->defaultFilter()); - if (filter->exec() == QDialog::Accepted) + sd_filter->setAvailableDates(JsonObject::Instance()->worklistFilters()); + sd_filter->setSelectedValue(JsonObject::Instance()->defaultFilter()); + if (sd_filter->exec() == QDialog::Accepted) { - QString pro = filter->getSelectedValue(); + QString flt = sd_filter->getSelectedValue(); //take effect - JsonObject::Instance()->setDefaultFilter(pro); + JsonObject::Instance()->setDefaultFilter(flt); btnFlt->setText(JsonObject::Instance()->defaultFilter()); } }); } +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); + +} +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); + +} \ No newline at end of file diff --git a/src/systemsettingform.h b/src/systemsettingform.h index d825e5b..37ab54c 100644 --- a/src/systemsettingform.h +++ b/src/systemsettingform.h @@ -5,6 +5,9 @@ class QPushButton; class QVBoxLayout; class SelectDialog; +class QLineEdit; +class ImageSwitch; +class IPAddress; class systemSettingForm : public QWidget { @@ -17,9 +20,36 @@ signals: public slots: private: - QVBoxLayout* layout = nullptr; - SelectDialog* protocal = nullptr; - SelectDialog* filter = nullptr; + //QVBoxLayout* layout = nullptr; + SelectDialog* sd_protocal = nullptr; + SelectDialog* sd_filter = nullptr; + + void loadServersInfo(); + void saveServersInfo(); + + QLineEdit* pacs_Name; + QLineEdit* recon_IP; + QLineEdit* daq_AE; + QLineEdit* recon_Port; + QLineEdit* local_Port; + QLineEdit* daq_Port; + + QLineEdit* wl_Name; + QLineEdit* pacs_AE; + QLineEdit* recon_AE; + QLineEdit* daq_IP; + QLineEdit* wl_Port; + QLineEdit* wl_IP; + QLineEdit* pacs_Port; + QLineEdit* recon_Name; + QLineEdit* pacs_IP; + QLineEdit* wl_AE; + QLineEdit* daq_Name; + + IPAddress* local_IP; + IPAddress* local_Mask; + IPAddress* local_Gate; + ImageSwitch* swt_verify; }; #endif // SYSTEMSETTINGFORM_H \ No newline at end of file