Add Version build function to CMakeLists.txt

This commit is contained in:
Krad
2022-03-08 10:43:35 +08:00
parent 95804d618f
commit 7edfe1d8f5
4 changed files with 28 additions and 3 deletions

10
AppVersion.h.in Normal file
View File

@@ -0,0 +1,10 @@
//
// Created by Krad on 2022/3/8.
//
#ifndef GUI_VERSION_H
#define GUI_VERSION_H
#define GUI_VERSION_MAJOR @GUI_VERSION_MAJOR@
#define GUI_VERSION_MINOR @GUI_VERSION_MINOR@
#define GUI_VERSION_BUILD @GUI_VERSION_BUILD@
#endif //GUI_VERSION_H

View File

@@ -5,6 +5,16 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -pthread")
# GUI Version
set(GUI_VERSION_MAJOR 0)
set(GUI_VERSION_MINOR 6)
set(GUI_VERSION_BUILD 8)
configure_file(
"AppVersion.h.in"
"AppVersion.h"
)
file(GLOB_RECURSE project_headers ./src/*.h)
file(GLOB_RECURSE project_cpps ./src/*.cpp)
file(GLOB_RECURSE project_cxx ./src/*.cxx)

View File

@@ -7,6 +7,7 @@
#include <QStringList>
#include "json/cmdhelper.h"
#include <QThread>
#include "AppVersion.h"
AboutWidget::AboutWidget(QWidget* parent)
: QWidget(parent)
@@ -70,7 +71,7 @@ void AboutWidget::initUi()
pMainLayout->addSpacing(subContentSpacing);
pGuiVer = new QLabel(this);
pGuiVer->setText(tr("GUI Software V1.3"));
pGuiVer->setText(QString(tr("GUI Software V%1")).arg(getGUIVersion()));
pGuiVer->setContentsMargins(subContentMargin, 0, 0, 0);
pMainLayout->addWidget(pGuiVer);
@@ -154,7 +155,7 @@ void AboutWidget::initUi()
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"));
pGuiVer->setText(QString(tr("GUI Software V%1")).arg(getGUIVersion()));
pEmbededSoftVer->setText(tr("Embedded Software V1.5"));
pReconSotfVer->setText(tr("Reconstruction Software V1.2"));
pFEBVer->setText(tr("FEB Information"));
@@ -177,3 +178,7 @@ void AboutWidget::openHelpFile()
// box.exec();
//}
}
QString AboutWidget::getGUIVersion() {
return QString("%1.%2.%3").arg(GUI_VERSION_MAJOR).arg(GUI_VERSION_MINOR).arg(GUI_VERSION_BUILD);
}

View File

@@ -20,7 +20,7 @@ public:
explicit AboutWidget(QWidget* parent = nullptr);
~AboutWidget();
QString getGUIVersion();
private slots:
void openHelpFile();