KNotifications

knotificationrestrictions.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2006 Aaron Seigo <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef KDELIBS_KNOTIFICATIONRESTRICTIONS_H
9 #define KDELIBS_KNOTIFICATIONRESTRICTIONS_H
10 
11 #include <knotifications_export.h>
12 
13 #include <QObject>
14 
15 #include <memory>
16 
17 /**
18  * @class KNotificationRestrictions knotificationrestrictions.h KNotificationRestrictions
19  *
20  * KNotificationRestrictions provides a simple mechanism to avoid disruptions
21  * during full screen presentations or other use cases where the screensaver or
22  * desktop notifications are inappropriate.
23  *
24  * Using KNotificationRestrictions is quite straightforward: create an instance
25  * of KNotificationRestrictions, passing in the set of or'd flags representing
26  * the services that should be prevented from interrupting the user. When done
27  * (for instance when the presentation is complete) simply delete the
28  * KNotificationRestrictions object.
29  *
30  * Example: to ensure the screensaver does not turn on during a presentation:
31  * @code
32  * void MyApp::doPresentation()
33  * {
34  * KNotificationRestrictions restrict(KNotificationRestrictions::ScreenSaver);
35  * // show presentation
36  * }
37  * @endcode
38  */
39 class KNOTIFICATIONS_EXPORT KNotificationRestrictions : public QObject
40 {
41  Q_OBJECT
42 
43 public:
44  /**
45  * @enum Service
46  * @see Services
47  */
48  enum Service {
49  /**
50  * The baseline "don't disable anything" value.
51  */
52  NoServices = 0,
53  /**
54  * Causes the screensaver to be prevented from automatically
55  * turning on.
56  */
57  ScreenSaver = 1,
58  /**
59  * Causes instant messaging and email notifications to not appear.
60  *
61  * @note <b>not implemented yet</b>
62  */
63  MessagingPopups = 2,
64  /**
65  * Causes non-critical desktop messages to be suppressed.
66  *
67  * @note <b>not implemented yet</b>
68  */
69  Notifications = 4,
70  /**
71  * Causes all desktop notifications, including critical ones
72  * (such as as "battery low" warnings) to be suppressed.
73  *
74  * @note <b>not implemented yet</b>
75  */
76  CriticalNotifications = 8,
77  NonCriticalServices = ScreenSaver | MessagingPopups | Notifications,
78  AllServices = NonCriticalServices | CriticalNotifications,
79  };
80  /**
81  * Stores a combination of #Service values.
82  */
83  Q_DECLARE_FLAGS(Services, Service)
84 
85  /**
86  * Constructs a new service for restrict some services.
87  *
88  * @param control the services to be restricted
89  * @param parent the parent of this object
90  */
91  explicit KNotificationRestrictions(Services control = NonCriticalServices, QObject *parent = nullptr);
92  ~KNotificationRestrictions() override;
93 
94  /**
95  * Constructs a new service for restrict some services.
96  *
97  * @param control the services to be restricted
98  * @param reason the reason for restriction
99  * @param parent the parent of this object
100  */
101  // TODO KF6 make reason optional
102  explicit KNotificationRestrictions(Services control, const QString &reason, QObject *parent = nullptr);
103 
104 private:
105  class Private;
106  std::unique_ptr<Private> const d;
107 
108  Q_PRIVATE_SLOT(d, void screensaverFakeKeyEvent())
109 };
110 
111 Q_DECLARE_OPERATORS_FOR_FLAGS(KNotificationRestrictions::Services)
112 #endif
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:49:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.