Files
GUI/src/dialogs/ReconSettingsDialog.cpp

111 lines
3.0 KiB
C++
Raw Normal View History

2024-04-25 14:37:38 +08:00
#include "ReconSettingsDialog.h"
#include "components/ULineEdit.h"
2024-06-20 18:07:34 +08:00
#include "components/ErrorLabel.h"
2024-04-25 14:37:38 +08:00
#include "dialogs/DicomSettingsArea.h"
#include "json/jsonobject.h"
#include "recon/ReconManager.h"
#include "log/UserOperationLog.h"
2024-04-25 14:37:38 +08:00
#include <QVBoxLayout>
namespace
{
const int ENDLINE_SPACE = 3;
}
ReconSettingsDialog::ReconSettingsDialog(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("Recon 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();
}
ReconSettingsDialog::~ReconSettingsDialog()
{
}
void ReconSettingsDialog::initConfig()
{
host serverInfo;
serverInfo = JsonObject::Instance()->getServer(JsonObject::RECON);
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 ReconSettingsDialog::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::RECON, serverInfo);
ReconManager::getInstance()->setReconIpAndPort(serverIp, serverPort);
QMetaObject::invokeMethod(ReconManager::getInstance(), "checkReconConnection", Qt::QueuedConnection);
LOG_USER_OPERATION("Set Recon Settings");
2024-04-25 14:37:38 +08:00
return true;
}