From 22de66fdc07cd22205a9239939205e270f6f9f20 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 11 Oct 2007 19:16:01 +0000 Subject: [PATCH] * 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 --- applet.cpp | 2 +- containment.cpp | 12 +++++++----- corona.cpp | 4 ++-- widgets/widget.cpp | 6 +++--- widgets/widget.h | 3 ++- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/applet.cpp b/applet.cpp index efd25d1d0..4d9a79aff 100644 --- a/applet.cpp +++ b/applet.cpp @@ -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()); diff --git a/containment.cpp b/containment.cpp index 05b67aedd..21ca63fdf 100644 --- a/containment.cpp +++ b/containment.cpp @@ -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; diff --git a/corona.cpp b/corona.cpp index be7a3752c..fb9cef6e3 100644 --- a/corona.cpp +++ b/corona.cpp @@ -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 applets; Plasma::Applet *tasksApplet = panel->addApplet("tasks"); diff --git a/widgets/widget.cpp b/widgets/widget.cpp index ae1156208..7b11e39c8 100644 --- a/widgets/widget.cpp +++ b/widgets/widget.cpp @@ -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; } diff --git a/widgets/widget.h b/widgets/widget.h index f86c33a4f..4bf940361 100644 --- a/widgets/widget.h +++ b/widgets/widget.h @@ -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,