make possible for containments to run as applets
take into account the slightly different behaviour needed when containments such as folderview act as a normal plasmoid BUG:333320
This commit is contained in:
parent
eb7bcc2677
commit
18f54dff73
@ -562,15 +562,18 @@ Types::FormFactor Applet::formFactor() const
|
||||
Containment *Applet::containment() const
|
||||
{
|
||||
Containment *c = qobject_cast<Containment*>(const_cast<Applet*>(this));
|
||||
if (c && qobject_cast<Corona *>(parent())) {
|
||||
if (c && c->isContainment()) {
|
||||
return c;
|
||||
} else {
|
||||
c = 0;
|
||||
}
|
||||
|
||||
QObject *parent = this->parent();
|
||||
|
||||
while (parent) {
|
||||
Containment *possibleC = qobject_cast<Containment*>(parent);
|
||||
if (possibleC) {
|
||||
|
||||
if (possibleC && possibleC->isContainment()) {
|
||||
c = possibleC;
|
||||
break;
|
||||
}
|
||||
@ -743,6 +746,13 @@ void Applet::timerEvent(QTimerEvent *event)
|
||||
|
||||
bool Applet::isContainment() const
|
||||
{
|
||||
//HACK: this is a special case for the systray
|
||||
//containment in an applet that is not a containment
|
||||
Applet *pa = qobject_cast<Applet *>(parent());
|
||||
if (pa && !pa->isContainment()) {
|
||||
return true;
|
||||
}
|
||||
//normal "acting as a containment" condition
|
||||
return qobject_cast<const Containment*>(this) && qobject_cast<Corona *>(parent());
|
||||
}
|
||||
|
||||
|
@ -177,28 +177,30 @@ void Containment::restore(KConfigGroup &group)
|
||||
restoreContents(group);
|
||||
setImmutability((Types::ImmutabilityType)group.readEntry("immutability", (int)Types::Mutable));
|
||||
|
||||
KConfigGroup cfg = KConfigGroup(corona()->config(), "ActionPlugins");
|
||||
cfg = KConfigGroup(&cfg, QString::number(containmentType()));
|
||||
if (isContainment()) {
|
||||
KConfigGroup cfg = KConfigGroup(corona()->config(), "ActionPlugins");
|
||||
cfg = KConfigGroup(&cfg, QString::number(containmentType()));
|
||||
|
||||
|
||||
//qDebug() << cfg.keyList();
|
||||
if (cfg.exists()) {
|
||||
foreach (const QString &key, cfg.keyList()) {
|
||||
//qDebug() << "loading" << key;
|
||||
setContainmentActions(key, cfg.readEntry(key, QString()));
|
||||
}
|
||||
} else { //shell defaults
|
||||
KConfigGroup defaultActionsCfg;
|
||||
if (d->type == Plasma::Types::PanelContainment) {
|
||||
defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->package().filePath("defaults")), "Panel");
|
||||
//Plasma::Types::DesktopContainment
|
||||
} else {
|
||||
defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->package().filePath("defaults")), "Desktop");
|
||||
}
|
||||
defaultActionsCfg = KConfigGroup(&defaultActionsCfg, "ContainmentActions");
|
||||
//qDebug() << cfg.keyList();
|
||||
if (cfg.exists()) {
|
||||
foreach (const QString &key, cfg.keyList()) {
|
||||
//qDebug() << "loading" << key;
|
||||
setContainmentActions(key, cfg.readEntry(key, QString()));
|
||||
}
|
||||
} else { //shell defaults
|
||||
KConfigGroup defaultActionsCfg;
|
||||
if (d->type == Plasma::Types::PanelContainment) {
|
||||
defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->package().filePath("defaults")), "Panel");
|
||||
//Plasma::Types::DesktopContainment
|
||||
} else {
|
||||
defaultActionsCfg = KConfigGroup(KSharedConfig::openConfig(corona()->package().filePath("defaults")), "Desktop");
|
||||
}
|
||||
defaultActionsCfg = KConfigGroup(&defaultActionsCfg, "ContainmentActions");
|
||||
|
||||
foreach (const QString &key, defaultActionsCfg.keyList()) {
|
||||
setContainmentActions(key, defaultActionsCfg.readEntry(key, QString()));
|
||||
foreach (const QString &key, defaultActionsCfg.keyList()) {
|
||||
setContainmentActions(key, defaultActionsCfg.readEntry(key, QString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ bool DeclarativeAppletScript::init()
|
||||
Plasma::Applet *a = applet();
|
||||
Plasma::Containment *pc = qobject_cast<Plasma::Containment *>(a);
|
||||
|
||||
if (pc) {
|
||||
if (pc && pc->isContainment()) {
|
||||
m_interface = new ContainmentInterface(this);
|
||||
|
||||
//fail? so it's a normal Applet
|
||||
|
Loading…
Reference in New Issue
Block a user