From 873106a7ca4ff8f15e823b1019b4f5b66332867a Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 2 May 2014 16:40:17 +0200 Subject: [PATCH] Track screen in the containment when inside an applet Make the system tray containment update which screen it is on when the system tray applet is moved. This fixes notifications if the panel is moved between screens. REVIEW: 117946 --- src/plasma/private/containment_p.cpp | 22 ++++++++++++++++++++++ src/plasma/private/containment_p.h | 19 +++---------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/plasma/private/containment_p.cpp b/src/plasma/private/containment_p.cpp index 9e673829e..e6299a964 100644 --- a/src/plasma/private/containment_p.cpp +++ b/src/plasma/private/containment_p.cpp @@ -41,6 +41,28 @@ namespace Plasma const char ContainmentPrivate::defaultWallpaper[] = "org.kde.image"; +ContainmentPrivate::ContainmentPrivate(Containment *c): + q(c), + formFactor(Types::Planar), + location(Types::Floating), + lastScreen(-1), // never had a screen + type(Plasma::Types::NoContainmentType) +{ + //if the parent is an applet (i.e we are the systray) + //we want to follow screen changed signals from the parent's containment + auto appletParent = qobject_cast(c->parent()); + if (appletParent) { + QObject::connect(appletParent->containment(), &Containment::screenChanged, c, &Containment::screenChanged); + } +} + +Plasma::ContainmentPrivate::~ContainmentPrivate() +{ + qDeleteAll(applets); + applets.clear(); +} + + void ContainmentPrivate::addDefaultActions(KActionCollection *actions, Containment *c) { actions->setConfigGroup("Shortcuts-Containment"); diff --git a/src/plasma/private/containment_p.h b/src/plasma/private/containment_p.h index 24049c716..8c691cd1f 100644 --- a/src/plasma/private/containment_p.h +++ b/src/plasma/private/containment_p.h @@ -44,23 +44,10 @@ class Containment; class ContainmentPrivate { public: - ContainmentPrivate(Containment *c) - : q(c), - formFactor(Types::Planar), - location(Types::Floating), - lastScreen(-1), // never had a screen - type(Plasma::Types::NoContainmentType) - { - } + ContainmentPrivate(Containment *c); - ~ContainmentPrivate() - { - // qDeleteAll is broken with Qt4.8, delete it by hand - while (!applets.isEmpty()) { - delete applets.first(); - } - applets.clear(); - } + + ~ContainmentPrivate(); void triggerShowAddWidgets(); void checkStatus(Plasma::Types::ItemStatus status);