add an option in extenderitem to use a config group completely in memory, intended for extenderitems that really aren't supposed to be saved and restored on disk.
the notifications one, but more important the job ones really don't have a big point to be saved. svn path=/trunk/KDE/kdelibs/; revision=1153692
This commit is contained in:
parent
2a46966c22
commit
2687d8595b
@ -217,8 +217,36 @@ KConfigGroup ExtenderItem::config() const
|
||||
if (!d->extender->d->applet) {
|
||||
return KConfigGroup();
|
||||
}
|
||||
|
||||
KConfigGroup cg = d->extender->d->applet.data()->config("ExtenderItems");
|
||||
return KConfigGroup(&cg, QString::number(d->extenderItemId));
|
||||
KConfigGroup itemCg = KConfigGroup(&cg, QString::number(d->extenderItemId));
|
||||
|
||||
//we try to figure out if we are a transient ExtenderItem
|
||||
//if we are, return an in memory config group (nothing will be saved on disk)
|
||||
//if we aren't, return the ExtenderItems subgroup of our applet, as usual
|
||||
if (d->transient) {
|
||||
//create the dummy config group pointer if doesn't exists
|
||||
if (!d->transientConfig) {
|
||||
d->transientConfig = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
|
||||
KConfigGroup dummyGroup = KConfigGroup(d->transientConfig, "ExtenderItems");
|
||||
itemCg.reparent(&dummyGroup);
|
||||
return itemCg;
|
||||
}
|
||||
KConfigGroup dummyGroup = KConfigGroup(d->transientConfig, "ExtenderItems");
|
||||
dummyGroup = KConfigGroup(&dummyGroup, QString::number(d->extenderItemId));
|
||||
return dummyGroup;
|
||||
} else {
|
||||
//if the dummy config pointer still exists, get rid of it
|
||||
if (d->transientConfig) {
|
||||
KConfigGroup dummyGroup = KConfigGroup(d->transientConfig, "ExtenderItems");
|
||||
dummyGroup = KConfigGroup(&dummyGroup, QString::number(d->extenderItemId));
|
||||
dummyGroup.reparent(&cg);
|
||||
delete d->transientConfig.data();
|
||||
d->transientConfig.clear();
|
||||
return dummyGroup;
|
||||
}
|
||||
return itemCg;
|
||||
}
|
||||
}
|
||||
|
||||
void ExtenderItem::setTitle(const QString &title)
|
||||
@ -317,7 +345,7 @@ void ExtenderItem::setExtender(Extender *extender, const QPointF &pos)
|
||||
d->extender->d->removeExtenderItem(this);
|
||||
|
||||
//move the configuration.
|
||||
if (d->hostApplet() && (extender != d->extender)) {
|
||||
if (!d->transient && d->hostApplet() && (extender != d->extender)) {
|
||||
KConfigGroup c = extender->d->applet.data()->config("ExtenderItems");
|
||||
config().reparent(&c);
|
||||
}
|
||||
@ -719,6 +747,16 @@ QSizeF ExtenderItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) cons
|
||||
return QGraphicsWidget::sizeHint(which, constraint);
|
||||
}
|
||||
|
||||
void ExtenderItem::setTransient(const bool transient)
|
||||
{
|
||||
d->transient = transient;
|
||||
}
|
||||
|
||||
bool ExtenderItem::isTransient() const
|
||||
{
|
||||
return d->transient;
|
||||
}
|
||||
|
||||
ExtenderItemPrivate::ExtenderItemPrivate(ExtenderItem *extenderItem, Extender *hostExtender)
|
||||
: q(extenderItem),
|
||||
widget(0),
|
||||
@ -731,7 +769,8 @@ ExtenderItemPrivate::ExtenderItemPrivate(ExtenderItem *extenderItem, Extender *h
|
||||
dragStarted(false),
|
||||
destroyActionVisibility(false),
|
||||
collapsed(false),
|
||||
expirationTimer(0)
|
||||
expirationTimer(0),
|
||||
transient(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -236,6 +236,23 @@ class PLASMA_EXPORT ExtenderItem : public QGraphicsWidget
|
||||
*/
|
||||
QAction *action(const QString &name) const;
|
||||
|
||||
/**
|
||||
* Set the ExtenderItem as transient: won't be saved in the Plasma config
|
||||
* and won't be restored. This is intended for items that have contents
|
||||
* valid only for this session.
|
||||
*
|
||||
* @param transient true if the ExtenderItem will be transient
|
||||
*
|
||||
* @since 4.6
|
||||
*/
|
||||
void setTransient(const bool transient);
|
||||
|
||||
/**
|
||||
* @return true if the ExtenderItem is transient.
|
||||
* @since 4.6
|
||||
*/
|
||||
bool isTransient() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Destroys the extender item. As opposed to calling delete on this class, destroy also
|
||||
|
Loading…
x
Reference in New Issue
Block a user