Add version info in the settings menu

fixes #239
remotes/origin/HEAD
Konstantinos Sideris 7 years ago
parent 64a6771dc8
commit f77a103209
  1. 23
      CMakeLists.txt
  2. 5
      cmake/version.hpp
  3. 6
      src/UserSettingsPage.cc

@ -9,7 +9,10 @@ include(GNUInstallDirs)
# Include Qt basic functions
include(QtCommon)
project(nheko LANGUAGES C CXX VERSION 0.2.0)
project(nheko LANGUAGES C CXX)
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "2")
set(CPACK_PACKAGE_VERSION_PATCH "1")
# Set PROJECT_VERSION_PATCH and PROJECT_VERSION_TWEAK to 0 if not present, needed by add_project_meta
fix_project_version()
@ -83,9 +86,6 @@ else(NOT CMAKE_BUILD_TYPE)
message("Build type set to '${CMAKE_BUILD_TYPE}'")
endif(NOT CMAKE_BUILD_TYPE)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(PATCH_OUT "0")
else("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
find_program(GIT git)
if(GIT)
execute_process(
@ -93,22 +93,20 @@ else("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
COMMAND ${GIT} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(PATCH_OUT "0-${GIT_OUT}")
else(GIT)
set(PATCH_OUT "0")
set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${GIT_OUT}")
endif(GIT)
endif("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(PROJECT_VERSION_PATCH ${PATCH_OUT})
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set(PROJECT_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR})
set(PROJECT_VERSION ${CPACK_PACKAGE_VERSION})
message(STATUS "Version: ${PROJECT_VERSION}")
cmake_host_system_information(RESULT BUILD_HOST QUERY HOSTNAME)
cmake_host_system_information(RESULT BUILD_OS QUERY OS_NAME)
set(BUILD_USER $ENV{USER})
configure_file(cmake/version.hpp config/version.hpp)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wall \
@ -231,6 +229,7 @@ include_directories(${LMDBXX_INCLUDE_DIRS})
include_directories(include)
include_directories(include/ui)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/config)
include_directories(${LMDB_INCLUDE_DIR})

@ -0,0 +1,5 @@
namespace nheko {
static constexpr const char *version = "${PROJECT_VERSION}";
static constexpr const char *build_user = "${BUILD_USER}@${BUILD_HOST}";
static constexpr const char *build_os = "${BUILD_OS}";
}

@ -28,6 +28,8 @@
#include "UserSettingsPage.h"
#include <ToggleButton.h>
#include "version.hpp"
UserSettings::UserSettings() { load(); }
void
@ -117,6 +119,9 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
auto heading_ = new QLabel(tr("User Settings"));
heading_->setStyleSheet("font-weight: bold; font-size: 22px;");
auto versionInfo = new QLabel(
QString("%1 | %2 | %3").arg(nheko::version).arg(nheko::build_user).arg(nheko::build_os));
topBarLayout_ = new QHBoxLayout;
topBarLayout_->setSpacing(0);
topBarLayout_->setMargin(0);
@ -215,6 +220,7 @@ UserSettingsPage::UserSettingsPage(QSharedPointer<UserSettings> settings, QWidge
topLayout_->addLayout(topBarLayout_);
topLayout_->addLayout(mainLayout_);
topLayout_->addStretch(1);
topLayout_->addWidget(versionInfo);
connect(themeCombo_,
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),

Loading…
Cancel
Save