2009-08-18 00:30:29 +02:00
|
|
|
/*
|
2009-08-18 00:31:18 +02:00
|
|
|
* Copyright (c) 2009 Chani Armitage <chani@kde.org>
|
2009-08-18 00:30:29 +02:00
|
|
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2009-12-27 23:16:11 +01:00
|
|
|
#ifndef PLASMA_CONTAINMENTACTIONS_H
|
|
|
|
#define PLASMA_CONTAINMENTACTIONS_H
|
2009-08-18 00:30:29 +02:00
|
|
|
|
2009-08-18 00:30:46 +02:00
|
|
|
#include <QList>
|
|
|
|
|
2009-08-18 00:30:29 +02:00
|
|
|
#include <kplugininfo.h>
|
|
|
|
|
|
|
|
#include <plasma/plasma.h>
|
|
|
|
#include <plasma/version.h>
|
|
|
|
|
2009-08-18 00:30:46 +02:00
|
|
|
class QAction;
|
|
|
|
|
2009-08-18 00:30:29 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2009-08-18 00:31:23 +02:00
|
|
|
class DataEngine;
|
2009-08-18 00:30:46 +02:00
|
|
|
class Containment;
|
2009-08-18 00:31:32 +02:00
|
|
|
class ContainmentActionsPrivate;
|
2009-08-18 00:30:29 +02:00
|
|
|
|
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* @class ContainmentActions plasma/containmentactions.h <Plasma/ContainmentActions>
|
2009-08-18 00:30:29 +02:00
|
|
|
*
|
2009-08-18 00:31:32 +02:00
|
|
|
* @short The base ContainmentActions class
|
2009-08-18 00:30:29 +02:00
|
|
|
*
|
2009-08-18 00:31:32 +02:00
|
|
|
* "ContainmentActions" are components that provide actions (usually displaying a contextmenu) in
|
2009-08-18 00:30:29 +02:00
|
|
|
* response to an event with a position (usually a mouse event).
|
|
|
|
*
|
2009-08-18 00:31:32 +02:00
|
|
|
* ContainmentActions plugins are registered using .desktop files. These files should be
|
2009-08-18 00:30:29 +02:00
|
|
|
* named using the following naming scheme:
|
|
|
|
*
|
2009-08-18 00:31:32 +02:00
|
|
|
* plasma-containmentactions-\<pluginname\>.desktop
|
2009-08-18 00:30:29 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-08-18 00:31:32 +02:00
|
|
|
class PLASMA_EXPORT ContainmentActions : public QObject
|
2009-08-18 00:30:29 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QString name READ name)
|
|
|
|
Q_PROPERTY(QString pluginName READ pluginName)
|
|
|
|
Q_PROPERTY(QString icon READ icon)
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* Default constructor for an empty or null containmentactions
|
2009-08-18 00:30:29 +02:00
|
|
|
*/
|
2009-08-18 00:31:32 +02:00
|
|
|
explicit ContainmentActions(QObject * parent = 0);
|
2009-08-18 00:30:29 +02:00
|
|
|
|
2009-08-18 00:31:32 +02:00
|
|
|
~ContainmentActions();
|
2009-08-18 00:30:29 +02:00
|
|
|
|
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* Returns the user-visible name for the containmentactions, as specified in the
|
2009-08-18 00:30:29 +02:00
|
|
|
* .desktop file.
|
|
|
|
*
|
2009-08-18 00:31:32 +02:00
|
|
|
* @return the user-visible name for the containmentactions.
|
2009-08-18 00:30:29 +02:00
|
|
|
**/
|
|
|
|
QString name() const;
|
|
|
|
|
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* Returns the plugin name for the containmentactions
|
2009-08-18 00:30:29 +02:00
|
|
|
*/
|
|
|
|
QString pluginName() const;
|
|
|
|
|
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* Returns the icon related to this containmentactions
|
2009-08-18 00:30:29 +02:00
|
|
|
**/
|
|
|
|
QString icon() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if initialized (usually by calling restore), false otherwise
|
|
|
|
*/
|
|
|
|
bool isInitialized() const;
|
|
|
|
|
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* This method should be called once the plugin is loaded or settings are changed.
|
2009-08-18 00:30:29 +02:00
|
|
|
* @param config Config group to load settings
|
|
|
|
* @see init
|
|
|
|
**/
|
|
|
|
void restore(const KConfigGroup &config);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is called when settings need to be saved.
|
|
|
|
* @param config Config group to save settings
|
|
|
|
**/
|
|
|
|
virtual void save(KConfigGroup &config);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the widget used in the configuration dialog.
|
2009-08-18 00:31:32 +02:00
|
|
|
* Add the configuration interface of the containmentactions to this widget.
|
2009-08-18 00:30:29 +02:00
|
|
|
*/
|
|
|
|
virtual QWidget *createConfigurationInterface(QWidget *parent);
|
|
|
|
|
2009-08-18 00:30:54 +02:00
|
|
|
/**
|
|
|
|
* This method is called when the user's configuration changes are accepted
|
|
|
|
*/
|
|
|
|
virtual void configurationAccepted();
|
|
|
|
|
2009-08-18 00:30:29 +02:00
|
|
|
/**
|
2009-08-18 00:30:58 +02:00
|
|
|
* Implement this to respond to events.
|
2009-08-18 00:30:29 +02:00
|
|
|
* The user can configure whatever button and modifier they like, so please don't look at
|
|
|
|
* those parameters.
|
2010-09-08 23:48:46 +02:00
|
|
|
* The event may be a QGraphicsSceneMouseEvent or a QGraphicsSceneWheelEvent.
|
2009-08-18 00:30:29 +02:00
|
|
|
*/
|
2009-08-18 00:30:58 +02:00
|
|
|
virtual void contextEvent(QEvent *event);
|
2009-08-18 00:30:29 +02:00
|
|
|
|
2009-08-18 00:30:46 +02:00
|
|
|
/**
|
|
|
|
* Implement this to provide a list of actions that can be added to another menu
|
|
|
|
* for example, when right-clicking an applet, the "Activity Options" submenu is populated
|
|
|
|
* with this.
|
|
|
|
*/
|
|
|
|
virtual QList<QAction*> contextualActions();
|
|
|
|
|
2009-08-18 00:31:23 +02:00
|
|
|
/**
|
|
|
|
* Loads the given DataEngine
|
|
|
|
*
|
|
|
|
* Tries to load the data engine given by @p name. Each engine is
|
|
|
|
* only loaded once, and that instance is re-used on all subsequent
|
|
|
|
* requests.
|
|
|
|
*
|
|
|
|
* If the data engine was not found, an invalid data engine is returned
|
|
|
|
* (see DataEngine::isValid()).
|
|
|
|
*
|
|
|
|
* Note that you should <em>not</em> delete the returned engine.
|
|
|
|
*
|
|
|
|
* @param name Name of the data engine to load
|
|
|
|
* @return pointer to the data engine if it was loaded,
|
|
|
|
* or an invalid data engine if the requested engine
|
|
|
|
* could not be loaded
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE DataEngine *dataEngine(const QString &name) const;
|
|
|
|
|
2009-08-18 00:30:29 +02:00
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* @return true if the containmentactions currently needs to be configured,
|
2009-08-18 00:30:29 +02:00
|
|
|
* otherwise, false
|
|
|
|
*/
|
|
|
|
bool configurationRequired() const;
|
|
|
|
|
2009-08-18 00:31:08 +02:00
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* Turns a mouse or wheel event into a string suitable for a ContainmentActions
|
2009-08-18 00:30:58 +02:00
|
|
|
* @return the string representation of the event
|
2009-08-18 00:30:46 +02:00
|
|
|
*/
|
2009-08-18 00:30:58 +02:00
|
|
|
static QString eventToString(QEvent *event);
|
2009-08-18 00:30:46 +02:00
|
|
|
|
2010-09-09 00:30:21 +02:00
|
|
|
/**
|
|
|
|
* Returns a popup position appropriate to the event and the size.
|
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param s size of the popup
|
|
|
|
* @param event a pointer to the event that triggered the popup
|
2010-09-09 00:30:21 +02:00
|
|
|
* @return the preferred top-left position for the popup
|
|
|
|
* @since 4.6
|
|
|
|
*/
|
|
|
|
QPoint popupPosition(const QSize &s, QEvent *event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @reimplemented
|
|
|
|
*/
|
2009-08-23 03:13:36 +02:00
|
|
|
bool event(QEvent *e);
|
|
|
|
|
2010-11-11 23:22:39 +01:00
|
|
|
/**
|
|
|
|
* @p newContainment the containment the plugin should be associated with.
|
|
|
|
* @since 4.6
|
|
|
|
*/
|
|
|
|
void setContainment(Containment *newContainment);
|
|
|
|
|
2009-08-18 00:30:29 +02:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* This constructor is to be used with the plugin loading systems
|
|
|
|
* found in KPluginInfo and KService. The argument list is expected
|
|
|
|
* to have one element: the KService service ID for the desktop entry.
|
|
|
|
*
|
|
|
|
* @param parent a QObject parent; you probably want to pass in 0
|
|
|
|
* @param args a list of strings containing one entry: the service id
|
|
|
|
*/
|
2009-08-18 00:31:32 +02:00
|
|
|
ContainmentActions(QObject *parent, const QVariantList &args);
|
2009-08-18 00:30:29 +02:00
|
|
|
|
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* This method is called once the containmentactions is loaded or settings are changed.
|
2009-08-18 00:30:29 +02:00
|
|
|
*
|
|
|
|
* @param config Config group to load settings
|
|
|
|
**/
|
|
|
|
virtual void init(const KConfigGroup &config);
|
|
|
|
|
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* When the containmentactions needs to be configured before being usable, this
|
2009-08-18 00:30:29 +02:00
|
|
|
* method can be called to denote that action is required
|
|
|
|
*
|
|
|
|
* @param needsConfiguring true if the applet needs to be configured,
|
|
|
|
* or false if it doesn't
|
|
|
|
*/
|
2009-08-18 00:31:08 +02:00
|
|
|
void setConfigurationRequired(bool needsConfiguring = true);
|
|
|
|
|
2009-08-18 00:30:46 +02:00
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* @return the containment the plugin is associated with.
|
2009-08-18 00:30:46 +02:00
|
|
|
*/
|
|
|
|
Containment *containment();
|
|
|
|
|
2009-08-18 00:31:03 +02:00
|
|
|
/**
|
|
|
|
* pastes the clipboard at a given location
|
|
|
|
*/
|
|
|
|
void paste(QPointF scenePos, QPoint screenPos);
|
|
|
|
|
2009-08-18 00:30:29 +02:00
|
|
|
private:
|
2009-08-18 00:31:32 +02:00
|
|
|
friend class ContainmentActionsPackage;
|
|
|
|
friend class ContainmentActionsPrivate;
|
|
|
|
ContainmentActionsPrivate *const d;
|
2009-08-18 00:30:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
/**
|
2009-08-18 00:31:32 +02:00
|
|
|
* Register a containmentactions when it is contained in a loadable module
|
2009-08-18 00:30:29 +02:00
|
|
|
*/
|
2009-08-18 00:31:32 +02:00
|
|
|
#define K_EXPORT_PLASMA_CONTAINMENTACTIONS(libname, classname) \
|
2009-08-18 00:30:29 +02:00
|
|
|
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
2009-08-18 00:31:32 +02:00
|
|
|
K_EXPORT_PLUGIN(factory("plasma_containmentactions_" #libname)) \
|
2009-08-18 00:30:29 +02:00
|
|
|
K_EXPORT_PLUGIN_VERSION(PLASMA_VERSION)
|
|
|
|
|
2009-12-27 23:16:11 +01:00
|
|
|
#endif // PLASMA_CONTAINMENTACTIONS_H
|