parley
themedbackgroundrenderer.cpp
Go to the documentation of this file.
29 ThemedBackgroundRenderer::ThemedBackgroundRenderer(QObject* parent, const QString& cacheFilename)
136 // we already renderered an image with that exact sizing, no need to waste resources on it again
203 margins.setBottom(m_renderer.boundsOnElement(rect + "-border-bottomleft").toAlignedRect().height());
207 margins.setRight(m_renderer.boundsOnElement(rect + "-border-topright").toAlignedRect().width());
223 rect.second = QRect(QPoint(margins.left(), margins.top()), rect.second.size() - QSize(margins.right() + margins.left(), margins.bottom() + margins.top()));
232 void ThemedBackgroundRenderer::renderRect(const QString& name, const QRect& rect, QPainter *p, bool fastScale)
234 renderItem(name, "center", rect, p, fastScale, Rect, Qt::IgnoreAspectRatio, Center, Centered, true);
235 renderItem(name, "center-ratio", rect, p, fastScale, Rect, Qt::IgnoreAspectRatio, Center, Centered, true);
236 renderItem(name, "center-noscale", rect, p, fastScale, NoScale, Qt::IgnoreAspectRatio, Center, Centered, true);
238 renderItem(name, "border-topleft", rect, p, fastScale, NoScale, Qt::IgnoreAspectRatio, Top, Corner, false);
239 renderItem(name, "border-topright", rect, p, fastScale, NoScale, Qt::IgnoreAspectRatio, Right, Corner, false);
240 renderItem(name, "border-bottomleft", rect, p, fastScale, NoScale, Qt::IgnoreAspectRatio, Left, Corner, false);
241 renderItem(name, "border-bottomright", rect, p, fastScale, NoScale, Qt::IgnoreAspectRatio, Bottom, Corner, false);
262 renderItem(name, QString(inside ? "inside" : "border") + "-" + edge, rect, p, fastScale, scaleBase, Qt::IgnoreAspectRatio, alignEdge, Centered, inside);
263 renderItem(name, QString(inside ? "inside" : "border") + "-" + edge + "-ratio", rect, p, fastScale, scaleBase, Qt::KeepAspectRatio, alignEdge, Centered, inside);
264 renderItem(name, QString(inside ? "inside" : "border") + "-" + edge + "-noscale", rect, p, fastScale, NoScale, Qt::IgnoreAspectRatio, alignEdge, Centered, inside);
265 renderItem(name, QString(inside ? "inside" : "border") + "-" + edge + "-repeat", rect, p, fastScale, scaleBase, Qt::IgnoreAspectRatio, alignEdge, Repeated, inside);
266 renderItem(name, QString(inside ? "inside" : "border") + "-" + edge + "-" + (scaleBase == Vertical ? "top" : "left"), rect, p, fastScale, NoScale, Qt::IgnoreAspectRatio, alignEdge, LeftTop, inside);
267 renderItem(name, QString(inside ? "inside" : "border") + "-" + edge + "-" + (scaleBase == Vertical ? "bottom" : "right"), rect, p, fastScale, NoScale, Qt::IgnoreAspectRatio, alignEdge, RightBottom, inside);
272 void ThemedBackgroundRenderer::renderItem(const QString& idBase, const QString& idSuffix, const QRect& rect, QPainter *p, bool fastScale, ScaleBase scaleBase, Qt::AspectRatioMode aspectRatio, Edge edge, Align align, bool inside)
275 // (otherwise, images could share a place in the cache which makes it useless if they have different sizes)
278 QString mappedId = m_rectMappings.contains(idBase) ? m_rectMappings.value(idBase) + '-' + idSuffix : id;
299 image = m_cache.getImage(id).scaled(itemRect.size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
327 QRect ThemedBackgroundRenderer::scaleRect(QRectF itemRect, const QRect& baseRect, ScaleBase scaleBase, Qt::AspectRatioMode aspectRatio)
399 QRect ThemedBackgroundRenderer::alignRect(QRect itemRect, const QRect &baseRect, Edge edge, Align align, bool inside)
void setInterval(int msec)
void clear()
QSize size() const
QRect toRect() const
void setSaveFilename(const QString &filename)
Definition: imagecache.h:42
int right() const
void setTop(int Top)
bool isEmpty() const
int left() const
void updateBackgroundTimeout()
Definition: themedbackgroundrenderer.cpp:128
QSizeF size() const
const T & at(int i) const
void setLeft(int left)
QPixmap getScaledBackground()
Definition: themedbackgroundrenderer.cpp:78
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
int height() const
int x() const
int y() const
QImage copy(const QRect &rectangle) const
QMargins contentMargins()
Definition: themedbackgroundrenderer.cpp:190
void setHeight(qreal height)
void moveTo(int x, int y)
QColor fontColor(const QString &context, const QColor &fallback)
Definition: themedbackgroundrenderer.cpp:106
const char * name() const
void append(const T &value)
bool empty() const
void fill(uint pixelValue)
int top() const
QSize toSize() const
int toInt(bool *ok, int base) const
bool isEmpty() const
void setRight(int right)
bool isEmpty() const
QRect rect() const
int bottom() const
void addRect(const QString &name, const QRect &rect)
Definition: themedbackgroundrenderer.cpp:69
QSizeF getSizeForId(const QString &id)
Definition: themedbackgroundrenderer.cpp:154
QPoint center() const
QFuture< T > run(Function function,...)
void setFuture(const QFuture< T > &future)
QRectF getRectForId(const QString &id)
Definition: themedbackgroundrenderer.cpp:161
void clear()
QString toLower() const
const T value(const Key &key) const
void updateImage(const QString &id, const QImage &image)
Definition: imagecache.cpp:39
bool isNull() const
bool contains(QChar ch, Qt::CaseSensitivity cs) const
void setTheme(const QString &theme)
Definition: themedbackgroundrenderer.cpp:50
T result() const
ThemedBackgroundRenderer(QObject *parent, const QString &cacheFilename)
Definition: themedbackgroundrenderer.cpp:29
void backgroundChanged(QPixmap pixmap)
void waitForFinished()
bool isNull() const
int width() const
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
qreal width() const
QString mid(int position, int n) const
void updateBackground()
Definition: themedbackgroundrenderer.cpp:119
void waitForFinished()
QPixmap getPixmapForId(const QString &id, QSize size=QSize())
Definition: themedbackgroundrenderer.cpp:168
void setWidth(qreal width)
QPoint topLeft() const
int length() const
void start(int msec)
~ThemedBackgroundRenderer()
Definition: themedbackgroundrenderer.cpp:40
qreal height() const
bool contains(const Key &key) const
int resultCount() const
void moveCenter(const QPoint &position)
void clearRects()
Definition: themedbackgroundrenderer.cpp:63
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void setFilenames(const QStringList &filename)
Definition: imagecache.cpp:25
void renderingFinished()
Definition: themedbackgroundrenderer.cpp:144
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
bool isRunning() const
void setSingleShot(bool singleShot)
void setBottom(int bottom)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:15:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.