1
class TaskManager : QObject {
4
#include "core/taskmanager.h"
8
API for managing progress notifications in Clementine's status bar.
10
When you are performing a slow operation, such as downloading data from the
11
network or parsing a file, it is useful to be able to provide progress
12
information to the user. Clementine displays information about any running
13
tasks with a spinner animation in the status bar.
15
When you start a new task, the TaskManager will give you an ID which you must
16
keep and use again later to update the task's progress or to mark it as
19
This is a singleton class, you can access its methods directly through the
20
C{clementine.task_manager} object:
22
>>> id = clementine.task_manager.StartTask("Finding some awesome music")
23
>>> clementine.task_manager.SetTaskProgress(id, 33, 100)
24
>>> clementine.task_manager.SetTaskProgress(id, 66, 100)
25
>>> clementine.task_manager.SetTaskFinished(id)
27
@group Signals: TasksChanged, PauseLibraryWatchers, ResumeLibraryWatchers
33
Object containing information about a running task.
40
bool blocks_library_scans;
43
QList<TaskManager::Task> GetTasks();
45
GetTasks() -> list of L{Task}s
46
Returns a list of all the tasks that are currently running.
48
Modifying the items in this list will have no effect - you have to use the other
49
methods in this class to update the status of a task.
52
int StartTask(const QString& name);
54
StartTask(name) -> int
57
@param name: A descriptive name of the task that will be displayed in the
60
@return: A new ID for this task. Use this ID when calling L{SetTaskFinished}
62
@note: Do not include ellipsis (...) in the name of the task, this is added
63
for you by the status bar.
66
void SetTaskBlocksLibraryScans(int id);
68
SetTaskBlocksLibraryScans(id)
69
Forces any library scans to wait until this task is complete.
71
It may be useful to set this flag on a task that modifies files in the library.
72
The LibraryWatcher will wait until the task is complete before starting to
76
void SetTaskProgress(int id, int progress, int max = 0);
78
SetTaskProgress(id, progress, max=0)
79
Updates the progress for this task.
81
The status bar shows the percentage progress of this task, calculated by
82
C{(progress / max * 100)}. C{max} must be provided the first time this
83
method is called for a given task, but after that it can be omitted to keep the
87
void SetTaskFinished(int id);
90
Marks the given task as finished, removing it from the status bar.
97
Emitted when the list of tasks returned by L{GetTasks()} is changed.
100
void PauseLibraryWatchers();
102
PauseLibraryWatchers()
103
Emitted when L{SetTaskBlocksLibraryScans()} is called on a task.
106
void ResumeLibraryWatchers();
108
ResumeLibraryWatchers()
109
Emitted when all tasks that blocked library scans have finished.