/* * SPDX-License-Identifier: GPL-3.0-only * MuseScore-CLA-applies * * MuseScore * Music Composition & Notation * * Copyright (C) 2021 MuseScore BVBA and others * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "autobotmodule.h" #include #include "modularity/ioc.h" #include "ui/iinteractiveuriregister.h" #include "ui/iuiactionsregister.h" #include "internal/autobot.h" #include "internal/autobotconfiguration.h" #include "view/autobotscriptsmodel.h" #include "view/testcaserunmodel.h" #include "engraving/infrastructure/draw/painter.h" #include "internal/draw/abpaintprovider.h" #include "internal/autobotactionscontroller.h" #include "internal/autobotactions.h" #include "internal/autobotscriptsrepository.h" #include "internal/api/apiregister.h" #include "internal/api/logapi.h" #include "internal/api/autobotapi.h" #include "internal/api/dispatcherapi.h" #include "internal/api/navigationapi.h" #include "internal/api/contextapi.h" #include "internal/api/shortcutsapi.h" #include "internal/api/interactiveapi.h" #include "internal/api/keyboardapi.h" #include "internal/api/accessibilityapi.h" #include "diagnostics/idiagnosticspathsregister.h" using namespace mu::autobot; using namespace mu::api; static std::shared_ptr s_configuration = std::make_shared(); static std::shared_ptr s_autobot = std::make_shared(); static std::shared_ptr s_actionsController = std::make_shared(); std::string AutobotModule::moduleName() const { return "autobot"; } void AutobotModule::registerExports() { modularity::ioc()->registerExport(moduleName(), s_autobot); modularity::ioc()->registerExport(moduleName(), s_configuration); modularity::ioc()->registerExport(moduleName(), new AutobotScriptsRepository()); modularity::ioc()->registerExport(moduleName(), new ApiRegister()); // draw::Painter::extended = AbPaintProvider::instance(); } void AutobotModule::resolveImports() { auto ir = modularity::ioc()->resolve(moduleName()); if (ir) { ir->registerQmlUri(Uri("musescore://autobot/batchtests"), "MuseScore/Autobot/BatchTestsDialog.qml"); ir->registerQmlUri(Uri("musescore://autobot/scripts"), "MuseScore/Autobot/ScriptsDialog.qml"); ir->registerQmlUri(Uri("musescore://autobot/selectfile"), "MuseScore/Autobot/AutobotSelectFileDialog.qml"); } auto ar = modularity::ioc()->resolve(moduleName()); if (ar) { ar->reg(std::make_shared()); } auto api = modularity::ioc()->resolve(moduleName()); if (api) { api->regApiCreator("global", "api.log", new ApiCreator()); api->regApiCreator("autobot", "api.autobot", new ApiCreator()); api->regApiCreator("autobot", "api.context", new ApiCreator()); api->regApiCreator("actions", "api.dispatcher", new ApiCreator()); api->regApiCreator("ui", "api.navigation", new ApiCreator()); api->regApiCreator("shortcuts", "api.shortcuts", new ApiCreator()); api->regApiCreator("global", "api.interactive", new ApiCreator()); api->regApiCreator("ui", "api.keyboard", new ApiCreator()); api->regApiCreator("accessibility", "api.accessibility", new ApiCreator()); } } void AutobotModule::registerUiTypes() { qmlRegisterType("MuseScore.Autobot", 1, 0, "AutobotScriptsModel"); qmlRegisterType("MuseScore.Autobot", 1, 0, "TestCaseRunModel"); } void AutobotModule::onInit(const framework::IApplication::RunMode&) { s_autobot->init(); s_actionsController->init(); //! --- Diagnostics --- auto pr = modularity::ioc()->resolve(moduleName()); if (pr) { for (const io::path& p : s_configuration->scriptsDirPaths()) { pr->reg("autobotScriptsPath", p); } pr->reg("autobotTestingFilesPath", s_configuration->testingFilesDirPath()); pr->reg("autobotDataPath", s_configuration->dataPath()); pr->reg("autobotSavingFilesPath", s_configuration->savingFilesPath()); pr->reg("autobotReportsPath", s_configuration->reportsPath()); pr->reg("autobotDrawDataPath", s_configuration->drawDataPath()); } }