Warning, file /plasma/kinfocenter/src/CommandOutputContext.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0003 SPDX-FileCopyrightText: 2021-2022 Harald Sitter <sitter@kde.org> 0004 */ 0005 0006 #pragma once 0007 0008 #include <QMap> 0009 #include <QObject> 0010 #include <QUrl> 0011 0012 // Somewhat general-purpose command executor. This class runs the executable with arguments, collecting all its output 0013 // and potentially filtering it to limit the lines to only ones matching. 0014 class CommandOutputContext : public QObject 0015 { 0016 Q_OBJECT 0017 Q_PROPERTY(QString executable READ executableName CONSTANT) 0018 Q_PROPERTY(QStringList arguments READ arguments CONSTANT) 0019 // Output. With filter applied. 0020 Q_PROPERTY(QString text MEMBER m_text NOTIFY textChanged) 0021 // Filter string. Case in-sensitive. If lines do not contain the filter string they'll be removed from text. 0022 Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) 0023 // Ready when the underlying process has terminated 0024 Q_PROPERTY(bool ready MEMBER m_ready NOTIFY readyChanged) 0025 // Potential error description. Empty when there is no error to report. 0026 Q_PROPERTY(QString error MEMBER m_error NOTIFY errorChanged) 0027 // Extra explanatory text for error conditions. Empty when no explanatory text has been specified. 0028 Q_PROPERTY(QString explanation MEMBER m_explanation NOTIFY explanationChanged) 0029 // URL where the user can report a bug when there is an error. Empty when there is no error, or no applicable place to report a bug 0030 Q_PROPERTY(QUrl bugReportUrl MEMBER m_bugReportUrl CONSTANT) 0031 public: 0032 CommandOutputContext(const QStringList &findExecutables, const QString &executable, const QStringList &arguments, QObject *parent = nullptr); 0033 CommandOutputContext(const QString &executable, const QStringList &arguments, QObject *parent = nullptr); 0034 0035 QString executableName() const; 0036 QStringList arguments() const; 0037 0038 QString filter() const; 0039 void setFilter(const QString &filter); 0040 Q_SIGNAL void filterChanged(); 0041 0042 Q_SIGNALS: 0043 void textChanged(); 0044 void readyChanged(); 0045 void errorChanged(); 0046 void explanationChanged(); 0047 0048 private: 0049 void reset(); 0050 void load(); 0051 void setError(const QString &message, const QString &explanation); 0052 void setReady(); 0053 0054 const QString m_executableName; 0055 QString m_executablePath; 0056 QMap<QString, QString> m_foundExecutablePaths; 0057 const QStringList m_arguments; 0058 const QUrl m_bugReportUrl; 0059 0060 QStringList m_originalLines; 0061 0062 bool m_ready = false; 0063 QString m_error; 0064 QString m_explanation; 0065 0066 QString m_text; // possibly filtered 0067 QString m_filter; 0068 };