Commit 3da48de3 authored by Jens Bache-Wiig's avatar Jens Bache-Wiig
Browse files

Don't cache toolbars twice. Fix flickering.

There was a flicker problem with the tool bars because of
missing information in the cache key. We added this info
and removed the redundant caching of toolbar gradients.

Done-with: thorbjorn
parent 751d7d04
......@@ -231,9 +231,9 @@ void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, c
if (StyleHelper::usePixmapCache()) {
QString key;
QColor keyColor = baseColor(lightColored);
key.sprintf("mh_horizontal %d %d %d %d %d",
key.sprintf("mh_horizontal %d %d %d %d %d %d",
spanRect.width(), spanRect.height(), clipRect.width(),
clipRect.height(), keyColor.rgb());
clipRect.height(), keyColor.rgb(), spanRect.x());
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
......@@ -78,8 +78,6 @@ public:
static void horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
// Pixmap cache should only be enabled for X11 due to slow gradients
static bool usePixmapCache() { return true; }
static void drawIconWithShadow(const QPixmap &px, const QPoint &pos, QPainter *p,
......@@ -763,42 +763,22 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
case CE_ToolBar:
QString key;
QColor keyColor = Utils::StyleHelper::baseColor(lightColored(widget));
key.sprintf("mh_toolbar %d %d %d", option->rect.width(), option->rect.height(), keyColor.rgb());;
QPixmap pixmap;
QPainter *p = painter;
QRect rect = option->rect;
bool horizontal = option->state & State_Horizontal;
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
pixmap = QPixmap(option->rect.size());
p = new QPainter(&pixmap);
rect = QRect(0, 0, option->rect.width(), option->rect.height());
rect = option->rect;
if (!Utils::StyleHelper::usePixmapCache() || !QPixmapCache::find(key, pixmap)) {
// Map offset for global window gradient
QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
QRect gradientSpan;
if (widget) {
if (widget)
gradientSpan = QRect(offset, widget->window()->size());
bool drawLightColored = lightColored(widget);
if (horizontal)
Utils::StyleHelper::horizontalGradient(p, gradientSpan, rect, drawLightColored);
Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
Utils::StyleHelper::verticalGradient(p, gradientSpan, rect, drawLightColored);
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
delete p;
QPixmapCache::insert(key, pixmap);
if (Utils::StyleHelper::usePixmapCache()) {
painter->drawPixmap(rect.topLeft(), pixmap);
Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment