added lastScreen and lastDesktop, to remember where things belong

svn path=/trunk/KDE/kdelibs/; revision=1128358
This commit is contained in:
Chani Armitage 2010-05-19 02:43:07 +00:00
parent 58ae4b444f
commit 3a10a5c507
3 changed files with 39 additions and 0 deletions

View File

@ -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)
{

View File

@ -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 &)

View File

@ -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<Applet*, AppletHandle*> handles;
QHash<QString, ContainmentActions*> actionPlugins;
int screen;
int lastScreen;
int desktop;
int lastDesktop;
QWeakPointer<AbstractToolBox> toolBox;
Context *con;
Containment::Type type;