* immediate sync on destroy(), prevents applets from being unremovable in perpetuity

* less of use of containment()->corona() internally since while that makes sense for external code, it's unecessarily slow for code in the lib
* some dyanmic_ -> qobject_ casts

svn path=/trunk/KDE/kdelibs/; revision=898746
This commit is contained in:
Aaron J. Seigo 2008-12-18 22:14:06 +00:00
parent c8621101c1
commit 0b9f1db281

View File

@ -178,6 +178,10 @@ uint Applet::id() const
void Applet::save(KConfigGroup &g) const void Applet::save(KConfigGroup &g) const
{ {
if (d->transient) {
return;
}
KConfigGroup group = g; KConfigGroup group = g;
if (!group.isValid()) { if (!group.isValid()) {
group = *d->mainConfigGroup(); group = *d->mainConfigGroup();
@ -341,11 +345,11 @@ KConfigGroup Applet::config() const
KConfigGroup Applet::globalConfig() const KConfigGroup Applet::globalConfig() const
{ {
KConfigGroup globalAppletConfig; KConfigGroup globalAppletConfig;
const Containment *c = containment();
QString group = isContainment() ? "ContainmentGlobals" : "AppletGlobals"; QString group = isContainment() ? "ContainmentGlobals" : "AppletGlobals";
if (c && c->corona()) { Corona *corona = qobject_cast<Corona*>(scene());
KSharedConfig::Ptr coronaConfig = c->corona()->config(); if (corona) {
KSharedConfig::Ptr coronaConfig = corona->config();
globalAppletConfig = KConfigGroup(coronaConfig, group); globalAppletConfig = KConfigGroup(coronaConfig, group);
} else { } else {
globalAppletConfig = KConfigGroup(KGlobal::config(), group); globalAppletConfig = KConfigGroup(KGlobal::config(), group);
@ -365,10 +369,16 @@ void Applet::destroy()
if (isContainment()) { if (isContainment()) {
d->cleanUpAndDelete(); d->cleanUpAndDelete();
} else { } else {
d->resetConfigurationObject();
connect(Animator::self(), SIGNAL(animationFinished(QGraphicsItem*,Plasma::Animator::Animation)), connect(Animator::self(), SIGNAL(animationFinished(QGraphicsItem*,Plasma::Animator::Animation)),
this, SLOT(appletAnimationComplete(QGraphicsItem*,Plasma::Animator::Animation))); this, SLOT(appletAnimationComplete(QGraphicsItem*,Plasma::Animator::Animation)));
Animator::self()->animateItem(this, Animator::DisappearAnimation); Animator::self()->animateItem(this, Animator::DisappearAnimation);
} }
Corona * corona = qobject_cast<Corona*>(scene());
if (corona) {
corona->requireConfigSync();
}
} }
bool Applet::destroyed() const bool Applet::destroyed() const
@ -540,9 +550,9 @@ QRect Applet::mapToView(const QGraphicsView *view, const QRectF &rect) const
QPoint Applet::popupPosition(const QSize &s) const QPoint Applet::popupPosition(const QSize &s) const
{ {
Q_ASSERT(containment()); Corona * corona = qobject_cast<Corona*>(scene());
Q_ASSERT(containment()->corona()); Q_ASSERT(corona);
return containment()->corona()->popupPosition(this, s); return corona->popupPosition(this, s);
} }
void Applet::updateConstraints(Plasma::Constraints constraints) void Applet::updateConstraints(Plasma::Constraints constraints)
@ -684,7 +694,7 @@ ImmutabilityType Applet::immutability() const
//Returning the more strict immutability between the applet immutability and Corona one //Returning the more strict immutability between the applet immutability and Corona one
ImmutabilityType coronaImmutability = Mutable; ImmutabilityType coronaImmutability = Mutable;
if (dynamic_cast<Corona*>(scene())) { if (qobject_cast<Corona*>(scene())) {
coronaImmutability = static_cast<Corona*>(scene())->immutability(); coronaImmutability = static_cast<Corona*>(scene())->immutability();
} }
@ -1099,7 +1109,7 @@ FormFactor Applet::formFactor() const
Containment *Applet::containment() const Containment *Applet::containment() const
{ {
if (isContainment()) { if (isContainment()) {
Containment *c = dynamic_cast<Containment*>(const_cast<Applet*>(this)); Containment *c = qobject_cast<Containment*>(const_cast<Applet*>(this));
if (c) { if (c) {
return c; return c;
} }
@ -1967,13 +1977,12 @@ KConfigGroup *AppletPrivate::mainConfigGroup()
} }
if (isContainment) { if (isContainment) {
const Containment *asContainment = qobject_cast<Containment*>(const_cast<Applet*>(q)); Corona *corona = qobject_cast<Corona*>(q->scene());
Q_ASSERT(asContainment);
KConfigGroup containmentConfig; KConfigGroup containmentConfig;
//kDebug() << "got a corona, baby?" << (QObject*)asContainment->corona(); //kDebug() << "got a corona, baby?" << (QObject*)corona;
if (asContainment->corona()) {
containmentConfig = KConfigGroup(asContainment->corona()->config(), "Containments"); if (corona) {
containmentConfig = KConfigGroup(corona->config(), "Containments");
} else { } else {
containmentConfig = KConfigGroup(KGlobal::config(), "Containments"); containmentConfig = KConfigGroup(KGlobal::config(), "Containments");
} }
@ -2013,7 +2022,7 @@ void AppletPrivate::checkImmutability()
const bool systemImmutable = q->globalConfig().isImmutable() || q->config().isImmutable() || const bool systemImmutable = q->globalConfig().isImmutable() || q->config().isImmutable() ||
((!isContainment && q->containment()) && ((!isContainment && q->containment()) &&
q->containment()->immutability() == SystemImmutable) || q->containment()->immutability() == SystemImmutable) ||
(dynamic_cast<Corona*>(q->scene()) && static_cast<Corona*>(q->scene())->immutability() == SystemImmutable); (qobject_cast<Corona*>(q->scene()) && static_cast<Corona*>(q->scene())->immutability() == SystemImmutable);
if (systemImmutable) { if (systemImmutable) {
q->updateConstraints(ImmutableConstraint); q->updateConstraints(ImmutableConstraint);