feat: add auto update version in about dialog

This commit is contained in:
Alexey Saprunov 2023-01-05 11:21:53 +04:00
parent 425250a2df
commit 686fa18c8f
8 changed files with 63 additions and 11 deletions

View File

@ -2,8 +2,16 @@ cmake_minimum_required(VERSION 2.8)
project(GPUI)
set(GPUI_VERSION_MAJOR 0)
set(GPUI_VERSION_MINOR 1)
execute_process(
COMMAND
bash -c "grep 'Version:' .gear/gpui.spec | awk -F ':' '{ print $2 }' | tr -d [:space:]"
OUTPUT_VARIABLE GPUI_GEAR_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
string(REPLACE "." ";" GEAR_VERSION_LIST ${GPUI_GEAR_VERSION})
list(GET GEAR_VERSION_LIST 0 GPUI_VERSION_MAJOR)
list(GET GEAR_VERSION_LIST 1 GPUI_VERSION_MINOR)
list(GET GEAR_VERSION_LIST 2 GPUI_VERSION_PATCH)
set(CMAKE_MODULE_PATH ${GPUI_SOURCE_DIR}/cmake)

View File

@ -24,7 +24,7 @@
#include "../core/snapindetailsfactory.h"
#include "../core/snapinloader.h"
#include "../core/snapinmanager.h"
#include "../core/version.h"
#include "../gui/commandlineparser.h"
#include "../gui/mainwindow.h"
@ -50,7 +50,7 @@ int main(int argc, char **argv)
app.setOrganizationName(QCoreApplication::translate("main", "BaseALT Ltd."));
app.setOrganizationDomain("basealt.ru");
app.setApplicationName("GPUI");
app.setApplicationVersion("0.2.17");
app.setApplicationVersion(getApplicationVersion());
gpui::CommandLineParser parser(app);
gpui::CommandLineOptions options{};

View File

@ -5,6 +5,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_SOURCE_DIR}/version.h)
file(GLOB HEADERS "*.h")
file(GLOB SOURCES "*.cpp")

36
src/core/version.h.in Normal file
View File

@ -0,0 +1,36 @@
/***********************************************************************************************************************
**
** Copyright (C) 2021 BaseALT Ltd. <org@basealt.ru>
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
***********************************************************************************************************************/
#ifndef VERSION_H
#define VERSION_H
#define GPUI_VERSION_MAJOR ${GPUI_VERSION_MAJOR}
#define GPUI_VERSION_MINOR ${GPUI_VERSION_MINOR}
#define GPUI_VERSION_PATCH ${GPUI_VERSION_PATCH}
inline QString getApplicationVersion()
{
return QString("%1.%2.%3")
.arg(GPUI_VERSION_MAJOR)
.arg(GPUI_VERSION_MINOR)
.arg(GPUI_VERSION_PATCH);
}
#endif //VERSION_H

View File

@ -19,17 +19,23 @@
***********************************************************************************************************************/
#include "aboutdialog.h"
#include "../core/version.h"
#include "ui_aboutdialog.h"
namespace gpui
{
AboutDialog::AboutDialog(QWidget* parent)
: QDialog(parent)
, ui(new Ui::AboutDialog())
{
ui->setupUi(this);
QString text = ui->versionLabel->text();
text = text.append(getApplicationVersion());
ui->versionLabel->setText(text);
}
AboutDialog::~AboutDialog()
@ -37,5 +43,4 @@ AboutDialog::~AboutDialog()
delete ui;
}
}

View File

@ -57,7 +57,7 @@
<item>
<widget class="QLabel" name="versionLabel">
<property name="text">
<string>Version 0.2.17</string>
<string>Version</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>

View File

@ -18,8 +18,8 @@
<message>
<location line="+10"/>
<location/>
<source>Version 0.2.17</source>
<translation>Version 0.2.17</translation>
<source>Version</source>
<translation>Version</translation>
</message>
<message>
<source>Version 0.2.0</source>

View File

@ -18,8 +18,8 @@
<message>
<location line="+10"/>
<location/>
<source>Version 0.2.17</source>
<translation>Версия 0.2.17</translation>
<source>Version</source>
<translation>Версия</translation>
</message>
<message>
<source>Version 0.2.0</source>