ver: add version show.

This commit is contained in:
2025-06-18 08:49:29 +08:00
parent a7d0099c3b
commit 540939f321
5 changed files with 41 additions and 3 deletions

View File

@@ -4,6 +4,8 @@ project(frelay VERSION 0.1.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(PROJECT_URL "https://github.com/taynpg/frelay")
if (MSVC)
add_compile_options(/utf-8)
endif()
@@ -24,6 +26,7 @@ endif()
set(CMAKE_DEBUG_POSTFIX "d")
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/)
include_directories(${PROJECT_BINARY_DIR})
add_definitions(-DFMT_HEADER_ONLY)
include_directories(3rd)
@@ -35,3 +38,20 @@ add_subdirectory(Gui)
add_subdirectory(Console)
add_subdirectory(Struct)
add_subdirectory(Test)
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION_GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file(version.h.in fversion.h)
message(STATUS "${CMAKE_SYSTEM_NAME} build dir:${PROJECT_BINARY_DIR}")
message(STATUS "VERSION_GIT_BRANCH: ${VERSION_GIT_BRANCH}")
message(STATUS "VERSION_GIT_HASH: ${VERSION_GIT_HASH}")

View File

@@ -1,8 +1,10 @@
#include "frelayGUI.h"
#include "frelayGUI.h"
#include <QSplitter>
#include <QLabel>
#include "./ui_frelayGUI.h"
#include <fversion.h>
static LogPrint* logPrint = nullptr;
@@ -13,6 +15,13 @@ frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGU
ControlSignal();
ControlLayout();
resize(1500, 800);
setWindowTitle(QString(tr("frelay %1")).arg(VERSION_NUM));
QLabel* permanent = new QLabel(this);
permanent->setFrameStyle(QFrame::Box | QFrame::Sunken);
permanent->setText(QString("%1 on %2").arg(VERSION_GIT_COMMIT).arg(VERSION_GIT_BRANCH));
this->statusBar()->addPermanentWidget(permanent);
}
frelayGUI::~frelayGUI()

View File

@@ -1,4 +1,4 @@
#ifndef FRELAYGUI_H
#ifndef FRELAYGUI_H
#define FRELAYGUI_H
#include <ClientCore.h>

View File

@@ -13,7 +13,7 @@ int main(int argc, char* argv[])
QFont font("Microsoft YaHei", 9);
a.setFont(font);
a.setWindowIcon(QIcon(":/ico/main.ico"));
a.setStyle("Windows");
//a.setStyle("Windows");
#endif
frelayGUI w;

9
version.h.in Normal file
View File

@@ -0,0 +1,9 @@
#ifndef VERSION_H
#define VERSION_H
#define VERSION_GIT_COMMIT "@VERSION_GIT_HASH@"
#define VERSION_GIT_BRANCH "@VERSION_GIT_BRANCH@"
#define VERSION_NUM "@PROJECT_VERSION@"
#define VERSION_URL "@PROJECT_URL@"
#endif