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 |
18 | * |
19 | * \inmodule KJobWidgets |
20 | * |
21 | * \brief This class implements a job tracker with a widget suited for embedding in a |
22 | * status bar. |
23 | */ |
24 | class KJOBWIDGETS_EXPORT KStatusBarJobTracker : public KAbstractWidgetJobTracker |
25 | { |
26 | Q_OBJECT |
27 | |
28 | public: |
29 | /*! |
30 | * \value NoInformation Does not show any information |
31 | * \value LabelOnly Shows an informative label for job progress |
32 | * \value ProgressOnly Shows a progress bar with the job completion |
33 | */ |
34 | enum StatusBarMode { |
35 | NoInformation = 0x0000, |
36 | LabelOnly = 0x0001, |
37 | ProgressOnly = 0x0002, |
38 | }; |
39 | Q_DECLARE_FLAGS(StatusBarModes, StatusBarMode) |
40 | |
41 | /*! |
42 | * Creates a new KStatusBarJobTracker |
43 | * |
44 | * \a parent the parent of this object and of the widget displaying the job progresses |
45 | * |
46 | * \a button true to display a stop button allowing to kill the job, false otherwise |
47 | */ |
48 | explicit KStatusBarJobTracker(QWidget *parent = nullptr, bool button = true); |
49 | |
50 | ~KStatusBarJobTracker() override; |
51 | |
52 | void registerJob(KJob *job) override; |
53 | |
54 | void unregisterJob(KJob *job) override; |
55 | |
56 | QWidget *widget(KJob *job) override; |
57 | |
58 | /*! |
59 | * Sets the mode of the status bar. |
60 | * |
61 | * \a statusBarMode what information the status bar will show (see StatusBarMode). |
62 | * LabelOnly by default |
63 | */ |
64 | void setStatusBarMode(StatusBarModes statusBarMode); |
65 | |
66 | public Q_SLOTS: |
67 | void description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) override; |
68 | void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) override; |
69 | void percent(KJob *job, unsigned long percent) override; |
70 | void speed(KJob *job, unsigned long value) override; |
71 | void slotClean(KJob *job) override; |
72 | |
73 | private: |
74 | Q_DECLARE_PRIVATE(KStatusBarJobTracker) |
75 | }; |
76 | |
77 | Q_DECLARE_OPERATORS_FOR_FLAGS(KStatusBarJobTracker::StatusBarModes) |
78 | |
79 | #endif |
80 | |