* fix order of constraints init so that geometry is done before screen affinity

* only adjust the size of the containment to the screen size if it is a DesktopContainMent

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=724225
This commit is contained in:
Aaron J. Seigo 2007-10-11 19:16:01 +00:00
parent c8281cbd05
commit 22de66fdc0
5 changed files with 15 additions and 12 deletions

View File

@ -1092,7 +1092,7 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
void Applet::setGeometry(const QRectF& geometry)
{
if (size() != geometry.size()) {
if (geometry.size().width() > 0 && geometry.size().height() > 0 && size() != geometry.size()) {
prepareGeometryChange();
qreal width = qBound(minimumSize().width(), geometry.size().width(), maximumSize().width());
qreal height = qBound(minimumSize().height(), geometry.size().height(), maximumSize().height());

View File

@ -126,9 +126,10 @@ void Containment::init()
void Containment::initConstraints(KConfigGroup* group)
{
kDebug() << "initConstraints" << group->name() << type();
setScreen(group->readEntry("screen", 0));
setFormFactor((Plasma::FormFactor)group->readEntry("formfactor", (int)Plasma::Planar));
setLocation((Plasma::Location)group->readEntry("location", (int)Plasma::Desktop));
setGeometry(group->readEntry("geometry", QRectF()));
setFormFactor((Plasma::FormFactor)group->readEntry("formfactor", (int)Plasma::Planar));
setScreen(group->readEntry("screen", 0));
}
void Containment::saveConstraints(KConfigGroup* group) const
@ -190,7 +191,7 @@ QSizeF Containment::contentSizeHint() const
void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
{
kDebug() << "let's see if we manage to get a context menu here, huh";
//kDebug() << "let's see if we manage to get a context menu here, huh";
if (!scene() || !KAuthorized::authorizeKAction("desktop_contextmenu")) {
QGraphicsItem::contextMenuEvent(event);
return;
@ -451,9 +452,10 @@ void Containment::setScreen(int screen)
screen = -1;
}
if (screen > -1) {
//kDebug() << "setting scrreen to " << screen << "and type is" << type();
if (screen > -1 && type() == DesktopContainment) {
setGeometry(desktop.screenGeometry(screen));
//kDebug() << "setting geometry to" << desktop.screenGeometry(screen);
//kDebug() << "setting geometry to" << desktop.screenGeometry(screen) << geometry();
}
d->screen = screen;

View File

@ -153,7 +153,6 @@ void Corona::loadApplets(const QString& configname)
if (c) {
containments.insert(c->id(), c);
c->initConstraints(&appletConfig);
c->setGeometry(appletConfig.readEntry("geometry", QRectF()));
kDebug() << "Containment" << c->id() << "geometry is" << c->geometry();
}
} else {
@ -179,7 +178,7 @@ void Corona::loadApplets(const QString& configname)
kDebug() << "creating applet " << cg.name() << "in containment" << cid;
int appId = cg.name().left(cg.name().indexOf('-')).toUInt();
c->addApplet(cg.readEntry("plugin", QString()), QVariantList(),
appId, cg.readEntry("geometry", QRectF()), true);
appId, cg.readEntry("geometry", QRectF()), true);
}
foreach (Containment* c, containments) {
@ -223,6 +222,7 @@ void Corona::loadDefaultSetup()
// make a panel at the bottom
Containment* panel = addContainment("panel", (QVariantList() << (int)Plasma::BottomEdge));
return;
// some default applets to get a usable UI
QList<Plasma::Applet*> applets;
Plasma::Applet *tasksApplet = panel->addApplet("tasks");

View File

@ -208,7 +208,7 @@ QRectF Widget::localGeometry() const
void Widget::setGeometry(const QRectF& geometry)
{
if (d->size != geometry.size()) {
if (geometry.size().width() > 0 && geometry.size().height() > 0 && d->size != geometry.size()) {
prepareGeometryChange();
qreal width = qBound(d->minimumSize.width(), geometry.size().width(), d->maximumSize.width());
qreal height = qBound(d->minimumSize.height(), geometry.size().height(), d->maximumSize.height());
@ -243,7 +243,7 @@ QSizeF Widget::sizeHint() const
if (layout()) {
return layout()->sizeHint();
} else {
return QSizeF();
return boundingRect().size();
}
}
@ -327,7 +327,7 @@ void Widget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
// Recreate the pixmap if it's gone.
if (pix.isNull()) {
pix = QPixmap(d->cacheSize);
pix.fill(Qt::transparent);
pix.fill(Qt::transparent);
exposed = brect;
}

View File

@ -45,7 +45,8 @@ class Layout;
* Widgets are rectangular, but can be in any visible shape by just using transparency to mask
* out non-rectangular areas.
*
* To implement a Widget, just subclass Plasma::Widget and implement at minimum, sizeHint() and paint()
* To implement a Widget, just subclass Plasma::Widget and implement at minimum,
* sizeHint() and paintWidget()
*/
class PLASMA_EXPORT Widget : public QObject,
public QGraphicsItem,