move toolbox stuff in containment

This commit is contained in:
Marco Martin 2013-12-27 13:58:16 +01:00
parent 92073445ce
commit 10f412ca4a
2 changed files with 46 additions and 45 deletions

View File

@ -147,51 +147,6 @@ void AppletInterface::init()
qDebug() << "Graphic object created:" << applet() << applet()->property("graphicObject");
//Create the ToolBox
Plasma::Containment *pc = qobject_cast<Plasma::Containment *>(applet());
if (pc && !qobject_cast<Plasma::Applet *>(pc->parent())) {
KConfigGroup defaults;
if (pc->containmentType() == Plasma::Types::DesktopContainment) {
defaults = KConfigGroup(KSharedConfig::openConfig(pc->corona()->package().filePath("defaults")), "Desktop");
} else if (pc->containmentType() == Plasma::Types::PanelContainment) {
defaults = KConfigGroup(KSharedConfig::openConfig(pc->corona()->package().filePath("defaults")), "Panel");
}
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
if (defaults.isValid()) {
pkg.setPath(defaults.readEntry("ToolBox", "org.kde.desktoptoolbox"));
} else {
pkg.setPath("org.kde.desktoptoolbox");
}
if (pkg.isValid()) {
QObject *toolBoxObject = m_qmlObject->createObjectFromSource(QUrl::fromLocalFile(pkg.filePath("mainscript")));
QObject *containmentGraphicObject = m_qmlObject->rootObject();
if (containmentGraphicObject && toolBoxObject) {
toolBoxObject->setProperty("parent", QVariant::fromValue(containmentGraphicObject));
containmentGraphicObject->setProperty("toolBox", QVariant::fromValue(toolBoxObject));
} else {
delete toolBoxObject;
}
qDebug() << "Loaded toolbox package" << pkg.path();
} else {
qWarning() << "Could not load toolbox package." << pkg.path();
}
}
//set parent, both as object hyerarchy and visually
//do this only for containments, applets will do it in compactrepresentationcheck
if (pc && m_qmlObject->rootObject()) {
m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this));
//set anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), "parent");
QQmlProperty prop(m_qmlObject->rootObject(), "anchors.fill");
prop.write(expr.evaluate());
}
geometryChanged(QRectF(), QRectF(x(), y(), width(), height()));
emit busyChanged();

View File

@ -100,6 +100,52 @@ void ContainmentInterface::init()
AppletInterface::init();
//Create the ToolBox
Plasma::Containment *pc = containment();
if (pc) {
KConfigGroup defaults;
if (pc->containmentType() == Plasma::Types::DesktopContainment) {
defaults = KConfigGroup(KSharedConfig::openConfig(pc->corona()->package().filePath("defaults")), "Desktop");
} else if (pc->containmentType() == Plasma::Types::PanelContainment) {
defaults = KConfigGroup(KSharedConfig::openConfig(pc->corona()->package().filePath("defaults")), "Panel");
}
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic");
if (defaults.isValid()) {
pkg.setPath(defaults.readEntry("ToolBox", "org.kde.desktoptoolbox"));
} else {
pkg.setPath("org.kde.desktoptoolbox");
}
if (pkg.isValid()) {
QObject *toolBoxObject = m_qmlObject->createObjectFromSource(QUrl::fromLocalFile(pkg.filePath("mainscript")));
QObject *containmentGraphicObject = m_qmlObject->rootObject();
if (containmentGraphicObject && toolBoxObject) {
toolBoxObject->setProperty("parent", QVariant::fromValue(containmentGraphicObject));
containmentGraphicObject->setProperty("toolBox", QVariant::fromValue(toolBoxObject));
} else {
delete toolBoxObject;
}
qDebug() << "Loaded toolbox package" << pkg.path();
} else {
qWarning() << "Could not load toolbox package." << pkg.path();
}
}
//set parent, both as object hyerarchy and visually
//do this only for containments, applets will do it in compactrepresentationcheck
if (m_qmlObject->rootObject()) {
m_qmlObject->rootObject()->setProperty("parent", QVariant::fromValue(this));
//set anchors
QQmlExpression expr(m_qmlObject->engine()->rootContext(), m_qmlObject->rootObject(), "parent");
QQmlProperty prop(m_qmlObject->rootObject(), "anchors.fill");
prop.write(expr.evaluate());
}
if (m_qmlObject->rootObject()->property("minimumWidth").isValid()) {
connect(m_qmlObject->rootObject(), SIGNAL(minimumWidthChanged()),
this, SIGNAL(minimumWidthChanged()));