provide a containment package specialization
this will allow containments to have a different qml file
This commit is contained in:
parent
75e9a7dcd5
commit
8b72b0b3ef
@ -44,17 +44,22 @@ void ChangeableMainScriptPackage::initPackage(Package *package)
|
||||
package->setRequired("mainscript", true);
|
||||
}
|
||||
|
||||
QString ChangeableMainScriptPackage::findMainScript(Package *package)
|
||||
QString ChangeableMainScriptPackage::findMainScript(Package *package) const
|
||||
{
|
||||
Q_UNUSED(package)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString ChangeableMainScriptPackage::mainScriptConfigKey() const
|
||||
{
|
||||
return QLatin1String("X-Plasma-MainScript");
|
||||
}
|
||||
|
||||
void ChangeableMainScriptPackage::pathChanged(Package *package)
|
||||
{
|
||||
KDesktopFile config(package->path() + "/metadata.desktop");
|
||||
KConfigGroup cg = config.desktopGroup();
|
||||
QString mainScript = cg.readEntry("X-Plasma-MainScript", QString());
|
||||
QString mainScript = cg.readEntry(mainScriptConfigKey(), QString());
|
||||
if (mainScript.isEmpty()) {
|
||||
mainScript = findMainScript(package);
|
||||
|
||||
@ -71,7 +76,7 @@ void ChangeableMainScriptPackage::pathChanged(Package *package)
|
||||
}
|
||||
}
|
||||
|
||||
QString PlasmoidPackage::findMainScript(Package *package)
|
||||
QString PlasmoidPackage::findMainScript(Package *package) const
|
||||
{
|
||||
const QString mainScript = package->path() + "/ui/main.qml";
|
||||
if (QFile::exists(mainScript)) {
|
||||
@ -125,6 +130,11 @@ void PlasmoidPackage::initPackage(Package *package)
|
||||
package->addDirectoryDefinition("animations", "animations", i18n("Animation scripts"));
|
||||
}
|
||||
|
||||
QString ContainmentPackage::mainScriptConfigKey() const
|
||||
{
|
||||
return QLatin1String("X-Plasma-Containment-MainScript");
|
||||
}
|
||||
|
||||
void DataEnginePackage::initPackage(Package *package)
|
||||
{
|
||||
ChangeableMainScriptPackage::initPackage(package);
|
||||
|
@ -33,7 +33,8 @@ public:
|
||||
void initPackage(Package *package);
|
||||
|
||||
protected:
|
||||
virtual QString findMainScript(Package *package);
|
||||
virtual QString findMainScript(Package *package) const;
|
||||
virtual QString mainScriptConfigKey() const;
|
||||
void pathChanged(Package *package);
|
||||
};
|
||||
|
||||
@ -43,7 +44,13 @@ public:
|
||||
void initPackage(Package *package);
|
||||
|
||||
protected:
|
||||
QString findMainScript(Package *package);
|
||||
QString findMainScript(Package *package) const;
|
||||
};
|
||||
|
||||
class ContainmentPackage : public PlasmoidPackage
|
||||
{
|
||||
public:
|
||||
QString mainScriptConfigKey() const;
|
||||
};
|
||||
|
||||
class DataEnginePackage : public ChangeableMainScriptPackage
|
||||
|
Loading…
Reference in New Issue
Block a user