| 993 | |
| 994 | |
| 995 | void ModuleWidget::createContextMenu() { |
| 996 | ui::Menu* menu = createMenu(); |
| 997 | assert(model); |
| 998 | |
| 999 | WeakPtr<ModuleWidget> weakThis = this; |
| 1000 | |
| 1001 | // Brand and module name |
| 1002 | menu->addChild(createMenuLabel(model->name)); |
| 1003 | menu->addChild(createMenuLabel(model->plugin->brand)); |
| 1004 | |
| 1005 | // Info |
| 1006 | menu->addChild(createSubmenuItem(string::translate("ModuleWidget.info"), "", [=](ui::Menu* menu) { |
| 1007 | model->appendContextMenu(menu); |
| 1008 | |
| 1009 | if (!weakThis) |
| 1010 | return; |
| 1011 | menu->addChild(new ui::MenuSeparator); |
| 1012 | menu->addChild(createMenuLabel(string::translate("ModuleWidget.moduleId"))); |
| 1013 | menu->addChild(createMenuLabel(string::f("%lld", (long long) weakThis->module->getId()))); |
| 1014 | })); |
| 1015 | |
| 1016 | // Preset |
| 1017 | menu->addChild(createSubmenuItem(string::translate("ModuleWidget.preset"), "", [=](ui::Menu* menu) { |
| 1018 | menu->addChild(createMenuItem(string::translate("ModuleWidget.copy"), widget::getKeyCommandName(GLFW_KEY_C, RACK_MOD_CTRL), [=]() { |
| 1019 | if (!weakThis) |
| 1020 | return; |
| 1021 | weakThis->copyClipboard(); |
| 1022 | })); |
| 1023 | |
| 1024 | menu->addChild(createMenuItem(string::translate("ModuleWidget.paste"), widget::getKeyCommandName(GLFW_KEY_V, RACK_MOD_CTRL), [=]() { |
| 1025 | if (!weakThis) |
| 1026 | return; |
| 1027 | weakThis->pasteClipboardAction(); |
| 1028 | })); |
| 1029 | |
| 1030 | menu->addChild(createMenuItem(string::translate("ModuleWidget.load"), "", [=]() { |
| 1031 | if (!weakThis) |
| 1032 | return; |
| 1033 | weakThis->loadDialog(); |
| 1034 | })); |
| 1035 | |
| 1036 | menu->addChild(createMenuItem(string::translate("ModuleWidget.saveAs"), "", [=]() { |
| 1037 | if (!weakThis) |
| 1038 | return; |
| 1039 | weakThis->saveDialog(); |
| 1040 | })); |
| 1041 | |
| 1042 | menu->addChild(createMenuItem(string::translate("ModuleWidget.saveTemplate"), "", [=]() { |
| 1043 | if (!weakThis) |
| 1044 | return; |
| 1045 | weakThis->saveTemplateDialog(); |
| 1046 | })); |
| 1047 | |
| 1048 | menu->addChild(createMenuItem(string::translate("ModuleWidget.clearTemplate"), "", [=]() { |
| 1049 | if (!weakThis) |
| 1050 | return; |
| 1051 | weakThis->clearTemplateDialog(); |
| 1052 | }, !weakThis->hasTemplate())); |
nothing calls this directly
no test coverage detected