From 871508e467d801a86c61411a0a9efc62e115bbfe Mon Sep 17 00:00:00 2001 From: Rob Scheepmaker Date: Wed, 29 Oct 2008 17:01:11 +0000 Subject: [PATCH] Store the title and icon in extenderitem's config so applets don't have to store/restore this info manually. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=877485 --- extenderitem.cpp | 12 ++++++++---- extenderitem.h | 10 +++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/extenderitem.cpp b/extenderitem.cpp index 7f234f8a8..5a46a1ac4 100644 --- a/extenderitem.cpp +++ b/extenderitem.cpp @@ -72,15 +72,19 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId) uint sourceAppletId = dg.readEntry("sourceAppletId", 0); - //TODO: automatically load title and icon. + //check if we're creating a new item or reinstantiating an existing one. if (!sourceAppletId) { //The item is new dg.writeEntry("sourceAppletPluginName", hostExtender->d->applet->pluginName()); dg.writeEntry("sourceAppletId", hostExtender->d->applet->id()); + dg.writeEntry("sourceIconName", hostExtender->d->applet->icon()); d->sourceApplet = hostExtender->d->applet; + d->collapseIcon = new Icon(KIcon(hostExtender->d->applet->icon()), "", this); } else { //The item already exists. d->name = dg.readEntry("extenderItemName", ""); + d->title = dg.readEntry("extenderTitle", ""); + d->collapseIcon = new Icon(KIcon(dg.readEntry("extenderIconName", "")), "", this); //Find the sourceapplet. Corona *corona = hostExtender->d->applet->containment()->corona(); @@ -97,15 +101,13 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId) //make sure we keep monitoring if the source applet still exists, so the return to source icon //can be hidden if it is removed. connect(d->sourceApplet, SIGNAL(destroyed()), this, SLOT(sourceAppletRemoved())); + connect(d->collapseIcon, SIGNAL(clicked()), this, SLOT(toggleCollapse())); //create the toolbox. d->toolbox = new QGraphicsWidget(this); d->toolboxLayout = new QGraphicsLinearLayout(d->toolbox); d->toolbox->setLayout(d->toolboxLayout); - //create the collapse/applet icon. - d->collapseIcon = new Icon(KIcon(hostExtender->d->applet->icon()), "", this); - connect(d->collapseIcon, SIGNAL(clicked()), this, SLOT(toggleCollapse())); //set the extender we want to move to. setExtender(hostExtender); @@ -135,6 +137,7 @@ KConfigGroup ExtenderItem::config() const void ExtenderItem::setTitle(const QString &title) { d->title = title; + config().writeEntry("extenderTitle", title); update(); } @@ -180,6 +183,7 @@ void ExtenderItem::setIcon(const QIcon &icon) void ExtenderItem::setIcon(const QString &icon) { d->collapseIcon->setIcon(icon); + config().writeEntry("extenderIconName", icon); } QIcon ExtenderItem::icon() const diff --git a/extenderitem.h b/extenderitem.h index aedc37c5b..e91f62632 100644 --- a/extenderitem.h +++ b/extenderitem.h @@ -112,7 +112,8 @@ class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget /** * @param title the title that will be shown in the extender item's dragger. Default is - * no title. + * no title. This title will also be stored in the item's configuration, so you don't have + * to manually store/restore this information for your extender items. */ void setTitle(const QString &title); @@ -123,7 +124,8 @@ class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget /** * You can assign names to extender items to look them up through the item() function. - * Make sure you only use unique names. + * Make sure you only use unique names. This name will be stored in the item's + * configuration. * @param name the name of the item. Defaults to an empty string. */ void setName(const QString &name); @@ -135,7 +137,9 @@ class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget /** * @param icon the icon name to display in the extender item's - * drag handle. Defaults to the source applet's icon. + * drag handle. Defaults to the source applet's icon. This icon name will also be stored + * in the item's configuration, so you don't have to manually store/restore this + * information. */ void setIcon(const QString &icon);