From f1f21d4f35dce80d0482d773adadee8f2d4ef91c Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Sun, 21 Nov 2021 12:00:15 -0600 Subject: [PATCH] Add mode to hide/show system processes. --- src/QProcessInfo.cpp | 12 ++++++++-- src/QProcessInfo.h | 2 +- src/SeerSlashProcWidget.cpp | 3 ++- src/SeerSlashProcWidget.h | 10 ++++---- src/SeerSlashProcWidget.ui | 46 ++++++++++++++++++++++++------------- 5 files changed, 48 insertions(+), 25 deletions(-) diff --git a/src/QProcessInfo.cpp b/src/QProcessInfo.cpp index 1cc24d0..d931a6b 100644 --- a/src/QProcessInfo.cpp +++ b/src/QProcessInfo.cpp @@ -11,7 +11,7 @@ #include #include -QProcessList QProcessInfo::enumerate() { +QProcessList QProcessInfo::populate(bool showSystemProcesses) { QProcessList ret; @@ -90,7 +90,15 @@ QProcessList QProcessInfo::enumerate() { cmdline.close(); } - ret.push_back(info); + // Add the process to the list. If it is a system process ([]), only add it + // if we're allowed. + if (info.name()[0] == '[') { + if (showSystemProcesses == true) { + ret.push_back(info); + } + }else{ + ret.push_back(info); + } } } diff --git a/src/QProcessInfo.h b/src/QProcessInfo.h index 62d8ec1..cc632e6 100644 --- a/src/QProcessInfo.h +++ b/src/QProcessInfo.h @@ -10,7 +10,7 @@ class QProcessInfo { public: QProcessInfo(); - static QProcessList enumerate(); + static QProcessList populate(bool showSystemProcesses); uint32_t pid () const; void setPid (uint32_t pid); diff --git a/src/SeerSlashProcWidget.cpp b/src/SeerSlashProcWidget.cpp index 6008b8e..3aee25c 100644 --- a/src/SeerSlashProcWidget.cpp +++ b/src/SeerSlashProcWidget.cpp @@ -47,6 +47,7 @@ SeerSlashProcWidget::SeerSlashProcWidget (QWidget* parent) : QWidget(parent) { processTreeWidget->resizeColumnToContents(2); processTreeWidget->setSortingEnabled(true); processTreeWidget->clear(); + systemProcessesCheckBox->setChecked(false); // Connect things. QObject::connect(searchLineEdit, &QLineEdit::textChanged, this, &SeerSlashProcWidget::handleSearchLineEdit); @@ -97,7 +98,7 @@ void SeerSlashProcWidget::refresh () { QApplication::setOverrideCursor(Qt::BusyCursor); // Scan the /proc file system. - QProcessList list = QProcessInfo::enumerate(); + QProcessList list = QProcessInfo::populate(systemProcessesCheckBox->isChecked()); // Loop through each entry and add it to our view. processTreeWidget->clear(); diff --git a/src/SeerSlashProcWidget.h b/src/SeerSlashProcWidget.h index 99a2b6c..8880512 100644 --- a/src/SeerSlashProcWidget.h +++ b/src/SeerSlashProcWidget.h @@ -12,15 +12,15 @@ class SeerSlashProcWidget : public QWidget, protected Ui::SeerSlashProcWidgetFor explicit SeerSlashProcWidget (QWidget* parent = 0); ~SeerSlashProcWidget (); - int selectedPid () const; - QString selectedName () const; - QString selectedCommandLine () const; + int selectedPid () const; + QString selectedName () const; + QString selectedCommandLine () const; public slots: - void refresh (); + void refresh (); protected slots: - void handleSearchLineEdit (const QString& text); + void handleSearchLineEdit (const QString& text); protected: private: diff --git a/src/SeerSlashProcWidget.ui b/src/SeerSlashProcWidget.ui index 41aa4a8..61dded1 100644 --- a/src/SeerSlashProcWidget.ui +++ b/src/SeerSlashProcWidget.ui @@ -14,20 +14,7 @@ System Process Browser - - - - Search in the list of processes. "*" is allowed. - - - - - - Search... - - - - + Refresh the list of processes. @@ -36,11 +23,12 @@ - + + .. - + true @@ -65,6 +53,32 @@ + + + + Search in the list of processes. "*" is allowed. + + + + + + Search... + + + + + + + Show system processes or hide them. + + + System Processes + + + false + + +