src/version.cpp

changeset 281
afed72b544f0
parent 280
d0774130e860
child 295
4241d948af28
equal deleted inserted replaced
280:d0774130e860 281:afed72b544f0
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19 #include <QString> 19 #include <QString>
20 #include <QDateTime> 20 #include <QDateTime>
21 #include <QLocale>
21 #include <QObject> 22 #include <QObject>
22 #include <time.h> 23 #include <time.h>
23 #include <hginfo.h> 24 #include <hginfo.h>
24 #include "src/version.h" 25 #include "src/version.h"
25 26
27 # define HGTEXT HG_NODE " (" HG_ALL_TAGS ")" 28 # define HGTEXT HG_NODE " (" HG_ALL_TAGS ")"
28 #else 29 #else
29 # define HGTEXT HG_NODE 30 # define HGTEXT HG_NODE
30 #endif 31 #endif
31 32
32 QString detailedVersionString() 33 QString detailedVersionString(QLocale::FormatType formatType)
33 { 34 {
34 return QStringLiteral(VERSION_STRING "-" HGTEXT) 35 return QStringLiteral(CMAKE_PROJECT_VERSION "-" HGTEXT)
35 + " (" + revisionDateString() + ")"; 36 + " (" + revisionDateString(formatType) + ")";
36 } 37 }
37 38
38 QString versionString() 39 QString versionString(QLocale::FormatType formatType)
39 { 40 {
40 #ifndef HG_VERSION_TAG 41 #ifndef HG_VERSION_TAG
41 return detailedVersionString(); 42 return detailedVersionString(formatType);
42 #else 43 #else
43 return QStringLiteral(HG_VERSION_TAG); 44 return QStringLiteral(HG_VERSION_TAG);
44 #endif 45 #endif
45 } 46 }
46 47
47 static QString makeFullVersionString() 48 static QString makeFullVersionString(QLocale::FormatType formatType)
48 { 49 {
49 QString versionstring = APPNAME " " + versionString(); 50 QString versionstring = CMAKE_PROJECT_NAME " " + versionString(formatType);
50 return versionstring; 51 return versionstring;
51 } 52 }
52 53
53 const QString& fullVersionString() 54 const QString& fullVersionString(QLocale::FormatType formatType)
54 { 55 {
55 static const QString cached = makeFullVersionString(); 56 static const QString cached = makeFullVersionString(formatType);
56 return cached; 57 return cached;
57 } 58 }
58 59
59 QString revisionDateString() 60 QString revisionDateString(QLocale::FormatType formatType)
60 { 61 {
61 const QDateTime dt = QDateTime::fromSecsSinceEpoch(HG_DATE_TIME); 62 const QDateTime dt = QDateTime::fromSecsSinceEpoch(HG_DATE_TIME);
62 return dt.toString(QObject::tr("d MMM yyyy")); 63 return QLocale{}.toString(dt.date(), formatType);
63 } 64 }

mercurial