Files
GUI/src/forms/settings/AboutForm.cpp
2023-09-07 17:30:26 +08:00

185 lines
5.9 KiB
C++

#include "AboutForm.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QHBoxLayout>
#include <QPushButton>
#include <QStringList>
#include <QThread>
#include <QScrollArea>
#include "event/EventCenter.h"
#include "json/cmdhelper.h"
#include "AppVersion.h"
#include "device/DeviceManager.h"
#include "recon/ReconManager.h"
#include "components/SlideWidget.h"
AboutForm::AboutForm(QWidget* aParent)
: QWidget(aParent)
,mReconSotfVer( new QLabel(this))
{
initUiWidget();
mReconSotfVer->setSizePolicy(QSizePolicy::Policy::Expanding,QSizePolicy::Policy::Expanding);
}
AboutForm::~AboutForm()
{
}
void AboutForm::setReconVersion(const QString& version)
{
mReconSotfVer->setText(version);
}
void AboutForm::initUiWidget()
{
const int subContentMargin = 10;
const int subContentSpacing = 20;
QVBoxLayout* pMainLayout;
QHBoxLayout* pProductVerLayout;
QLabel* pProductVer;
QPushButton* pBtnHelp;
QLabel* pCompanyCopyRight;
QLabel* pGuiVer;
QLabel* pEmbededSoftVer;
QLabel* pFEBVer;
QLabel* pQtVer;
QLabel* pQtCopyright;
QLabel* pJsoncppVer;
QLabel* pJsoncppCopyright;
QLabel* pDcmtkVer;
QLabel* pDcmtkCopyright;
QLabel* pSUSEVer;
this->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
QHBoxLayout * l = new QHBoxLayout(this);
QScrollArea* scrollArea = new QScrollArea(this);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
l->addWidget(scrollArea);
SlideWidget * widget = new SlideWidget(this);
scrollArea->setWidget(widget);
scrollArea->setWidgetResizable(true);
widget->setVerticalScrollBar(scrollArea->verticalScrollBar());
pMainLayout = new QVBoxLayout(widget);
pMainLayout->setAlignment(Qt::AlignLeft);
pMainLayout->setSpacing(10);
pProductVerLayout = new QHBoxLayout;
pMainLayout->addLayout(pProductVerLayout);
pProductVer = new QLabel(this);
pProductVer->setText(tr("HJ-USCT-01 V1.0"));
pProductVerLayout->addWidget(pProductVer);
pBtnHelp = new QPushButton(this);
pBtnHelp->setText(tr("?"));
pBtnHelp->setFixedWidth(50);
pProductVerLayout->addWidget(pBtnHelp);
pCompanyCopyRight = new QLabel(this);
pCompanyCopyRight->setObjectName("normal");
pCompanyCopyRight->setText(tr("Copyright © 2017-2022 Zhejiang Equilibrium Nine Medical Equipment Co., Ltd. All Rights Reversed"));
pMainLayout->addWidget(pCompanyCopyRight);
pMainLayout->addSpacing(subContentSpacing);
pGuiVer = new QLabel(this);
pGuiVer->setText(QString(tr("GUI Software V%1")).arg(getGUIVersion()));
pMainLayout->addWidget(pGuiVer);
pEmbededSoftVer = new QLabel(this);
pEmbededSoftVer->setText(tr("Embedded Software %1").arg(getEmbVersion()));
pMainLayout->addWidget(pEmbededSoftVer);
mReconSotfVer->setText(tr("Reconstruction Software Loading..."));
pMainLayout->addWidget(mReconSotfVer);
pMainLayout->addSpacing(subContentSpacing);
pFEBVer = new QLabel(this);
pFEBVer->setText(tr("FEB Information"));
pMainLayout->addWidget(pFEBVer);
pMainLayout->addSpacing(subContentSpacing);
pQtVer = new QLabel(tr("Qt 5.12.0"), this);
pMainLayout->addWidget(pQtVer);
pMainLayout->addSpacing(subContentSpacing);
pSUSEVer = new QLabel(this);
pSUSEVer->setText(tr("Loading..."));
pMainLayout->addWidget(pSUSEVer);
pMainLayout->addSpacing(subContentSpacing);
pDcmtkVer = new QLabel(this);
pDcmtkVer->setText(tr("Loading..."));
pMainLayout->addWidget(pDcmtkVer);
pDcmtkCopyright = new QLabel(this);
pDcmtkCopyright->setObjectName("normal");
pDcmtkCopyright->setText(tr("Copyright (c) 1994-2021, OFFIS e.V."));
pMainLayout->addWidget(pDcmtkCopyright);
pMainLayout->addSpacing(subContentSpacing);
pJsoncppVer = new QLabel(this);
pJsoncppVer->setText(tr("cJSON"));
pMainLayout->addWidget(pJsoncppVer);
pJsoncppCopyright = new QLabel(this);
pJsoncppCopyright->setObjectName("normal");
pJsoncppCopyright->setText(tr("Copyright (c) 2009-2017 Dave Gamble"));
pMainLayout->addWidget(pJsoncppCopyright);
pMainLayout->addSpacing(subContentSpacing);
pMainLayout->addStretch();
QThread* t = QThread::create([=]() {
pSUSEVer->setText(cmdHelper::Instance()->getLinuxVersion());
pDcmtkVer->setText(cmdHelper::Instance()->getDCMTKVersion());
});
t->start();
connect(t, SIGNAL(finished()), t, SLOT(deleteLater()));
QMetaObject::invokeMethod(ReconManager::getInstance(), "getReconVersion", Qt::QueuedConnection);
connect(ReconManager::getInstance(), &ReconManager::getReconVersionResponsed,this,&AboutForm::setReconVersion,Qt::QueuedConnection);
connect(pBtnHelp, SIGNAL(clicked()), this, SLOT(openHelpFile()));
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
pProductVer->setText(tr("HJ-USCT-01 V1.0"));
pBtnHelp->setText(tr("?"));
pCompanyCopyRight->setText(tr("Copyright © 2017-2020 Zhejiang Equilibrium Nine Medical Equipment Co., Ltd. All Rights Reversed"));
pGuiVer->setText(QString(tr("GUI Software V%1")).arg(getGUIVersion()));
pEmbededSoftVer->setText(tr("Embedded Software %1").arg(getEmbVersion()));
mReconSotfVer->setText(tr("Reconstruction Software V1.2"));
pFEBVer->setText(tr("FEB Information"));
});
}
void AboutForm::openHelpFile()
{
QString userManulFile = QCoreApplication::applicationDirPath() + "/userManual.pdf";
QFileInfo file(userManulFile);
if (file.exists())
{
QDesktopServices::openUrl(QUrl::fromLocalFile(userManulFile));
}
}
QString AboutForm::getGUIVersion()
{
if (GUI_VERSION_BETA)
{
return QString("%1.%2.%3 beta").arg(GUI_VERSION_MAJOR).arg(GUI_VERSION_MINOR).arg(GUI_VERSION_BUILD);
}
return QString("%1.%2.%3").arg(GUI_VERSION_MAJOR).arg(GUI_VERSION_MINOR).arg(GUI_VERSION_BUILD);
}
QString AboutForm::getEmbVersion()
{
return DeviceManager::Default()->getSoftwareVersion();
}