本文整理汇总了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));
}
示例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;
}
}