don't load toolbox on types not desktop or panel

exclude customdesktop and custompanel
This commit is contained in:
Marco Martin 2016-01-19 23:44:24 +01:00
parent 9e1226f26f
commit fd9b5bd006

View File

@ -109,35 +109,37 @@ void ContainmentInterface::init()
defaults = KConfigGroup(KSharedConfig::openConfig(m_containment->corona()->package().filePath("defaults")), "Panel"); defaults = KConfigGroup(KSharedConfig::openConfig(m_containment->corona()->package().filePath("defaults")), "Panel");
} }
KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML");
pkg.setDefaultPackageRoot("plasma/packages");
if (defaults.isValid()) { if (defaults.isValid()) {
pkg.setPath(defaults.readEntry("ToolBox", "org.kde.desktoptoolbox")); KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML");
} else { pkg.setDefaultPackageRoot("plasma/packages");
pkg.setPath("org.kde.desktoptoolbox");
}
PlasmaQuick::PackageUrlInterceptor *interceptor = dynamic_cast<PlasmaQuick::PackageUrlInterceptor *>(qmlObject()->engine()->urlInterceptor()); if (defaults.isValid()) {
if (interceptor) { pkg.setPath(defaults.readEntry("ToolBox", "org.kde.desktoptoolbox"));
interceptor->addAllowedPath(pkg.path()); } else {
} pkg.setPath("org.kde.desktoptoolbox");
}
if (pkg.metadata().isValid() && !pkg.metadata().isHidden()) { PlasmaQuick::PackageUrlInterceptor *interceptor = dynamic_cast<PlasmaQuick::PackageUrlInterceptor *>(qmlObject()->engine()->urlInterceptor());
if (pkg.isValid()) { if (interceptor) {
QObject *containmentGraphicObject = qmlObject()->rootObject(); interceptor->addAllowedPath(pkg.path());
}
QVariantHash toolboxProperties; if (pkg.metadata().isValid() && !pkg.metadata().isHidden()) {
toolboxProperties["parent"] = QVariant::fromValue(this); if (pkg.isValid()) {
QObject *toolBoxObject = qmlObject()->createObjectFromSource(QUrl::fromLocalFile(pkg.filePath("mainscript")), 0, toolboxProperties); QObject *containmentGraphicObject = qmlObject()->rootObject();
if (toolBoxObject && containmentGraphicObject) {
containmentGraphicObject->setProperty("toolBox", QVariant::fromValue(toolBoxObject)); QVariantHash toolboxProperties;
toolboxProperties["parent"] = QVariant::fromValue(this);
QObject *toolBoxObject = qmlObject()->createObjectFromSource(QUrl::fromLocalFile(pkg.filePath("mainscript")), 0, toolboxProperties);
if (toolBoxObject && containmentGraphicObject) {
containmentGraphicObject->setProperty("toolBox", QVariant::fromValue(toolBoxObject));
}
} else {
qWarning() << "Could not load toolbox package." << pkg.path();
} }
} else { } else {
qWarning() << "Could not load toolbox package." << pkg.path(); qWarning() << "Toolbox not loading, toolbox package is either invalid or disabled.";
} }
} else {
qWarning() << "Toolbox not loading, toolbox package is either invalid or disabled.";
} }
} }