src/version.cpp

Tue, 28 Jun 2022 17:59:34 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Tue, 28 Jun 2022 17:59:34 +0300
changeset 291
42b4953dff85
parent 281
afed72b544f0
child 295
4241d948af28
permissions
-rw-r--r--

Let's bring GLEW back after all

24
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
1 /*
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
2 * LDForge: LDraw parts authoring CAD
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
3 * Copyright (C) 2013 - 2020 Teemu Piippo
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
4 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
5 * This program is free software: you can redistribute it and/or modify
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
6 * it under the terms of the GNU General Public License as published by
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
8 * (at your option) any later version.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
9 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
10 * This program is distributed in the hope that it will be useful,
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
13 * GNU General Public License for more details.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
14 *
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
15 * You should have received a copy of the GNU General Public License
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
17 */
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 1
diff changeset
18
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #include <QString>
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
20 #include <QDateTime>
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
21 #include <QLocale>
280
d0774130e860 Fix build
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 273
diff changeset
22 #include <QObject>
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 #include <time.h>
264
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 250
diff changeset
24 #include <hginfo.h>
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 250
diff changeset
25 #include "src/version.h"
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
27 #ifdef HG_ALL_TAGS
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
28 # define HGTEXT HG_NODE " (" HG_ALL_TAGS ")"
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
29 #else
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
30 # define HGTEXT HG_NODE
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
31 #endif
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
32
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
33 QString detailedVersionString(QLocale::FormatType formatType)
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34 {
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
35 return QStringLiteral(CMAKE_PROJECT_VERSION "-" HGTEXT)
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
36 + " (" + revisionDateString(formatType) + ")";
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
37 }
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
38
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
39 QString versionString(QLocale::FormatType formatType)
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
40 {
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
41 #ifndef HG_VERSION_TAG
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
42 return detailedVersionString(formatType);
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
43 #else
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
44 return QStringLiteral(HG_VERSION_TAG);
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
45 #endif
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46 }
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
47
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
48 static QString makeFullVersionString(QLocale::FormatType formatType)
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
49 {
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
50 QString versionstring = CMAKE_PROJECT_NAME " " + versionString(formatType);
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
51 return versionstring;
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
52 }
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
53
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
54 const QString& fullVersionString(QLocale::FormatType formatType)
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
55 {
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
56 static const QString cached = makeFullVersionString(formatType);
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
57 return cached;
1
51d14b0c68c0 add version
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
58 }
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
59
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
60 QString revisionDateString(QLocale::FormatType formatType)
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
61 {
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
62 const QDateTime dt = QDateTime::fromSecsSinceEpoch(HG_DATE_TIME);
281
afed72b544f0 - Add CMake build type to about page and window title
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 280
diff changeset
63 return QLocale{}.toString(dt.date(), formatType);
272
9d52b119b3f5 Sort out versions more, add about page
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 268
diff changeset
64 }

mercurial