7#include <QStandardPaths>
8#include <QProcessEnvironment>
9#include <QLoggingCategory>
13#include "Information.h"
14#include "ui_Information.h"
15#include "RabbitCommonTools.h"
18static Q_LOGGING_CATEGORY(log,
"RabbitCommon.DlgAbout.Information")
21 const QString &szInfo, QWidget *parent) :
26 ui->tabWidget->removeTab(0);
28 SetContext(tr(
"Application"), szApp + szInfo);
30 QString szRabbitCommon;
31 szRabbitCommon =
"\n" + tr(
"### RabbitCommon") +
"\n";
34 SetContext(tr(
"RabbitCommon"), szRabbitCommon);
37 szQt = tr(
"### Qt") +
"\n";
38 szQt +=
"- " + tr(
"Runtime version: ") + QString(qVersion()) +
"\n";
39 szQt +=
"- " + tr(
"Compile version: ") + QString(QT_VERSION_STR) +
"\n";
40 szQt +=
"- " + tr(
"Libraries:") +
"\n";
41#if QT_VERSION > QT_VERSION_CHECK(5, 8, 0)
42 szQt +=
" - " + tr(
"Version: ")
43 + QLibraryInfo::version().toString() +
"\n";
45 szQt +=
" - " + tr(
"Is debug build: ") + QString::number(QLibraryInfo::isDebugBuild()) +
"\n";
46#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
47 szQt +=
" - " + tr(
"Is shared build: ") + QString::number(QLibraryInfo::isSharedBuild()) +
"\n";
49 szQt +=
" - " + tr(
"Path: ") +
"\n";
50 szQt += GetLibrariesLocation();
51 szQt +=
"- " + tr(
"Locale: ") + QLocale::system().name() +
"\n";
52 szQt +=
"- " + tr(
"Icon: ") +
"\n";
53 szQt +=
" - " + tr(
"Theme: ") + QIcon::themeName() +
"\n";
54 szQt +=
" - " + tr(
"Search paths:") +
"\n";
55 foreach(
auto iconPath, QIcon::themeSearchPaths())
57 szQt +=
" - " + iconPath +
"\n";
59#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
60 szQt +=
" - " + tr(
"Fallback theme: ") + QIcon::fallbackThemeName() +
"\n";
61 szQt +=
" - " + tr(
"Fallback search paths:") +
"\n";
62 foreach(
auto iconFallback, QIcon::fallbackSearchPaths())
64 szQt +=
" - " + iconFallback +
"\n";
67 szQt +=
"### " + tr(
"Dependency libraries:") +
"\n";
68 szQt += tr(
"- OpenSSL:") +
"\n";
69 if(QSslSocket::supportsSsl())
71#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 3))
72 szQt +=
" - " + tr(
"Build Version: ")
73 + QSslSocket::sslLibraryBuildVersionString() +
"\n";
75 szQt +=
" - " + tr(
"Installed Version: ")
76 + QSslSocket::sslLibraryVersionString() +
"\n";
78#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 3))
79 szQt +=
" - " + tr(
"Build Version: ")
80 + QSslSocket::sslLibraryBuildVersionString() +
"\n";
82 szQt +=
" - " + tr(
"Don't install OPENSSL dynamic library. Please install it") +
"\n";
84#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
85 szQt +=
"### " + tr(
"Standard paths:") +
"\n";
86 szQt +=
"- " + tr(
"Standard paths:") +
"\n";
87 QMetaEnum metaEnum = QMetaEnum::fromType<QStandardPaths::StandardLocation>();
88 int nMaxType = metaEnum.keyCount();
89 for(
int i = 0; i < nMaxType; i++)
91 QStandardPaths::StandardLocation type = (QStandardPaths::StandardLocation)i;
92 QStringList lstPath = QStandardPaths::standardLocations(type);
93 if(!lstPath.isEmpty())
95 szQt +=
" - " + QStandardPaths::displayName(type) +
"["
96 + QString(metaEnum.valueToKey(i))
97 +
"(" + QString::number(type) +
")]: ";
98 if(lstPath.size() == 1)
99 szQt += lstPath.at(0);
101 foreach (
auto p, lstPath) {
102 szQt += QString(
"\n") +
" - " + p;
107 szQt +=
"- " + tr(
"Writable Location:") +
"\n";
108 for(
int i = 0; i < nMaxType; i++)
110 QStandardPaths::StandardLocation type = (QStandardPaths::StandardLocation)i;
111 QString szPath = QStandardPaths::writableLocation(type);
112 if(!szPath.isEmpty()) {
113 szQt +=
" - " + QStandardPaths::displayName(type) +
"["
114 + QString(metaEnum.valueToKey(i))
115 +
"(" + QString::number(type) +
")]: ";
122 SetContext(tr(
"Qt"), szQt);
125#if QT_VERSION > QT_VERSION_CHECK(5, 4, 0)
126 szOS =
"### " + tr(
"OS") +
"\n";
127 szOS +=
"- " + tr(
"OS: ") + QSysInfo::prettyProductName() +
"\n";
128 szOS +=
" - " + tr(
"product type: ") + QSysInfo::productType() +
"\n";
129 szOS +=
" - " + tr(
"product version: ") + QSysInfo::productVersion() +
"\n";
130 szOS +=
"- " + tr(
"Kernel type: ") + QSysInfo::kernelType() +
"\n";
131 szOS +=
"- " + tr(
"Kernel version: ") + QSysInfo::kernelVersion() +
"\n";
132#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
133 if(!QSysInfo::bootUniqueId().isEmpty())
134 szOS +=
"- " + tr(
"Boot Id: ") + QSysInfo::bootUniqueId() +
"\n";
136 szOS +=
"- " + tr(
"Build ABI: ") + QSysInfo::buildAbi() +
"\n";
137 szOS +=
"- " + tr(
"CPU: ") +
"\n";
138 szOS +=
" - " + tr(
"Architecture: ")
139 + QSysInfo::currentCpuArchitecture() +
"\n";
140 szOS +=
" - " + tr(
"Build architecture: ")
141 + QSysInfo::buildCpuArchitecture() +
"\n";
144 szHost =
"### " + tr(
"Host") +
"\n";
145#if QT_VERSION > QT_VERSION_CHECK(5, 6, 0)
146 szHost +=
"- " + tr(
"Host name: ") + QSysInfo::machineHostName() +
"\n";
148 szHost +=
"- " + tr(
"Domain name: ") + QHostInfo::localDomainName() +
"\n";
152 szEnv +=
"### " + tr(
"Environment:") +
"\n";
153 auto env = QProcessEnvironment::systemEnvironment();
154 foreach (
auto key, env.keys()) {
155 szEnv +=
" - " + key +
"=" + env.value(key) +
"\n";
158 if(!szHost.isEmpty())
159 SetContext(tr(
"Host"), szHost + szOS + szEnv);
161 qDebug(log) << (szApp + szInfo + szRabbitCommon
162 + szQt + szOS + szHost + szEnv).toStdString().c_str();
165CInformation::~CInformation()
170void CInformation::SetContext(
const QString& szTitle,
const QString& szContext)
172 if(szTitle.isEmpty() || szContext.isEmpty())
174 qCritical(log) <<
"Title or context is empty";
178 QTextEdit* pEdit =
new QTextEdit(ui->tabWidget);
180 pEdit->setReadOnly(
true);
181 pEdit->setWordWrapMode(QTextOption::NoWrap);
182 ui->tabWidget->addTab(pEdit, szTitle);
183 pEdit->setHtml(CDlgAbout::MarkDownToHtml(szContext));
185 QTextCursor cursor = pEdit->textCursor();
186 cursor.movePosition(QTextCursor::Start);
187 pEdit->setTextCursor(cursor);
191#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
192QString CInformation::GetLibrariesLocation(QLibraryInfo::LibraryLocation path)
194QString CInformation::GetLibrariesLocation(QLibraryInfo::LibraryPath path)
198#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
199 szQt += QLibraryInfo::location(path);
200#elif QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
201 szQt += QLibraryInfo::path(path);
203 foreach(
auto s, QLibraryInfo::paths(path))
212QString CInformation::GetLibrariesLocation()
215 szQt +=
" - PrefixPath: " + GetLibrariesLocation(QLibraryInfo::PrefixPath);
216 szQt +=
" - DocumentationPath: " + GetLibrariesLocation(QLibraryInfo::DocumentationPath);
217 szQt +=
" - HeadersPath: " + GetLibrariesLocation(QLibraryInfo::HeadersPath);
218 szQt +=
" - LibrariesPath: " + GetLibrariesLocation(QLibraryInfo::LibrariesPath);
219 szQt +=
" - LibraryExecutablesPath: " + GetLibrariesLocation(QLibraryInfo::LibraryExecutablesPath);
220 szQt +=
" - BinariesPath: " + GetLibrariesLocation(QLibraryInfo::BinariesPath);
221 szQt +=
" - PluginsPath: " + GetLibrariesLocation(QLibraryInfo::PluginsPath);
222#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
223 szQt +=
" - QmlImportsPath: " + GetLibrariesLocation(QLibraryInfo::QmlImportsPath);
225 szQt +=
" - ArchDataPath: " + GetLibrariesLocation(QLibraryInfo::ArchDataPath);
226 szQt +=
" - DataPath: " + GetLibrariesLocation(QLibraryInfo::DataPath);
227 szQt +=
" - TranslationsPath: " + GetLibrariesLocation(QLibraryInfo::TranslationsPath);
228 szQt +=
" - ExamplesPath: " + GetLibrariesLocation(QLibraryInfo::ExamplesPath);
229 szQt +=
" - TestsPath: " + GetLibrariesLocation(QLibraryInfo::TestsPath);
230 szQt +=
" - SettingsPath: " + GetLibrariesLocation(QLibraryInfo::SettingsPath);