1 | /* |
2 | This file is part of the KDE project |
3 | SPDX-FileCopyrightText: 2000 Matej Koss <koss@miesto.sk> |
4 | SPDX-FileCopyrightText: 2007 Kevin Ottens <ervin@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-only |
7 | */ |
8 | |
9 | #ifndef KSTATUSBARJOBTRACKER_H |
10 | #define KSTATUSBARJOBTRACKER_H |
11 | |
12 | #include <kabstractwidgetjobtracker.h> |
13 | |
14 | class KStatusBarJobTrackerPrivate; |
15 | |
16 | /** |
17 | * @class KStatusBarJobTracker kstatusbarjobtracker.h KStatusBarJobTracker |
18 | * |
19 | * This class implements a job tracker with a widget suited for embedding in a |
20 | * status bar. |
21 | */ |
22 | class KJOBWIDGETS_EXPORT KStatusBarJobTracker : public KAbstractWidgetJobTracker |
23 | { |
24 | Q_OBJECT |
25 | |
26 | public: |
27 | /** |
28 | * @see StatusBarModes |
29 | */ |
30 | enum StatusBarMode { |
31 | NoInformation = 0x0000, ///< Does not show any information |
32 | LabelOnly = 0x0001, ///< Shows an informative label for job progress |
33 | ProgressOnly = 0x0002, ///< Shows a progress bar with the job completion |
34 | }; |
35 | |
36 | /** |
37 | * Stores a combination of #StatusBarMode values. |
38 | */ |
39 | Q_DECLARE_FLAGS(StatusBarModes, StatusBarMode) |
40 | |
41 | /** |
42 | * Creates a new KStatusBarJobTracker |
43 | * |
44 | * @param parent the parent of this object and of the widget displaying the job progresses |
45 | * @param button true to display a stop button allowing to kill the job, false otherwise |
46 | */ |
47 | explicit KStatusBarJobTracker(QWidget *parent = nullptr, bool button = true); |
48 | |
49 | /** |
50 | * Destroys a KStatusBarJobTracker |
51 | */ |
52 | ~KStatusBarJobTracker() override; |
53 | |
54 | /** |
55 | * Register a new job in this tracker. |
56 | * |
57 | * @param job the job to register |
58 | */ |
59 | void registerJob(KJob *job) override; |
60 | |
61 | /** |
62 | * Unregister a job from this tracker. |
63 | * |
64 | * @param job the job to unregister |
65 | */ |
66 | void unregisterJob(KJob *job) override; |
67 | |
68 | /** |
69 | * The widget associated to this tracker. |
70 | * |
71 | * @return the widget displaying the job progresses |
72 | */ |
73 | QWidget *widget(KJob *job) override; |
74 | |
75 | /** |
76 | * Sets the mode of the status bar. |
77 | * |
78 | * @param statusBarMode what information the status bar will show (see StatusBarMode). |
79 | * LabelOnly by default |
80 | */ |
81 | void setStatusBarMode(StatusBarModes statusBarMode); |
82 | |
83 | public Q_SLOTS: |
84 | /** |
85 | * The following slots are inherited from KJobTrackerInterface. |
86 | */ |
87 | virtual void description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) override; |
88 | void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) override; |
89 | void percent(KJob *job, unsigned long percent) override; |
90 | void speed(KJob *job, unsigned long value) override; |
91 | void slotClean(KJob *job) override; |
92 | |
93 | private: |
94 | Q_DECLARE_PRIVATE(KStatusBarJobTracker) |
95 | }; |
96 | |
97 | Q_DECLARE_OPERATORS_FOR_FLAGS(KStatusBarJobTracker::StatusBarModes) |
98 | |
99 | #endif |
100 | |