23 #include "private/dataengineconsumer_p.h"
24 #include "private/packages_p.h"
25 #include "private/containmentactions_p.h"
26 #include "private/containment_p.h"
29 #include <QMouseEvent>
30 #include <QWheelEvent>
31 #include <QGraphicsSceneContextMenuEvent>
32 #include <QGraphicsSceneMouseEvent>
33 #include <QGraphicsSceneWheelEvent>
37 #include <kservicetypetrader.h>
38 #include <kstandarddirs.h>
48 : d(new ContainmentActionsPrivate(KService::serviceByStorageId(QString()), this))
50 setParent(parentObject);
54 : d(new ContainmentActionsPrivate(KService::serviceByStorageId(args.count() > 0 ?
55 args[0].
toString() : QString()), this))
60 QVariantList &mutableArgs =
const_cast<QVariantList &
>(args);
61 if (!mutableArgs.isEmpty()) {
62 mutableArgs.removeFirst();
65 setParent(parentObject);
77 KService::List offers = KServiceTypeTrader::self()->query(
"Plasma/ContainmentActions", constraint);
78 return KPluginInfo::fromServices(offers);
83 if (containmentActionsName.isEmpty()) {
87 QString constraint = QString(
"[X-KDE-PluginInfo-Name] == '%1'").arg(containmentActionsName);
88 KService::List offers = KServiceTypeTrader::self()->query(
"Plasma/ContainmentActions", constraint);
90 if (offers.isEmpty()) {
91 kDebug() <<
"offers is empty for " << containmentActionsName;
95 KService::Ptr offer = offers.first();
96 KPluginLoader plugin(*offer);
102 QVariantList allArgs;
103 allArgs << offer->storageId() << args;
107 if (!containmentActions) {
108 kDebug() <<
"Couldn't load containmentActions \"" << containmentActionsName <<
"\"! reason given: " << error;
111 return containmentActions;
116 if (!info.isValid()) {
124 if (!ContainmentActionsPrivate::s_packageStructure) {
128 return ContainmentActionsPrivate::s_packageStructure;
133 if (d->containment) {
134 return d->containment;
141 if (!d->containmentActionsDescription.isValid()) {
142 return i18n(
"Unknown ContainmentActions");
145 return d->containmentActionsDescription.name();
150 if (!d->containmentActionsDescription.isValid()) {
154 return d->containmentActionsDescription.icon();
159 if (!d->containmentActionsDescription.isValid()) {
163 return d->containmentActionsDescription.pluginName();
168 return d->initialized;
174 d->initialized =
true;
206 return QList<QAction*>();
211 return d->dataEngine(name);
216 return d->needsConfig;
222 d->needsConfig = needsConfig;
228 Qt::KeyboardModifiers modifiers;
230 switch (event->type()) {
231 case QEvent::MouseButtonPress:
232 case QEvent::MouseButtonRelease:
234 QMouseEvent *e =
static_cast<QMouseEvent*
>(
event);
235 int m = QObject::staticQtMetaObject.indexOfEnumerator(
"MouseButtons");
236 QMetaEnum mouse = QObject::staticQtMetaObject.enumerator(m);
237 trigger += mouse.valueToKey(e->button());
238 modifiers = e->modifiers();
241 case QEvent::GraphicsSceneMousePress:
242 case QEvent::GraphicsSceneMouseRelease:
243 case QEvent::GraphicsSceneMouseDoubleClick:
245 QGraphicsSceneMouseEvent *e =
static_cast<QGraphicsSceneMouseEvent*
>(
event);
246 int m = QObject::staticQtMetaObject.indexOfEnumerator(
"MouseButtons");
247 QMetaEnum mouse = QObject::staticQtMetaObject.enumerator(m);
248 trigger += mouse.valueToKey(e->button());
249 modifiers = e->modifiers();
254 QWheelEvent *e =
static_cast<QWheelEvent*
>(
event);
255 int o = QObject::staticQtMetaObject.indexOfEnumerator(
"Orientations");
256 QMetaEnum orient = QObject::staticQtMetaObject.enumerator(o);
258 trigger += orient.valueToKey(e->orientation());
259 modifiers = e->modifiers();
262 case QEvent::GraphicsSceneWheel:
264 QGraphicsSceneWheelEvent *e =
static_cast<QGraphicsSceneWheelEvent*
>(
event);
265 int o = QObject::staticQtMetaObject.indexOfEnumerator(
"Orientations");
266 QMetaEnum orient = QObject::staticQtMetaObject.enumerator(o);
268 trigger += orient.valueToKey(e->orientation());
269 modifiers = e->modifiers();
272 case QEvent::GraphicsSceneContextMenu:
273 case QEvent::ContextMenu:
275 int m = QObject::staticQtMetaObject.indexOfEnumerator(
"MouseButtons");
276 QMetaEnum mouse = QObject::staticQtMetaObject.enumerator(m);
277 trigger = mouse.valueToKey(Qt::RightButton);
278 modifiers = Qt::NoModifier;
285 int k = QObject::staticQtMetaObject.indexOfEnumerator(
"KeyboardModifiers");
286 QMetaEnum kbd = QObject::staticQtMetaObject.enumerator(k);
288 trigger += kbd.valueToKeys(modifiers);
297 c->d->dropData(scenePos, screenPos);
303 switch (event->type()) {
304 case QEvent::GraphicsSceneMousePress:
305 case QEvent::GraphicsSceneMouseRelease:
306 case QEvent::GraphicsSceneMouseDoubleClick:
307 return static_cast<QGraphicsSceneMouseEvent*
>(event)->screenPos();
309 case QEvent::GraphicsSceneWheel:
310 return static_cast<QGraphicsSceneWheelEvent*
>(event)->screenPos();
312 case QEvent::GraphicsSceneContextMenu:
313 return static_cast<QGraphicsSceneContextMenuEvent*
>(event)->screenPos();
324 switch (event->type()) {
325 case QEvent::GraphicsSceneMousePress:
326 case QEvent::GraphicsSceneMouseRelease:
327 case QEvent::GraphicsSceneMouseDoubleClick:
328 return static_cast<QGraphicsSceneMouseEvent*
>(event)->scenePos();
330 case QEvent::GraphicsSceneWheel:
331 return static_cast<QGraphicsSceneWheelEvent*
>(event)->scenePos();
333 case QEvent::GraphicsSceneContextMenu:
334 return static_cast<QGraphicsSceneContextMenuEvent*
>(event)->scenePos();
345 return dynamic_cast<QGraphicsSceneEvent *
>(event) == 0;
361 QPoint pos = screenPos;
362 if (applet &&
containment()->d->isPanelContainment()) {
364 if (event->type() != QEvent::GraphicsSceneContextMenu ||
365 static_cast<QGraphicsSceneContextMenuEvent *
>(
event)->reason() == QGraphicsSceneContextMenuEvent::Mouse) {
369 if (pos.y() + s.height() < screenPos.y()) {
370 pos.setY(screenPos.y());
373 if (pos.x() + s.width() < screenPos.x()) {
374 pos.setX(screenPos.x());
390 d->containment = newContainment;
395 #include "containmentactions.moc"