|
Krita Source Code Documentation
|
#include <KisIdleTasksManager.h>
Inheritance diagram for KisIdleTasksManager:Classes | |
| struct | Private |
| struct | TaskGuard |
Public Member Functions | |
| TaskGuard | addIdleTaskWithGuard (KisIdleTaskStrokeStrategyFactory factory) |
| Registers the factory for the idle task. | |
| KisIdleTasksManager () | |
| void | setImage (KisImageSP image) |
| ~KisIdleTasksManager () | |
Private Slots | |
| void | slotImageIsIdle () |
| void | slotImageIsModified () |
| void | slotTaskIsCompleted () |
Private Member Functions | |
| int | addIdleTask (KisIdleTaskStrokeStrategyFactory factory) |
| void | removeIdleTask (int id) |
| void | triggerIdleTask (int id) |
Private Attributes | |
| QScopedPointer< Private > | m_d |
A special per-main-window manager that handles jobs that should be run in the background while the user is idle. The manager automatically restarts all the jobs when the image is modified. E.g. updates the overview image or histogram.
The manager is owned by KisViewManager, which automatically connects it to the currently active image. When the image becomes idle, the manager starts its tasks one-by-one.
If you want to add a new task to the manager, just provide a factory to addIdleTaskWithGuard() method. This factory should create and return a stroke strategy for the idle task to be run.
The factory will be called by the task manager every time when it thinks that the idle task should be started.
addIdleTaskWithGuard() returns a TaskGuard handle, which represents the registered task. It is a movable object that will automatically de-register the idle task on destruction.
If your idle-task-factory is a lambda object, make sure that the lifetime of the objects you capture into the lambda's closure is longer than the lifetime of the corresponding TaskGuard handle. In other words, if you capture this into your lambda, make sure that the corresponding TaskGuard also belongs to this or destroyed manually in the destructor.
Definition at line 46 of file KisIdleTasksManager.h.
| KisIdleTasksManager::KisIdleTasksManager | ( | ) |
Definition at line 36 of file KisIdleTasksManager.cpp.
References connect(), m_d, slotImageIsIdle(), and slotImageIsModified().
|
default |
|
private |
TODO: don't restart the whole queue on the the task change, just restart the currently added task
Definition at line 57 of file KisIdleTasksManager.cpp.
References m_d, and triggerIdleTask().
| KisIdleTasksManager::TaskGuard KisIdleTasksManager::addIdleTaskWithGuard | ( | KisIdleTaskStrokeStrategyFactory | factory | ) |
Registers the factory for the idle task.
The manager will use this factory to start the task after every image modification.
| factory | is a functor creating a KisIdleTaskStrokeStrategy that will actually execute the task |
Definition at line 107 of file KisIdleTasksManager.cpp.
References addIdleTask().
|
private |
Definition at line 74 of file KisIdleTasksManager.cpp.
References KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, and kismpl::mem_equal_to().
| void KisIdleTasksManager::setImage | ( | KisImageSP | image | ) |
Definition at line 45 of file KisIdleTasksManager.cpp.
References m_d, and slotImageIsModified().
|
privateslot |
Definition at line 121 of file KisIdleTasksManager.cpp.
References connect(), KisImage::endStroke(), KisIdleTaskStrokeStrategy::idleTaskCookie(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, kismpl::mem_equal_to(), slotTaskIsCompleted(), and KisImage::startStroke().
|
privateslot |
|
privateslot |
Definition at line 148 of file KisIdleTasksManager.cpp.
References m_d, and slotImageIsIdle().
|
private |
Definition at line 89 of file KisIdleTasksManager.cpp.
References KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, and kismpl::mem_equal_to().
|
private |
Definition at line 138 of file KisIdleTasksManager.h.