make really sure the wallpaper is loaded only once

and that an empty wallpaper is not loaded at all
This commit is contained in:
Marco Martin 2013-08-08 17:21:11 +02:00
parent 9b52bfad89
commit ce13335f36
3 changed files with 13 additions and 4 deletions

View File

@ -167,7 +167,7 @@ void ContainmentInterface::appletRemovedForward(Plasma::Applet *applet)
void ContainmentInterface::loadWallpaper()
{
if (m_appletScriptEngine->drawWallpaper()) {
if (m_appletScriptEngine->drawWallpaper() && !containment()->wallpaper().isEmpty()) {
delete m_wallpaperInterface;
m_wallpaperInterface = new WallpaperInterface(this);

View File

@ -38,10 +38,12 @@ WallpaperInterface::WallpaperInterface(ContainmentInterface *parent)
m_configLoader(0),
m_configuration(0)
{
if (!m_containmentInterface->containment()->wallpaper().isEmpty()) {
syncWallpaperPackage();
}
connect(m_containmentInterface->containment(), &Plasma::Containment::wallpaperChanged,
this, &WallpaperInterface::syncWallpaperPackage);
syncWallpaperPackage();
}
WallpaperInterface::~WallpaperInterface()
@ -80,6 +82,13 @@ Plasma::ConfigLoader *WallpaperInterface::configScheme()
void WallpaperInterface::syncWallpaperPackage()
{
qWarning()<<"22222222222222222"<<m_wallpaperPlugin<<" "<<m_containmentInterface->containment()->wallpaper();
if (m_wallpaperPlugin == m_containmentInterface->containment()->wallpaper()) {
return;
}
m_wallpaperPlugin = m_containmentInterface->containment()->wallpaper();
if (!m_qmlObject) {
m_qmlObject = new QmlObject(this);
m_qmlObject->setInitializationDelayed(true);
@ -87,7 +96,7 @@ void WallpaperInterface::syncWallpaperPackage()
m_pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
m_pkg.setDefaultPackageRoot("plasma/wallpapers");
m_pkg.setPath(m_containmentInterface->containment()->wallpaper());
m_pkg.setPath(m_wallpaperPlugin);
m_configLoader->deleteLater();
m_configuration->deleteLater();
@ -120,7 +129,6 @@ void WallpaperInterface::syncWallpaperPackage()
} else {
qWarning() << "Error loading the wallpaper, package not found";
}
emit packageChanged();
emit configurationChanged();
}

View File

@ -57,6 +57,7 @@ private Q_SLOTS:
void syncWallpaperPackage();
private:
QString m_wallpaperPlugin;
ContainmentInterface *m_containmentInterface;
QmlObject *m_qmlObject;
Plasma::Package m_pkg;