App: Add utility method to get app name with version included

This commit is contained in:
Chris Hennes
2025-01-29 10:50:19 +01:00
committed by WandererFan
parent b94aa0eb5f
commit d2194bbeda
3 changed files with 15 additions and 0 deletions

View File

@@ -38,6 +38,7 @@
# include <boost/scope_exit.hpp>
# include <chrono>
# include <random>
# include <fmt/format.h>
#endif
#ifdef FC_OS_WIN32
@@ -1145,6 +1146,17 @@ std::string Application::getExecutableName()
return mConfig["ExeName"];
}
std::string Application::getNameWithVersion()
{
auto appname = QCoreApplication::applicationName().toStdString();
auto config = App::Application::Config();
auto major = config["BuildVersionMajor"];
auto minor = config["BuildVersionMinor"];
auto point = config["BuildVersionPoint"];
auto suffix = config["BuildVersionSuffix"];
return fmt::format("{} {}.{}.{}{}", appname, major, minor, point, suffix);
}
std::string Application::getTempPath()
{
return mConfig["AppTempPath"];

View File

@@ -413,6 +413,7 @@ public:
//@{
static std::string getHomePath();
static std::string getExecutableName();
static std::string getNameWithVersion();
/*!
Returns the temporary directory. By default, this is set to the
system's temporary directory but can be customized by the user.

View File

@@ -102,6 +102,8 @@
#include <boost/filesystem/path.hpp>
#include <boost/scope_exit.hpp>
#include <fmt/format.h>
#endif //_PreComp_
#endif // APP_PRECOMPILED_H