release broadcasted backgrounds when not needed

--an example could be when the user decides to change
wallpaper plugin for its desktop from a slideshow
to other wallpaper plugins
pull/5/head
Michail Vourlakos 6 years ago
parent ffac993845
commit e303130ef6

@ -88,8 +88,7 @@ void BackgroundCache::settingsFileChanged(const QString &file) {
}
}
QString BackgroundCache::backgroundFromConfig(const KConfigGroup &config) const {
auto wallpaperPlugin = config.readEntry("wallpaperplugin");
QString BackgroundCache::backgroundFromConfig(const KConfigGroup &config, QString wallpaperPlugin) const {
auto wallpaperConfig = config.group("Wallpaper").group(wallpaperPlugin).group("General");
if (wallpaperConfig.hasKey("Image")) {
@ -131,6 +130,7 @@ void BackgroundCache::reload()
for (const auto &containmentId : plasmaConfigContainments.groupList()) {
const auto containment = plasmaConfigContainments.group(containmentId);
const auto wallpaperPlugin = containment.readEntry("wallpaperplugin", QString());
const auto lastScreen = containment.readEntry("lastScreen", 0);
const auto activity = containment.readEntry("activityId", QString());
@ -138,7 +138,7 @@ void BackgroundCache::reload()
//! the containment is not a plasma desktop
if (activity.isEmpty() || !isDesktopContainment(containment)) continue;
const auto returnedBackground = backgroundFromConfig(containment);
const auto returnedBackground = backgroundFromConfig(containment, wallpaperPlugin);
QString background = returnedBackground;
@ -152,6 +152,16 @@ void BackgroundCache::reload()
QString screenName = m_pool->connector(lastScreen);
//! Take case of broadcasted backgrounds, when their plugin is changed they should be disabled
if (pluginExistsFor(activity,screenName)
&& m_plugins[activity][screenName] != wallpaperPlugin
&& backgroundIsBroadcasted(activity, screenName)){
//! in such case the Desktop changed wallpaper plugin and the broadcasted wallpapers should be removed
setBroadcastedBackgroundsEnabled(activity, screenName, false);
}
m_plugins[activity][screenName] = wallpaperPlugin;
if (backgroundIsBroadcasted(activity, screenName)) {
continue;
}
@ -428,5 +438,10 @@ bool BackgroundCache::backgroundIsBroadcasted(QString activity, QString screenNa
return m_broadcasted.contains(activity) && m_broadcasted[activity].contains(screenName);
}
bool BackgroundCache::pluginExistsFor(QString activity, QString screenName)
{
return m_plugins.contains(activity) && m_plugins[activity].contains(screenName);
}
}
}

@ -71,13 +71,14 @@ private:
BackgroundCache(QObject *parent = nullptr);
bool backgroundIsBroadcasted(QString activity, QString screenName);
bool pluginExistsFor(QString activity, QString screenName);
bool areaIsBusy(float bright1, float bright2);
bool busyForFile(QString imageFile, Plasma::Types::Location location);
bool isDesktopContainment(const KConfigGroup &containment) const;
float brightnessForFile(QString imageFile, Plasma::Types::Location location);
float brightnessFromArea(QImage &image, int firstRow, int firstColumn, int endRow, int endColumn);
QString backgroundFromConfig(const KConfigGroup &config) const;
QString backgroundFromConfig(const KConfigGroup &config, QString wallpaperPlugin) const;
void updateImageCalculations(QString imageFile, Plasma::Types::Location location);
@ -88,9 +89,14 @@ private:
//! screen aware backgrounds: activity id, screen name, backgroundfile
QHash<QString, QHash<QString, QString>> m_backgrounds;
//! backgrounds that are broadcasted (not found through plasma files)
//! for specific: activity id, screen names tracked
//! plugin names tracked: activity id, screen name, pluginName
QHash<QString, QHash<QString, QString>> m_plugins;
//! backgrounds that are broadcasted (not found through plasma files):
//! and have higher priority: activity id, screen names
QHash<QString, QList<QString>> m_broadcasted;
//! image file and brightness per edge
QHash<QString, EdgesHash> m_hintsCache;

Loading…
Cancel
Save