KAuth

kauthobjectdecorator.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2009-2012 Dario Freddi <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef OBJECTDECORATOR_H
9 #define OBJECTDECORATOR_H
10 
11 #include <QObject>
12 #include <kauthaction.h>
13 
14 #include <kauth_export.h>
15 
16 namespace KAuth
17 {
18 class ObjectDecoratorPrivate;
19 
20 /**
21  * @class ObjectDecorator kauthobjectdecorator.h <KAuthObjectDecorator>
22  *
23  * @brief A decorator to add auth features to a button or an action
24  *
25  * @author Dario Freddi <[email protected]>
26  */
27 class KAUTH_EXPORT ObjectDecorator : public QObject
28 {
29  Q_OBJECT
30 public:
31  /**
32  * Instantiate a new decorator attached to an object
33  *
34  * @param parent The parent object this decorator will be attached to
35  */
36  explicit ObjectDecorator(QObject *parent);
37 
38  /**
39  * Destructs the decorator
40  */
41  ~ObjectDecorator();
42 
43  /**
44  * Returns the action object associated with this decorator, or 0 if it does not have one
45  *
46  * @returns the KAuth::Action associated with this decorator.
47  */
48  KAuth::Action authAction() const;
49 
50  /**
51  * Sets the action object associated with this decorator
52  *
53  * By setting a KAuth::Action, this decorator will become associated with it, and
54  * whenever the action or button it is attached to gets clicked, it will trigger the
55  * authorization and execution process for the action.
56  * Pass 0 to this function to disassociate the decorator
57  *
58  * @param action the KAuth::Action to associate with this decorator.
59  */
60  void setAuthAction(const KAuth::Action &action);
61 
62  /**
63  * Sets the action object associated with this decorator
64  *
65  * Overloaded member to allow creating the action by name
66  *
67  * @param actionName the name of the action to associate
68  */
69  void setAuthAction(const QString &actionName);
70 
71 Q_SIGNALS:
72  /**
73  * Signal emitted when the action is authorized
74  *
75  * If the decorator needs authorization, whenever the user triggers it,
76  * the authorization process automatically begins.
77  * If it succeeds, this signal is emitted. The KAuth::Action object is provided for convenience
78  * if you have multiple Action objects, but of course it's always the same set with
79  * setAuthAction().
80  *
81  * WARNING: If your button or action needs authorization you should connect eventual slots
82  * processing stuff to this signal, and NOT clicked/triggered. Clicked/triggered will be emitted
83  * even if the user has not been authorized
84  *
85  * @param action The object set with setAuthAction()
86  */
87  void authorized(const KAuth::Action &action);
88 
89 private:
90  friend class ObjectDecoratorPrivate;
91  ObjectDecoratorPrivate *const d;
92 
93  Q_PRIVATE_SLOT(d, void slotActivated())
94  Q_PRIVATE_SLOT(d, void authStatusChanged(KAuth::Action::AuthStatus))
95 };
96 
97 } // namespace KAuth
98 
99 #endif // OBJECTDECORATOR_H
A decorator to add auth features to a button or an action.
AuthStatus
The three values set by authorization methods.
Definition: kauthaction.h:77
Class to access, authorize and execute actions.
Definition: kauthaction.h:70
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Oct 21 2021 22:53:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.