Fixed a type, making destroy() function again. Move the destruction of temporary extender
items to applet, since in extender's dtor, applet's config isn't accessible anymore. Only fire itemDetached when an item is really moved, not only when being dragged away. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=841509
This commit is contained in:
parent
d109b09bf3
commit
3bfb1bf662
13
applet.cpp
13
applet.cpp
@ -181,6 +181,19 @@ void Applet::save(KConfigGroup &g) const
|
|||||||
KConfigGroup appletConfigGroup(&group, "Configuration");
|
KConfigGroup appletConfigGroup(&group, "Configuration");
|
||||||
|
|
||||||
if (extender()) {
|
if (extender()) {
|
||||||
|
//This would probably be nicer if it was located in extender. But in it's dtor, this won't
|
||||||
|
//work since when that get's called, the applet's config() isn't accesible anymore. (same
|
||||||
|
//problem with calling saveState(). Doing this in saveState() might be a possibility, but
|
||||||
|
//that would require every extender savestate implementation to call it's parent function,
|
||||||
|
//which isn't very nice.
|
||||||
|
foreach (ExtenderItem *item, extender()->attachedItems()) {
|
||||||
|
if (!item->isDetached() && item->autoExpireDelay()) {
|
||||||
|
//destroy temporary extender items, so their configuration won't linger after a
|
||||||
|
//plasma restart.
|
||||||
|
item->destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extender()->saveState();
|
extender()->saveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,14 +56,6 @@ Extender::Extender(Applet *applet)
|
|||||||
|
|
||||||
Extender::~Extender()
|
Extender::~Extender()
|
||||||
{
|
{
|
||||||
//FIXME: this used to work, not anymore... fix.
|
|
||||||
foreach (ExtenderItem *item, attachedItems()) {
|
|
||||||
if (!item->isDetached() && item->autoExpireDelay()) {
|
|
||||||
//destroy temporary extender items, so their configuration won't linger after a plasma
|
|
||||||
//restart.
|
|
||||||
item->destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +256,6 @@ void ExtenderPrivate::removeExtenderItem(ExtenderItem *item)
|
|||||||
{
|
{
|
||||||
attachedExtenderItems.removeOne(item);
|
attachedExtenderItems.removeOne(item);
|
||||||
q->itemRemovedEvent(item);
|
q->itemRemovedEvent(item);
|
||||||
emit q->itemDetached(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtenderPrivate::adjustSizeHints()
|
void ExtenderPrivate::adjustSizeHints()
|
||||||
|
@ -75,8 +75,8 @@ class ExtenderItemPrivate
|
|||||||
{
|
{
|
||||||
qreal left, top, right, bottom;
|
qreal left, top, right, bottom;
|
||||||
dragger->getMargins(left, top, right, bottom);
|
dragger->getMargins(left, top, right, bottom);
|
||||||
QRectF rect(0, 0, q->size().width(), top + bottom +
|
QRectF rect(0, 0, q->size().width(),
|
||||||
dragger->elementSize("hint-preferred-icon-size").height());
|
dragger->elementSize("hint-preferred-icon-size").height() + top + bottom);
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ class ExtenderItemPrivate
|
|||||||
{
|
{
|
||||||
qreal left, top, right, bottom;
|
qreal left, top, right, bottom;
|
||||||
dragger->getMargins(left, top, right, bottom);
|
dragger->getMargins(left, top, right, bottom);
|
||||||
return dragHandleRect().adjusted(left + collapseIcon->size().width(), top,
|
return dragHandleRect().adjusted(left + collapseIcon->size().width() + 1, top,
|
||||||
-toolbox->size().width(), -bottom);
|
-toolbox->size().width(), -bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,14 +396,13 @@ void ExtenderItem::setExtender(Extender *extender, const QPointF &pos)
|
|||||||
//first remove this item from the old extender.
|
//first remove this item from the old extender.
|
||||||
if (d->extender) {
|
if (d->extender) {
|
||||||
d->extender->d->removeExtenderItem(this);
|
d->extender->d->removeExtenderItem(this);
|
||||||
|
emit d->extender->itemDetached(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//move the configuration.
|
//move the configuration.
|
||||||
if (d->hostApplet() && (extender != d->extender)) {
|
if (d->hostApplet() && (extender != d->extender)) {
|
||||||
kDebug() << "moving configuration";
|
kDebug() << "moving configuration";
|
||||||
KConfigGroup c = extender->d->applet->config("ExtenderItems");
|
KConfigGroup c = extender->d->applet->config("ExtenderItems");
|
||||||
kDebug() << "hostAppletId is " << d->hostApplet()->id();
|
|
||||||
kDebug() << "config name is " << config().name();
|
|
||||||
config().reparent(&c);
|
config().reparent(&c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,8 +489,7 @@ uint ExtenderItem::sourceAppletId() const
|
|||||||
|
|
||||||
void ExtenderItem::destroy()
|
void ExtenderItem::destroy()
|
||||||
{
|
{
|
||||||
kDebug() << "deleting config group.";
|
d->hostApplet()->config("ExtenderItems").deleteGroup(QString::number(d->extenderItemId));
|
||||||
d->hostApplet()->config("ExtenderItem").deleteGroup(QString::number(d->extenderItemId));
|
|
||||||
if (d->extender) {
|
if (d->extender) {
|
||||||
d->extender->d->removeExtenderItem(this);
|
d->extender->d->removeExtenderItem(this);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user