246 lines
6.7 KiB
C++
246 lines
6.7 KiB
C++
#include "aboutwidget.h"
|
|
#include <QVBoxLayout>
|
|
#include <QLabel>
|
|
#include <QHBoxLayout>
|
|
#include <QPushButton>
|
|
#include "event/EventCenter.h"
|
|
#include <QStringList>
|
|
#include <QProcess>
|
|
|
|
#include<stdio.h>
|
|
#define BUFFER_LENGTH 100
|
|
|
|
AboutWidget::AboutWidget(QWidget* parent)
|
|
: QWidget(parent)
|
|
{
|
|
initUi();
|
|
}
|
|
|
|
AboutWidget::~AboutWidget()
|
|
{
|
|
|
|
}
|
|
|
|
void AboutWidget::initUi()
|
|
{
|
|
const int subContentMargin = 10;
|
|
const int subContentSpacing = 20;
|
|
|
|
QVBoxLayout* pMainLayout;
|
|
QHBoxLayout* pProductVerLayout;
|
|
QLabel* pProductVer;
|
|
QPushButton* pBtnHelp;
|
|
QLabel* pCompanyCopyRight;
|
|
QLabel* pGuiVer;
|
|
QLabel* pEmbededSoftVer;
|
|
QLabel* pReconSotfVer;
|
|
QLabel* pFEBVer;
|
|
QLabel* pQtVer;
|
|
QLabel* pQtCopyright;
|
|
//QLabel* pLogVer;
|
|
//QLabel* pLogCopyright;
|
|
QLabel* pJsoncppVer;
|
|
QLabel* pJsoncppCopyright;
|
|
QLabel* pDcmtkVer;
|
|
QLabel* pDcmtkCopyright;
|
|
|
|
QLabel* pSUSEVer;
|
|
|
|
this->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
|
pMainLayout = new QVBoxLayout(this);
|
|
pMainLayout->setAlignment(Qt::AlignLeft);
|
|
pMainLayout->setSpacing(10);
|
|
|
|
pProductVerLayout = new QHBoxLayout(this);
|
|
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"));
|
|
pCompanyCopyRight->setContentsMargins(subContentMargin, 0, 0, 0);
|
|
pMainLayout->addWidget(pCompanyCopyRight);
|
|
|
|
pMainLayout->addSpacing(subContentSpacing);
|
|
|
|
pGuiVer = new QLabel(this);
|
|
pGuiVer->setText(tr("GUI Software V1.3"));
|
|
pGuiVer->setContentsMargins(subContentMargin, 0, 0, 0);
|
|
pMainLayout->addWidget(pGuiVer);
|
|
|
|
pEmbededSoftVer = new QLabel(this);
|
|
pEmbededSoftVer->setText(tr("Embedded Software V1.5"));
|
|
pEmbededSoftVer->setContentsMargins(subContentMargin, 0, 0, 0);
|
|
pMainLayout->addWidget(pEmbededSoftVer);
|
|
|
|
pReconSotfVer = new QLabel(this);
|
|
pReconSotfVer->setText(tr("Reconstruction Software V1.2"));
|
|
pReconSotfVer->setContentsMargins(subContentMargin, 0, 0, 0);
|
|
pMainLayout->addWidget(pReconSotfVer);
|
|
pMainLayout->addSpacing(subContentSpacing);
|
|
|
|
pFEBVer = new QLabel(this);
|
|
pFEBVer->setText(tr("FEB Information"));
|
|
pFEBVer->setContentsMargins(subContentMargin, 0, 0, 0);
|
|
pMainLayout->addWidget(pFEBVer);
|
|
pMainLayout->addSpacing(subContentSpacing);
|
|
|
|
|
|
pQtVer = new QLabel(tr("Qt 5.12.0"), this);
|
|
pMainLayout->addWidget(pQtVer);
|
|
//pQtCopyright = new QLabel(tr("Copyright (c) 2017 The Qt Company Ltd."), this);
|
|
//pQtCopyright->setObjectName("normal");
|
|
//pQtCopyright->setContentsMargins(subContentMargin, 0, 0, 0);
|
|
//pMainLayout->addWidget(pQtCopyright);
|
|
pMainLayout->addSpacing(subContentSpacing);
|
|
|
|
//pLogVer = new QLabel(this);
|
|
//pLogVer->setText(tr("spdlog 1.8.2"));
|
|
//pLogVer->setObjectName("lbl_aboutwidget_log4cxx");
|
|
//pMainLayout->addWidget(pLogVer);
|
|
//pLogCopyright = new QLabel(this);
|
|
//pLogCopyright->setText(tr("Copyright (c) 2016 Gabi Melman."));
|
|
//pLogCopyright->setContentsMargins(subContentMargin, 0, 0, 0);
|
|
//pMainLayout->addWidget(pLogCopyright);
|
|
|
|
|
|
|
|
|
|
pSUSEVer = new QLabel(this);
|
|
pSUSEVer->setText(getLinuxVersion());
|
|
pMainLayout->addWidget(pSUSEVer);
|
|
pMainLayout->addSpacing(subContentSpacing);
|
|
|
|
pDcmtkVer = new QLabel(this);
|
|
pDcmtkVer->setText(getDCMTKVersion());
|
|
pMainLayout->addWidget(pDcmtkVer);
|
|
pDcmtkCopyright = new QLabel(this);
|
|
pDcmtkCopyright->setObjectName("normal");
|
|
pDcmtkCopyright->setText(tr("Copyright (c) 1994-2021, OFFIS e.V."));
|
|
pDcmtkCopyright->setContentsMargins(subContentMargin, 0, 0, 0);
|
|
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"));
|
|
pJsoncppCopyright->setContentsMargins(subContentMargin, 0, 0, 0);
|
|
pMainLayout->addWidget(pJsoncppCopyright);
|
|
pMainLayout->addSpacing(subContentSpacing);
|
|
|
|
pMainLayout->addStretch();
|
|
|
|
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(tr("GUI Software V1.3"));
|
|
pEmbededSoftVer->setText(tr("Embedded Software V1.5"));
|
|
pReconSotfVer->setText(tr("Reconstruction Software V1.2"));
|
|
pFEBVer->setText(tr("FEB Information"));
|
|
});
|
|
}
|
|
|
|
|
|
bool AboutWidget::execResult(const char* cmd, std::string& result) {
|
|
#ifndef WIN32
|
|
FILE* fp = nullptr;
|
|
if (!(fp = popen(cmd, "r")))
|
|
{
|
|
result.append(strerror(errno));
|
|
pclose(fp);
|
|
return false;
|
|
}
|
|
char buffer[BUFFER_LENGTH];
|
|
memset(buffer, 0, BUFFER_LENGTH);
|
|
while (fgets(buffer, BUFFER_LENGTH, fp))
|
|
{
|
|
result.append(buffer, strlen(buffer) - 1);
|
|
}
|
|
pclose(fp);
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif // WIN32
|
|
|
|
}
|
|
|
|
|
|
QString AboutWidget::getLinuxVersion()
|
|
{
|
|
std::string str;
|
|
if (execResult("cat /proc/version", str))
|
|
{
|
|
QString qstr = QString::fromStdString(str);
|
|
return qstr.section(')', 0, 0).append(")");
|
|
}
|
|
return QString("Unable to get Linux version!");
|
|
}
|
|
|
|
QString AboutWidget::getDCMTKVersion()
|
|
{
|
|
std::string str;
|
|
if (execResult2("zypper info dcmtk", str))
|
|
{
|
|
QString qstr = QString::fromStdString(str);
|
|
QStringList strList = qstr.split('\n');
|
|
for (int i = 0; i < strList.size(); i++)
|
|
{
|
|
if (strList.at(i).contains("Version"))
|
|
{
|
|
QStringList strList2 = strList.at(i).split(':');
|
|
return QString("DCMTK %1").arg(strList2[1]);
|
|
}
|
|
}
|
|
};
|
|
return QString("Unable to get DCMTK version!");
|
|
}
|
|
|
|
|
|
bool AboutWidget::execResult2(const char* cmd, std::string& result)
|
|
{
|
|
|
|
QProcess* myProcess = new QProcess;
|
|
QStringList args;
|
|
args << "-c" << cmd;
|
|
connect(myProcess, SIGNAL(finished(int)), myProcess, SLOT(deleteLater()));
|
|
myProcess->start("/bin/sh", args);
|
|
|
|
if (!myProcess->waitForFinished() || myProcess->exitCode() != 0) {
|
|
return false;
|
|
}
|
|
|
|
result.append(myProcess->readAllStandardOutput());
|
|
return true;
|
|
|
|
}
|
|
void AboutWidget::openHelpFile()
|
|
{
|
|
QString userManulFile = QCoreApplication::applicationDirPath() + "/userManual.pdf";
|
|
|
|
QFileInfo file(userManulFile);
|
|
if (file.exists())
|
|
{
|
|
QDesktopServices::openUrl(QUrl::fromLocalFile(userManulFile));
|
|
}
|
|
//else
|
|
//{
|
|
// EQ9MessageBox box;
|
|
// box.setMessage(tr("can't find the user manual file!"));
|
|
// box.exec();
|
|
//}
|
|
} |