cut some fat; we don't actually use the shadow item, and haven't since before 4.0

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=839264
This commit is contained in:
Aaron J. Seigo 2008-07-29 16:52:44 +00:00
parent bea1a12168
commit f0c70f7c41
4 changed files with 6 additions and 230 deletions

View File

@ -54,7 +54,6 @@ set(plasma_LIB_SRCS
scripting/scriptengine.cpp
service.cpp
servicejob.cpp
shadowitem.cpp
svg.cpp
theme.cpp
toolbox.cpp

View File

@ -68,7 +68,6 @@
#include "plasma/packages_p.h"
#include "plasma/plasma.h"
#include "plasma/scripting/appletscript.h"
#include "plasma/shadowitem_p.h"
#include "plasma/svg.h"
#include "plasma/panelsvg.h"
#include "plasma/theme.h"
@ -597,30 +596,6 @@ void Applet::setBackgroundHints(const BackgroundHints hints)
d->background = 0;
setContentsMargins(0, 0, 0, 0);
}
//Draw the shadow?
//There are various problems with shadows right now:
//
//1) shadows can be seen through translucent areas, which is probably technically correct ubt
//looks odd
//2) the shape of the item odesn't conform to the shape of the standard background, e.g. with
//rounded corners
#ifdef DYNAMIC_SHADOWS
if (hints & ShadowedBackground) {
if (d->shadow) {
d->shadow->setVisible(true);
} else {
d->shadow = new ShadowItem(this);
if (scene()) {
scene()->addItem(d->shadow);
d->shadow->show();
}
}
} else {
delete d->shadow;
d->shadow = 0;
}
#endif
}
bool Applet::hasFailedToLaunch() const
@ -765,21 +740,12 @@ void Applet::flushPendingConstraintsEvents()
if (c & Plasma::FormFactorConstraint) {
FormFactor f = formFactor();
//FIXME: this is a bit of a mess: calling setBackgroundHints twice,
// and moving an item to a non-vert/horiz containment that
// normally doesn't request a background would then get one!
if (f == Planar) {
setBackgroundHints(d->backgroundHints|ShadowedBackground);
} else if (d->backgroundHints&ShadowedBackground) {
setBackgroundHints(d->backgroundHints^ShadowedBackground);
}
if (!isContainment() && f != Vertical && f != Horizontal) {
setBackgroundHints(d->backgroundHints|StandardBackground);
} else if(d->backgroundHints&StandardBackground) {
setBackgroundHints(d->backgroundHints^StandardBackground);
} else if(d->backgroundHints&TranslucentBackground) {
setBackgroundHints(d->backgroundHints^TranslucentBackground);
setBackgroundHints(d->backgroundHints | StandardBackground);
} else if(d->backgroundHints & StandardBackground) {
setBackgroundHints(d->backgroundHints ^ StandardBackground);
} else if(d->backgroundHints & TranslucentBackground) {
setBackgroundHints(d->backgroundHints ^ TranslucentBackground);
}
}
@ -864,11 +830,6 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
p = painter;
}
if (d->shadow && d->shadow->shadowedSize() != boundingRect().size()) {
//kDebug() << "sizes are " << d->shadow->shadowedSize() << boundingRect().size();
d->shadow->generate();
}
p->save();
if (transform().isRotating()) {
@ -1364,36 +1325,13 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
{
//kDebug() << change;
switch (change) {
case ItemPositionChange:
if (d->shadow) {
d->shadow->adjustPosition();
}
break;
case ItemSceneHasChanged: {
QGraphicsScene *newScene = qvariant_cast<QGraphicsScene*>(value);
if (newScene) {
d->checkImmutability();
}
if (d->shadow) {
if (d->shadow->scene()) {
d->shadow->scene()->removeItem(d->shadow);
}
if (newScene) {
newScene->addItem(d->shadow);
d->shadow->generate();
d->shadow->adjustPosition();
d->shadow->show();
}
}
}
break;
case ItemVisibleChange:
if (d->shadow) {
d->shadow->setVisible(isVisible());
}
break;
case ItemPositionHasChanged:
emit geometryChanged();
break;
@ -1528,7 +1466,6 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
background(0),
script(0),
configXml(0),
shadow(0),
mainConfig(0),
pendingConstraints(NoConstraint),
aspectRatioMode(Plasma::KeepAspectRatio),
@ -1551,13 +1488,12 @@ AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet
AppletPrivate::~AppletPrivate()
{
foreach ( const QString& engine, loadedEngines ) {
foreach (const QString& engine, loadedEngines) {
DataEngineManager::self()->unloadEngine( engine );
}
delete background;
delete package;
delete configXml;
delete shadow;
delete mainConfig;
}

View File

@ -1,109 +0,0 @@
/*
* Copyright 2007 by Zack Rusin <zack@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "shadowitem_p.h"
#include "effects/blur.cpp"
#include <QPainter>
#include <QImage>
#include <QDebug>
namespace Plasma
{
ShadowItem::ShadowItem(QGraphicsItem *item)
{
setZValue(20);
m_shadowParent = 0;
m_offset = QPointF(12, 12);
setShadowParent(item);
}
void ShadowItem::setShadowParent(QGraphicsItem *item)
{
m_shadowParent = item;
adjustPosition();
generate();
}
QGraphicsItem * ShadowItem::shadowParent() const
{
return m_shadowParent;
}
QSize ShadowItem::shadowedSize() const
{
QSize s = boundingRect().size().toSize();
return s - QSize(32, 32);
}
void ShadowItem::generate()
{
if (!m_shadowParent) {
return;
}
QPainterPath path = m_shadowParent->shape();
QRectF rect = path.boundingRect();
QSize s = rect.size().toSize() + QSize(30, 30);
QImage img(s, QImage::Format_ARGB32_Premultiplied);
img.fill(0);
QPainter p(&img);
p.translate(15, 15);
p.setRenderHint(QPainter::Antialiasing);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.fillPath(path, Qt::gray);
p.end();
#ifdef DO_GLOW
QImage blurred = img;
expblur<16, 7>(img, 7);
p.begin(&img);
p.setCompositionMode(QPainter::CompositionMode_Plus);
p.drawImage(0, 0, blurred);
p.end();
#else
expblur<16, 7>(img, 7);
#endif
setPixmap(QPixmap::fromImage(img));
}
void ShadowItem::adjustPosition()
{
if (!m_shadowParent) {
return;
}
setPos(m_shadowParent->pos() - m_offset);
}
void ShadowItem::setOffset(const QPointF &offset)
{
m_offset = offset;
}
QPointF ShadowItem::offset() const
{
return m_offset;
}
}

View File

@ -1,50 +0,0 @@
/*
* Copyright 2007 by Zack Rusin <zack@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SHADOWITEM_P_H
#define SHADOWITEM_P_H
#include <QtGui/QGraphicsPixmapItem>
namespace Plasma
{
class ShadowItem : public QGraphicsPixmapItem
{
public:
explicit ShadowItem(QGraphicsItem* item);
void setShadowParent(QGraphicsItem *item);
QGraphicsItem *shadowParent() const;
void setOffset(const QPointF &offset);
QPointF offset() const;
QSize shadowedSize() const;
void generate();
void adjustPosition();
private:
QGraphicsItem *m_shadowParent;
QPointF m_offset;
};
}
#endif