compress changed notification events and share the blur effect watcher between themes
This commit is contained in:
parent
359cc3d68a
commit
a859f6915c
69
theme.cpp
69
theme.cpp
@ -85,8 +85,9 @@ public:
|
|||||||
defaultWallpaperWidth(DEFAULT_WALLPAPER_WIDTH),
|
defaultWallpaperWidth(DEFAULT_WALLPAPER_WIDTH),
|
||||||
defaultWallpaperHeight(DEFAULT_WALLPAPER_HEIGHT),
|
defaultWallpaperHeight(DEFAULT_WALLPAPER_HEIGHT),
|
||||||
pixmapCache(0),
|
pixmapCache(0),
|
||||||
|
cachesToDiscard(NoCache),
|
||||||
locolor(false),
|
locolor(false),
|
||||||
compositingActive(KWindowSystem::compositingActive()),
|
compositingActive(KWindowSystem::self()->compositingActive()),
|
||||||
blurActive(false),
|
blurActive(false),
|
||||||
isDefault(false),
|
isDefault(false),
|
||||||
useGlobal(true),
|
useGlobal(true),
|
||||||
@ -97,26 +98,32 @@ public:
|
|||||||
ThemeConfig config;
|
ThemeConfig config;
|
||||||
cacheTheme = config.cacheTheme();
|
cacheTheme = config.cacheTheme();
|
||||||
|
|
||||||
|
saveTimer = new QTimer(q);
|
||||||
|
saveTimer->setSingleShot(true);
|
||||||
|
saveTimer->setInterval(600);
|
||||||
|
QObject::connect(saveTimer, SIGNAL(timeout()), q, SLOT(scheduledCacheUpdate()));
|
||||||
|
|
||||||
|
updateNotificationTimer = new QTimer(q);
|
||||||
|
updateNotificationTimer->setSingleShot(true);
|
||||||
|
updateNotificationTimer->setInterval(500);
|
||||||
|
QObject::connect(updateNotificationTimer, SIGNAL(timeout()), q, SLOT(notifyOfChanged()));
|
||||||
|
|
||||||
if (QPixmap::defaultDepth() > 8) {
|
if (QPixmap::defaultDepth() > 8) {
|
||||||
QObject::connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool)), q, SLOT(compositingChanged(bool)));
|
QObject::connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool)), q, SLOT(compositingChanged(bool)));
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
//watch for blur effect property changes as well
|
//watch for blur effect property changes as well
|
||||||
effectWatcher = new EffectWatcher("_KDE_NET_WM_BLUR_BEHIND_REGION");
|
if (!s_blurEffectWatcher) {
|
||||||
QObject::connect(effectWatcher, SIGNAL(effectChanged(bool)), q, SLOT(blurBehindChanged(bool)));
|
s_blurEffectWatcher = new EffectWatcher("_KDE_NET_WM_BLUR_BEHIND_REGION");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
saveTimer = new QTimer(q);
|
QObject::connect(s_blurEffectWatcher, SIGNAL(effectChanged(bool)), q, SLOT(blurBehindChanged(bool)));
|
||||||
saveTimer->setSingleShot(true);
|
#endif
|
||||||
QObject::connect(saveTimer, SIGNAL(timeout()), q, SLOT(scheduledCacheUpdate()));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~ThemePrivate()
|
~ThemePrivate()
|
||||||
{
|
{
|
||||||
delete pixmapCache;
|
delete pixmapCache;
|
||||||
#ifdef Q_WS_X11
|
|
||||||
delete effectWatcher;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup &config()
|
KConfigGroup &config()
|
||||||
@ -143,6 +150,8 @@ public:
|
|||||||
void compositingChanged(bool active);
|
void compositingChanged(bool active);
|
||||||
void discardCache(CacheTypes caches);
|
void discardCache(CacheTypes caches);
|
||||||
void scheduledCacheUpdate();
|
void scheduledCacheUpdate();
|
||||||
|
void scheduleThemeChangeNotification(CacheTypes caches);
|
||||||
|
void notifyOfChanged();
|
||||||
void colorsChanged();
|
void colorsChanged();
|
||||||
void blurBehindChanged(bool blur);
|
void blurBehindChanged(bool blur);
|
||||||
bool useCache();
|
bool useCache();
|
||||||
@ -158,6 +167,7 @@ public:
|
|||||||
static const char *systemColorsTheme;
|
static const char *systemColorsTheme;
|
||||||
static const char *themeRcFile;
|
static const char *themeRcFile;
|
||||||
static PackageStructure::Ptr packageStructure;
|
static PackageStructure::Ptr packageStructure;
|
||||||
|
static EffectWatcher *s_blurEffectWatcher;
|
||||||
|
|
||||||
Theme *q;
|
Theme *q;
|
||||||
QString themeName;
|
QString themeName;
|
||||||
@ -182,11 +192,10 @@ public:
|
|||||||
QHash<styles, QString> cachedStyleSheets;
|
QHash<styles, QString> cachedStyleSheets;
|
||||||
QHash<QString, QString> discoveries;
|
QHash<QString, QString> discoveries;
|
||||||
QTimer *saveTimer;
|
QTimer *saveTimer;
|
||||||
|
QTimer *updateNotificationTimer;
|
||||||
int toolTipDelay;
|
int toolTipDelay;
|
||||||
|
CacheTypes cachesToDiscard;
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
|
||||||
EffectWatcher *effectWatcher;
|
|
||||||
#endif
|
|
||||||
bool locolor : 1;
|
bool locolor : 1;
|
||||||
bool compositingActive : 1;
|
bool compositingActive : 1;
|
||||||
bool blurActive : 1;
|
bool blurActive : 1;
|
||||||
@ -203,6 +212,7 @@ const char *ThemePrivate::themeRcFile = "plasmarc";
|
|||||||
// the system colors theme is used to cache unthemed svgs with colorization needs
|
// the system colors theme is used to cache unthemed svgs with colorization needs
|
||||||
// these svgs do not follow the theme's colors, but rather the system colors
|
// these svgs do not follow the theme's colors, but rather the system colors
|
||||||
const char *ThemePrivate::systemColorsTheme = "internal-system-colors";
|
const char *ThemePrivate::systemColorsTheme = "internal-system-colors";
|
||||||
|
EffectWatcher *ThemePrivate::s_blurEffectWatcher = 0;
|
||||||
|
|
||||||
bool ThemePrivate::useCache()
|
bool ThemePrivate::useCache()
|
||||||
{
|
{
|
||||||
@ -270,8 +280,8 @@ void ThemePrivate::compositingChanged(bool active)
|
|||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
if (compositingActive != active) {
|
if (compositingActive != active) {
|
||||||
compositingActive = active;
|
compositingActive = active;
|
||||||
discardCache(PixmapCache | SvgElementsCache);
|
//kDebug() << QTime::currentTime();
|
||||||
emit q->themeChanged();
|
scheduleThemeChangeNotification(PixmapCache | SvgElementsCache);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -324,17 +334,31 @@ void ThemePrivate::scheduledCacheUpdate()
|
|||||||
|
|
||||||
void ThemePrivate::colorsChanged()
|
void ThemePrivate::colorsChanged()
|
||||||
{
|
{
|
||||||
discardCache(PixmapCache);
|
|
||||||
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
|
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
|
||||||
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
|
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
|
||||||
viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors);
|
viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors);
|
||||||
emit q->themeChanged();
|
scheduleThemeChangeNotification(PixmapCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemePrivate::blurBehindChanged(bool blur)
|
void ThemePrivate::blurBehindChanged(bool blur)
|
||||||
{
|
{
|
||||||
|
if (blurActive != blur) {
|
||||||
blurActive = blur;
|
blurActive = blur;
|
||||||
discardCache(PixmapCache | SvgElementsCache);
|
scheduleThemeChangeNotification(PixmapCache | SvgElementsCache);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThemePrivate::scheduleThemeChangeNotification(CacheTypes caches)
|
||||||
|
{
|
||||||
|
cachesToDiscard |= caches;
|
||||||
|
updateNotificationTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThemePrivate::notifyOfChanged()
|
||||||
|
{
|
||||||
|
//kDebug() << cachesToDiscard;
|
||||||
|
discardCache(cachesToDiscard);
|
||||||
|
cachesToDiscard = NoCache;
|
||||||
emit q->themeChanged();
|
emit q->themeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,7 +536,6 @@ void Theme::settingsChanged()
|
|||||||
d->setThemeName(cg.readEntry("name", ThemePrivate::defaultTheme), false);
|
d->setThemeName(cg.readEntry("name", ThemePrivate::defaultTheme), false);
|
||||||
cg = KConfigGroup(cg.config(), "PlasmaToolTips");
|
cg = KConfigGroup(cg.config(), "PlasmaToolTips");
|
||||||
d->toolTipDelay = cg.readEntry("Delay", qreal(0.7));
|
d->toolTipDelay = cg.readEntry("Delay", qreal(0.7));
|
||||||
kDebug() << "delay for tooltips is ...." << d->toolTipDelay << "**************";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theme::setThemeName(const QString &themeName)
|
void Theme::setThemeName(const QString &themeName)
|
||||||
@ -674,9 +697,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
cg.sync();
|
cg.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
discardCache(SvgElementsCache);
|
scheduleThemeChangeNotification(SvgElementsCache);
|
||||||
|
|
||||||
emit q->themeChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Theme::themeName() const
|
QString Theme::themeName() const
|
||||||
@ -689,7 +710,7 @@ QString Theme::imagePath(const QString &name) const
|
|||||||
// look for a compressed svg file in the theme
|
// look for a compressed svg file in the theme
|
||||||
if (name.contains("../") || name.isEmpty()) {
|
if (name.contains("../") || name.isEmpty()) {
|
||||||
// we don't support relative paths
|
// we don't support relative paths
|
||||||
kDebug() << "Theme says: bad image path " << name;
|
//kDebug() << "Theme says: bad image path " << name;
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -962,7 +983,7 @@ void Theme::insertIntoCache(const QString& key, const QPixmap& pix, const QStrin
|
|||||||
|
|
||||||
d->keysToCache.insert(key, id);
|
d->keysToCache.insert(key, id);
|
||||||
d->idsToCache.insert(id, key);
|
d->idsToCache.insert(id, key);
|
||||||
d->saveTimer->start(600);
|
d->saveTimer->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
theme.h
1
theme.h
@ -409,6 +409,7 @@ class PLASMA_EXPORT Theme : public QObject
|
|||||||
Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &))
|
Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &))
|
||||||
Q_PRIVATE_SLOT(d, void scheduledCacheUpdate())
|
Q_PRIVATE_SLOT(d, void scheduledCacheUpdate())
|
||||||
Q_PRIVATE_SLOT(d, void onAppExitCleanup())
|
Q_PRIVATE_SLOT(d, void onAppExitCleanup())
|
||||||
|
Q_PRIVATE_SLOT(d, void notifyOfChanged())
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user