core: move crash/version debug info to one place

This commit is contained in:
outfoxxed 2026-03-14 00:30:53 -07:00
parent 4b77936c80
commit 1123d5ab4f
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
5 changed files with 89 additions and 46 deletions

View file

@ -41,6 +41,7 @@ qt_add_library(quickshell-core STATIC
colorquantizer.cpp
toolsupport.cpp
streamreader.cpp
debuginfo.cpp
)
qt_add_qml_module(quickshell-core

68
src/core/debuginfo.cpp Normal file
View file

@ -0,0 +1,68 @@
#include "debuginfo.hpp"
#include <fcntl.h>
#include <qconfig.h>
#include <qcontainerfwd.h>
#include <qdebug.h>
#include <qfile.h>
#include <qfloat16.h>
#include <qhashfunctions.h>
#include <qtversion.h>
#include <unistd.h>
#include "build.hpp"
namespace qs::debuginfo {
QString qsVersion() {
return QS_VERSION " (revision " GIT_REVISION ", distributed by " DISTRIBUTOR ")";
}
QString qtVersion() { return qVersion() % QStringLiteral(" (built against " QT_VERSION_STR ")"); }
QString systemInfo() {
QString info;
auto stream = QTextStream(&info);
stream << "/etc/os-release:";
auto osReleaseFile = QFile("/etc/os-release");
if (osReleaseFile.open(QFile::ReadOnly)) {
stream << '\n' << osReleaseFile.readAll() << '\n';
osReleaseFile.close();
} else {
stream << "FAILED TO OPEN\n";
}
stream << "/etc/lsb-release:";
auto lsbReleaseFile = QFile("/etc/lsb-release");
if (lsbReleaseFile.open(QFile::ReadOnly)) {
stream << '\n' << lsbReleaseFile.readAll();
lsbReleaseFile.close();
} else {
stream << "FAILED TO OPEN\n";
}
return info;
}
QString combinedInfo() {
QString info;
auto stream = QTextStream(&info);
stream << "===== Version Information =====\n";
stream << "Quickshell: " << qsVersion() << '\n';
stream << "Qt: " << qtVersion() << '\n';
stream << "\n===== Build Information =====\n";
stream << "Build Type: " << BUILD_TYPE << '\n';
stream << "Compiler: " << COMPILER << '\n';
stream << "Compile Flags: " << COMPILE_FLAGS << '\n';
stream << "Configuration:\n" << BUILD_CONFIGURATION << '\n';
stream << "\n===== System Information =====\n";
stream << systemInfo();
return info;
}
} // namespace qs::debuginfo

12
src/core/debuginfo.hpp Normal file
View file

@ -0,0 +1,12 @@
#pragma once
#include <qcontainerfwd.h>
namespace qs::debuginfo {
QString qsVersion();
QString qtVersion();
QString systemInfo();
QString combinedInfo();
} // namespace qs::debuginfo