forked from qt-creator/qt-creator
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
This commit is contained in:
@@ -231,9 +231,9 @@ void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, c
|
|||||||
if (StyleHelper::usePixmapCache()) {
|
if (StyleHelper::usePixmapCache()) {
|
||||||
QString key;
|
QString key;
|
||||||
QColor keyColor = baseColor(lightColored);
|
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(),
|
spanRect.width(), spanRect.height(), clipRect.width(),
|
||||||
clipRect.height(), keyColor.rgb());
|
clipRect.height(), keyColor.rgb(), spanRect.x());
|
||||||
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
if (!QPixmapCache::find(key, 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 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 verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false);
|
||||||
static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
|
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 bool usePixmapCache() { return true; }
|
||||||
|
|
||||||
static void drawIconWithShadow(const QPixmap &px, const QPoint &pos, QPainter *p,
|
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:
|
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;
|
QRect rect = option->rect;
|
||||||
bool horizontal = option->state & State_Horizontal;
|
bool horizontal = option->state & State_Horizontal;
|
||||||
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
|
rect = option->rect;
|
||||||
pixmap = QPixmap(option->rect.size());
|
|
||||||
p = new QPainter(&pixmap);
|
|
||||||
rect = QRect(0, 0, option->rect.width(), option->rect.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Utils::StyleHelper::usePixmapCache() || !QPixmapCache::find(key, pixmap)) {
|
// Map offset for global window gradient
|
||||||
// Map offset for global window gradient
|
QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
|
||||||
QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
|
widget->mapToGlobal(option->rect.topLeft());
|
||||||
widget->mapToGlobal(option->rect.topLeft());
|
QRect gradientSpan;
|
||||||
QRect gradientSpan;
|
if (widget)
|
||||||
if (widget) {
|
gradientSpan = QRect(offset, widget->window()->size());
|
||||||
gradientSpan = QRect(offset, widget->window()->size());
|
|
||||||
}
|
|
||||||
bool drawLightColored = lightColored(widget);
|
|
||||||
if (horizontal)
|
|
||||||
Utils::StyleHelper::horizontalGradient(p, gradientSpan, rect, drawLightColored);
|
|
||||||
else
|
|
||||||
Utils::StyleHelper::verticalGradient(p, gradientSpan, rect, drawLightColored);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
|
bool drawLightColored = lightColored(widget);
|
||||||
delete p;
|
if (horizontal)
|
||||||
QPixmapCache::insert(key, pixmap);
|
Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
|
||||||
}
|
else
|
||||||
if (Utils::StyleHelper::usePixmapCache()) {
|
Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored);
|
||||||
painter->drawPixmap(rect.topLeft(), pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->setPen(Utils::StyleHelper::borderColor());
|
painter->setPen(Utils::StyleHelper::borderColor());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user