handle the setting of the default type a bit differently; delay it until init and only if the subclass hasn't set something on us

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=742839
This commit is contained in:
Aaron J. Seigo 2007-11-29 00:20:37 +00:00
parent c746f91370
commit eb62d53f8f
2 changed files with 29 additions and 18 deletions

View File

@ -60,7 +60,7 @@ public:
screen(-1), screen(-1),
immutable(false), immutable(false),
toolbox(0), toolbox(0),
type(Containment::DesktopContainment) type(Containment::NoContainmentType)
{ {
} }
@ -89,6 +89,7 @@ Containment::Containment(QGraphicsItem* parent,
// WARNING: do not access config() OR globalConfig() in this method! // WARNING: do not access config() OR globalConfig() in this method!
// that requires a scene, which is not available at this point // that requires a scene, which is not available at this point
setDrawStandardBackground(false); setDrawStandardBackground(false);
setContainmentType(CustomContainment);
} }
Containment::Containment(QObject* parent, const QVariantList& args) Containment::Containment(QObject* parent, const QVariantList& args)
@ -117,21 +118,8 @@ void Containment::init()
connect(Phase::self(), SIGNAL(animationComplete(QGraphicsItem*,Plasma::Phase::Animation)), connect(Phase::self(), SIGNAL(animationComplete(QGraphicsItem*,Plasma::Phase::Animation)),
this, SLOT(appletAnimationComplete(QGraphicsItem*,Plasma::Phase::Animation))); this, SLOT(appletAnimationComplete(QGraphicsItem*,Plasma::Phase::Animation)));
if (isContainment() && containmentType() == DesktopContainment) { if (d->type == NoContainmentType) {
Plasma::PushButton *tool = new Plasma::PushButton(i18n("Add Widgets")); setContainmentType(DesktopContainment);
tool->resize(tool->sizeHint());
addToolBoxTool(tool);
connect(tool, SIGNAL(clicked()), this, SIGNAL(showAddWidgets()));
tool = new Plasma::PushButton(i18n("Zoom In"));
connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomIn()));
tool->resize(tool->sizeHint());
addToolBoxTool(tool);
tool = new Plasma::PushButton(i18n("Zoom Out"));
connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomOut()));
tool->resize(tool->sizeHint());
addToolBoxTool(tool);
} }
} }
@ -170,6 +158,28 @@ Containment::Type Containment::containmentType() const
void Containment::setContainmentType(Containment::Type type) void Containment::setContainmentType(Containment::Type type)
{ {
d->type = type; d->type = type;
if (isContainment() && type == DesktopContainment) {
if (!d->toolbox) {
Plasma::PushButton *tool = new Plasma::PushButton(i18n("Add Widgets"));
tool->resize(tool->sizeHint());
addToolBoxTool(tool);
connect(tool, SIGNAL(clicked()), this, SIGNAL(showAddWidgets()));
tool = new Plasma::PushButton(i18n("Zoom In"));
connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomIn()));
tool->resize(tool->sizeHint());
addToolBoxTool(tool);
tool = new Plasma::PushButton(i18n("Zoom Out"));
connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomOut()));
tool->resize(tool->sizeHint());
addToolBoxTool(tool);
}
} else {
delete d->toolbox;
d->toolbox = 0;
}
} }
Corona* Containment::corona() const Corona* Containment::corona() const
@ -309,7 +319,7 @@ void Containment::setFormFactor(FormFactor formFactor)
//FIXME: need a layout type here! //FIXME: need a layout type here!
break; break;
default: default:
kDebug() << "This can't be happening! Or... can it? ;)"; kDebug() << "This can't be happening! Or... can it? ;)" << d->formFactor;
break; break;
} }

View File

@ -64,7 +64,8 @@ class PLASMA_EXPORT Containment : public Applet
typedef QList<Applet*> List; typedef QList<Applet*> List;
typedef QHash<QString, Applet*> Dict; typedef QHash<QString, Applet*> Dict;
enum Type { DesktopContainment = 0 /**< A desktop containment */, enum Type { NoContainmentType = -1 /**< @internal */,
DesktopContainment = 0 /**< A desktop containment */,
PanelContainment /**< A desktop panel */, PanelContainment /**< A desktop panel */,
CustomContainment /**< A containment that is neither a desktop nor a panel, CustomContainment /**< A containment that is neither a desktop nor a panel,
but something application specific */ but something application specific */