[add] system setting

This commit is contained in:
xueyan hu
2021-12-09 10:00:01 +08:00
parent 68855ab605
commit 37a79fae5d
16 changed files with 1034 additions and 51 deletions

View File

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

View File

@@ -0,0 +1,59 @@
#ifndef IMAGESWITCH_H
#define IMAGESWITCH_H
/**
* 图片开关控件 作者:feiyangqingyun(QQ:517216493) 2016-11-25
* 1. 自带三种开关按钮样式。
* 2. 可自定义开关图片。
*/
#include <QWidget>
#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

View File

@@ -0,0 +1,213 @@
#pragma execution_character_set("utf-8")
#include "ipaddress.h"
#include <QLabel>
#include <QLineEdit>
#include <QBoxLayout>
#include <QRegExp>
#include <QValidator>
#include <QKeyEvent>
#include <QDebug>
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;
}
}

View File

@@ -0,0 +1,52 @@
#ifndef IPADDRESS_H
#define IPADDRESS_H
#include <QWidget>
#include <QString>
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

View File

@@ -35,6 +35,7 @@ EditPatientForm::EditPatientForm(QWidget *parent) :
btnFemale=btnF; btnFemale=btnF;
btnMale=btnM; btnMale=btnM;
QHBoxLayout* layout =new QHBoxLayout(this->ui->editcmdWidget); QHBoxLayout* layout =new QHBoxLayout(this->ui->editcmdWidget);
ADD_TOOL_BTN(Cancel,":/icons/close_circle.png"); ADD_TOOL_BTN(Cancel,":/icons/close_circle.png");
ADD_TOOL_BTN(Accpet,":/icons/selected.png"); ADD_TOOL_BTN(Accpet,":/icons/selected.png");
btnCancel->setEnabled(editEnable); btnCancel->setEnabled(editEnable);

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

View File

@@ -19,7 +19,7 @@ JsonObject::~JsonObject()
savecfg(); 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()) if (!loadcfg())
return; return;
@@ -29,8 +29,10 @@ void JsonObject::setJsonString(const char* catergory, const char* stringName, co
cJSON* Item = cJSON_CreateString(stringValue); cJSON* Item = cJSON_CreateString(stringValue);
cJSON_ReplaceItemInObject(first, stringName, Item); cJSON_ReplaceItemInObject(first, stringName, Item);
if (save)
savecfg(); {
savecfg();
}
} }
char* JsonObject::getJsonString(const char* catergory, const char* stringName) 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()); setJsonString("protocol", "default", str.toStdString().c_str());
} }
QString JsonObject::defaultFilter() QString JsonObject::defaultFilter()
{ {
char* str = getJsonString("worklistfilter", "default"); char* str = getJsonString("worklistfilter", "default");
@@ -227,4 +227,83 @@ bool JsonObject::savecfg()
outFile.close(); outFile.close();
m_bLoaded = false; m_bLoaded = false;
return true; 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();
} }

View File

