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


C++ WindowManager::getFrameAttachmentPoints方法代码示例

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


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

示例1: showContextMenu

void FrameAttachmentPoint::showContextMenu(QPoint point)
{
    //Show menus with all attached frames and submenu where to attach it to
    clearActionReceivers();

    WindowManager* windowManager = Carbon::get()->getWindowManager();
    QMenu menu(windowManager->getMainWindow());
    QMenu* submenu;
    QAction* action;

    //For all attached frames, add frame menu
    int frame = 0;
    for (auto it = mAttachedFrames.begin(); it != mAttachedFrames.end(); it++) 
    {
        submenu = menu.addMenu((*it)->getCaption());
     
        //for all possible targets, add commands
        {
            NumberedActionReceiver* receiver;
            
            //Copy command
            receiver = new NumberedActionReceiver(frame, COMMAND_COPY);
            mActionReceivers.push_back(receiver);
            connect(receiver, SIGNAL(actionReceived(int,int)), this, SLOT(onContextMenuClick(int,int)));
            action = submenu->addAction(QIcon(":copy"), "Copy", receiver, SLOT(receiveAction()));
            action->setToolTip("Create a copy of the plugin.");
            if (!PluginFactory::getFactory().canCreatePlugin((*it)->getClassId())) //Disable copy if plugin cant be created anymore
                action->setEnabled(false);

            //Delete command
            receiver = new NumberedActionReceiver(frame, COMMAND_DELETE);
            mActionReceivers.push_back(receiver);
            connect(receiver, SIGNAL(actionReceived(int,int)), this, SLOT(onContextMenuClick(int,int)));
            action = submenu->addAction(QIcon(":delete"), "Delete", receiver, SLOT(receiveAction()));
            action->setToolTip("Delete the plugin.");
        }

        submenu->addSeparator();

        //for all possible targets, add target frames
        int target = COMMAND_MAX_ID;
        for (auto tar_it = windowManager->getFrameAttachmentPoints().begin(); tar_it != windowManager->getFrameAttachmentPoints().end(); tar_it++)
        {
            NumberedActionReceiver* receiver = new NumberedActionReceiver(frame, target);
            mActionReceivers.push_back(receiver);

            connect(receiver, SIGNAL(actionReceived(int,int)), this, SLOT(onContextMenuClick(int,int)));

            if (tar_it->second == this)
                action = submenu->addAction(QIcon(":accept"), tar_it->second->getName(), receiver, SLOT(receiveAction()));
            else
                action = submenu->addAction(tar_it->second->getName(), receiver, SLOT(receiveAction()));
            
            target++;
        }
        frame++;
    }

    menu.exec(mAttachmentPoint->mapToGlobal(point));
}
开发者ID:MadMaxPavlo,项目名称:SimSpark-SPL,代码行数:60,代码来源:frameattachmentpoint.cpp

示例2: onContextMenuClick

void FrameAttachmentPoint::onContextMenuClick(int frame, int command)
{
    if (frame >= 0 && frame < mAttachedFrames.size())
    {
        auto framePos = mAttachedFrames.begin();
        for (int i = 0; i < frame; i++) framePos++;

        //Check for command
        if (command == COMMAND_COPY)
        {
            //Copy the plugin
            PluginManager* manager = Carbon::get()->getPluginManager();
            AbstractPlugin* plugin = manager->createPlugin(*(*framePos)->getPluginDefinition(), true);
        }
        else if (command == COMMAND_DELETE)
        {
            //Delete the plugin
            PluginManager* manager = Carbon::get()->getPluginManager();
            manager->deletePlugin((*framePos)->getPluginId(), true);
        }
        else if (command >= COMMAND_MAX_ID)
        {
            //Reattach the plugin
            int target = command - COMMAND_MAX_ID;
            WindowManager* manager = Carbon::get()->getWindowManager();
            if ((int)manager->getFrameAttachmentPoints().size() > target && target >= 0)
            {
                auto pos = manager->getFrameAttachmentPoints().begin(); 
                for (int i = 0; i < target; i++) pos++;

                manager->changeAttachment(*framePos, pos->second->getName());
            }
        }
    }
    else
    {
        LOG_ERROR() << "Illegal frame index " << frame;
    }
}
开发者ID:MadMaxPavlo,项目名称:SimSpark-SPL,代码行数:39,代码来源:frameattachmentpoint.cpp


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