本文整理汇总了C++中Host::rootItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Host::rootItem方法的具体用法?C++ Host::rootItem怎么用?C++ Host::rootItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::rootItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void PlasmoidProtocol::init()
{
//this should never happen
if (m_containment) {
return;
}
Host* h = qobject_cast<Host*>(parent());
QQuickItem* rootItem = h->rootItem();
if (rootItem) {
m_systrayApplet = rootItem->property("_plasma_applet").value<Plasma::Applet*>();
}
if (!m_systrayApplet) {
qWarning() << "Don't have a parent applet, Can't initialize the Plasmoid protocol!!!";
return;
}
int containmentId = 0;
KConfigGroup cg = m_systrayApplet->config();
cg = KConfigGroup(&cg, "Containments");
if (cg.isValid() && cg.groupList().size()) {
containmentId = cg.groupList().first().toInt();
}
m_containment = new Plasma::Containment(m_systrayApplet, QStringLiteral("null"), containmentId);
m_containment->setImmutability(Plasma::Types::Mutable);
m_containment->setFormFactor(Plasma::Types::Horizontal);
m_containment->setLocation(m_systrayApplet->location());
m_containment->setContainmentActions(QStringLiteral("RightButton;NoModifier"), QStringLiteral("org.kde.contextmenu"));
m_containment->init();
emit m_systrayApplet->containment()->corona()->containmentAdded(m_containment);
connect(m_systrayApplet, &Plasma::Applet::locationChanged, this, [=]() {
m_containment->setLocation(m_systrayApplet->location());
});
m_systrayApplet->setProperty("containment", QVariant::fromValue(m_containment));
restorePlasmoids();
}