1 | /* |
2 | SPDX-License-Identifier: LGPL-2.0-or-later |
3 | SPDX-FileCopyrightText: 2003 Marc Mutz <mutz@kde.org> |
4 | SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org> |
5 | */ |
6 | |
7 | #ifndef KCURSORSAVER_H |
8 | #define KCURSORSAVER_H |
9 | #include <kguiaddons_export.h> |
10 | |
11 | #include <QCursor> |
12 | |
13 | class KCursorSaverPrivate; |
14 | |
15 | /*! |
16 | * \class KCursorSaver |
17 | * \inmodule KGuiAddons |
18 | * \brief Class to temporarily set a mouse cursor and restore the previous one on destruction. |
19 | * |
20 | * Create a KCursorSaver object when you want to set the cursor. |
21 | * As soon as it gets out of scope, it will restore the original |
22 | * cursor. |
23 | * \code |
24 | * KCursorSaver saver(Qt::WaitCursor); |
25 | * ... long-running operation here ... |
26 | * \endcode |
27 | * \since 5.73 |
28 | */ |
29 | class KGUIADDONS_EXPORT KCursorSaver |
30 | { |
31 | public: |
32 | /*! |
33 | * Creates a KCursorSaver, setting the mouse cursor to \a shape. |
34 | */ |
35 | explicit KCursorSaver(Qt::CursorShape shape); |
36 | |
37 | KCursorSaver(KCursorSaver &&other); |
38 | |
39 | /*! |
40 | * restore the cursor |
41 | */ |
42 | ~KCursorSaver(); |
43 | |
44 | /*! |
45 | * call this to explicitly restore the cursor |
46 | */ |
47 | void restoreCursor(); |
48 | |
49 | KCursorSaver &operator=(KCursorSaver &&other); |
50 | |
51 | private: |
52 | KCursorSaver(KCursorSaver &other) = delete; |
53 | void operator=(const KCursorSaver &rhs) = delete; |
54 | KCursorSaverPrivate *const d; |
55 | }; |
56 | |
57 | #endif |
58 | |