From 09e09a9cd88535a28b7ecbf7201bc0ecc17d6869 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Thu, 3 Aug 2017 15:03:20 +0200 Subject: [PATCH] [Breeze Style] Fix flickering during KPageTreeView animation QTreeView animates expanding/collapsing of branches. It renders the widget into a temporary pixmap for speed which is then animated. The pixmap's background, however, is unconditionally filled with the widget's palette's base color which is different from the window background color onto which we paint when side panel frames are disabled. This leads to flickering as the background is different during the animation. Depending on the colorscheme this can be quite noticeable (e.g. Honeycomb). Differential Revision: https://phabricator.kde.org/D7089 --- kstyle/breezestyle.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index 14a9570a..264378ea 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include namespace BreezePrivate @@ -398,6 +399,17 @@ namespace Breeze scrollArea->viewport()->setForegroundRole( QPalette::WindowText ); } + // QTreeView animates expanding/collapsing branches. It paints them into a + // temp pixmap whose background is unconditionally filled with the palette's + // *base* color which is usually different from the window's color + // cf. QTreeViewPrivate::renderTreeToPixmapForAnimation() + if ( QTreeView *treeView = qobject_cast( scrollArea ) ) { + if (treeView->isAnimated()) { + QPalette pal( treeView->palette() ); + pal.setColor( QPalette::Active, QPalette::Base, treeView->palette().color( treeView->backgroundRole() ) ); + treeView->setPalette(pal); + } + } } }