本文整理汇总了C++中KPopupMenu::iconSet方法的典型用法代码示例。如果您正苦于以下问题:C++ KPopupMenu::iconSet方法的具体用法?C++ KPopupMenu::iconSet怎么用?C++ KPopupMenu::iconSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KPopupMenu
的用法示例。
在下文中一共展示了KPopupMenu::iconSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertActionItems
//.........这里部分代码省略.........
// Check whether the selected items only consist of files...
const KFileItemList* list = m_dolphinView->selectedItems();
assert(list != 0);
KFileItemListIterator mimeIt(*list);
KFileItem* item = 0;
insert = true;
while (insert && ((item = mimeIt.current()) != 0)) {
insert = !item->isDir();
++mimeIt;
}
}
if (!insert) {
// Check whether the MIME types of all selected files match
// to the mimetype of the service action. As soon as one MIME
// type does not match, no service menu is shown at all.
const KFileItemList* list = m_dolphinView->selectedItems();
assert(list != 0);
KFileItemListIterator mimeIt(*list);
KFileItem* item = 0;
insert = true;
while (insert && ((item = mimeIt.current()) != 0)) {
const QString mimeType((*mimeIt)->mimetype());
const QString mimeGroup(mimeType.left(mimeType.find('/')));
insert = (*it == mimeType) ||
((*it).right(1) == "*") &&
((*it).left((*it).find('/')) == mimeGroup);
++mimeIt;
}
}
if (insert) {
menu = actionsMenu;
const QString submenuName = cfg.readEntry( "X-KDE-Submenu" );
if (!submenuName.isEmpty()) {
menu = new KPopupMenu();
actionsMenu->insertItem(submenuName, menu, submenuID);
}
QValueList<KDEDesktopMimeType::Service> userServices =
KDEDesktopMimeType::userDefinedServices(*dirIt + *entryIt, true);
QValueList<KDEDesktopMimeType::Service>::Iterator serviceIt;
for (serviceIt = userServices.begin(); serviceIt != userServices.end(); ++serviceIt) {
KDEDesktopMimeType::Service service = (*serviceIt);
if (!service.m_strIcon.isEmpty()) {
menu->insertItem(SmallIcon(service.m_strIcon),
service.m_strName,
actionsIDStart + actionsIndex);
}
else {
menu->insertItem(service.m_strName,
actionsIDStart + actionsIndex);
}
actionsVector.append(service);
++actionsIndex;
}
}
}
}
}
}
const int itemsCount = actionsMenu->count();
if (itemsCount == 0) {
// no actions are available at all, hence show the "Actions"
// submenu disabled
actionsMenu->setEnabled(false);
}
if (itemsCount == 1) {
// Exactly one item is available. Instead of showing a sub menu with
// only one item, show the item directly in the root menu.
if (menu == actionsMenu) {
// The item is an action, hence show the action in the root menu.
const int id = actionsMenu->idAt(0);
const QString text(actionsMenu->text(id));
const QIconSet* iconSet = actionsMenu->iconSet(id);
if (iconSet == 0) {
popup->insertItem(text, id);
}
else {
popup->insertItem(*iconSet, text, id);
}
}
else {
// The item is a sub menu, hence show the sub menu in the root menu.
popup->insertItem(actionsMenu->text(submenuID), menu);
}
actionsMenu->deleteLater();
actionsMenu = 0;
}
else {
popup->insertItem(i18n("Actions"), actionsMenu);
}
}