mechanism for coronas to load plasmoids from custom folders
applications such as Amarok can look for their plasmoids in their own data dir in order to not have all mixed up
This commit is contained in:
parent
088210363c
commit
2751b72835
@ -56,7 +56,8 @@ class PluginLoaderPrivate
|
||||
public:
|
||||
PluginLoaderPrivate()
|
||||
: isDefaultLoader(false),
|
||||
packageRE("[^a-zA-Z0-9\\-_]")
|
||||
plasmoidsDataDir(PLASMA_RELATIVE_DATA_INSTALL_DIR),
|
||||
packageRE(QLatin1String("[^a-zA-Z0-9\\-_]"))
|
||||
{
|
||||
KPackage::PackageLoader::self()->addKnownPackageStructure("Plasma/Applet", new PlasmoidPackage());
|
||||
KPackage::PackageLoader::self()->addKnownPackageStructure("Plasma/DataEngine", new DataEnginePackage());
|
||||
@ -77,6 +78,7 @@ public:
|
||||
static QString s_plasmoidsPluginDir;
|
||||
static QString s_servicesPluginDir;
|
||||
static QString s_containmentActionsPluginDir;
|
||||
QString plasmoidsDataDir;
|
||||
QRegExp packageRE;
|
||||
};
|
||||
|
||||
@ -228,6 +230,7 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari
|
||||
}
|
||||
}
|
||||
|
||||
p.setDefaultPackageRoot(d->plasmoidsDataDir + "/plasmoids/");
|
||||
// backwards compatibility: search in the root plugins directory
|
||||
// TODO: remove when Plasma 5.4 is released
|
||||
{
|
||||
@ -270,6 +273,16 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari
|
||||
return applet;
|
||||
}
|
||||
|
||||
void PluginLoader::setAppletsDataDirectory(const QString &dir)
|
||||
{
|
||||
d->plasmoidsDataDir = dir;
|
||||
}
|
||||
|
||||
QString PluginLoader::appletsDataDirectory() const
|
||||
{
|
||||
return d->plasmoidsDataDir;
|
||||
}
|
||||
|
||||
DataEngine *PluginLoader::loadDataEngine(const QString &name)
|
||||
{
|
||||
DataEngine *engine = d->isDefaultLoader ? 0 : internalLoadDataEngine(name);
|
||||
@ -525,7 +538,11 @@ Package PluginLoader::loadPackage(const QString &packageFormat, const QString &s
|
||||
structure = new PackageStructure();
|
||||
structure->d->internalStructure = internalStructure;
|
||||
d->structures.insert(hashkey, structure);
|
||||
return Package(structure);
|
||||
Package p(structure);
|
||||
if (packageFormat == "Plasma/Applet") {
|
||||
p.setDefaultPackageRoot(d->plasmoidsDataDir + "/plasmoids/");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,31 @@ public:
|
||||
Applet *loadApplet(const QString &name, uint appletId = 0,
|
||||
const QVariantList &args = QVariantList());
|
||||
|
||||
/**
|
||||
* Sets the data directory for plasmoids.
|
||||
* By default plasmoid packages will be loaded from the
|
||||
* "plasma" data directory, usually under the "share"
|
||||
* subdirectory of the install prefix.
|
||||
* An application that uses a custom plasma shell
|
||||
* can have its private plasmoids
|
||||
* in its own data directory, not having them mixeed
|
||||
* with the ones from plasma desktop.
|
||||
* It takes effect only in applets loaded after setting
|
||||
* this, so use it at the application startup.
|
||||
*
|
||||
* @param dir data directory name
|
||||
* @since 5.18
|
||||
*/
|
||||
void setAppletsDataDirectory(const QString &dir);
|
||||
|
||||
/**
|
||||
* @return the custom applets data directory.
|
||||
* Default is "plasma"
|
||||
*
|
||||
* @since 5.18
|
||||
*/
|
||||
QString appletsDataDirectory() const;
|
||||
|
||||
/**
|
||||
* Load a DataEngine plugin.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user