mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-22 20:47:45 +00:00
Small improvements to the ProcessWatcher API
Changes the PID parameter to qint64 to be consistent with KProcessList and QProcess. Also adds a QObject parent parameter.
This commit is contained in:
parent
1b1dca1bfb
commit
2ee0606a56
2 changed files with 5 additions and 5 deletions
|
@ -3,7 +3,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
/// Listens and waits for a process to finish.
|
||||
|
@ -11,7 +10,7 @@ class ProcessWatcher : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProcessWatcher(const int PID);
|
||||
explicit ProcessWatcher(qint64 PID, QObject *parent = nullptr);
|
||||
|
||||
Q_SIGNALS:
|
||||
void finished();
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
|
||||
#include "moc_processwatcher.cpp"
|
||||
|
||||
ProcessWatcher::ProcessWatcher(const int PID)
|
||||
ProcessWatcher::ProcessWatcher(const qint64 PID, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_timer = new QTimer();
|
||||
m_timer = new QTimer(this);
|
||||
connect(m_timer, &QTimer::timeout, this, [this, PID] {
|
||||
const auto info = KProcessList::processInfo(PID);
|
||||
// If we can't find the PID, bail!
|
||||
|
@ -19,6 +20,6 @@ ProcessWatcher::ProcessWatcher(const int PID)
|
|||
Q_EMIT finished();
|
||||
}
|
||||
});
|
||||
m_timer->setInterval(std::chrono::seconds(30));
|
||||
m_timer->setInterval(std::chrono::seconds(5));
|
||||
m_timer->start();
|
||||
}
|
Loading…
Add table
Reference in a new issue