From 79d929e848a6d86c941a76d88bc880bd6e14c0a1 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Thu, 11 Oct 2007 23:20:59 +0000 Subject: [PATCH] bit a bit more careful about what we do depending on what sort of Containment we are. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=724315 --- containment.cpp | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/containment.cpp b/containment.cpp index 21ca63fdf..f8b934792 100644 --- a/containment.cpp +++ b/containment.cpp @@ -103,20 +103,22 @@ void Containment::init() { // setCachePaintMode(NoCacheMode); setFlag(QGraphicsItem::ItemIsMovable, false); - KConfigGroup config(KGlobal::config(), "General"); - d->wallpaperPath = config.readEntry("wallpaper", QString()); - - //kDebug() << "wallpaperPath is" << d->wallpaperPath << QFile::exists(d->wallpaperPath); - if (d->wallpaperPath.isEmpty() || - !QFile::exists(d->wallpaperPath)) { - //kDebug() << "SVG wallpaper!"; - d->background = new Plasma::Svg("widgets/wallpaper", this); - } - setAcceptDrops(true); + if (type() == DesktopContainment) { + KConfigGroup config(KGlobal::config(), "General"); + d->wallpaperPath = config.readEntry("wallpaper", QString()); + + //kDebug() << "wallpaperPath is" << d->wallpaperPath << QFile::exists(d->wallpaperPath); + if (d->wallpaperPath.isEmpty() || + !QFile::exists(d->wallpaperPath)) { + kDebug() << "SVG wallpaper!"; + d->background = new Plasma::Svg("widgets/wallpaper", this); + } + } + if (type() == PanelContainment) { - kDebug() << "we are a panel, let's move ourselves to a negative coordinate system"; + //kDebug() << "we are a panel, let's move ourselves to a negative coordinate system"; QDesktopWidget desktop; QRect r = desktop.screenGeometry(screen()); translate(0, -r.height()); @@ -125,7 +127,7 @@ void Containment::init() void Containment::initConstraints(KConfigGroup* group) { - kDebug() << "initConstraints" << group->name() << type(); + //kDebug() << "initConstraints" << group->name() << type(); setLocation((Plasma::Location)group->readEntry("location", (int)Plasma::Desktop)); setGeometry(group->readEntry("geometry", QRectF())); setFormFactor((Plasma::FormFactor)group->readEntry("formfactor", (int)Plasma::Planar)); @@ -148,6 +150,13 @@ void Containment::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRect& contentsRect) { + //FIXME: this should probably ALL move to the Desktop containment, save for drawing a rect + // in case there is no other drawing going on + if (type() != DesktopContainment) { + return; + } + + //kDebug() << "paintInterface of background"; //TODO: we should have a way to do this outside of the paint event! if (d->background) { d->background->resize(contentsRect.size()); @@ -159,7 +168,8 @@ void Containment::paintInterface(QPainter *painter, } } else { // got nothing to paint! - painter->drawRect(contentsRect); + //kDebug() << "got nothing?"; + painter->drawRect(contentsRect.adjusted(1, 1, -1, -1)); return; } @@ -173,11 +183,13 @@ void Containment::paintInterface(QPainter *painter, if (d->background) { // Plasma::Svg doesn't support drawing only part of the image (it only // supports drawing the whole image to a rect), so we blit to 0,0-w,h - d->background->paint(painter, 0, 0); + d->background->paint(painter, contentsRect); + //kDebug() << "draw svg of background"; } else if (d->bitmapBackground) { // for pixmaps we draw only the exposed part (untransformed since the // bitmapBackground already has the size of the viewport) painter->drawPixmap(option->exposedRect, *d->bitmapBackground, option->exposedRect); + //kDebug() << "draw pixmap of background"; } // restore transformation and composition mode