From 458d98a279f95b91590809c8e1800038f1a47131 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 14 Oct 2023 20:44:59 +0200 Subject: [PATCH] Allow logging a few useful Qt-related information by setting env variable Log Qt-related info when the environment variable QT_UTILITIES_LOG_QT_CONFIG is set. --- settingsdialog/qtsettings.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/settingsdialog/qtsettings.cpp b/settingsdialog/qtsettings.cpp index c0015d9..6fd10a3 100644 --- a/settingsdialog/qtsettings.cpp +++ b/settingsdialog/qtsettings.cpp @@ -12,14 +12,19 @@ #include "../misc/desktoputils.h" +#include "resources/config.h" + #include "ui_qtappearanceoptionpage.h" #include "ui_qtenvoptionpage.h" #include "ui_qtlanguageoptionpage.h" +#include + #include #include #include #include +#include #include #include #include @@ -338,6 +343,24 @@ void QtSettings::apply() // apply locale m_d->previousLocale = QLocale(); QLocale::setDefault(m_d->customLocale ? QLocale(m_d->localeName) : m_d->defaultLocale); + + // log some debug information on the first call if env variable set + static auto debugInfoLogged = false; + if (debugInfoLogged) { + return; + } + const auto debugLoggingEnabled = CppUtilities::isEnvVariableSet(PROJECT_VARNAME_UPPER "_LOG_QT_CONFIG"); + if (debugLoggingEnabled.has_value() && debugLoggingEnabled.value()) { + if (const auto os = QOperatingSystemVersion::current(); os.type() != QOperatingSystemVersion::Unknown) { + std::cerr << "OS name and version: " << os.name().toStdString() << ' ' << os.version().toString().toStdString() << '\n'; + } + std::cerr << "Qt version: " << qVersion() << '\n'; + std::cerr << "Qt platform (set QT_QPA_PLATFORM to override): " << QGuiApplication::platformName().toStdString() << '\n'; + std::cerr << "Qt locale: " << QLocale().name().toStdString() << '\n'; + std::cerr << "Qt library paths: " << QCoreApplication::libraryPaths().join(':').toStdString() << '\n'; + std::cerr << "Qt theme search paths: " << QIcon::themeSearchPaths().join(':').toStdString() << '\n'; + debugInfoLogged = true; + } } /*!