Plasma

containmentactions.h
1 /*
2  SPDX-FileCopyrightText: 2009 Chani Armitage <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef PLASMA_CONTAINMENTACTIONS_H
8 #define PLASMA_CONTAINMENTACTIONS_H
9 
10 #include <QList>
11 
12 #include <plasma/plasma_export.h>
13 #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 94)
14 #include <KPluginInfo>
15 #endif
16 
17 #include <plasma/plasma.h>
18 
19 class QAction;
20 class KPluginMetaData;
21 class KConfigGroup;
22 
23 namespace Plasma
24 {
25 class DataEngine;
26 class Containment;
27 class ContainmentActionsPrivate;
28 
29 /**
30  * @class ContainmentActions plasma/containmentactions.h <Plasma/ContainmentActions>
31  *
32  * @short The base ContainmentActions class
33  *
34  * "ContainmentActions" are components that provide actions (usually displaying a contextmenu) in
35  * response to an event with a position (usually a mouse event).
36  *
37  * ContainmentActions plugins are registered using .desktop files. These files should be
38  * named using the following naming scheme:
39  *
40  * plasma-containmentactions-<pluginname>.desktop
41  *
42  */
43 
44 class PLASMA_EXPORT ContainmentActions : public QObject
45 {
46  Q_OBJECT
47 
48 public:
49  /**
50  * Default constructor for an empty or null containmentactions
51  */
52  explicit ContainmentActions(QObject *parent = nullptr);
53 
54  ~ContainmentActions() override;
55 
56 #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 67)
57  /**
58  * @return the plugin info for this ContainmentActions instance,
59  * including name, pluginName and icon
60  * @since 5.0
61  *
62  * @deprecated since 5.67, use metadata
63  */
64  PLASMA_DEPRECATED_VERSION(5, 67, "use metadata()")
65  KPluginInfo pluginInfo() const;
66 #endif
67 
68  /**
69  * @return metadata for this ContainmentActions instance
70  * including name, pluginName and icon
71  * @since 5.67
72  */
73  KPluginMetaData metadata() const;
74 
75  /**
76  * This method should be called once the plugin is loaded or settings are changed.
77  * @param config Config group to load settings
78  * @see init
79  **/
80  virtual void restore(const KConfigGroup &config);
81 
82  /**
83  * This method is called when settings need to be saved.
84  * @param config Config group to save settings
85  **/
86  virtual void save(KConfigGroup &config);
87 
88  /**
89  * Returns the widget used in the configuration dialog.
90  * Add the configuration interface of the containmentactions to this widget.
91  */
92  virtual QWidget *createConfigurationInterface(QWidget *parent);
93 
94  /**
95  * This method is called when the user's configuration changes are accepted
96  */
97  virtual void configurationAccepted();
98 
99  /**
100  * Called when a "next" action is triggered (e.g. by mouse wheel scroll). This
101  * can be used to scroll through a list of items this plugin manages such as
102  * windows, virtual desktops, activities, etc.
103  * @see performPrevious
104  */
105  virtual void performNextAction();
106 
107  /**
108  * Called when a "previous" action is triggered (e.g. by mouse wheel scroll). This
109  * can be used to scroll through a list of items this plugin manages such as
110  * windows, virtual desktops, activities, etc.
111  * @see performNext
112  */
113  virtual void performPreviousAction();
114 
115  /**
116  * Implement this to provide a list of actions that can be added to another menu
117  * for example, when right-clicking an applet, the "Activity Options" submenu is populated
118  * with this.
119  */
120  virtual QList<QAction *> contextualActions();
121 
122  /**
123  * Turns a mouse or wheel event into a string suitable for a ContainmentActions
124  * @return the string representation of the event
125  */
126  static QString eventToString(QEvent *event);
127 
128  /**
129  * @p newContainment the containment the plugin should be associated with.
130  * @since 4.6
131  */
132  void setContainment(Containment *newContainment);
133 
134  /**
135  * @return the containment the plugin is associated with.
136  */
137  Containment *containment();
138 
139 protected:
140  /**
141  * This constructor is to be used with the plugin loading systems
142  * found in KPluginInfo and KService. The argument list is expected
143  * to have one element: the KService service ID for the desktop entry.
144  *
145  * @param parent a QObject parent; you probably want to pass in 0
146  * @param args a list of strings containing one entry: the service id
147  */
148  ContainmentActions(QObject *parent, const QVariantList &args);
149 
150 private:
151  ContainmentActionsPrivate *const d;
152 };
153 
154 } // Plasma namespace
155 
156 #if PLASMA_ENABLE_DEPRECATED_SINCE(5, 88)
157 /**
158  * Register a containmentactions when it is contained in a loadable module
159  * @deprecated Since 5.88, use K_PLUGIN_CLASS_WITH_JSON instead
160  */
161 /* clang-format off */
162 #define K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON(libname, classname, jsonFile) \
163  K_PLUGIN_FACTORY_WITH_JSON(factory, jsonFile, registerPlugin<classname>();)
164 /* clang-format on */
165 #endif
166 
167 #endif // PLASMA_CONTAINMENTACTIONS_H
Namespace for everything in libplasma.
Definition: datamodel.cpp:14
The base ContainmentActions class.
The base class for plugins that provide backgrounds and applet grouping containers.
Definition: containment.h:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 04:17:13 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.