Don't reparse the metadata file if it's already loaded
By doing so, we don't tie ourselves to the desktop format as well as we leverage cached data. Expose Plasma::Package::kPackage REVIEW: 129278
This commit is contained in:
parent
a940089a8f
commit
6d47160367
@ -161,6 +161,11 @@ void Package::setServicePrefix(const QString &servicePrefix)
|
||||
d->servicePrefix = servicePrefix;
|
||||
}
|
||||
|
||||
KPackage::Package Package::kPackage() const
|
||||
{
|
||||
return *d->internalPackage;
|
||||
}
|
||||
|
||||
bool Package::allowExternalPaths() const
|
||||
{
|
||||
return d->internalPackage->allowExternalPaths();
|
||||
|
@ -31,6 +31,10 @@ class KJob;
|
||||
|
||||
#ifndef PLASMA_NO_DEPRECATED
|
||||
|
||||
namespace KPackage {
|
||||
class Package;
|
||||
}
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -343,6 +347,13 @@ public:
|
||||
*/
|
||||
PLASMA_DEPRECATED KJob *uninstall(const QString &packageName, const QString &packageRoot);
|
||||
|
||||
/**
|
||||
* @returns the wrapped KPackage::Package instance, which deprecated this class
|
||||
*
|
||||
* @since 5.28
|
||||
*/
|
||||
KPackage::Package kPackage() const;
|
||||
|
||||
private:
|
||||
QExplicitlySharedDataPointer<PackagePrivate> d;
|
||||
friend class PackagePrivate;
|
||||
|
@ -55,9 +55,8 @@ void ChangeableMainScriptPackage::pathChanged(KPackage::Package *package)
|
||||
return;
|
||||
}
|
||||
|
||||
KDesktopFile config(package->path() + "/metadata.desktop");
|
||||
KConfigGroup cg = config.desktopGroup();
|
||||
QString mainScript = cg.readEntry(mainScriptConfigKey(), QString());
|
||||
KPluginMetaData md(package->metadata().metaDataFileName());
|
||||
QString mainScript = md.value("X-Plasma-MainScript");
|
||||
|
||||
if (!mainScript.isEmpty()) {
|
||||
package->addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
|
||||
|
@ -199,9 +199,7 @@ QList<QAction *> WallpaperInterface::contextualActions() const
|
||||
|
||||
bool WallpaperInterface::supportsMimetype(const QString &mimetype) const
|
||||
{
|
||||
//FIXME: a less brutal way? packages should have valid KService :/
|
||||
KDesktopFile desktop(m_pkg.path() + "/" + "metadata.desktop");
|
||||
return desktop.desktopGroup().readEntry<QStringList>("X-Plasma-DropMimeTypes", QStringList()).contains(mimetype);
|
||||
return KPluginMetaData::readStringList(m_pkg.kPackage().metadata().rawData(), "X-Plasma-DropMimeTypes").contains(mimetype);
|
||||
}
|
||||
|
||||
void WallpaperInterface::setUrl(const QUrl &url)
|
||||
|
Loading…
x
Reference in New Issue
Block a user