Files
GUI/src/dialogs/ReconSettingsDialog.cpp

111 lines
2.9 KiB
C++
Raw Normal View History

2024-04-25 14:37:38 +08:00
#include "ReconSettingsDialog.h"
#include "components/ULineEdit.h"
#include "dialogs/DicomSettingsArea.h"
#include "json/jsonobject.h"
#include "recon/ReconManager.h"
2024-04-25 14:37:38 +08:00
#include <QVBoxLayout>
#include <QLabel>
namespace
{
const int ENDLINE_SPACE = 3;
}
ReconSettingsDialog::ReconSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
: GUIFormBaseDialog(aParent, aWindowFlag)
, mSettingsArea(new DicomSettingsArea(this))
, mErrorText(new QLabel(this))
{
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->setObjectName("warn");
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.name);
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())
{
mErrorText->setText(tr("AE can't be empty"));
return false;
}
if(serverAETitle.isEmpty())
{
mErrorText->setText(tr("Server AE can't be empty"));
return false;
}
if(serverIp.isEmpty())
{
mErrorText->setText(tr("Server Ip can't be empty"));
return false;
}
if(serverPort.isEmpty())
{
mErrorText->setText(tr("Server Port can't be empty"));
return false;
}
if(!mSettingsArea->isIpAddressValid())
{
mErrorText->setText(tr("Ip Address is not valid"));
return false;
}
if(!mSettingsArea->isPortValid())
{
mErrorText->setText(tr("Port is not valid"));
return false;
}
host serverInfo;
serverInfo.ip = serverIp;
serverInfo.ae = serverAETitle;
serverInfo.name = myAETitle;
serverInfo.port = serverPort;
JsonObject::Instance()->setServer(JsonObject::RECON, serverInfo);
ReconManager::getInstance()->setReconIpAndPort(serverIp, serverPort);
QMetaObject::invokeMethod(ReconManager::getInstance(), "checkReconConnection", Qt::QueuedConnection);
2024-04-25 14:37:38 +08:00
return true;
}