本文整理汇总了C++中plasma::DataEngine::sources方法的典型用法代码示例。如果您正苦于以下问题:C++ DataEngine::sources方法的具体用法?C++ DataEngine::sources怎么用?C++ DataEngine::sources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plasma::DataEngine
的用法示例。
在下文中一共展示了DataEngine::sources方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void ActivityManager::init() {
Plasma::ToolTipManager::self()->registerWidget(this);
extender()->setEmptyExtenderMessage(i18n("No Activities..."));
// don't grow too much height
extender()->setMaximumHeight(300);
if (extender()->item("Activities") == 0) {
// create the item
Plasma::ExtenderItem *item = new Plasma::ExtenderItem(extender());
// initialize the item
initExtenderItem(item);
// set item name and title
item->setName("Activities");
item->setTitle("Activities");
}
// connect data sources
Plasma::DataEngine *engine = dataEngine("org.kde.activities");
foreach (const QString source, engine->sources())
activityAdded(source);
// activity addition and removal
connect(engine, SIGNAL(sourceAdded(QString)), this, SLOT(activityAdded(QString)));
connect(engine, SIGNAL(sourceRemoved(QString)), this, SLOT(activityRemoved(QString)));
}
示例2: makeMenu
void SwitchWindow::makeMenu()
{
m_menu->clear();
Plasma::DataEngine *tasks = dataEngine("tasks");
if (!tasks->isValid()) {
return;
}
QMultiHash<int, QAction*> desktops;
//make all the window actions
foreach (const QString &source, tasks->sources()) {
Plasma::DataEngine::Data window = tasks->query(source);
if (window.value("startup").toBool()) {
//kDebug() << "skipped fake task" << source;
continue;
}
if (!window.value("onCurrentActivity").toBool()) {
continue;
}
QString name = window.value("visibleNameWithState").toString();
if (name.isEmpty()) {
kDebug() << "failed source" << source;
continue;
}
QAction *action = new QAction(name, m_menu);
action->setIcon(window.value("icon").value<QIcon>());
action->setData(source);
desktops.insert(window.value("desktop").toInt(), action);
}
//sort into menu
if (m_mode == CurrentDesktop) {
int currentDesktop = KWindowSystem::currentDesktop();
m_menu->addTitle(i18n("Windows"));
m_menu->addActions(desktops.values(currentDesktop));
m_menu->addActions(desktops.values(-1));
} else {
int numDesktops = KWindowSystem::numberOfDesktops();
if (m_mode == AllFlat) {
for (int i = 1; i <= numDesktops; ++i) {
if (desktops.contains(i)) {
QString name = KWindowSystem::desktopName(i);
name = QString("%1: %2").arg(i).arg(name);
m_menu->addTitle(name);
m_menu->addActions(desktops.values(i));
}
}
if (desktops.contains(-1)) {
m_menu->addTitle(i18n("All Desktops"));
m_menu->addActions(desktops.values(-1));
}
} else { //submenus
for (int i = 1; i <= numDesktops; ++i) {
if (desktops.contains(i)) {
QString name = KWindowSystem::desktopName(i);
name = QString("%1: %2").arg(i).arg(name);
KMenu *subMenu = new KMenu(name, m_menu);
subMenu->addActions(desktops.values(i));
m_menu->addMenu(subMenu);
}
}
if (desktops.contains(-1)) {
KMenu *subMenu = new KMenu(i18n("All Desktops"), m_menu);
subMenu->addActions(desktops.values(-1));
m_menu->addMenu(subMenu);
}
}
}
m_menu->adjustSize();
}