remove createLayout from Containment. now each containment will need to implement its own layouting. this is not so big a deal since FreeLayout is no longer needed to make applets behave properly. now panels can do whatever the heck they want.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=802255
This commit is contained in:
parent
fa166c72ef
commit
69524609a3
@ -355,8 +355,6 @@ void Containment::setFormFactor(FormFactor formFactor)
|
||||
//kDebug() << "switching FF to " << formFactor;
|
||||
FormFactor was = d->formFactor;
|
||||
|
||||
createLayout(formFactor);
|
||||
|
||||
d->formFactor = formFactor;
|
||||
|
||||
if (isContainment() && containmentType() == PanelContainment && was != formFactor) {
|
||||
@ -364,73 +362,9 @@ void Containment::setFormFactor(FormFactor formFactor)
|
||||
d->positionPanel(true);
|
||||
}
|
||||
|
||||
QGraphicsLayout *lay = layout();
|
||||
QGraphicsLinearLayout * linearLay = dynamic_cast<QGraphicsLinearLayout *>(lay);
|
||||
if (linearLay) {
|
||||
foreach (Applet* applet, d->applets) {
|
||||
applet->updateConstraints(Plasma::FormFactorConstraint);
|
||||
}
|
||||
}
|
||||
updateConstraints(Plasma::FormFactorConstraint);
|
||||
}
|
||||
|
||||
void Containment::createLayout(FormFactor formFactor)
|
||||
{
|
||||
//note: setting a new layout autodeletes the old one
|
||||
//and creating a layout calls setLayout on the parent
|
||||
switch (formFactor) {
|
||||
case Planar:
|
||||
case MediaCenter:
|
||||
//setLayout(new QGraphicsLinearLayout());
|
||||
break;
|
||||
case Horizontal: {
|
||||
if
|
||||
(!layout())
|
||||
{
|
||||
QGraphicsLinearLayout *lay = new QGraphicsLinearLayout();
|
||||
lay->setOrientation(Qt::Horizontal);
|
||||
lay->setContentsMargins(0, 0, 0, 0);
|
||||
lay->setSpacing(4);
|
||||
lay->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
|
||||
setLayout(lay);
|
||||
}
|
||||
else
|
||||
{
|
||||
QGraphicsLayout *lay = layout();
|
||||
QGraphicsLinearLayout * linearLay = dynamic_cast<QGraphicsLinearLayout *>(lay);
|
||||
if (linearLay) {
|
||||
linearLay->setOrientation(Qt::Horizontal);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Vertical: {
|
||||
if
|
||||
(!layout())
|
||||
{
|
||||
QGraphicsLinearLayout *lay = new QGraphicsLinearLayout();
|
||||
lay->setOrientation(Qt::Vertical);
|
||||
lay->setContentsMargins(0, 0, 0, 0);
|
||||
lay->setSpacing(4);
|
||||
setLayout(lay);
|
||||
}
|
||||
else
|
||||
{
|
||||
QGraphicsLayout *lay = layout();
|
||||
QGraphicsLinearLayout * linearLay = dynamic_cast<QGraphicsLinearLayout *>(lay);
|
||||
if (linearLay) {
|
||||
linearLay->setOrientation(Qt::Vertical);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
kDebug() << "This can't be happening! Or... can it? ;)" << d->formFactor;
|
||||
//setLayout(0); //auto-delete
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FormFactor Containment::formFactor() const
|
||||
{
|
||||
if (isContainment()) {
|
||||
@ -1001,7 +935,8 @@ void Containment::Private::containmentConstraintsEvent(Plasma::Constraints const
|
||||
toolBox->enableTool("addwidgets", q->immutability() == NotImmutable);
|
||||
}
|
||||
|
||||
if (constraints & Plasma::FormFactorConstraint && toolBox) {
|
||||
if (constraints & Plasma::FormFactorConstraint) {
|
||||
if (toolBox) {
|
||||
if (q->formFactor() == Vertical) {
|
||||
toolBox->setOrientation(Qt::Vertical);
|
||||
//defaults to horizontal
|
||||
@ -1010,6 +945,11 @@ void Containment::Private::containmentConstraintsEvent(Plasma::Constraints const
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Applet *applet, applets) {
|
||||
applet->updateConstraints(Plasma::FormFactorConstraint);
|
||||
}
|
||||
}
|
||||
|
||||
if (constraints & Plasma::SizeConstraint) {
|
||||
switch (q->containmentType()) {
|
||||
case PanelContainment:
|
||||
|
@ -344,16 +344,6 @@ class PLASMA_EXPORT Containment : public Applet
|
||||
*/
|
||||
void setContainmentType(Containment::Type type);
|
||||
|
||||
/**
|
||||
* Optionally creates a layout for the Containment for the new
|
||||
* form factor. This is called before the current form factor is
|
||||
* reset, and adding applets to the new layout, if any, is handled
|
||||
* automatically.
|
||||
*
|
||||
* @param formFactor the new FormFacto
|
||||
*/
|
||||
virtual void createLayout(FormFactor formFactor);
|
||||
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
Loading…
Reference in New Issue
Block a user