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{
42 Q_OBJECT
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 * @return metadata for this ContainmentActions instance
54 * including name, pluginName and icon
55 * @since 5.67
56 */
57 KPluginMetaData metadata() const;
58
59 /**
60 * This method should be called once the plugin is loaded or settings are changed.
61 * @param config Config group to load settings
62 * @see init
63 **/
64 virtual void restore(const KConfigGroup &config);
65
66 /**
67 * This method is called when settings need to be saved.
68 * @param config Config group to save settings
69 **/
70 virtual void save(KConfigGroup &config);
71
72 /**
73 * Returns the widget used in the configuration dialog.
74 * Add the configuration interface of the containmentactions to this widget.
75 */
76 virtual QWidget *createConfigurationInterface(QWidget *parent);
77
78 /**
79 * This method is called when the user's configuration changes are accepted
80 */
81 virtual void configurationAccepted();
82
83 /**
84 * Called when a "next" action is triggered (e.g. by mouse wheel scroll). This
85 * can be used to scroll through a list of items this plugin manages such as
86 * windows, virtual desktops, activities, etc.
87 * @see performPrevious
88 */
89 virtual void performNextAction();
90
91 /**
92 * Called when a "previous" action is triggered (e.g. by mouse wheel scroll). This
93 * can be used to scroll through a list of items this plugin manages such as
94 * windows, virtual desktops, activities, etc.
95 * @see performNext
96 */
97 virtual void performPreviousAction();
98
99 /**
100 * Implement this to provide a list of actions that can be added to another menu
101 * for example, when right-clicking an applet, the "Activity Options" submenu is populated
102 * with this.
103 */
104 virtual QList<QAction *> contextualActions();
105
106 /**
107 * Turns a mouse or wheel event into a string suitable for a ContainmentActions
108 * @return the string representation of the event
109 */
110 static QString eventToString(QEvent *event);
111
112 /**
113 * @p newContainment the containment the plugin should be associated with.
114 * @since 4.6
115 */
116 void setContainment(Containment *newContainment);
117
118 /**
119 * @return the containment the plugin is associated with.
120 */
121 Containment *containment();
122
123protected:
124 /**
125 * This constructor is to be used with the plugin loading systems
126 * found in KPluginInfo and KService. The argument list is expected
127 * to have one element: the KService service ID for the desktop entry.
128 *
129 * @param parent a QObject parent; you probably want to pass in 0
130 * @param args a list of strings containing one entry: the service id
131 */
132 ContainmentActions(QObject *parent, const QVariantList &args);
133
134private:
135 ContainmentActionsPrivate *const d;
136};
137
138} // Plasma namespace
139
140#endif // PLASMA_CONTAINMENTACTIONS_H
The base ContainmentActions class.
The base class for plugins that provide backgrounds and applet grouping containers.
Definition containment.h:47
Namespace for everything in libplasma.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:34:35 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.