feat: Add ErrorLabel component.
This commit is contained in:
17
src/components/ErrorLabel.cpp
Normal file
17
src/components/ErrorLabel.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include "ErrorLabel.h"
|
||||||
|
|
||||||
|
ErrorLabel::ErrorLabel(QWidget* aParent)
|
||||||
|
: QLabel(aParent)
|
||||||
|
{
|
||||||
|
setObjectName("warn");
|
||||||
|
setWordWrap(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ErrorLabel::setErrorText(const QString& aText)
|
||||||
|
{
|
||||||
|
QFont font = this->font();
|
||||||
|
QFontMetrics metrics(font);
|
||||||
|
int width = metrics.width(aText);
|
||||||
|
this->setFixedHeight(metrics.lineSpacing() * (width / this->width()) + 30 );
|
||||||
|
setText(aText);
|
||||||
|
}
|
||||||
14
src/components/ErrorLabel.h
Normal file
14
src/components/ErrorLabel.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef ERRORLABEL_H
|
||||||
|
#define ERRORLABEL_H
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
class ErrorLabel : public QLabel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ErrorLabel(QWidget* aParent);
|
||||||
|
|
||||||
|
void setErrorText(const QString& aText);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ERRORLABEL_H
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "MppsSettingsDialog.h"
|
#include "MppsSettingsDialog.h"
|
||||||
|
|
||||||
#include "components/ULineEdit.h"
|
#include "components/ULineEdit.h"
|
||||||
|
#include "components/ErrorLabel.h"
|
||||||
#include "dialogs/DicomSettingsArea.h"
|
#include "dialogs/DicomSettingsArea.h"
|
||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
#include "log/UserOperationLog.h"
|
#include "log/UserOperationLog.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -16,7 +16,7 @@ namespace
|
|||||||
MppsSettingsDialog::MppsSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
|
MppsSettingsDialog::MppsSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
|
||||||
: GUIFormBaseDialog(aParent, aWindowFlag)
|
: GUIFormBaseDialog(aParent, aWindowFlag)
|
||||||
, mSettingsArea(new DicomSettingsArea(this))
|
, mSettingsArea(new DicomSettingsArea(this))
|
||||||
, mErrorText(new QLabel(this))
|
, mErrorText(new ErrorLabel(this))
|
||||||
{
|
{
|
||||||
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
||||||
layout->setSpacing(10);
|
layout->setSpacing(10);
|
||||||
@@ -33,7 +33,6 @@ MppsSettingsDialog::MppsSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindow
|
|||||||
endline->setObjectName("endline");
|
endline->setObjectName("endline");
|
||||||
layout->addWidget(endline);
|
layout->addWidget(endline);
|
||||||
layout->addWidget(mErrorText);
|
layout->addWidget(mErrorText);
|
||||||
mErrorText->setObjectName("warn");
|
|
||||||
mErrorText->hide();
|
mErrorText->hide();
|
||||||
|
|
||||||
initConfig();
|
initConfig();
|
||||||
@@ -65,37 +64,37 @@ bool MppsSettingsDialog::updateReferenceData()
|
|||||||
|
|
||||||
if(myAETitle.isEmpty())
|
if(myAETitle.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("AE can't be empty"));
|
mErrorText->setErrorText(tr("AE can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverAETitle.isEmpty())
|
if(serverAETitle.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server AE can't be empty"));
|
mErrorText->setErrorText(tr("Server AE can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverIp.isEmpty())
|
if(serverIp.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server Ip can't be empty"));
|
mErrorText->setErrorText(tr("Server Ip can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverPort.isEmpty())
|
if(serverPort.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server Port can't be empty"));
|
mErrorText->setErrorText(tr("Server Port can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isIpAddressValid())
|
if(!mSettingsArea->isIpAddressValid())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Ip Address is not valid"));
|
mErrorText->setErrorText(tr("Ip Address is not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isPortValid())
|
if(!mSettingsArea->isPortValid())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Port is not valid"));
|
mErrorText->setErrorText(tr("Port is not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "dialogs/GUIFormBaseDialog.h"
|
#include "dialogs/GUIFormBaseDialog.h"
|
||||||
|
|
||||||
class DicomSettingsArea;
|
class DicomSettingsArea;
|
||||||
class QLabel;
|
class ErrorLabel;
|
||||||
|
|
||||||
class MppsSettingsDialog : public GUIFormBaseDialog
|
class MppsSettingsDialog : public GUIFormBaseDialog
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DicomSettingsArea* mSettingsArea;
|
DicomSettingsArea* mSettingsArea;
|
||||||
QLabel* mErrorText;
|
ErrorLabel* mErrorText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MPPSSETTINGSDIALOG_H
|
#endif // MPPSSETTINGSDIALOG_H
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
#include "dialogs/DicomSettingsArea.h"
|
#include "dialogs/DicomSettingsArea.h"
|
||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
#include "log/UserOperationLog.h"
|
#include "log/UserOperationLog.h"
|
||||||
|
#include "components/ErrorLabel.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -14,7 +14,7 @@ namespace
|
|||||||
PacsSettingsDialog::PacsSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
|
PacsSettingsDialog::PacsSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
|
||||||
: GUIFormBaseDialog(aParent, aWindowFlag)
|
: GUIFormBaseDialog(aParent, aWindowFlag)
|
||||||
, mSettingsArea(new DicomSettingsArea(this))
|
, mSettingsArea(new DicomSettingsArea(this))
|
||||||
, mErrorText(new QLabel(this))
|
, mErrorText(new ErrorLabel(this))
|
||||||
{
|
{
|
||||||
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
||||||
layout->setSpacing(10);
|
layout->setSpacing(10);
|
||||||
@@ -31,7 +31,6 @@ PacsSettingsDialog::PacsSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindow
|
|||||||
endline->setObjectName("endline");
|
endline->setObjectName("endline");
|
||||||
layout->addWidget(endline);
|
layout->addWidget(endline);
|
||||||
layout->addWidget(mErrorText);
|
layout->addWidget(mErrorText);
|
||||||
mErrorText->setObjectName("warn");
|
|
||||||
mErrorText->hide();
|
mErrorText->hide();
|
||||||
|
|
||||||
initConfig();
|
initConfig();
|
||||||
@@ -62,37 +61,37 @@ bool PacsSettingsDialog::updateReferenceData()
|
|||||||
|
|
||||||
if(myAETitle.isEmpty())
|
if(myAETitle.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("AE can't be empty"));
|
mErrorText->setErrorText(tr("AE can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverAETitle.isEmpty())
|
if(serverAETitle.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server AE can't be empty"));
|
mErrorText->setErrorText(tr("Server AE can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverIp.isEmpty())
|
if(serverIp.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server Ip can't be empty"));
|
mErrorText->setErrorText(tr("Server Ip can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverPort.isEmpty())
|
if(serverPort.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server Port can't be empty"));
|
mErrorText->setErrorText(tr("Server Port can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isIpAddressValid())
|
if(!mSettingsArea->isIpAddressValid())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Ip Address is not valid"));
|
mErrorText->setErrorText(tr("Ip Address is not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isPortValid())
|
if(!mSettingsArea->isPortValid())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Port is not valid"));
|
mErrorText->setErrorText(tr("Port is not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "dialogs/GUIFormBaseDialog.h"
|
#include "dialogs/GUIFormBaseDialog.h"
|
||||||
|
|
||||||
class DicomSettingsArea;
|
class DicomSettingsArea;
|
||||||
class QLabel;
|
class ErrorLabel;
|
||||||
|
|
||||||
class PacsSettingsDialog : public GUIFormBaseDialog
|
class PacsSettingsDialog : public GUIFormBaseDialog
|
||||||
{
|
{
|
||||||
@@ -22,7 +22,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DicomSettingsArea* mSettingsArea;
|
DicomSettingsArea* mSettingsArea;
|
||||||
QLabel* mErrorText;
|
ErrorLabel* mErrorText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PACSSETTINGSDIALOG_H
|
#endif // PACSSETTINGSDIALOG_H
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#include "ReconSettingsDialog.h"
|
#include "ReconSettingsDialog.h"
|
||||||
#include "components/ULineEdit.h"
|
#include "components/ULineEdit.h"
|
||||||
|
#include "components/ErrorLabel.h"
|
||||||
#include "dialogs/DicomSettingsArea.h"
|
#include "dialogs/DicomSettingsArea.h"
|
||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
#include "recon/ReconManager.h"
|
#include "recon/ReconManager.h"
|
||||||
#include "log/UserOperationLog.h"
|
#include "log/UserOperationLog.h"
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -16,7 +16,7 @@ namespace
|
|||||||
ReconSettingsDialog::ReconSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
|
ReconSettingsDialog::ReconSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
|
||||||
: GUIFormBaseDialog(aParent, aWindowFlag)
|
: GUIFormBaseDialog(aParent, aWindowFlag)
|
||||||
, mSettingsArea(new DicomSettingsArea(this))
|
, mSettingsArea(new DicomSettingsArea(this))
|
||||||
, mErrorText(new QLabel(this))
|
, mErrorText(new ErrorLabel(this))
|
||||||
{
|
{
|
||||||
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
||||||
layout->setSpacing(10);
|
layout->setSpacing(10);
|
||||||
@@ -33,7 +33,6 @@ ReconSettingsDialog::ReconSettingsDialog(QWidget* aParent, Qt::WindowFlags aWind
|
|||||||
endline->setObjectName("endline");
|
endline->setObjectName("endline");
|
||||||
layout->addWidget(endline);
|
layout->addWidget(endline);
|
||||||
layout->addWidget(mErrorText);
|
layout->addWidget(mErrorText);
|
||||||
mErrorText->setObjectName("warn");
|
|
||||||
mErrorText->hide();
|
mErrorText->hide();
|
||||||
|
|
||||||
initConfig();
|
initConfig();
|
||||||
@@ -64,37 +63,37 @@ bool ReconSettingsDialog::updateReferenceData()
|
|||||||
|
|
||||||
if(myAETitle.isEmpty())
|
if(myAETitle.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("AE can't be empty"));
|
mErrorText->setErrorText(tr("AE can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverAETitle.isEmpty())
|
if(serverAETitle.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server AE can't be empty"));
|
mErrorText->setErrorText(tr("Server AE can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverIp.isEmpty())
|
if(serverIp.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server Ip can't be empty"));
|
mErrorText->setErrorText(tr("Server Ip can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverPort.isEmpty())
|
if(serverPort.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server Port can't be empty"));
|
mErrorText->setErrorText(tr("Server Port can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isIpAddressValid())
|
if(!mSettingsArea->isIpAddressValid())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Ip Address is not valid"));
|
mErrorText->setErrorText(tr("Ip Address is not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isPortValid())
|
if(!mSettingsArea->isPortValid())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Port is not valid"));
|
mErrorText->setErrorText(tr("Port is not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "dialogs/GUIFormBaseDialog.h"
|
#include "dialogs/GUIFormBaseDialog.h"
|
||||||
|
|
||||||
class DicomSettingsArea;
|
class DicomSettingsArea;
|
||||||
class QLabel;
|
class ErrorLabel;
|
||||||
|
|
||||||
class ReconSettingsDialog : public GUIFormBaseDialog
|
class ReconSettingsDialog : public GUIFormBaseDialog
|
||||||
{
|
{
|
||||||
@@ -22,7 +22,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DicomSettingsArea* mSettingsArea;
|
DicomSettingsArea* mSettingsArea;
|
||||||
QLabel* mErrorText;
|
ErrorLabel* mErrorText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RECONSETTINGSDIALOG_H
|
#endif // RECONSETTINGSDIALOG_H
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "WorklistSettingsDialog.h"
|
#include "WorklistSettingsDialog.h"
|
||||||
#include "components/ULineEdit.h"
|
#include "components/ULineEdit.h"
|
||||||
|
#include "components/ErrorLabel.h"
|
||||||
#include "dialogs/DicomSettingsArea.h"
|
#include "dialogs/DicomSettingsArea.h"
|
||||||
#include "json/jsonobject.h"
|
#include "json/jsonobject.h"
|
||||||
#include "log/UserOperationLog.h"
|
#include "log/UserOperationLog.h"
|
||||||
@@ -15,7 +16,7 @@ namespace
|
|||||||
WorklistSettingsDialog::WorklistSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
|
WorklistSettingsDialog::WorklistSettingsDialog(QWidget* aParent, Qt::WindowFlags aWindowFlag)
|
||||||
: GUIFormBaseDialog(aParent, aWindowFlag)
|
: GUIFormBaseDialog(aParent, aWindowFlag)
|
||||||
, mSettingsArea(new DicomSettingsArea(this))
|
, mSettingsArea(new DicomSettingsArea(this))
|
||||||
, mErrorText(new QLabel(this))
|
, mErrorText(new ErrorLabel(this))
|
||||||
{
|
{
|
||||||
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
|
||||||
layout->setSpacing(10);
|
layout->setSpacing(10);
|
||||||
@@ -32,7 +33,6 @@ WorklistSettingsDialog::WorklistSettingsDialog(QWidget* aParent, Qt::WindowFlags
|
|||||||
endline->setObjectName("endline");
|
endline->setObjectName("endline");
|
||||||
layout->addWidget(endline);
|
layout->addWidget(endline);
|
||||||
layout->addWidget(mErrorText);
|
layout->addWidget(mErrorText);
|
||||||
mErrorText->setObjectName("warn");
|
|
||||||
mErrorText->hide();
|
mErrorText->hide();
|
||||||
|
|
||||||
initConfig();
|
initConfig();
|
||||||
@@ -63,37 +63,37 @@ bool WorklistSettingsDialog::updateReferenceData()
|
|||||||
|
|
||||||
if(myAETitle.isEmpty())
|
if(myAETitle.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("AE can't be empty"));
|
mErrorText->setErrorText(tr("AE can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverAETitle.isEmpty())
|
if(serverAETitle.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server AE can't be empty"));
|
mErrorText->setErrorText(tr("Server AE can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverIp.isEmpty())
|
if(serverIp.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server Ip can't be empty"));
|
mErrorText->setErrorText(tr("Server Ip can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverPort.isEmpty())
|
if(serverPort.isEmpty())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Server Port can't be empty"));
|
mErrorText->setErrorText(tr("Server Port can't be empty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isIpAddressValid())
|
if(!mSettingsArea->isIpAddressValid())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Ip Address is not valid"));
|
mErrorText->setErrorText(tr("Ip Address is not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mSettingsArea->isPortValid())
|
if(!mSettingsArea->isPortValid())
|
||||||
{
|
{
|
||||||
mErrorText->setText(tr("Port is not valid"));
|
mErrorText->setErrorText(tr("Port is not valid"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include "dialogs/GUIFormBaseDialog.h"
|
#include "dialogs/GUIFormBaseDialog.h"
|
||||||
|
|
||||||
class DicomSettingsArea;
|
class DicomSettingsArea;
|
||||||
class QLabel;
|
class ErrorLabel;
|
||||||
|
|
||||||
class WorklistSettingsDialog : public GUIFormBaseDialog
|
class WorklistSettingsDialog : public GUIFormBaseDialog
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DicomSettingsArea* mSettingsArea;
|
DicomSettingsArea* mSettingsArea;
|
||||||
QLabel* mErrorText;
|
ErrorLabel* mErrorText;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WORKLISTSETTINGSDIALOG_H
|
#endif // WORKLISTSETTINGSDIALOG_H
|
||||||
|
|||||||
Reference in New Issue
Block a user