@@ -6,24 +6,33 @@ class QString;
class QStringList; class QStringList;
class QTranslator; class QTranslator;
//#define setJsonString(catergory,stringName,stringValue)\
// if (!loadcfg())\ struct host {
// return;\ QString name;
// cJSON* first = cJSON_FindItemInObject(json_root, #catergory);\ QString ae;
// if (first){\ QString ip;
// cJSON* Item = cJSON_CreateString(#stringValue);\ QString port;
// cJSON_ReplaceItemInObject(first, #stringName, Item);\ //QString isDefault;
// }\ };
// savecfg(); struct localhost {
QString ip;
QString mask;
QString gateway;
};
class JsonObject class JsonObject
{ {
public: public:
static JsonObject* Instance() static JsonObject* Instance()
{ {
static JsonObject obj; static JsonObject obj;
return &obj; return &obj;
} }
enum ServerType
{
WORKLIST, PACS, DAQ, RECON
};
QStringList language(); QStringList language();
void setDefaultLanguage(QString str); void setDefaultLanguage(QString str);
@@ -49,8 +58,14 @@ public:
QString defaultFilter(); QString defaultFilter();
void setDefaultFilter(QString str); void setDefaultFilter(QString str);
host getServer(ServerType type);
void setServer(ServerType type, const host& list);
localhost getLocalHost();
void setLocalHost(const localhost& lh);
private: 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); char* getJsonString(const char* catergory, const char* stringName);
bool loadcfg(); bool loadcfg();

View File

@@ -30,5 +30,11 @@
<file>fonts/DroidSansFallback.ttf</file> <file>fonts/DroidSansFallback.ttf</file>
<file>translations/en_US.qm</file> <file>translations/en_US.qm</file>
<file>translations/zh_CN.qm</file> <file>translations/zh_CN.qm</file>
<file>icons/imageswitch/btncheckoff1.png</file>
<file>icons/imageswitch/btncheckoff2.png</file>
<file>icons/imageswitch/btncheckoff3.png</file>
<file>icons/imageswitch/btncheckon1.png</file>
<file>icons/imageswitch/btncheckon2.png</file>
<file>icons/imageswitch/btncheckon3.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -8,48 +8,413 @@
#include <QLineEdit> #include <QLineEdit>
#include <QEvent> #include <QEvent>
#include <QToolButton>
#include "json/jsonobject.h" #include "json/jsonobject.h"
#include "SelectDialog.h" #include "SelectDialog.h"
#include "components/ImageSwitch.h"
#include "components/ipaddress.h"
systemSettingForm::systemSettingForm(QWidget* parent) : QWidget(parent) 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); QWidget* centralWidget = 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* filterHeader = new QWidget(this); verticalLayout = new QVBoxLayout(centralWidget);
layout->addWidget(filterHeader); verticalLayout->setSpacing(6);
QHBoxLayout* filterHeaderLayout = new QHBoxLayout(filterHeader); verticalLayout->setContentsMargins(11, 11, 11, 11);
filterHeaderLayout->addWidget(new QLabel(tr("Default Worklist Filter"))); verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
QPushButton* btnFlt = new QPushButton(filterHeader); block1 = new QWidget(centralWidget);
filterHeaderLayout->addWidget(btnFlt); block1->setObjectName(QString::fromUtf8("block1"));
filterHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding)); 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()); btnPro->setText(JsonObject::Instance()->defaultProtocal());
btnFlt->setText(JsonObject::Instance()->defaultFilter()); btnFlt->setText(JsonObject::Instance()->defaultFilter());
loadServersInfo();
//connection
connect(btnCancel, &QToolButton::clicked, [=]() {
loadServersInfo();
});
connect(btnAccept, &QToolButton::clicked, [=]() {
saveServersInfo();
});
connect(btnPro, &QPushButton::clicked, [=]() { connect(btnPro, &QPushButton::clicked, [=]() {
if (!protocal) { if (!sd_protocal) {
protocal = new SelectDialog(this); sd_protocal = new SelectDialog(this);
protocal->setWindowModality(Qt::WindowModal); sd_protocal->setWindowModality(Qt::WindowModal);
} }
protocal->setAvailableDates(JsonObject::Instance()->protocals()); sd_protocal->setAvailableDates(JsonObject::Instance()->protocals());
protocal->setSelectedValue(JsonObject::Instance()->defaultProtocal()); sd_protocal->setSelectedValue(JsonObject::Instance()->defaultProtocal());
if (protocal->exec() == QDialog::Accepted) if (sd_protocal->exec() == QDialog::Accepted)
{ {
QString pro = protocal->getSelectedValue(); QString pro = sd_protocal->getSelectedValue();
//take effect //take effect
JsonObject::Instance()->setDefaultProtocal(pro); JsonObject::Instance()->setDefaultProtocal(pro);
btnPro->setText(JsonObject::Instance()->defaultProtocal()); btnPro->setText(JsonObject::Instance()->defaultProtocal());
@@ -57,20 +422,90 @@ systemSettingForm::systemSettingForm(QWidget* parent) : QWidget(parent)
}); });
connect(btnFlt, &QPushButton::clicked, [=]() { connect(btnFlt, &QPushButton::clicked, [=]() {
if (!protocal) { if (!sd_filter) {
filter = new SelectDialog(this); sd_filter = new SelectDialog(this);
filter->setWindowModality(Qt::WindowModal); sd_filter->setWindowModality(Qt::WindowModal);
} }
filter->setAvailableDates(JsonObject::Instance()->worklistFilters()); sd_filter->setAvailableDates(JsonObject::Instance()->worklistFilters());
filter->setSelectedValue(JsonObject::Instance()->defaultFilter()); sd_filter->setSelectedValue(JsonObject::Instance()->defaultFilter());
if (filter->exec() == QDialog::Accepted) if (sd_filter->exec() == QDialog::Accepted)
{ {
QString pro = filter->getSelectedValue(); QString flt = sd_filter->getSelectedValue();
//take effect //take effect
JsonObject::Instance()->setDefaultFilter(pro); JsonObject::Instance()->setDefaultFilter(flt);
btnFlt->setText(JsonObject::Instance()->defaultFilter()); 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);
}

View File

@@ -5,6 +5,9 @@
class QPushButton; class QPushButton;
class QVBoxLayout; class QVBoxLayout;
class SelectDialog; class SelectDialog;
class QLineEdit;
class ImageSwitch;
class IPAddress;
class systemSettingForm : public QWidget class systemSettingForm : public QWidget
{ {
@@ -17,9 +20,36 @@ signals:
public slots: public slots:
private: private:
QVBoxLayout* layout = nullptr; //QVBoxLayout* layout = nullptr;
SelectDialog* protocal = nullptr; SelectDialog* sd_protocal = nullptr;
SelectDialog* filter = 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 #endif // SYSTEMSETTINGFORM_H