当前位置: 首页>>代码示例>>C++>>正文


C++ KMenu::actions方法代码示例

本文整理汇总了C++中KMenu::actions方法的典型用法代码示例。如果您正苦于以下问题:C++ KMenu::actions方法的具体用法?C++ KMenu::actions怎么用?C++ KMenu::actions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KMenu的用法示例。


在下文中一共展示了KMenu::actions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setServiceMenu

void Configuration::setServiceMenu()
{
    KMenu *menu = qobject_cast<KMenu*>(sender());

    if (menu->actions().count() > 1)
    {
        return;
    }

    KServiceGroup::Ptr rootGroup = KServiceGroup::group(menu->actions()[0]->data().toString());

    if (!rootGroup || !rootGroup->isValid() || rootGroup->noDisplay())
    {
        return;
    }

    KServiceGroup::List list = rootGroup->entries(true, true, true, true);

    QAction *action = menu->addAction(KIcon("list-add"), i18n("Add This Menu"));
    action->setData(rootGroup->relPath());

    menu->addSeparator();

    for (int i = 0; i < list.count(); ++i)
    {
        if (list.at(i)->isType(KST_KService))
        {
            const KService::Ptr service = KService::Ptr::staticCast(list.at(i));

            action = menu->addAction(KIcon(service->icon()), service->name());
            action->setEnabled(false);
        }
        else if (list.at(i)->isType(KST_KServiceGroup))
        {
            const KServiceGroup::Ptr group = KServiceGroup::Ptr::staticCast(list.at(i));

            if (group->noDisplay() || group->childCount() == 0)
            {
                continue;
            }

            KMenu *subMenu = new KMenu(menu);

            QAction *action = subMenu->addAction(QString());
            action->setData(group->relPath());
            action->setVisible(false);

            action = menu->addAction(KIcon(group->icon()), group->caption());
            action->setMenu(subMenu);

            connect(subMenu, SIGNAL(aboutToShow()), this, SLOT(setServiceMenu()));
        }
        else if (list.at(i)->isType(KST_KServiceSeparator))
        {
            menu->addSeparator();
        }
    }
}
开发者ID:amithash,项目名称:fancytasks,代码行数:58,代码来源:FancyTasksConfiguration.cpp

示例2: setupHelpButton

void setupHelpButton(KDialog* dialog, KAboutData* aboutData)
{
    QObject::disconnect(dialog, SIGNAL(helpClicked()),
                        dialog, SLOT(slotHelp()));

    KHelpMenu* helpMenu = new KHelpMenu(dialog, aboutData, false);
    KMenu* menu         = helpMenu->menu();
    menu->removeAction(menu->actions().first());

    QAction* openHandbookAction = new QAction(i18n("Handbook"), dialog);

    QObject::connect(openHandbookAction, SIGNAL(triggered(bool)),
                     dialog, SLOT(slotHelp()));

    menu->insertAction(menu->actions().first(), openHandbookAction);
    dialog->button(KDialog::Help)->setMenu(menu);
}
开发者ID:UIKit0,项目名称:digikam-2012-kipi-plugins,代码行数:17,代码来源:dialogutils.cpp

示例3: selectedIndexes

void
ServiceCollectionTreeView::contextMenuEvent( QContextMenuEvent * event )
{
    if ( m_playableTracks )
        CollectionTreeView::contextMenuEvent( event );
    else
    {
        QModelIndexList indices = selectedIndexes();
        if( filterModel() )
        {
            QModelIndexList tmp;
            foreach( const QModelIndex &idx, indices )
            {
                tmp.append( filterModel()->mapToSource( idx ) );
            }
            indices = tmp;
        }

        if( !indices.isEmpty() )
        {
            KMenu menu;
            if( indices.count() == 1 )
            {
                if( indices.first().isValid() && indices.first().internalPointer() )
                {
                    Meta::DataPtr data = static_cast<CollectionTreeItem*>( indices.first().internalPointer() )->data();
                    if( data )
                    {
                        Meta::CustomActionsCapability *cac = data->create<Meta::CustomActionsCapability>();
                        if( cac )
                        {
                            QList<PopupDropperAction*> actions = cac->customActions();
                            if( actions.count() )
                                menu.addSeparator();
                            foreach( PopupDropperAction *action, actions )
                                menu.addAction( action );
                            delete cac;
                        }
                    }
                }
            }

            if( menu.actions().count() > 0 )
            {
                (void)menu.exec( event->globalPos() );
                QSet<CollectionTreeItem*> items;
                foreach( const QModelIndex &index, indices )
                {
                    if( index.isValid() && index.internalPointer() )
                        items.insert( static_cast<CollectionTreeItem*>( index.internalPointer() ) );
                }
            }
开发者ID:weiligang512,项目名称:apue-test,代码行数:52,代码来源:ServiceCollectionTreeView.cpp


注:本文中的KMenu::actions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。