9#include <QStandardPaths>
10#include <QProcessEnvironment>
11#include <QLoggingCategory>
16#include "Information.h"
17#include "ui_Information.h"
18#include "RabbitCommonTools.h"
21static Q_LOGGING_CATEGORY(log,
"RabbitCommon.DlgAbout.Information")
24 const QString &szInfo, QWidget *parent) :
29 ui->tabWidget->removeTab(0);
31 SetContext(tr(
"Application"), szApp + szInfo);
33 QString szRabbitCommon;
34 szRabbitCommon =
"\n" + tr(
"### RabbitCommon") +
"\n";
37 SetContext(tr(
"RabbitCommon"), szRabbitCommon);
40 szQt = tr(
"### Qt") +
"\n";
41 szQt +=
"- " + tr(
"Runtime version: ") + QString(qVersion()) +
"\n";
42 szQt +=
"- " + tr(
"Compile version: ") + QString(QT_VERSION_STR) +
"\n";
43 szQt +=
"- " + tr(
"Libraries:") +
"\n";
44 #if QT_VERSION > QT_VERSION_CHECK(5, 8, 0)
45 szQt +=
" - " + tr(
"Version: ")
46 + QLibraryInfo::version().toString() +
"\n";
48 szQt +=
" - " + tr(
"Is debug build: ") + QString::number(QLibraryInfo::isDebugBuild()) +
"\n";
49 #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
50 szQt +=
" - " + tr(
"Is shared build: ") + QString::number(QLibraryInfo::isSharedBuild()) +
"\n";
52 szQt +=
" - " + tr(
"Path: ") +
"\n";
53 szQt += GetLibrariesLocation();
54 szQt +=
"- " + tr(
"Locale: ") + QLocale::system().name() +
"\n";
55 szQt +=
"- " + tr(
"Icon: ") +
"\n";
56 szQt +=
" - " + tr(
"Theme: ") + QIcon::themeName() +
"\n";
57 szQt +=
" - " + tr(
"Search paths:") +
"\n";
58 foreach(
auto iconPath, QIcon::themeSearchPaths())
60 szQt +=
" - " + iconPath +
"\n";
62 #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
63 szQt +=
" - " + tr(
"Fallback theme: ") + QIcon::fallbackThemeName() +
"\n";
64 szQt +=
" - " + tr(
"Fallback search paths:") +
"\n";
65 foreach(
auto iconFallback, QIcon::fallbackSearchPaths())
67 szQt +=
" - " + iconFallback +
"\n";
70 szQt +=
"### " + tr(
"Dependency libraries:") +
"\n";
71 szQt += tr(
"- OpenSSL:") +
"\n";
72 if(QSslSocket::supportsSsl())
74 #if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 3))
75 szQt +=
" - " + tr(
"Build Version: ")
76 + QSslSocket::sslLibraryBuildVersionString() +
"\n";
78 szQt +=
" - " + tr(
"Installed Version: ")
79 + QSslSocket::sslLibraryVersionString() +
"\n";
81 #if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 3))
82 szQt +=
" - " + tr(
"Build Version: ")
83 + QSslSocket::sslLibraryBuildVersionString() +
"\n";
85 szQt +=
" - " + tr(
"Don't install OPENSSL dynamic library. Please install it") +
"\n";
88#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
89 szQt +=
"### " + tr(
"Standard paths:") +
"\n";
90 szQt +=
"- " + tr(
"Standard paths:") +
"\n";
91 QMetaEnum metaEnum = QMetaEnum::fromType<QStandardPaths::StandardLocation>();
92 int nMaxType = metaEnum.keyCount();
93 for(
int i = 0; i < nMaxType; i++)
95 QStandardPaths::StandardLocation type = (QStandardPaths::StandardLocation)i;
96 QStringList lstPath = QStandardPaths::standardLocations(type);
97 if(!lstPath.isEmpty())
99 szQt +=
" - " + QStandardPaths::displayName(type) +
"["
100 + QString(metaEnum.valueToKey(i))
101 +
"(" + QString::number(type) +
")]: ";
102 if(lstPath.size() == 1)
103 szQt += lstPath.at(0);
105 foreach (
auto p, lstPath) {
106 szQt += QString(
"\n") +
" - " + p;
111 szQt +=
"- " + tr(
"Writable Location:") +
"\n";
112 for(
int i = 0; i < nMaxType; i++)
114 QStandardPaths::StandardLocation type = (QStandardPaths::StandardLocation)i;
115 QString szPath = QStandardPaths::writableLocation(type);
116 if(!szPath.isEmpty()) {
117 szQt +=
" - " + QStandardPaths::displayName(type) +
"["
118 + QString(metaEnum.valueToKey(i))
119 +
"(" + QString::number(type) +
")]: ";
127 SetContext(tr(
"Qt"), szQt);
130#if QT_VERSION > QT_VERSION_CHECK(5, 4, 0)
131 szOS =
"### " + tr(
"OS") +
"\n";
132 szOS +=
"- " + tr(
"OS: ") + QSysInfo::prettyProductName() +
"\n";
133 szOS +=
" - " + tr(
"Product type: ") + QSysInfo::productType() +
"\n";
134 szOS +=
" - " + tr(
"Product version: ") + QSysInfo::productVersion() +
"\n";
135 szOS +=
"- " + tr(
"Kernel type: ") + QSysInfo::kernelType() +
"\n";
136 szOS +=
"- " + tr(
"Kernel version: ") + QSysInfo::kernelVersion() +
"\n";
137 #if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
138 if(!QSysInfo::bootUniqueId().isEmpty())
139 szOS +=
"- " + tr(
"Boot Id: ") + QSysInfo::bootUniqueId() +
"\n";
141 szOS +=
"- " + tr(
"Build ABI: ") + QSysInfo::buildAbi() +
"\n";
142 szOS +=
"- " + tr(
"CPU: ") +
"\n";
143 int nCPU = QThread::idealThreadCount();
144 szOS +=
" - " + tr(
"Number:") +
" " + QString::number(nCPU) +
"\n";
146 szOS +=
" - " + tr(
"Architecture: ")
147 + QSysInfo::currentCpuArchitecture() +
"\n";
148 szOS +=
" - " + tr(
"Build architecture: ")
149 + QSysInfo::buildCpuArchitecture() +
"\n";
151 #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
152 szOS +=
"- " + tr(
"Theme:") +
" ";
153 switch(QApplication::styleHints()->colorScheme()) {
154 case Qt::ColorScheme::Dark:
157 case Qt::ColorScheme::Light:
160 case Qt::ColorScheme::Unknown:
161 szOS += tr(
"Unknown");
168 szHost =
"### " + tr(
"Host") +
"\n";
169 #if QT_VERSION > QT_VERSION_CHECK(5, 6, 0)
170 szHost +=
"- " + tr(
"Host name: ") + QSysInfo::machineHostName() +
"\n";
172 szHost +=
"- " + tr(
"Domain name: ") + QHostInfo::localDomainName() +
"\n";
177 szEnv +=
"### " + tr(
"Environment") +
"\n";
178 auto env = QProcessEnvironment::systemEnvironment();
179 foreach (
auto key, env.keys()) {
180 szEnv +=
" - " + key +
"=" + env.value(key) +
"\n";
183 if(!szHost.isEmpty())
184 SetContext(tr(
"Host"), szHost + szOS + szEnv);
186 qDebug(log) << (szApp + szInfo + szRabbitCommon
187 + szQt + szOS + szHost + szEnv).toStdString().c_str();
190CInformation::~CInformation()
195void CInformation::SetContext(
const QString& szTitle,
const QString& szContext)
197 if(szTitle.isEmpty() || szContext.isEmpty())
199 qCritical(log) <<
"Title or context is empty";
203 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
204 szHtml = RabbitCommon::CTools::MarkDownToHtml(szContext);
208 QTextBrowser* pEdit =
new QTextBrowser(ui->tabWidget);
210 pEdit->setOpenExternalLinks(
true);
211 pEdit->setOpenLinks(
true);
212 pEdit->setReadOnly(
true);
213 pEdit->setWordWrapMode(QTextOption::NoWrap);
214 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
215 pEdit->setMarkdown(szContext);
217 pEdit->setHtml(szHtml);
220 QTextCursor cursor = pEdit->textCursor();
221 cursor.movePosition(QTextCursor::Start);
222 pEdit->setTextCursor(cursor);
225 ui->tabWidget->addTab(pEdit, szTitle);
228#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
229QString CInformation::GetLibrariesLocation(QLibraryInfo::LibraryLocation path)
231QString CInformation::GetLibrariesLocation(QLibraryInfo::LibraryPath path)
235 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
236 szQt += QLibraryInfo::location(path);
237 #elif QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
238 szQt += QLibraryInfo::path(path);
240 foreach(
auto s, QLibraryInfo::paths(path))
249QString CInformation::GetLibrariesLocation()
252 szQt +=
" - PrefixPath: " + GetLibrariesLocation(QLibraryInfo::PrefixPath);
253 szQt +=
" - DocumentationPath: " + GetLibrariesLocation(QLibraryInfo::DocumentationPath);
254 szQt +=
" - HeadersPath: " + GetLibrariesLocation(QLibraryInfo::HeadersPath);
255 szQt +=
" - LibrariesPath: " + GetLibrariesLocation(QLibraryInfo::LibrariesPath);
256 szQt +=
" - LibraryExecutablesPath: " + GetLibrariesLocation(QLibraryInfo::LibraryExecutablesPath);
257 szQt +=
" - BinariesPath: " + GetLibrariesLocation(QLibraryInfo::BinariesPath);
258 szQt +=
" - PluginsPath: " + GetLibrariesLocation(QLibraryInfo::PluginsPath);
259 #if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
260 szQt +=
" - QmlImportsPath: " + GetLibrariesLocation(QLibraryInfo::QmlImportsPath);
262 szQt +=
" - ArchDataPath: " + GetLibrariesLocation(QLibraryInfo::ArchDataPath);
263 szQt +=
" - DataPath: " + GetLibrariesLocation(QLibraryInfo::DataPath);
264 szQt +=
" - TranslationsPath: " + GetLibrariesLocation(QLibraryInfo::TranslationsPath);
265 szQt +=
" - ExamplesPath: " + GetLibrariesLocation(QLibraryInfo::ExamplesPath);
266 szQt +=
" - TestsPath: " + GetLibrariesLocation(QLibraryInfo::TestsPath);
267 szQt +=
" - SettingsPath: " + GetLibrariesLocation(QLibraryInfo::SettingsPath);