From 3a10a5c5073d60b9fb00b26f2ab5fac94ad72543 Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Wed, 19 May 2010 02:43:07 +0000 Subject: [PATCH] added lastScreen and lastDesktop, to remember where things belong svn path=/trunk/KDE/kdelibs/; revision=1128358 --- containment.cpp | 21 +++++++++++++++++++++ containment.h | 14 ++++++++++++++ private/containment_p.h | 4 ++++ 3 files changed, 39 insertions(+) diff --git a/containment.cpp b/containment.cpp index 8fcfae97e..e96c30ffb 100644 --- a/containment.cpp +++ b/containment.cpp @@ -356,6 +356,8 @@ void Containment::restore(KConfigGroup &group) setLocation((Plasma::Location)group.readEntry("location", (int)d->location)); setFormFactor((Plasma::FormFactor)group.readEntry("formfactor", (int)d->formFactor)); //kDebug() << "setScreen from restore"; + d->lastScreen = group.readEntry("lastScreen", d->lastScreen); + d->lastDesktop = group.readEntry("lastDesktop", d->lastDesktop); setScreen(group.readEntry("screen", d->screen), group.readEntry("desktop", d->desktop)); QString activityId = group.readEntry("activityId", QString()); if (!activityId.isEmpty()) { @@ -417,7 +419,9 @@ void Containment::save(KConfigGroup &g) const } group.writeEntry("screen", d->screen); + group.writeEntry("lastScreen", d->lastScreen); group.writeEntry("desktop", d->desktop); + group.writeEntry("lastDesktop", d->lastDesktop); group.writeEntry("formfactor", (int)d->formFactor); group.writeEntry("location", (int)d->location); group.writeEntry("activity", d->context()->currentActivity()); @@ -1059,6 +1063,7 @@ void Containment::setScreen(int newScreen, int newDesktop) int oldScreen = d->screen; d->screen = newScreen; + updateConstraints(Plasma::ScreenConstraint); if (oldScreen != newScreen || oldDesktop != newDesktop) { @@ -1067,6 +1072,12 @@ void Containment::setScreen(int newScreen, int newDesktop) KConfigGroup c = config(); c.writeEntry("screen", d->screen); c.writeEntry("desktop", d->desktop); + if (newScreen != -1) { + d->lastScreen = newScreen; + d->lastDesktop = newDesktop; + c.writeEntry("lastScreen", d->lastScreen); + c.writeEntry("lastDesktop", d->lastDesktop); + } emit configNeedsSaving(); } @@ -1087,11 +1098,21 @@ int Containment::screen() const return d->screen; } +int Containment::lastScreen() const +{ + return d->lastScreen; +} + int Containment::desktop() const { return d->desktop; } +int Containment::lastDesktop() const +{ + return d->lastDesktop; +} + KPluginInfo::List Containment::listContainments(const QString &category, const QString &parentApp) { diff --git a/containment.h b/containment.h index 0b120d678..7045b59db 100644 --- a/containment.h +++ b/containment.h @@ -255,11 +255,25 @@ class PLASMA_EXPORT Containment : public Applet */ int screen() const; + /** + * @return the last screen number this containment had + * only returns -1 if it's never ever been on a screen + * @since 4.5 + */ + int lastScreen() const; + /** * @return the viewport (e.g. virtual desktop) this Containment is associated with. */ int desktop() const; + /** + * @return the viewport (e.g. virtual desktop) this Containment was associated with + * last time it had a screen + * @since 4.5 + */ + int lastDesktop() const; + /** * @reimp * @sa Applet::save(KConfigGroup &) diff --git a/private/containment_p.h b/private/containment_p.h index 32913ad9e..001b75676 100644 --- a/private/containment_p.h +++ b/private/containment_p.h @@ -48,7 +48,9 @@ public: focusedApplet(0), wallpaper(0), screen(-1), // no screen + lastScreen(-1), desktop(-1), // all desktops + lastDesktop(-1), con(0), type(Containment::NoContainmentType), showDropZoneDelayTimer(0), @@ -164,7 +166,9 @@ public: QMap handles; QHash actionPlugins; int screen; + int lastScreen; int desktop; + int lastDesktop; QWeakPointer toolBox; Context *con; Containment::Type type;