本文整理汇总了C++中KMenu::activeAction方法的典型用法代码示例。如果您正苦于以下问题:C++ KMenu::activeAction方法的具体用法?C++ KMenu::activeAction怎么用?C++ KMenu::activeAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KMenu
的用法示例。
在下文中一共展示了KMenu::activeAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool WindowList::eventFilter(QObject *object, QEvent *event)
{
if (event->type() == QEvent::ContextMenu) {
KMenu *menu = qobject_cast<KMenu*>(object);
if (menu && menu->activeAction() && menu->activeAction()->data().type() == QVariant::ULongLong) {
QContextMenuEvent *cmEvent = static_cast<QContextMenuEvent *>(event);
QList<QAction*> actionList;
TaskManager::TaskItem item(this, TaskManager::TaskManager::self()->findTask((WId)menu->activeAction()->data().toULongLong()));
TaskManager::GroupManager groupManager(this);
TaskManager::BasicMenu taskMenu(NULL, &item, &groupManager, actionList);
if (taskMenu.exec(cmEvent->globalPos())) {
m_listMenu->hide();
}
return true;
}
} else if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent->button() != Qt::LeftButton) {
return false;
}
KMenu *menu = static_cast<KMenu*>(object);
if (menu && menu->activeAction() && menu->activeAction()->data().type() == QVariant::ULongLong) {
m_dragStartPosition = mouseEvent->pos();
}
} else if (event->type() == QEvent::MouseMove) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if (!(mouseEvent->buttons() & Qt::LeftButton) || (mouseEvent->pos() - m_dragStartPosition).manhattanLength() < QApplication::startDragDistance()) {
return false;
}
KMenu *menu = static_cast<KMenu*>(object);
if (menu && menu->activeAction() && menu->activeAction()->data().type() == QVariant::ULongLong) {
QDrag *drag = new QDrag(menu);
QMimeData *mimeData = new QMimeData;
QByteArray data;
WId window = (WId)menu->activeAction()->data().toULongLong();
data.resize(sizeof(WId));
memcpy(data.data(), &window, sizeof(WId));
mimeData->setData("windowsystem/winid", data);
drag->setMimeData(mimeData);
drag->setPixmap(menu->activeAction()->icon().pixmap(32, 32));
m_listMenu->hide();
drag->exec();
return true;
}
}
return QObject::eventFilter(object, event);
}