Files
GUI/src/dialogs/PacsSettingsDialog.cpp

107 lines
2.7 KiB
C++
Raw Normal View History

2024-04-25 14:37:38 +08:00
#include "PacsSettingsDialog.h"
#include "dialogs/DicomSettingsArea.h"
#include "json/jsonobject.h"
#include "log/UserOperationLog.h"
2024-06-20 18:07:34 +08:00
#include "components/ErrorLabel.h"
2024-04-25 14:37:38 +08:00
#include <QVBoxLayout>
namespace
{
const int ENDLINE_SPACE = 3;
}
PacsSettingsDialog::PacsSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
: GUIFormBaseDialog(aParent, aWindowFlag)
, mSettingsArea(new DicomSettingsArea(this))
2024-06-20 18:07:34 +08:00
, mErrorText(new ErrorLabel(this))
2024-04-25 14:37:38 +08:00
{
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
layout->setSpacing(10);
//Title
QLabel* title = new QLabel(this);
title->setAlignment(Qt::AlignCenter);
title->setText(tr("PACS Settings"));
title->setObjectName("title");
layout->addWidget(title);
layout->addWidget(mSettingsArea);
QLabel* endline = new QLabel(this);
endline->setFixedHeight(ENDLINE_SPACE);
endline->setObjectName("endline");
layout->addWidget(endline);
layout->addWidget(mErrorText);
mErrorText->hide();
initConfig();
}
PacsSettingsDialog::~PacsSettingsDialog()
{
}
void PacsSettingsDialog::initConfig()
{
host serverInfo;
serverInfo = JsonObject::Instance()->getServer(JsonObject::PACS);
mSettingsArea->setServerAETitle(serverInfo.ae);
mSettingsArea->setServerIpAddress(serverInfo.ip);
mSettingsArea->setMyAETitle(serverInfo.localAE);
2024-04-25 14:37:38 +08:00
mSettingsArea->setServerPort(serverInfo.port);
}
bool PacsSettingsDialog::updateReferenceData()
{
QString myAETitle = mSettingsArea->getMyAETitle();
QString serverIp = mSettingsArea->getServerIpAddress();
QString serverPort = mSettingsArea->getServerPort();
QString serverAETitle = mSettingsArea->getServerAETitle();
mErrorText->show();
if(myAETitle.isEmpty())
{
2024-06-20 18:07:34 +08:00
mErrorText->setErrorText(tr("AE can't be empty"));
2024-04-25 14:37:38 +08:00
return false;
}
if(serverAETitle.isEmpty())
{
2024-06-20 18:07:34 +08:00
mErrorText->setErrorText(tr("Server AE can't be empty"));
2024-04-25 14:37:38 +08:00
return false;
}
if(serverIp.isEmpty())
{
2024-06-20 18:07:34 +08:00
mErrorText->setErrorText(tr("Server Ip can't be empty"));
2024-04-25 14:37:38 +08:00
return false;
}
if(serverPort.isEmpty())
{
2024-06-20 18:07:34 +08:00
mErrorText->setErrorText(tr("Server Port can't be empty"));
2024-04-25 14:37:38 +08:00
return false;
}
if(!mSettingsArea->isIpAddressValid())
{
2024-06-20 18:07:34 +08:00
mErrorText->setErrorText(tr("Ip Address is not valid"));
2024-04-25 14:37:38 +08:00
return false;
}
if(!mSettingsArea->isPortValid())
{
2024-06-20 18:07:34 +08:00
mErrorText->setErrorText(tr("Port is not valid"));
2024-04-25 14:37:38 +08:00
return false;
}
host serverInfo;
serverInfo.ip = serverIp;
serverInfo.ae = serverAETitle;
serverInfo.localAE = myAETitle;
2024-04-25 14:37:38 +08:00
serverInfo.port = serverPort;
JsonObject::Instance()->setServer(JsonObject::PACS, serverInfo);
LOG_USER_OPERATION("Set PACS Settings");
2024-04-25 14:37:38 +08:00
return true;
}