Commit de483d47 authored by Marco Martin's avatar Marco Martin
Browse files

introduce candidateContainments

DesktopView contains a property candidateContainments which are all containments with the same screen for all activities.
Plasma mobile can use it to do activity switching with a swipe gesture
replaces D11333

Test Plan:
tested with gesture based activity switching in plasma mobile including creating and deleting
of activities

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision:
parent 05b09613
......@@ -24,11 +24,13 @@
#include <QQmlEngine>
#include <QQmlContext>
#include <QScreen>
#include <QQuickItem>
#include <qopenglshaderprogram.h>
#include <kwindowsystem.h>
#include <klocalizedstring.h>
#include <KAuthorized>
#include <kactivities/controller.h>
#include <KPackage/Package>
......@@ -57,6 +59,13 @@ DesktopView::DesktopView(Plasma::Corona *corona, QScreen *targetScreen)
QObject::connect(corona, &Plasma::Corona::kPackageChanged,
this, &DesktopView::coronaPackageChanged);
KActivities::Controller *m_activityController = new KActivities::Controller(this);
QObject::connect(m_activityController, &KActivities::Controller::activityAdded,
this, &DesktopView::candidateContainmentsChanged);
QObject::connect(m_activityController, &KActivities::Controller::activityRemoved,
this, &DesktopView::candidateContainmentsChanged);
if (QQuickWindow::sceneGraphBackend() != QLatin1String("software")) {
connect(this, &DesktopView::sceneGraphInitialized, this,
[this, corona]() {
......@@ -197,6 +206,19 @@ DesktopView::SessionType DesktopView::sessionType() const
QVariantMap DesktopView::candidateContainmentsGraphicItems() const
QVariantMap map;
if (!containment()) {
return map;
for (auto cont : corona()->containmentsForScreen(containment()->screen())) {
map[cont->activity()] = cont->property("_plasma_graphicObject");
return map;
bool DesktopView::event(QEvent *e)
if (e->type() == QEvent::PlatformSurface) {
......@@ -40,6 +40,9 @@ class DesktopView : public PlasmaQuick::ContainmentView
//What kind of plasma session we're in: are we in a full workspace, an application?...
Q_PROPERTY(SessionType sessionType READ sessionType CONSTANT)
Q_PROPERTY(QVariantMap candidateContainments READ candidateContainmentsGraphicItems NOTIFY candidateContainmentsChanged)
enum WindowType {
Window, /** The window is a normal resizable window with titlebar and appears in the taskbar */
......@@ -72,6 +75,8 @@ public:
SessionType sessionType() const;
QVariantMap candidateContainmentsGraphicItems() const;
bool event(QEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
......@@ -88,6 +93,7 @@ private Q_SLOTS:
void stayBehindChanged();
void windowTypeChanged();
void candidateContainmentsChanged();
void coronaPackageChanged(const KPackage::Package &package);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment