2024-07-30 19:15:37 -04:00
|
|
|
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#include "processwatcher.h"
|
|
|
|
|
|
|
|
#include <KProcessList>
|
|
|
|
|
|
|
|
#include "moc_processwatcher.cpp"
|
|
|
|
|
2024-08-22 17:59:00 -04:00
|
|
|
ProcessWatcher::ProcessWatcher(const qint64 PID, QObject *parent)
|
|
|
|
: QObject(parent)
|
2024-07-30 19:15:37 -04:00
|
|
|
{
|
2024-08-22 17:59:00 -04:00
|
|
|
m_timer = new QTimer(this);
|
2024-07-30 19:15:37 -04:00
|
|
|
connect(m_timer, &QTimer::timeout, this, [this, PID] {
|
|
|
|
const auto info = KProcessList::processInfo(PID);
|
|
|
|
// If we can't find the PID, bail!
|
|
|
|
if (!info.isValid()) {
|
|
|
|
m_timer->stop();
|
|
|
|
deleteLater();
|
|
|
|
Q_EMIT finished();
|
|
|
|
}
|
|
|
|
});
|
2024-08-22 17:59:00 -04:00
|
|
|
m_timer->setInterval(std::chrono::seconds(5));
|
2024-07-30 19:15:37 -04:00
|
|
|
m_timer->start();
|
|
|
|
}
|