no longer provide access to the package from the class, let Package do that; adapt to Package merge

This commit is contained in:
Aaron Seigo 2011-07-15 12:58:06 +02:00
parent d91fede662
commit 8d5cd041c0
2 changed files with 12 additions and 40 deletions

View File

@ -97,8 +97,6 @@ public:
}
};
PackageStructure::Ptr WallpaperPrivate::s_packageStructure(0);
Wallpaper::Wallpaper(QObject * parentObject)
: d(new WallpaperPrivate(KService::serviceByStorageId(QString()), this))
{
@ -209,20 +207,6 @@ Wallpaper *Wallpaper::load(const KPluginInfo &info, const QVariantList &args)
return load(info.pluginName(), args);
}
PackageStructure::Ptr Wallpaper::packageStructure(Wallpaper *paper)
{
if (paper) {
PackageStructure::Ptr package(new WallpaperPackage(paper));
return package;
}
if (!WallpaperPrivate::s_packageStructure) {
WallpaperPrivate::s_packageStructure = new WallpaperPackage();
}
return WallpaperPrivate::s_packageStructure;
}
QString Wallpaper::name() const
{
if (!d->wallpaperDescription.isValid()) {
@ -459,19 +443,20 @@ WallpaperPrivate::WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper)
if (!api.isEmpty()) {
const QString path = KStandardDirs::locate("data",
"plasma/wallpapers/" + wallpaperDescription.pluginName() + '/');
PackageStructure::Ptr structure =
Plasma::packageStructure(api, Plasma::WallpaperComponent);
structure->setPath(path);
package = new Package(path, structure);
package = new Package(Package::load("Plasma/Wallpaper", api));
package->setPath(path);
if (package->isValid()) {
script = Plasma::loadScriptEngine(api, q);
}
script = Plasma::loadScriptEngine(api, q);
if (!script) {
kDebug() << "Could not create a" << api << "ScriptEngine for the"
<< wallpaperDescription.name() << "Wallpaper.";
<< wallpaperDescription.name() << "Wallpaper.";
delete package;
package = 0;
}
}
}
}
}
@ -511,7 +496,6 @@ void WallpaperPrivate::setupScriptSupport()
{
Q_ASSERT(package);
kDebug() << "setting up script support, package is in" << package->path()
<< "which is a" << package->structure()->type() << "package"
<< ", main script is" << package->filePath("mainscript");
const QString translationsPath = package->filePath("translations");
@ -624,9 +608,9 @@ void Wallpaper::setPreviewDuringConfiguration(const bool preview)
d->needsPreviewDuringConfiguration = preview;
}
const Package *Wallpaper::package() const
Package Wallpaper::package() const
{
return d->package;
return d->package ? *d->package : Package();
}
} // Plasma namespace

View File

@ -24,8 +24,8 @@
#include <kmimetype.h>
#include <kplugininfo.h>
#include <plasma/package.h>
#include <plasma/plasma.h>
#include <plasma/packagestructure.h>
#include <plasma/version.h>
namespace Plasma
@ -33,7 +33,6 @@ namespace Plasma
class DataEngine;
class WallpaperPrivate;
class Package;
/**
* @class Wallpaper plasma/wallpaper.h <Plasma/Wallpaper>
@ -129,17 +128,6 @@ class PLASMA_EXPORT Wallpaper : public QObject
**/
static Wallpaper *load(const KPluginInfo &info, const QVariantList &args = QVariantList());
/**
* Returns the Package specialization for wallpapers. May be queried for 'preferred'
* which will return the preferred wallpaper image path given the associated Wallpaper
* object, if any.
*
* @param paper the Wallpaper object to associated the PackageStructure with,
* which will then use the Wallpaper object to define things such as
* default size and resize methods.
*/
static PackageStructure::Ptr packageStructure(Wallpaper *paper = 0);
/**
* Returns the user-visible name for the wallpaper, as specified in the
* .desktop file.
@ -153,7 +141,7 @@ class PLASMA_EXPORT Wallpaper : public QObject
*
* @return the Package object, or 0 if none
**/
const Package *package() const;
Package package() const;
/**
* Returns the plugin name for the wallpaper