Make all items persistent by default, even if still attached. This allows us to restore their position and their collapsed state.
svn path=/trunk/KDE/kdelibs/; revision=912127
This commit is contained in:
parent
8a0159e10e
commit
bfb771ddd8
11
applet.cpp
11
applet.cpp
@ -143,15 +143,15 @@ Applet::~Applet()
|
|||||||
//problem with calling saveState(). Doing this in saveState() might be a possibility, but
|
//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,
|
//that would require every extender savestate implementation to call it's parent function,
|
||||||
//which isn't very nice.
|
//which isn't very nice.
|
||||||
|
d->extender->saveState();
|
||||||
|
|
||||||
foreach (ExtenderItem *item, d->extender->attachedItems()) {
|
foreach (ExtenderItem *item, d->extender->attachedItems()) {
|
||||||
if (!item->isDetached() || item->autoExpireDelay()) {
|
if (item->autoExpireDelay()) {
|
||||||
//destroy temporary extender items, or items that aren't detached, so their
|
//destroy temporary extender items, or items that aren't detached, so their
|
||||||
//configuration won't linger after a plasma restart.
|
//configuration won't linger after a plasma restart.
|
||||||
item->destroy();
|
item->destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->extender->saveState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete d;
|
delete d;
|
||||||
@ -590,7 +590,10 @@ void Applet::constraintsEvent(Plasma::Constraints constraints)
|
|||||||
|
|
||||||
void Applet::initExtenderItem(ExtenderItem *item)
|
void Applet::initExtenderItem(ExtenderItem *item)
|
||||||
{
|
{
|
||||||
Q_UNUSED(item)
|
kWarning() << "Missing implementation of initExtenderItem in the applet "
|
||||||
|
<< item->config().readEntry("SourceAppletPluginName", "")
|
||||||
|
<< "!\n Any applet that uses extenders should implement initExtenderItem to "
|
||||||
|
<< "instantiate a widget. Destroying the item...";
|
||||||
item->destroy();
|
item->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
61
extender.cpp
61
extender.cpp
@ -386,8 +386,6 @@ void ExtenderPrivate::loadExtenderItems()
|
|||||||
|
|
||||||
//first create a list of extenderItems, and then sort them on their position, so the items get
|
//first create a list of extenderItems, and then sort them on their position, so the items get
|
||||||
//recreated in the correct order.
|
//recreated in the correct order.
|
||||||
//TODO: this restoring of the correct order should now be done in itemAddedEvent instead of
|
|
||||||
//here, to allow easy subclassing of Extender.
|
|
||||||
QList<QPair<int, QString> > groupList;
|
QList<QPair<int, QString> > groupList;
|
||||||
foreach (const QString &extenderItemId, cg.groupList()) {
|
foreach (const QString &extenderItemId, cg.groupList()) {
|
||||||
KConfigGroup dg = cg.group(extenderItemId);
|
KConfigGroup dg = cg.group(extenderItemId);
|
||||||
@ -398,6 +396,7 @@ void ExtenderPrivate::loadExtenderItems()
|
|||||||
//iterate over the extender items
|
//iterate over the extender items
|
||||||
for (int i = 0; i < groupList.count(); i++) {
|
for (int i = 0; i < groupList.count(); i++) {
|
||||||
QPair<int, QString> pair = groupList[i];
|
QPair<int, QString> pair = groupList[i];
|
||||||
|
|
||||||
KConfigGroup dg = cg.group(pair.second);
|
KConfigGroup dg = cg.group(pair.second);
|
||||||
|
|
||||||
//load the relevant settings.
|
//load the relevant settings.
|
||||||
@ -411,43 +410,37 @@ void ExtenderPrivate::loadExtenderItems()
|
|||||||
kDebug() << "applet id = " << applet->id();
|
kDebug() << "applet id = " << applet->id();
|
||||||
kDebug() << "sourceappletid = " << sourceAppletId;
|
kDebug() << "sourceappletid = " << sourceAppletId;
|
||||||
|
|
||||||
if (sourceAppletId != applet->id()) {
|
//find the source applet.
|
||||||
//find the source applet.
|
Corona *corona = applet->containment()->corona();
|
||||||
Corona *corona = applet->containment()->corona();
|
Applet *sourceApplet = 0;
|
||||||
Applet *sourceApplet = 0;
|
foreach (Containment *containment, corona->containments()) {
|
||||||
foreach (Containment *containment, corona->containments()) {
|
foreach (Applet *applet, containment->applets()) {
|
||||||
foreach (Applet *applet, containment->applets()) {
|
if (applet->id() == sourceAppletId) {
|
||||||
if (applet->id() == sourceAppletId) {
|
sourceApplet = applet;
|
||||||
sourceApplet = applet;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//There is no source applet. We just instantiate one just for the sake of creating
|
//There is no source applet. We just instantiate one just for the sake of creating
|
||||||
//detachables.
|
//detachables.
|
||||||
if (!sourceApplet) {
|
if (!sourceApplet) {
|
||||||
kDebug() << "creating a temporary applet as factory";
|
kDebug() << "creating a temporary applet as factory";
|
||||||
sourceApplet = Applet::load(appletName);
|
sourceApplet = Applet::load(appletName);
|
||||||
temporarySourceApplet = true;
|
temporarySourceApplet = true;
|
||||||
//TODO: maybe add an option to applet to indicate that it shouldn't be deleted after
|
//TODO: maybe add an option to applet to indicate that it shouldn't be deleted after
|
||||||
//having used it as factory.
|
//having used it as factory.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sourceApplet) {
|
if (!sourceApplet) {
|
||||||
kDebug() << "sourceApplet is null? appletName = " << appletName;
|
kDebug() << "sourceApplet is null? appletName = " << appletName;
|
||||||
kDebug() << " extenderItemId = " << extenderItemId;
|
kDebug() << " extenderItemId = " << extenderItemId;
|
||||||
} else {
|
|
||||||
ExtenderItem *item = new ExtenderItem(q, extenderItemId.toInt());
|
|
||||||
sourceApplet->initExtenderItem(item);
|
|
||||||
|
|
||||||
if (temporarySourceApplet) {
|
|
||||||
delete sourceApplet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//this entry is still here, probably because plasma crashed, but it isn't detached and
|
ExtenderItem *item = new ExtenderItem(q, extenderItemId.toInt());
|
||||||
//should be reinstantiated. Just delete the entry.
|
sourceApplet->initExtenderItem(item);
|
||||||
cg.deleteGroup(pair.second);
|
|
||||||
|
if (temporarySourceApplet) {
|
||||||
|
delete sourceApplet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,8 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId)
|
|||||||
//The item already exists.
|
//The item already exists.
|
||||||
d->name = dg.readEntry("extenderItemName", "");
|
d->name = dg.readEntry("extenderItemName", "");
|
||||||
d->title = dg.readEntry("extenderTitle", "");
|
d->title = dg.readEntry("extenderTitle", "");
|
||||||
|
setCollapsed(dg.readEntry("isCollapsed", false));
|
||||||
|
|
||||||
QString iconName = dg.readEntry("extenderIconName", "utilities-desktop-extra");
|
QString iconName = dg.readEntry("extenderIconName", "utilities-desktop-extra");
|
||||||
if (iconName.isEmpty()) {
|
if (iconName.isEmpty()) {
|
||||||
iconName = "utilities-desktop-extra";
|
iconName = "utilities-desktop-extra";
|
||||||
@ -279,11 +281,7 @@ Extender *ExtenderItem::extender() const
|
|||||||
|
|
||||||
bool ExtenderItem::isCollapsed() const
|
bool ExtenderItem::isCollapsed() const
|
||||||
{
|
{
|
||||||
if (!d->widget) {
|
return d->collapsed;
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return !d->widget->isVisible();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtenderItem::setAutoExpireDelay(uint time)
|
void ExtenderItem::setAutoExpireDelay(uint time)
|
||||||
@ -381,6 +379,9 @@ void ExtenderItem::destroy()
|
|||||||
|
|
||||||
void ExtenderItem::setCollapsed(bool collapsed)
|
void ExtenderItem::setCollapsed(bool collapsed)
|
||||||
{
|
{
|
||||||
|
config().writeEntry("isCollapsed", collapsed);
|
||||||
|
d->collapsed = collapsed;
|
||||||
|
|
||||||
qreal marginWidth = d->bgLeft + d->bgRight + d->dragLeft + d->dragRight;
|
qreal marginWidth = d->bgLeft + d->bgRight + d->dragLeft + d->dragRight;
|
||||||
qreal marginHeight = d->bgTop + d->bgBottom + 2 * d->dragTop + 2 * d->dragBottom;
|
qreal marginHeight = d->bgTop + d->bgBottom + 2 * d->dragTop + 2 * d->dragBottom;
|
||||||
|
|
||||||
@ -828,6 +829,7 @@ ExtenderItemPrivate::ExtenderItemPrivate(ExtenderItem *extenderItem, Extender *h
|
|||||||
mouseOver(false),
|
mouseOver(false),
|
||||||
dragStarted(false),
|
dragStarted(false),
|
||||||
destroyActionVisibility(false),
|
destroyActionVisibility(false),
|
||||||
|
collapsed(false),
|
||||||
expirationTimer(0)
|
expirationTimer(0)
|
||||||
{
|
{
|
||||||
dragLeft = dragTop = dragRight = dragBottom = 0;
|
dragLeft = dragTop = dragRight = dragBottom = 0;
|
||||||
|
@ -98,6 +98,7 @@ class ExtenderItemPrivate
|
|||||||
bool mouseOver;
|
bool mouseOver;
|
||||||
bool dragStarted;
|
bool dragStarted;
|
||||||
bool destroyActionVisibility;
|
bool destroyActionVisibility;
|
||||||
|
bool collapsed;
|
||||||
|
|
||||||
QTimer *expirationTimer;
|
QTimer *expirationTimer;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user