Libplasma

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

KDE's Doxygen guidelines are available online.