File indexing completed on 2024-05-19 05:49:18

0001 /*
0002     SPDX-FileCopyrightText: 2007 Nicolas Ternisien <nicolas.ternisien@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "xsessionLogMode.h"
0008 
0009 #include <KLocalizedString>
0010 
0011 #include "ksystemlog_debug.h"
0012 
0013 #include "xsessionAnalyzer.h"
0014 #include "xsessionConfiguration.h"
0015 #include "xsessionConfigurationWidget.h"
0016 #include "xsessionItemBuilder.h"
0017 
0018 XSessionLogMode::XSessionLogMode()
0019     : LogMode(QStringLiteral(X_SESSION_LOG_MODE_ID), i18n("X Session Log"), QStringLiteral(X_SESSION_MODE_ICON))
0020 {
0021     d->logModeConfiguration = QSharedPointer<XSessionConfiguration>(new XSessionConfiguration());
0022 
0023     d->logModeConfigurationWidget = new XSessionConfigurationWidget();
0024 
0025     d->itemBuilder = new XSessionItemBuilder();
0026 
0027     d->action = createDefaultAction();
0028     d->action->setToolTip(i18n("Display the X Session log."));
0029     d->action->setWhatsThis(
0030         i18n("Displays the X Session log in the current tab. X Session log is the place where graphical programs "
0031              "write their output. See this log if you want to know why a program has crashed, or why your desktop "
0032              "environment (Plasma, Gnome, Unity, Xfce, LXQt, ...) has not started."));
0033 
0034     auto *configuration = logModeConfiguration<XSessionConfiguration *>();
0035     checkLogFilesPresence(QStringList() << configuration->xsessionPath());
0036 }
0037 
0038 XSessionLogMode::~XSessionLogMode()
0039 {
0040 }
0041 
0042 Analyzer *XSessionLogMode::createAnalyzer(const QVariant &options)
0043 {
0044     Q_UNUSED(options)
0045     return new XSessionAnalyzer(this);
0046 }
0047 
0048 QVector<LogFile> XSessionLogMode::createLogFiles()
0049 {
0050     auto *configuration = Globals::instance().findLogMode(QStringLiteral(X_SESSION_LOG_MODE_ID))->logModeConfiguration<XSessionConfiguration *>();
0051 
0052     const QVector<LogFile> logFiles{configuration->findGenericLogFile(configuration->xsessionPath())};
0053     return logFiles;
0054 }
0055 
0056 #include "moc_xsessionLogMode.cpp"