• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

parley

  • sources
  • kde-4.14
  • kdeedu
  • parley
  • src
  • practice
themedbackgroundrenderer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  Copyright 2010 Daniel Laidig <laidig@kde.org>
3  ***************************************************************************/
4 
5 /***************************************************************************
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  ***************************************************************************/
13 
14 #include "themedbackgroundrenderer.h"
15 
16 #include "settings/kgametheme/kgametheme.h"
17 #include <kdebug.h>
18 #include <kstandarddirs.h>
19 #include <unistd.h>
20 
21 #include <QtConcurrentRun>
22 #include <QPainter>
23 #include <QMargins>
24 #include <QPalette>
25 #include <QApplication>
26 
27 using namespace Practice;
28 
29 ThemedBackgroundRenderer::ThemedBackgroundRenderer(QObject* parent, const QString& cacheFilename)
30  : QObject(parent), m_haveCache(true), m_queuedRequest(false), m_isFastScaledRender(true)
31 {
32  m_theme = new KGameTheme();
33  m_cache.setSaveFilename(KStandardDirs::locateLocal("appdata", cacheFilename));
34  m_timer.setSingleShot(true);
35  m_timer.setInterval(1000);
36  connect(&m_timer, SIGNAL(timeout()), this, SLOT(updateBackgroundTimeout()));
37  connect(&m_watcher, SIGNAL(finished()), this, SLOT(renderingFinished()));
38 }
39 
40 ThemedBackgroundRenderer::~ThemedBackgroundRenderer()
41 {
42  if (m_future.isRunning()) {
43  kDebug() << "Waiting for rendering to finish";
44  m_future.waitForFinished();
45  }
46  m_cache.saveCache();
47  delete m_theme;
48 }
49 
50 void ThemedBackgroundRenderer::setTheme(const QString &theme)
51 {
52  if (!m_theme->load(theme)) {
53  kDebug() << "could not load theme" << theme;
54  }
55  m_renderer.load(m_theme->graphics());
56  m_cache.setFilenames(QStringList(m_theme->graphics()) << m_theme->path());
57  m_haveCache = !m_cache.isEmpty();
58  m_lastScaledRenderRects.clear();
59  m_lastFullRenderRects.clear();
60  m_rectMappings.clear();
61 }
62 
63 void ThemedBackgroundRenderer::clearRects()
64 {
65  m_rects.clear();
66  m_rectMappings.clear();
67 }
68 
69 void ThemedBackgroundRenderer::addRect(const QString& name, const QRect& rect)
70 {
71  m_rects.append(qMakePair<QString, QRect>(name, rect));
72  if (!m_rectMappings.contains(name)) {
73  QString mapped = m_theme->property("X-Parley-" + name);
74  m_rectMappings[name] = mapped.isEmpty() ? name : mapped;
75  }
76 }
77 
78 QPixmap ThemedBackgroundRenderer::getScaledBackground()
79 {
80  if (m_rects.isEmpty() || m_rects[0].second.isEmpty()) {
81  return QPixmap();
82  }
83  if (m_future.isRunning() || m_future.resultCount()) {
84  return QPixmap();
85  }
86  if (m_cache.isEmpty()) {
87  m_timer.start(0);
88  return QPixmap();
89  }
90  if (m_lastScaledRenderRects == m_rects) {
91  // we already renderered an image with that exact sizing, no need to waste resources on it again
92  return QPixmap();
93  }
94 
95  QFutureWatcher<QImage> watcher;
96  m_future = QtConcurrent::run(this, &ThemedBackgroundRenderer::renderBackground, true);
97  watcher.setFuture(m_future);
98  watcher.waitForFinished();
99 
100  QPixmap result = QPixmap::fromImage(m_future.result());
101  m_future = QFuture<QImage>();
102  m_lastScaledRenderRects = m_rects;
103  return result;
104 }
105 
106 QColor ThemedBackgroundRenderer::fontColor(const QString& context, const QColor& fallback)
107 {
108  QString text = m_theme->property("X-Parley-Font-Color-" + context).toLower();
109  if (text.length() == 6 && text.contains(QRegExp("[0-9a-f]{6}"))) {
110  return QColor(text.mid(0, 2).toInt(0, 16),
111  text.mid(2, 2).toInt(0, 16),
112  text.mid(4, 2).toInt(0, 16));
113 
114  }
115 
116  return fallback;
117 }
118 
119 void ThemedBackgroundRenderer::updateBackground()
120 {
121  if (m_rects.isEmpty() || m_rects[0].second.isEmpty()) {
122  return;
123  }
124  m_timer.start();
125 
126 }
127 
128 void ThemedBackgroundRenderer::updateBackgroundTimeout()
129 {
130  bool fastScale = false;
131  if (m_future.isRunning()) {
132  m_timer.start(); // restart the timer again
133  return;
134  }
135  if (m_lastFullRenderRects == m_rects && m_lastScaledRenderRects == m_rects) {
136  // we already renderered an image with that exact sizing, no need to waste resources on it again
137  return;
138  }
139  m_future = QtConcurrent::run(this, &ThemedBackgroundRenderer::renderBackground, fastScale);
140  m_watcher.setFuture(m_future);
141  m_lastFullRenderRects = m_rects;
142 }
143 
144 void ThemedBackgroundRenderer::renderingFinished()
145 {
146  if (!m_future.resultCount()) {
147  //kDebug() << "there is no image!";
148  return;
149  }
150  emit backgroundChanged(QPixmap::fromImage(m_future.result()));
151  m_future = QFuture<QImage>();
152 }
153 
154 QSizeF ThemedBackgroundRenderer::getSizeForId(const QString& id)
155 {
156  if (!m_renderer.elementExists(id))
157  return QSizeF();
158  return m_renderer.boundsOnElement(id).size();
159 }
160 
161 QRectF ThemedBackgroundRenderer::getRectForId(const QString& id)
162 {
163  if (!m_renderer.elementExists(id))
164  return QRectF();
165  return m_renderer.boundsOnElement(id);
166 }
167 
168 QPixmap ThemedBackgroundRenderer::getPixmapForId(const QString& id, QSize size)
169 {
170  if (!m_renderer.elementExists(id))
171  return QPixmap();
172  QRectF itemRect = m_renderer.boundsOnElement(id);
173  if (itemRect.isNull())
174  return QPixmap();
175  if (size.isEmpty())
176  size = itemRect.size().toSize();
177 
178  if (m_cache.imageSize(id) != size) {
179  QImage image(size, QImage::Format_ARGB32_Premultiplied);
180  image.fill(QColor(Qt::transparent).rgba());
181  QPainter p(&image);
182  m_renderer.render(&p, id, QRectF(QPointF(0, 0), size));
183  m_cache.updateImage(id, image);
184  return QPixmap::fromImage(image);
185  } else {
186  return QPixmap::fromImage(m_cache.getImage(id));
187  }
188 }
189 
190 QMargins ThemedBackgroundRenderer::contentMargins()
191 {
192  QString rect;
193  if (!m_rects.empty()) {
194  rect = m_rects.at(0).first;
195  }
196  if (m_rectMappings.contains(rect)) {
197  rect = m_rectMappings.value(rect);
198  }
199  QMargins margins;
200  if (m_renderer.elementExists(rect + "-border-topleft"))
201  margins.setTop(m_renderer.boundsOnElement(rect + "-border-topleft").toAlignedRect().height());
202  if (m_renderer.elementExists(rect + "-border-bottomleft"))
203  margins.setBottom(m_renderer.boundsOnElement(rect + "-border-bottomleft").toAlignedRect().height());
204  if (m_renderer.elementExists(rect + "-border-topleft"))
205  margins.setLeft(m_renderer.boundsOnElement(rect + "-border-topleft").toAlignedRect().width());
206  if (m_renderer.elementExists(rect + "-border-topright"))
207  margins.setRight(m_renderer.boundsOnElement(rect + "-border-topright").toAlignedRect().width());
208  return margins;
209 }
210 
211 QImage ThemedBackgroundRenderer::renderBackground(bool fastScale)
212 {
213  m_isFastScaledRender = false;
214 
215  QImage image(m_rects[0].second.size(), QImage::Format_ARGB32_Premultiplied);
216  image.fill(QColor(Qt::transparent).rgba());
217  QPainter p(&image);
218 
219  QPair<QString, QRect> rect;
220  Q_FOREACH(rect, m_rects) {
221  if (!m_rects.isEmpty() && rect == m_rects[0]) {
222  QMargins margins = contentMargins();
223  rect.second = QRect(QPoint(margins.left(), margins.top()), rect.second.size() - QSize(margins.right() + margins.left(), margins.bottom() + margins.top()));
224  }
225  renderRect(rect.first, rect.second, &p, fastScale);
226  }
227 
228  //kDebug() << "image rendered, time:" << t.elapsed();
229  return image;
230 }
231 
232 void ThemedBackgroundRenderer::renderRect(const QString& name, const QRect& rect, QPainter *p, bool fastScale)
233 {
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);
237 
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);
242 
243  QStringList edges;
244  edges << "top" << "bottom" << "left" << "right";
245  Q_FOREACH(const QString & edge, edges) {
246  ScaleBase scaleBase;
247  Edge alignEdge;
248  if (edge == QLatin1String("top")) {
249  alignEdge = Top;
250  scaleBase = Horizontal;
251  } else if (edge == QLatin1String("bottom")) {
252  alignEdge = Bottom;
253  scaleBase = Horizontal;
254  } else if (edge == QLatin1String("right")) {
255  alignEdge = Right;
256  scaleBase = Vertical;
257  } else {
258  alignEdge = Left;
259  scaleBase = Vertical;
260  }
261  for (int inside = 1; inside >= 0; inside--) {
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);
268  }
269  }
270 }
271 
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)
273 {
274  // the id without the mapping, which we need to use for caching
275  // (otherwise, images could share a place in the cache which makes it useless if they have different sizes)
276  QString id = idBase + '-' + idSuffix;
277  // the id according to the mapping specified in the desktop file
278  QString mappedId = m_rectMappings.contains(idBase) ? m_rectMappings.value(idBase) + '-' + idSuffix : id;
279 
280  if (!m_renderer.elementExists(mappedId))
281  return;
282  QRectF itemRectF = m_renderer.boundsOnElement(mappedId);
283  if (itemRectF.isNull() || rect.isNull())
284  return;
285 
286  //kDebug() << "draw item" << id;
287 // kDebug() << "original item rect:" << itemRect << m_renderer.boundsOnElement(id);
288  QRect itemRect = scaleRect(itemRectF, rect, scaleBase, aspectRatio);
289 // kDebug() << "scaled" << itemRect;
290  itemRect = alignRect(itemRect, rect, edge, align, inside);
291 // kDebug() << "aligned" << itemRect;
292 
293  QImage image;
294  if (m_cache.imageSize(id) == itemRect.size()) {
295  // kDebug() << "found in cache:" << id;
296  image = m_cache.getImage(id);
297  } else if (fastScale && !m_cache.imageSize(id).isEmpty()) {
298  // kDebug() << "FAST SCALE for:" << id;
299  image = m_cache.getImage(id).scaled(itemRect.size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
300  m_isFastScaledRender = true;
301  } else {
302  // kDebug() << "NOT IN CACHE, render svg:" << id;
303  image = QImage(itemRect.size(), QImage::Format_ARGB32_Premultiplied);
304  image.fill(QColor(Qt::transparent).rgba());
305  QPainter painter(&image);
306  if (align == Repeated) {
307  QImage tile(itemRectF.toRect().size(), QImage::Format_ARGB32_Premultiplied);
308  tile.fill(QColor(Qt::transparent).rgba());
309  QPainter tilePainter(&tile);
310  m_renderer.render(&tilePainter, mappedId, QRect(QPoint(0, 0), tile.size()));
311  painter.fillRect(image.rect(), QBrush(tile));
312  } else if (aspectRatio == Qt::KeepAspectRatioByExpanding) {
313  m_renderer.render(&painter, mappedId, QRect(QPoint(0, 0), itemRect.size()));
314  painter.end();
315  QRect croppedRect = rect;
316  croppedRect.moveCenter(itemRect.center());
317  image = image.copy(croppedRect);
318  } else {
319  m_renderer.render(&painter, mappedId, QRect(QPoint(0, 0), itemRect.size()));
320  }
321  m_cache.updateImage(id, image);
322  m_haveCache = true;
323  }
324  p->drawImage(itemRect.topLeft(), image);
325 }
326 
327 QRect ThemedBackgroundRenderer::scaleRect(QRectF itemRect, const QRect& baseRect, ScaleBase scaleBase, Qt::AspectRatioMode aspectRatio)
328 {
329  qreal verticalFactor = 0;
330  qreal horizontalFactor = 0;
331  switch (scaleBase) {
332  case NoScale:
333  return itemRect.toRect();
334  case Horizontal:
335  switch (aspectRatio) {
336  case Qt::IgnoreAspectRatio:
337  itemRect.setWidth(baseRect.width());
338  return itemRect.toRect();
339  case Qt::KeepAspectRatio:
340  horizontalFactor = baseRect.width() / itemRect.width();
341  itemRect.setWidth(baseRect.width());
342  itemRect.setHeight(itemRect.height()*horizontalFactor);
343  return itemRect.toRect();
344  case Qt::KeepAspectRatioByExpanding:
345  kWarning() << "KeepAspectRatioByExpanding only works for the center";
346  return itemRect.toRect();
347  }
348  break;
349  case Vertical:
350  switch (aspectRatio) {
351  case Qt::IgnoreAspectRatio:
352  itemRect.setHeight(baseRect.height());
353  return itemRect.toRect();
354  case Qt::KeepAspectRatio:
355  verticalFactor = baseRect.height() / itemRect.height();
356  itemRect.setHeight(baseRect.height());
357  itemRect.setWidth(itemRect.width()*verticalFactor);
358  return itemRect.toRect();
359  case Qt::KeepAspectRatioByExpanding:
360  kWarning() << "KeepAspectRatioByExpanding only works for the center";
361  return itemRect.toRect();
362  }
363  break;
364  case Rect:
365  switch (aspectRatio) {
366  case Qt::IgnoreAspectRatio:
367  itemRect.setWidth(baseRect.width());
368  itemRect.setHeight(baseRect.height());
369  return itemRect.toRect();
370  case Qt::KeepAspectRatio:
371  horizontalFactor = baseRect.width() / itemRect.width();
372  verticalFactor = baseRect.height() / itemRect.height();
373  if (verticalFactor < horizontalFactor) {
374  itemRect.setHeight(baseRect.height());
375  itemRect.setWidth(itemRect.width()*verticalFactor);
376  } else {
377  itemRect.setWidth(baseRect.width());
378  itemRect.setHeight(itemRect.height()*horizontalFactor);
379  }
380  return itemRect.toRect();
381  case Qt::KeepAspectRatioByExpanding:
382  horizontalFactor = baseRect.width() / itemRect.width();
383  verticalFactor = baseRect.height() / itemRect.height();
384  if (verticalFactor > horizontalFactor) {
385  itemRect.setHeight(baseRect.height());
386  itemRect.setWidth(itemRect.width()*verticalFactor);
387  } else {
388  itemRect.setWidth(baseRect.width());
389  itemRect.setHeight(itemRect.height()*horizontalFactor);
390  }
391  return itemRect.toRect();
392  }
393  break;
394  }
395  // kDebug() << "unhandled scaling option";
396  return itemRect.toRect();
397 }
398 
399 QRect ThemedBackgroundRenderer::alignRect(QRect itemRect, const QRect &baseRect, Edge edge, Align align, bool inside)
400 {
401  if (edge == Center) {
402  int x = baseRect.x() + (baseRect.width() - itemRect.width()) / 2;
403  int y = baseRect.y() + (baseRect.height() - itemRect.height()) / 2;
404  itemRect.moveTo(x, y);
405  return itemRect;
406  }
407 
408  if (edge == Top || edge == Bottom) {
409  // set x coordinate
410  int x = 0;
411  switch (align) {
412  case Corner:
413  if (edge == Top) {
414  x = baseRect.x() - itemRect.width();
415  } else {
416  x = baseRect.x() + baseRect.width();
417  }
418  break;
419  case LeftTop:
420  x = baseRect.x();
421  break;
422  case Centered:
423  case Repeated:
424  x = baseRect.x() + (baseRect.width() - itemRect.width()) / 2;
425  break;
426  case RightBottom:
427  x = baseRect.x() + baseRect.width() - itemRect.width();
428  break;
429  }
430  // set y coordinate
431  int y = baseRect.y();
432  if (edge == Bottom) {
433  y += baseRect.height() - itemRect.height();
434  }
435  if ((!inside) && edge == Top) {
436  y -= itemRect.height();
437  } else if (!inside) {
438  y += itemRect.height();
439  }
440  itemRect.moveTo(x, y);
441  return itemRect;
442  } else if (edge == Left || edge == Right) {
443  // set y coordinate
444  int y = 0;
445  switch (align) {
446  case Corner:
447  if (edge == Right) {
448  y = baseRect.y() - itemRect.height();
449  } else {
450  y = baseRect.y() + baseRect.height();
451  }
452  break;
453  case LeftTop:
454  y = baseRect.y();
455  break;
456  case Centered:
457  case Repeated:
458  y = baseRect.y() + (baseRect.height() - itemRect.height()) / 2;
459  break;
460  case RightBottom:
461  y = baseRect.y() + baseRect.height() - itemRect.height();
462  break;
463  }
464  // set x coordinate
465  int x = baseRect.x();
466  if (edge == Right) {
467  x += baseRect.width() - itemRect.width();
468  }
469  if ((!inside) && edge == Left) {
470  x -= itemRect.width();
471  } else if (!inside) {
472  x += itemRect.width();
473  }
474  itemRect.moveTo(x, y);
475  return itemRect;
476  }
477  // kDebug() << "unhandled alignment option";
478  return itemRect;
479 }
480 
481 #include "themedbackgroundrenderer.moc"
QTimer::setInterval
void setInterval(int msec)
QList::clear
void clear()
QRect::size
QSize size() const
QRectF::toRect
QRect toRect() const
Practice::ImageCache::setSaveFilename
void setSaveFilename(const QString &filename)
Definition: imagecache.h:42
Practice::ThemedBackgroundRenderer::NoScale
Definition: themedbackgroundrenderer.h:37
QMargins::right
int right() const
QMargins::setTop
void setTop(int Top)
QSize::isEmpty
bool isEmpty() const
Practice::ThemedBackgroundRenderer::LeftTop
Definition: themedbackgroundrenderer.h:53
QMargins::left
int left() const
Practice::ThemedBackgroundRenderer::updateBackgroundTimeout
void updateBackgroundTimeout()
Definition: themedbackgroundrenderer.cpp:128
QRectF::size
QSizeF size() const
QList::at
const T & at(int i) const
KGameTheme::path
QString path() const
Definition: kgametheme.cpp:139
QMargins::setLeft
void setLeft(int left)
Practice::ThemedBackgroundRenderer::getScaledBackground
QPixmap getScaledBackground()
Definition: themedbackgroundrenderer.cpp:78
QPixmap::fromImage
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
Practice::ThemedBackgroundRenderer::Edge
Edge
Definition: themedbackgroundrenderer.h:43
QRect::height
int height() const
QBrush
QRect::x
int x() const
QRect::y
int y() const
KGameTheme
Class for loading theme files.
Definition: kgametheme.h:42
QPoint
Practice::ThemedBackgroundRenderer::Top
Definition: themedbackgroundrenderer.h:44
QImage::copy
QImage copy(const QRect &rectangle) const
Practice::ThemedBackgroundRenderer::contentMargins
QMargins contentMargins()
Definition: themedbackgroundrenderer.cpp:190
KGameTheme::graphics
virtual QString graphics() const
Definition: kgametheme.cpp:157
Practice::ThemedBackgroundRenderer::Left
Definition: themedbackgroundrenderer.h:46
QRectF::setHeight
void setHeight(qreal height)
QPointF
QRect::moveTo
void moveTo(int x, int y)
QRegExp
Practice::ThemedBackgroundRenderer::fontColor
QColor fontColor(const QString &context, const QColor &fallback)
Definition: themedbackgroundrenderer.cpp:106
QObject::name
const char * name() const
QRect
QList::append
void append(const T &value)
QList::empty
bool empty() const
QImage::fill
void fill(uint pixelValue)
QObject
QMargins::top
int top() const
QSizeF::toSize
QSize toSize() const
QString::toInt
int toInt(bool *ok, int base) const
QList::isEmpty
bool isEmpty() const
QPainter
QMargins::setRight
void setRight(int right)
QString::isEmpty
bool isEmpty() const
QImage::rect
QRect rect() const
QMargins::bottom
int bottom() const
Practice::ThemedBackgroundRenderer::Corner
Definition: themedbackgroundrenderer.h:52
Practice::ThemedBackgroundRenderer::addRect
void addRect(const QString &name, const QRect &rect)
Definition: themedbackgroundrenderer.cpp:69
Practice::ThemedBackgroundRenderer::getSizeForId
QSizeF getSizeForId(const QString &id)
Definition: themedbackgroundrenderer.cpp:154
QRect::center
QPoint center() const
QtConcurrent::run
QFuture< T > run(Function function,...)
QString
QColor
QFutureWatcher::setFuture
void setFuture(const QFuture< T > &future)
QStringList
QPair
QPixmap
Practice::ThemedBackgroundRenderer::getRectForId
QRectF getRectForId(const QString &id)
Definition: themedbackgroundrenderer.cpp:161
Practice::ImageCache::saveCache
void saveCache()
Definition: imagecache.cpp:91
KGameTheme::load
virtual bool load(const QString &file)
Load a specific theme file.
Definition: kgametheme.cpp:67
Practice::ImageCache::imageSize
QSize imageSize(const QString &id)
Definition: imagecache.cpp:44
QHash::clear
void clear()
QString::toLower
QString toLower() const
QHash::value
const T value(const Key &key) const
Practice::ImageCache::updateImage
void updateImage(const QString &id, const QImage &image)
Definition: imagecache.cpp:39
QRectF::isNull
bool isNull() const
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
QSize
Practice::ThemedBackgroundRenderer::setTheme
void setTheme(const QString &theme)
Definition: themedbackgroundrenderer.cpp:50
QFuture::result
T result() const
Practice::ImageCache::getImage
QImage getImage(const QString &id)
Definition: imagecache.cpp:52
Practice::ThemedBackgroundRenderer::Repeated
Definition: themedbackgroundrenderer.h:55
Practice::ThemedBackgroundRenderer::ThemedBackgroundRenderer
ThemedBackgroundRenderer(QObject *parent, const QString &cacheFilename)
Definition: themedbackgroundrenderer.cpp:29
Practice::ImageCache::isEmpty
bool isEmpty()
Definition: imagecache.h:38
QImage
Practice::ThemedBackgroundRenderer::Rect
Definition: themedbackgroundrenderer.h:40
Practice::ThemedBackgroundRenderer::backgroundChanged
void backgroundChanged(QPixmap pixmap)
QFutureWatcher::waitForFinished
void waitForFinished()
Practice::ThemedBackgroundRenderer::RightBottom
Definition: themedbackgroundrenderer.h:56
QRect::isNull
bool isNull() const
Practice::ThemedBackgroundRenderer::ScaleBase
ScaleBase
Definition: themedbackgroundrenderer.h:36
QRect::width
int width() const
QPainter::drawImage
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
QRectF::width
qreal width() const
QString::mid
QString mid(int position, int n) const
Practice::ThemedBackgroundRenderer::updateBackground
void updateBackground()
Definition: themedbackgroundrenderer.cpp:119
QFuture::waitForFinished
void waitForFinished()
QSizeF
Practice::ThemedBackgroundRenderer::getPixmapForId
QPixmap getPixmapForId(const QString &id, QSize size=QSize())
Definition: themedbackgroundrenderer.cpp:168
QLatin1String
QRectF
QRectF::setWidth
void setWidth(qreal width)
Practice::ThemedBackgroundRenderer::Center
Definition: themedbackgroundrenderer.h:48
QMargins
kgametheme.h
QRect::topLeft
QPoint topLeft() const
QString::length
int length() const
QFutureWatcher< QImage >
Practice::ThemedBackgroundRenderer::Horizontal
Definition: themedbackgroundrenderer.h:38
QTimer::start
void start(int msec)
Practice::ThemedBackgroundRenderer::~ThemedBackgroundRenderer
~ThemedBackgroundRenderer()
Definition: themedbackgroundrenderer.cpp:40
QRectF::height
qreal height() const
QHash::contains
bool contains(const Key &key) const
QFuture::resultCount
int resultCount() const
Practice::ThemedBackgroundRenderer::Centered
Definition: themedbackgroundrenderer.h:54
QRect::moveCenter
void moveCenter(const QPoint &position)
Practice::ThemedBackgroundRenderer::clearRects
void clearRects()
Definition: themedbackgroundrenderer.cpp:63
QFuture< QImage >
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Practice::ThemedBackgroundRenderer::Bottom
Definition: themedbackgroundrenderer.h:45
themedbackgroundrenderer.h
Practice::ThemedBackgroundRenderer::Right
Definition: themedbackgroundrenderer.h:47
Practice::ImageCache::setFilenames
void setFilenames(const QStringList &filename)
Definition: imagecache.cpp:25
Practice::ThemedBackgroundRenderer::renderingFinished
void renderingFinished()
Definition: themedbackgroundrenderer.cpp:144
Practice::ThemedBackgroundRenderer::Vertical
Definition: themedbackgroundrenderer.h:39
QImage::scaled
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
KGameTheme::property
QString property(const QString &key) const
Definition: kgametheme.cpp:128
QFuture::isRunning
bool isRunning() const
QTimer::setSingleShot
void setSingleShot(bool singleShot)
QMargins::setBottom
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

KDE's Doxygen guidelines are available online.

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal