| 1 | /* |
| 2 | This file is part of the KDE project |
| 3 | SPDX-FileCopyrightText: 2025 Kai Uwe Broulik <kde@broulik.de> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef KINHIBITIONJOBTRACKER_H |
| 9 | #define KINHIBITIONJOBTRACKER_H |
| 10 | |
| 11 | #include <KJobTrackerInterface> |
| 12 | #include <kjobwidgets_export.h> |
| 13 | |
| 14 | #include <memory> |
| 15 | |
| 16 | class KJob; |
| 17 | class KInhibitionJobTrackerPrivate; |
| 18 | |
| 19 | /*! |
| 20 | * \class KInhibitionJobTracker |
| 21 | * |
| 22 | * \inmodule KJobWidgets |
| 23 | * |
| 24 | * \brief Block standby mode while a job is running. |
| 25 | * |
| 26 | * This job tracker will prevent the system from going into standby mode |
| 27 | * while a given job is running. This can be used to guard potentially lengthy |
| 28 | * operations, such as copying files, encoding videos, extracting archives, etc. |
| 29 | * |
| 30 | * When the job is started, a power management inhibition is posted after a |
| 31 | * short delay. When the job is paused, the inhibition is lifted until the job |
| 32 | * is resumed again. |
| 33 | * |
| 34 | * \since 6.18 |
| 35 | */ |
| 36 | class KJOBWIDGETS_EXPORT KInhibitionJobTracker : public KJobTrackerInterface |
| 37 | { |
| 38 | Q_OBJECT |
| 39 | |
| 40 | public: |
| 41 | /*! |
| 42 | * Creates a new KInhibitionJobTracker |
| 43 | * |
| 44 | * \a parent the parent object |
| 45 | */ |
| 46 | explicit KInhibitionJobTracker(QObject *parent = nullptr); |
| 47 | |
| 48 | /*! |
| 49 | * Creates a new KJobTrackerInterface |
| 50 | * |
| 51 | * \a parent the parent object |
| 52 | */ |
| 53 | ~KInhibitionJobTracker() override; |
| 54 | |
| 55 | /*! |
| 56 | * Register a new job in this tracker. |
| 57 | * |
| 58 | * \a job the job to register |
| 59 | */ |
| 60 | void registerJob(KJob *job) override; |
| 61 | |
| 62 | /*! |
| 63 | * Unregister a job from this tracker. |
| 64 | * |
| 65 | * \a job the job to unregister |
| 66 | */ |
| 67 | void unregisterJob(KJob *job) override; |
| 68 | |
| 69 | protected Q_SLOTS: |
| 70 | void finished(KJob *job) override; |
| 71 | void suspended(KJob *job) override; |
| 72 | void resumed(KJob *job) override; |
| 73 | void description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) override; |
| 74 | |
| 75 | private: |
| 76 | std::unique_ptr<KInhibitionJobTrackerPrivate> const d; |
| 77 | }; |
| 78 | |
| 79 | #endif // KINHIBITIONJOBTRACKER_H |
| 80 | |