Commit 3876c89c authored by Nicolas Fella's avatar Nicolas Fella Committed by Vlad Zahorodnii
Browse files

Avoid recreating palette in DecorationPalette::palette

KColorScheme::createApplicationPalette is quite expensive and DecorationPalette::palette is called quite a lot

Cache the result and only update when needed
parent 645f5adf
Pipeline #151550 passed with stage
in 15 minutes and 24 seconds
......@@ -121,13 +121,15 @@ QColor DecorationPalette::color(KDecoration2::ColorGroup group, KDecoration2::Co
QPalette DecorationPalette::palette() const
{
return m_legacyPalette ? m_legacyPalette->palette : KColorScheme::createApplicationPalette(m_colorSchemeConfig);
return m_legacyPalette ? m_legacyPalette->palette : m_applicationPalette;
}
void DecorationPalette::update()
{
m_colorSchemeConfig->sync();
m_applicationPalette = KColorScheme::createApplicationPalette(m_colorSchemeConfig);
if (KColorScheme::isColorSetSupported(m_colorSchemeConfig, KColorScheme::Header)) {
m_palette.active = KColorScheme(QPalette::Normal, KColorScheme::Header, m_colorSchemeConfig);
m_palette.inactive = KColorScheme(QPalette::Inactive, KColorScheme::Header, m_colorSchemeConfig);
......
......@@ -68,6 +68,7 @@ private:
KSharedConfig::Ptr m_colorSchemeConfig;
ModernPalette m_palette;
QPalette m_applicationPalette;
};
}
......
Supports Markdown
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