From 5986afe4b924a5215cce4a43752aa6405471a960 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Thu, 7 Nov 2024 15:34:27 +0200 Subject: [PATCH] Add XDG_SESSION_TYPE to diagnostics IB-8134 Signed-off-by: Raul Metsma --- client/Diagnostics_unix.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/client/Diagnostics_unix.cpp b/client/Diagnostics_unix.cpp index 0cb612322..d36da789a 100644 --- a/client/Diagnostics_unix.cpp +++ b/client/Diagnostics_unix.cpp @@ -90,8 +90,7 @@ void Diagnostics::run() info.clear(); #ifndef Q_OS_DARWIN - QStringList package = packages({"open-eid"}, false); - if( !package.isEmpty() ) + if(QStringList package = packages({"open-eid"}, false); !package.isEmpty()) s << "" << tr("Base version:") << " " << package.first() << "
"; #endif s << "" << tr("Application version:") << " " << QCoreApplication::applicationVersion() << " (" << QSysInfo::WordSize << " bit)
"; @@ -101,13 +100,10 @@ void Diagnostics::run() s << "" << tr("OS:") << " " << Common::applicationOs() << "
"; #ifndef Q_OS_DARWIN s << "" << tr("CPU:") << " "; - QFile f( "/proc/cpuinfo" ); - if( f.open( QFile::ReadOnly ) ) + if(QFile f("/proc/cpuinfo"); f.open(QFile::ReadOnly)) { - QRegularExpression rx(QStringLiteral("model name.*\\: (.*)\n")); - rx.setPatternOptions(QRegularExpression::InvertedGreedinessOption); - QRegularExpressionMatch match = rx.match(QString::fromLocal8Bit(f.readAll())); - if(match.hasMatch()) + static const QRegularExpression rx(QStringLiteral("model name.*\\: (.*)\n"), QRegularExpression::InvertedGreedinessOption); + if(QRegularExpressionMatch match = rx.match(QString::fromLocal8Bit(f.readAll())); match.hasMatch()) s << match.captured(1); } s << "
"; @@ -140,8 +136,9 @@ void Diagnostics::run() info.clear(); #ifndef Q_OS_DARWIN - QStringList browsers = packages({"chromium-browser", "firefox", "MozillaFirefox", "google-chrome-stable"}); - if( !browsers.isEmpty() ) + s << "

XDG_SESSION_TYPE: " << qEnvironmentVariable("XDG_SESSION_TYPE"); + + if(QStringList browsers = packages({"chromium-browser", "firefox", "MozillaFirefox", "google-chrome-stable"}); !browsers.isEmpty()) s << "

" << tr("Browsers:") << "
" << browsers.join(QStringLiteral("
")) << "

"; emit update( info ); info.clear(); @@ -149,8 +146,7 @@ void Diagnostics::run() QProcess p; p.start(QStringLiteral("lsusb"), QStringList()); p.waitForFinished(); - QString cmd = QString::fromLocal8Bit( p.readAll() ); - if( !cmd.isEmpty() ) + if(QString cmd = QString::fromLocal8Bit(p.readAll()); !cmd.isEmpty()) s << "" << tr("USB info:") << "
" << cmd.replace( "\n", "
" ) << "
"; emit update( info ); info.clear();