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
This commit is contained in:
parent
bd7e7b10c9
commit
871508e467
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user