Warning, file /plasma/drkonqi/src/coredump/gui/main.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2020-2022 Harald Sitter <sitter@kde.org> 0003 0004 #include <QApplication> 0005 #include <QCommandLineParser> 0006 #include <QDebug> 0007 #include <QIcon> 0008 #include <QQmlApplicationEngine> 0009 #include <QQmlContext> 0010 0011 #include <KAboutData> 0012 #include <KConfigGroup> 0013 #include <KLocalizedString> 0014 0015 #include <config-drkonqi.h> 0016 #include <coredumpwatcher.h> 0017 0018 #include "DetailsLoader.h" 0019 #include "Patient.h" 0020 #include "PatientModel.h" 0021 0022 int main(int argc, char *argv[]) 0023 { 0024 QApplication app(argc, argv); 0025 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0026 app.setAttribute(Qt::AA_UseHighDpiPixmaps, true); 0027 #endif 0028 app.setApplicationName(QStringLiteral("drkonqi-coredump-gui")); 0029 app.setOrganizationDomain(QStringLiteral("kde.org")); 0030 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("tools-report-bug"), app.windowIcon())); 0031 0032 KAboutData aboutData(QStringLiteral("drkonqi"), 0033 i18nc("@title CLI title", "DrKonqi Intensive Care"), 0034 QString::fromLatin1(PROJECT_VERSION), 0035 i18nc("@info program description", "Offers detailed view of past crashes"), 0036 KAboutLicense::GPL, 0037 i18n("(C) 2020-2022, The DrKonqi Authors")); 0038 aboutData.setDesktopFileName(QStringLiteral("org.kde.drkonqi.coredump.gui")); 0039 KAboutData::setApplicationData(aboutData); 0040 0041 QCommandLineParser parser; 0042 aboutData.setupCommandLine(&parser); 0043 parser.process(app); 0044 aboutData.processCommandLine(&parser); 0045 0046 PatientModel model(Patient::staticMetaObject); 0047 qmlRegisterSingletonInstance("org.kde.drkonqi.coredump.gui", 1, 0, "PatientModel", &model); 0048 qmlRegisterType<DetailsLoader>("org.kde.drkonqi.coredump.gui", 1, 0, "DetailsLoader"); 0049 0050 KLocalizedContext i18nContext; 0051 i18nContext.setTranslationDomain(QStringLiteral(TRANSLATION_DOMAIN)); 0052 0053 QQmlApplicationEngine engine; 0054 engine.rootContext()->setContextObject(&i18nContext); 0055 0056 const QUrl url(QStringLiteral("qrc:/main.qml")); 0057 QObject::connect( 0058 &engine, 0059 &QQmlApplicationEngine::objectCreated, 0060 &app, 0061 [url](QObject *obj, const QUrl &objUrl) { 0062 if (!obj && url == objUrl) { 0063 qWarning() << "ABORT ABORT"; 0064 QCoreApplication::exit(-1); 0065 } 0066 }, 0067 Qt::QueuedConnection); 0068 engine.load(url); 0069 0070 auto expectedJournal = owning_ptr_call<sd_journal>(sd_journal_open, SD_JOURNAL_LOCAL_ONLY); 0071 Q_ASSERT(expectedJournal.ret == 0); 0072 Q_ASSERT(expectedJournal.value); 0073 CoredumpWatcher watcher(std::move(expectedJournal.value), {}, {}, nullptr); 0074 QObject::connect(&watcher, &CoredumpWatcher::newDump, &model, [&](const Coredump &dump) { 0075 model.addObject(std::make_unique<Patient>(dump)); 0076 }); 0077 QObject::connect(&watcher, &CoredumpWatcher::atLogEnd, &model, [&]() { 0078 model.setReady(true); 0079 }); 0080 watcher.metaObject()->invokeMethod(&watcher, &CoredumpWatcher::start, Qt::QueuedConnection); 0081 0082 return app.exec(); 0083 }