QMenu* Scene_c3t3_item::contextMenu() { const char* prop_name = "Menu modified by Scene_c3t3_item."; QMenu* menu = Scene_item::contextMenu(); // Use dynamic properties: // http://doc.qt.io/qt-5/qobject.html#property bool menuChanged = menu->property(prop_name).toBool(); if (!menuChanged) { QAction* actionExportFacetsInComplex = menu->addAction(tr("Export facets in complex")); actionExportFacetsInComplex->setObjectName("actionExportFacetsInComplex"); connect(actionExportFacetsInComplex, SIGNAL(triggered()), this, SLOT(export_facets_in_complex())); QAction* actionShowSpheres = menu->addAction(tr("Show protecting &spheres")); actionShowSpheres->setCheckable(true); actionShowSpheres->setObjectName("actionShowSpheres"); connect(actionShowSpheres, SIGNAL(toggled(bool)), this, SLOT(show_spheres(bool))); menu->setProperty(prop_name, true); }
QMenu* Scene_polylines_item::contextMenu() { const char* prop_name = "Menu modified by Scene_polylines_item."; QMenu* menu = Scene_item::contextMenu(); // Use dynamic properties: // http://doc.qt.io/qt-5/qobject.html#property bool menuChanged = menu->property(prop_name).toBool(); if(!menuChanged) { menu->addSeparator(); // TODO: add actions to display corners QAction* action = menu->addAction(tr("Display corners with radius...")); connect(action, SIGNAL(triggered()), this, SLOT(change_corner_radii())); QAction* actionSmoothPolylines = menu->addAction(tr("Smooth polylines")); actionSmoothPolylines->setObjectName("actionSmoothPolylines"); connect(actionSmoothPolylines, SIGNAL(triggered()),this, SLOT(smooth())); menu->setProperty(prop_name, true); } return menu; }
QMenu* Scene_polylines_item::contextMenu() { const char* prop_name = "Menu modified by Scene_polylines_item."; QMenu* menu = Scene_item::contextMenu(); // Use dynamic properties: // http://doc.qt.io/qt-5/qobject.html#property bool menuChanged = menu->property(prop_name).toBool(); if(!menuChanged) { menu->addSeparator(); // TODO: add actions to display corners QAction* action = menu->addAction(tr("Display corners with radius...")); connect(action, SIGNAL(triggered()), this, SLOT(change_corner_radii())); QAction* actionSmoothPolylines = menu->addAction(tr("Smooth polylines")); actionSmoothPolylines->setObjectName("actionSmoothPolylines"); connect(actionSmoothPolylines, SIGNAL(triggered()),this, SLOT(smooth())); QMenu *container = new QMenu(tr("Line Width")); QWidgetAction *sliderAction = new QWidgetAction(0); connect(d->line_Slider, &QSlider::valueChanged, this, &Scene_polylines_item::itemChanged); sliderAction->setDefaultWidget(d->line_Slider); container->addAction(sliderAction); menu->addMenu(container); menu->setProperty(prop_name, true); } return menu; }
QMenu* Scene_combinatorial_map_item::contextMenu() { const char* prop_name = "Menu modified by Scene_combinatorial_map_item."; QMenu* menu = Scene_item::contextMenu(); // Use dynamic properties: // http://doc.qt.io/qt-5/qobject.html#property bool menuChanged = menu->property(prop_name).toBool(); if(!menuChanged) { QAction* actionSelectNextVolume = menu->addAction(tr("Iterate over volumes")); actionSelectNextVolume->setObjectName("actionSelectNextVolume"); connect(actionSelectNextVolume, SIGNAL(triggered()),this, SLOT(set_next_volume())); exportSelectedVolume = menu->addAction(tr("Export current volume as polyhedron")); exportSelectedVolume->setObjectName("exportSelectedVolume"); connect(exportSelectedVolume, SIGNAL(triggered()),this, SLOT(export_current_volume_as_polyhedron())); exportSelectedVolume->setEnabled(volume_to_display!=0); menu->setProperty(prop_name, true); if(is_from_corefinement()){ //Export union as polyhedron QAction* exportUnion = menu->addAction(tr("Export union as polyhedron")); exportUnion->setObjectName("exportUnion"); connect(exportUnion, SIGNAL(triggered()),this, SLOT(export_union_as_polyhedron())); //Export intersection as polyhedron QAction* exportIntersection = menu->addAction(tr("Export intersection as polyhedron")); exportIntersection->setObjectName("exportIntersection"); connect(exportIntersection, SIGNAL(triggered()),this, SLOT(export_intersection_as_polyhedron())); //Export A minus B as polyhedron QAction* exportAMinusB = menu->addAction(tr("Export A minus B as polyhedron")); exportAMinusB->setObjectName("exportAMinusB"); connect(exportAMinusB, SIGNAL(triggered()),this, SLOT(export_A_minus_B_as_polyhedron())); //Export B minus A as polyhedron QAction* exportBMinusA = menu->addAction(tr("Export B minus A as polyhedron")); exportBMinusA->setObjectName("exportBMinusA"); connect(exportBMinusA, SIGNAL(triggered()),this, SLOT(export_B_minus_A_as_polyhedron())); } } return menu; }
void CBookshelfIndex::initActions() { // Each action has a type attached to it as a dynamic property, see actionenum.h. // Menuitem and its subitems can have the same type. // Actions can have also "singleItemAction" property if // it supports only one item. // See contextMenu() and BTIndexItem for how these properties are used later. // Actions are added to the popup menu and also to a list for easy foreach access. QMenu* actionMenu = 0; QAction* action = 0; // -------------------------Grouping -------------------------------------- actionMenu = new QMenu(tr("Grouping"), this); actionMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::grouping::icon)); actionMenu->setProperty("indexActionType", QVariant(Grouping)); m_groupingGroup = new QActionGroup(this); QObject::connect(m_groupingGroup, SIGNAL(triggered(QAction*)), this, SLOT(actionChangeGrouping(QAction*)) ); //TODO: set the inital checked state action = newQAction(tr("Category/Language"), CResMgr::mainIndex::grouping::icon, 0, 0, 0, this); action->setCheckable(true); action->setProperty("indexActionType", QVariant(Grouping)); action->setProperty("grouping", BTModuleTreeItem::CatLangMod); actionMenu->addAction(action); m_groupingGroup->addAction(action); if (m_grouping == BTModuleTreeItem::CatLangMod) action->setChecked(true); m_actionList.append(action); action = newQAction(tr("Category"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this); action->setCheckable(true); m_groupingGroup->addAction(action); if (m_grouping == BTModuleTreeItem::CatMod) action->setChecked(true); action->setProperty("indexActionType", QVariant(Grouping)); action->setProperty("grouping", BTModuleTreeItem::CatMod); actionMenu->addAction(action); m_actionList.append(action); action = newQAction(tr("Language/Category"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this); action->setCheckable(true); m_groupingGroup->addAction(action); if (m_grouping == BTModuleTreeItem::LangCatMod) action->setChecked(true); actionMenu->addAction(action); action->setProperty("indexActionType", QVariant(Grouping)); action->setProperty("grouping", BTModuleTreeItem::LangCatMod); m_actionList.append(action); action = newQAction(tr("Language"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this); action->setCheckable(true); m_groupingGroup->addAction(action); if (m_grouping == BTModuleTreeItem::LangMod) action->setChecked(true); actionMenu->addAction(action); action->setProperty("indexActionType", QVariant(Grouping)); action->setProperty("grouping", BTModuleTreeItem::LangMod); m_actionList.append(action); action = newQAction(tr("Works only"),CResMgr::mainIndex::grouping::icon, 0, 0, 0, this); action->setCheckable(true); m_groupingGroup->addAction(action); if (m_grouping == BTModuleTreeItem::Mod) action->setChecked(true); actionMenu->addAction(action); action->setProperty("indexActionType", QVariant(Grouping)); action->setProperty("grouping", BTModuleTreeItem::Mod); m_actionList.append(action); action = m_popup->addMenu(actionMenu); action->setProperty("indexActionType", QVariant(Grouping)); m_actionList.append(action); // ------------Hide--------------------- action = newQAction(tr("Hide/unhide works..."),CResMgr::mainIndex::search::icon, 0, this, SLOT(actionHideModules()), this); action->setProperty("indexActionType", QVariant(HideModules)); //action->setProperty("multiItemAction", QVariant(true)); m_popup->addAction(action); m_actionList.append(action); // -------------------Show hidden--------------------------- action = newQAction(tr("Show hidden"),CResMgr::mainIndex::search::icon, 0, 0, 0, this); action->setProperty("indexActionType", QVariant(ShowAllModules)); action->setCheckable(true); QObject::connect(action, SIGNAL(toggled(bool)), this, SLOT(actionShowModules(bool))); if (m_showHidden) action->setChecked(true); else action->setChecked(false); m_popup->addAction(action); m_actionList.append(action); m_popup->addSeparator(); //------------------------------------------------------------ //----------------- Actions for items ------------------------ // -------------------------Edit module -------------------------------- actionMenu = new QMenu(tr("Edit"), this); actionMenu->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::editModuleMenu::icon) ); // actionMenu->setDelayed(false); actionMenu->setProperty("indexActionType", QVariant(EditModule)); actionMenu->setProperty("singleItemAction", QVariant(true)); //m_actionList.append(actionMenu); action = newQAction(tr("Plain text..."),CResMgr::mainIndex::editModulePlain::icon, 0, this, SLOT(actionEditModulePlain()), this); actionMenu->addAction(action); m_actionList.append(action); action->setProperty("indexActionType", QVariant(EditModule)); action->setProperty("singleItemAction", QVariant(true)); action = newQAction(tr("HTML..."),CResMgr::mainIndex::editModuleHTML::icon, 0, this, SLOT(actionEditModuleHTML()), this); actionMenu->addAction(action); m_actionList.append(action); action->setProperty("indexActionType", QVariant(EditModule)); action->setProperty("singleItemAction", QVariant(true)); m_actionList.append(m_popup->addMenu(actionMenu)); // ------------------------ Misc actions ------------------------------------- action = newQAction(tr("Search..."),CResMgr::mainIndex::search::icon, 0, this, SLOT(actionSearchInModules()), this); action->setProperty("indexActionType", QVariant(SearchModules)); action->setProperty("multiItemAction", QVariant(true)); m_popup->addAction(action); m_actionList.append(action); action = newQAction(tr("Unlock..."),CResMgr::mainIndex::unlockModule::icon, 0, this, SLOT(actionUnlockModule()), this); m_popup->addAction(action); action->setProperty("indexActionType", QVariant(UnlockModule)); action->setProperty("singleItemAction", QVariant(true)); m_actionList.append(action); action = newQAction(tr("About..."),CResMgr::mainIndex::aboutModule::icon, 0, this, SLOT(actionAboutModule()), this); m_popup->addAction(action); action->setProperty("singleItemAction", QVariant(true)); action->setProperty("indexActionType", QVariant(AboutModule)); m_actionList.append(action); }