diff --git a/containment.cpp b/containment.cpp index 6a58ccb84..e6e08c83f 100644 --- a/containment.cpp +++ b/containment.cpp @@ -833,6 +833,28 @@ void Containment::keyPressEvent(QKeyEvent *event) } } +void Containment::wheelEvent(QGraphicsSceneWheelEvent *event) +{ + if (containmentType() == DesktopContainment) { + QGraphicsItem* item = scene()->itemAt(event->scenePos()); + if (item == this) { + int numDesktops = KWindowSystem::numberOfDesktops(); + int currentDesktop = KWindowSystem::currentDesktop(); + + if (event->delta() > 0) { + KWindowSystem::setCurrentDesktop(currentDesktop % numDesktops + 1); + } else { + KWindowSystem::setCurrentDesktop((numDesktops + currentDesktop - 2) % numDesktops + 1); + } + + event->accept(); + return; + } + } + + Applet::wheelEvent(event); +} + bool Containment::sceneEventFilter(QGraphicsItem *watched, QEvent *event) { Applet *applet = qgraphicsitem_cast(watched); diff --git a/containment.h b/containment.h index 413efd40a..7a0fcfa6a 100644 --- a/containment.h +++ b/containment.h @@ -414,6 +414,7 @@ class PLASMA_EXPORT Containment : public Applet void hoverEnterEvent(QGraphicsSceneHoverEvent *event); void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); void keyPressEvent(QKeyEvent *event); + void wheelEvent(QGraphicsSceneWheelEvent *event); bool sceneEventFilter(QGraphicsItem *watched, QEvent *event); QVariant itemChange(GraphicsItemChange change, const QVariant &value);