Enable DeviceCoordinateCacheMode by default. Overload update() to give
it invalidate-like behavior, and remove invalidate(). Revert last change to analogclock, cached behavior is now enabled for all applets. If you want to disable caching, call setCachePaintMode(NoCacheMode) from your applet's constructor. svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=710764
This commit is contained in:
parent
6828d212bb
commit
1cf7d7c0f6
@ -89,6 +89,7 @@ Widget::Widget(QGraphicsItem *parent,QObject* parentObject)
|
|||||||
{
|
{
|
||||||
setFlag(QGraphicsItem::ItemClipsToShape, true);
|
setFlag(QGraphicsItem::ItemClipsToShape, true);
|
||||||
setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
|
setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
|
||||||
|
setCachePaintMode(DeviceCoordinateCacheMode);
|
||||||
d->parent = dynamic_cast<Widget *>(parent);
|
d->parent = dynamic_cast<Widget *>(parent);
|
||||||
|
|
||||||
if (d->parent) {
|
if (d->parent) {
|
||||||
@ -114,17 +115,13 @@ qreal Widget::opacity() const
|
|||||||
void Widget::setCachePaintMode(CachePaintMode mode, const QSize &size)
|
void Widget::setCachePaintMode(CachePaintMode mode, const QSize &size)
|
||||||
{
|
{
|
||||||
d->cachePaintMode = mode;
|
d->cachePaintMode = mode;
|
||||||
d->cacheSize = size;
|
|
||||||
if (mode == NoCacheMode) {
|
if (mode == NoCacheMode) {
|
||||||
QPixmapCache::remove(d->cacheKey);
|
QPixmapCache::remove(d->cacheKey);
|
||||||
d->cacheKey.clear();
|
d->cacheKey.clear();
|
||||||
update();
|
|
||||||
} else {
|
} else {
|
||||||
if (mode == ItemCoordinateCacheMode) {
|
|
||||||
d->cacheKey = QString("%1").arg(long(this));
|
d->cacheKey = QString("%1").arg(long(this));
|
||||||
d->cacheSize = size;
|
if (mode == ItemCoordinateCacheMode)
|
||||||
}
|
d->cacheSize = size.isNull() ? boundingRect().size().toSize() : size;
|
||||||
invalidate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,11 +130,11 @@ Widget::CachePaintMode Widget::cachePaintMode() const
|
|||||||
return d->cachePaintMode;
|
return d->cachePaintMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::invalidate(const QRectF &rect)
|
void Widget::update(const QRectF &rect)
|
||||||
{
|
{
|
||||||
if (d->cachePaintMode != NoCacheMode)
|
if (d->cachePaintMode != NoCacheMode)
|
||||||
d->cacheInvalidated |= rect.isNull() ? boundingRect() : rect;
|
d->cacheInvalidated |= rect.isNull() ? boundingRect() : rect;
|
||||||
update(rect);
|
QGraphicsItem::update(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::Orientations Widget::expandingDirections() const
|
Qt::Orientations Widget::expandingDirections() const
|
||||||
|
@ -225,9 +225,9 @@ public:
|
|||||||
* Invalidates the widget's cache paint mode for a given item rectangle.
|
* Invalidates the widget's cache paint mode for a given item rectangle.
|
||||||
* @param rect the optional invalidated rectangle; if null, defaults to boundingRect().
|
* @param rect the optional invalidated rectangle; if null, defaults to boundingRect().
|
||||||
*/
|
*/
|
||||||
void invalidate(const QRectF &rect = QRectF());
|
void update(const QRectF &rect = QRectF());
|
||||||
inline void invalidate(qreal _x, qreal _y, qreal w, qreal h)
|
inline void update(qreal _x, qreal _y, qreal w, qreal h)
|
||||||
{ invalidate(QRectF(_x, _y, w, h)); }
|
{ update(QRectF(_x, _y, w, h)); }
|
||||||
|
|
||||||
virtual QGraphicsItem* graphicsItem();
|
virtual QGraphicsItem* graphicsItem();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user