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
This commit is contained in:
parent
645f5adfc2
commit
3876c89cc1
2 changed files with 4 additions and 1 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue