/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/EditorPlugins/AI/EditorPluginAi/Actions/AiActions.cpp
59 строк
2 KB
Jan Krassnigg
Map plugin options to all document menus
09 май 2025, 10:09
09 май 2025, 10:09
07e4377
Код
Авторство
О чём код?
#include <EditorPluginAi/EditorPluginAiPCH.h> #include <EditorPluginAi/Actions/AiActions.h> #include <EditorPluginAi/Dialogs/AiProjectSettingsDlg.moc.h> #include <GuiFoundation/Action/ActionMapManager.h> EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezAiAction, 0, ezRTTINoAllocator) EZ_END_DYNAMIC_REFLECTED_TYPE; ezActionDescriptorHandle ezAiActions::s_hCategoryAi; ezActionDescriptorHandle ezAiActions::s_hProjectSettings; void ezAiActions::RegisterActions() { s_hCategoryAi = EZ_REGISTER_CATEGORY("Ai"); s_hProjectSettings = EZ_REGISTER_ACTION_1("Ai.Settings.Project", ezActionScope::Document, "Ai", "", ezAiAction, ezAiAction::ActionType::ProjectSettings); } void ezAiActions::UnregisterActions() { ezActionManager::UnregisterAction(s_hCategoryAi); ezActionManager::UnregisterAction(s_hProjectSettings); } void ezAiActions::MapMenuActions() { ezActionMap* pMap = ezActionMapManager::GetActionMap("AssetMenuBar"); EZ_ASSERT_DEV(pMap != nullptr, "Mapping the actions failed!"); pMap->MapAction(s_hCategoryAi, "G.Plugins.Settings", 10.0f); pMap->MapAction(s_hProjectSettings, "G.Plugins.Settings", "Ai", 1.0f); } ezAiAction::ezAiAction(const ezActionContext& context, const char* szName, ActionType type) : ezButtonAction(context, szName, false, "") { m_Type = type; switch (m_Type) { case ActionType::ProjectSettings: SetIconPath(":/AiPlugin/ezAiPlugin.svg"); break; } } ezAiAction::~ezAiAction() = default; void ezAiAction::Execute(const ezVariant& value) { if (m_Type == ActionType::ProjectSettings) { ezQtAiProjectSettingsDlg dlg(nullptr); if (dlg.exec() == QDialog::Accepted) { ezToolsProject::BroadcastConfigChanged(); } } }