This repository has been archived by the owner on Mar 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplicationbase.cpp
170 lines (150 loc) · 3.52 KB
/
applicationbase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//
// SmartServer
// Copyright (C) 2021 АО "Нефтеавтоматика"
//
// Разработчик
// Ананьев А.А. <[email protected]>
//
#include "applicationbase.h"
#include "appsettings.h"
#include "applogger.h"
QString ApplicationBase::appDescription;
QString ApplicationBase::appCopyright;
QString ApplicationBase::appBuildNumber;
QString ApplicationBase::appRevision;
QString ApplicationBase::appBranch;
QTranslator ApplicationBase::appTranslator;
///
/// \brief ApplicationBase::ApplicationBase
/// \param argv
///
ApplicationBase::ApplicationBase(int&, char **argv)
{
QCoreApplication::setApplicationName(QFileInfo(argv[0]).completeBaseName());
qInfo().noquote() << QCoreApplication::applicationName() << appVersion(false, true);
qInfo().noquote() << applicationCopyright() << "\n";
// логирование
AppLogger::getInstance();
}
///
/// \brief ApplicationBase::setupTranslator
/// \param file
///
void ApplicationBase::setupTranslator(const QString& file)
{
if(appTranslator.load(file))
{
QCoreApplication::installTranslator(&appTranslator);
}
else
{
qWarning() << "Не удалось установить переводчик из" << file;
}
}
///
/// \brief ApplicationBase::applicationBuildNumber
/// \return
///
QString ApplicationBase::applicationBuildNumber()
{
return appBuildNumber;
}
///
/// \brief ApplicationBase::setApplicationBuildNumber
/// \param build
///
void ApplicationBase::setApplicationBuildNumber(const QString& build)
{
appBuildNumber = build;
}
///
/// \brief ApplicationBase::revisionNumber
/// \return
///
QString ApplicationBase::revisionNumber()
{
return appRevision;
}
///
/// \brief ApplicationBase::setRevisionNumber
/// \param revision
///
void ApplicationBase::setRevisionNumber(const QString& revision)
{
appRevision = revision;
}
///
/// \brief ApplicationBase::applicationBranch
/// \return
///
QString ApplicationBase::applicationBranch()
{
return appBranch;
}
///
/// \brief ApplicationBase::setApplicationBranch
/// \param branch
///
void ApplicationBase::setApplicationBranch(const QString& branch)
{
appBranch = branch;
}
///
/// \brief ApplicationBase::appVersion
/// \param includeQtVersion
/// \param includeCpuArch
/// \return
///
QString ApplicationBase::appVersion(bool includeQtVersion, bool includeCpuArch)
{
QString version;
if(applicationBranch() != "main")
{
version = QString("%1-%2.%3").arg(qApp->applicationVersion(), applicationBranch(), revisionNumber());
}
else
{
version = QString("%1.%2").arg(qApp->applicationVersion(), applicationBuildNumber());
}
if(includeQtVersion)
{
version.append(QString(" (Qt %1)").arg(qVersion()));
}
if(includeCpuArch)
{
version.append(QString(" %1").arg(QSysInfo::currentCpuArchitecture()));
}
return version;
}
///
/// \brief ApplicationBase::applicationCopyright
/// \return
///
QString ApplicationBase::applicationCopyright()
{
return appCopyright;
}
///
/// \brief ApplicationBase::setApplicationCopyright
/// \param copyright
///
void ApplicationBase::setApplicationCopyright(const QString& copyright)
{
appCopyright = copyright;
}
///
/// \brief ApplicationBase::applicationDescription
/// \return
///
QString ApplicationBase::applicationDescription()
{
return appDescription;
}
///
/// \brief ApplicationBase::setApplicarionDescription
/// \param des
///
void ApplicationBase::setApplicarionDescription(const QString& desc)
{
appDescription = desc;
}