/* * 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 "palettemodule.h" #include #include "log.h" #include "config.h" #include "modularity/ioc.h" #include "ui/iuiengine.h" #include "ui/iinteractiveuriregister.h" #include "ui/iuiactionsregister.h" #include "accessibility/iqaccessibleinterfaceregister.h" #include "internal/paletteconfiguration.h" #include "internal/paletteuiactions.h" #include "internal/paletteactionscontroller.h" #include "internal/paletteworkspacesetup.h" #include "internal/paletteprovider.h" #include "internal/palettecell.h" #include "view/paletterootmodel.h" #include "view/palettepropertiesmodel.h" #include "view/palettecellpropertiesmodel.h" #include "view/palettespanelcontextmenumodel.h" #include "view/drumsetpanelview.h" #include "view/widgets/masterpalette.h" #include "view/widgets/specialcharactersdialog.h" #include "view/widgets/editdrumsetdialog.h" #include "view/widgets/timesignaturepropertiesdialog.h" #include "view/widgets/keyedit.h" #include "view/widgets/timedialog.h" using namespace mu::palette; using namespace mu::modularity; using namespace mu::ui; using namespace mu::accessibility; static std::shared_ptr s_paletteProvider = std::make_shared(); static std::shared_ptr s_actionsController = std::make_shared(); static std::shared_ptr s_paletteUiActions = std::make_shared(s_actionsController); static std::shared_ptr s_configuration = std::make_shared(); static std::shared_ptr s_paletteWorkspaceSetup = std::make_shared(); static void palette_init_qrc() { Q_INIT_RESOURCE(palette); } std::string PaletteModule::moduleName() const { return "palette"; } void PaletteModule::registerExports() { ioc()->registerExport(moduleName(), s_paletteProvider); ioc()->registerExport(moduleName(), s_configuration); } void PaletteModule::resolveImports() { auto ar = ioc()->resolve(moduleName()); if (ar) { ar->reg(s_paletteUiActions); } auto ir = ioc()->resolve(moduleName()); if (ir) { ir->registerUri(Uri("musescore://palette/masterpalette"), ContainerMeta(ContainerType::QWidgetDialog, Ms::MasterPalette::static_metaTypeId())); ir->registerUri(Uri("musescore://palette/specialcharacters"), ContainerMeta(ContainerType::QWidgetDialog, Ms::SpecialCharactersDialog::static_metaTypeId())); ir->registerUri(Uri("musescore://palette/timesignatureproperties"), ContainerMeta(ContainerType::QWidgetDialog, Ms::TimeSignaturePropertiesDialog::static_metaTypeId())); ir->registerUri(Uri("musescore://palette/editdrumset"), ContainerMeta(ContainerType::QWidgetDialog, Ms::EditDrumsetDialog::static_metaTypeId())); ir->registerUri(Uri("musescore://palette/properties"), ContainerMeta(ContainerType::QmlDialog, "MuseScore/Palette/PalettePropertiesDialog.qml")); ir->registerUri(Uri("musescore://palette/cellproperties"), ContainerMeta(ContainerType::QmlDialog, "MuseScore/Palette/PaletteCellPropertiesDialog.qml")); ir->registerUri(Uri("musescore://notation/keysignatures"), ContainerMeta(ContainerType::QWidgetDialog, qRegisterMetaType("KeySignaturesDialog"))); ir->registerUri(Uri("musescore://notation/timesignatures"), ContainerMeta(ContainerType::QWidgetDialog, qRegisterMetaType("TimeSignaturesDialog"))); } auto accr = ioc()->resolve(moduleName()); if (accr) { accr->registerInterfaceGetter("mu::palette::PaletteWidget", PaletteWidget::accessibleInterface); accr->registerInterfaceGetter("mu::palette::PaletteCell", PaletteCell::accessibleInterface); } } void PaletteModule::registerResources() { palette_init_qrc(); } void PaletteModule::registerUiTypes() { using namespace Ms; qmlRegisterUncreatableType("MuseScore.Palette", 1, 0, "PaletteProvider", "Cannot create"); qmlRegisterUncreatableType("MuseScore.Palette", 1, 0, "PaletteController", "Cannot …"); qmlRegisterUncreatableType("MuseScore.Palette", 1, 0, "PaletteElementEditor", "Cannot …"); qmlRegisterUncreatableType("MuseScore.Palette", 1, 0, "PaletteTreeModel", "Cannot create"); qmlRegisterUncreatableType("MuseScore.Palette", 1, 0, "FilterPaletteTreeModel", "Cannot"); qmlRegisterType("MuseScore.Palette", 1, 0, "PalettesPanelContextMenuModel"); qmlRegisterType("MuseScore.Palette", 1, 0, "PaletteRootModel"); qmlRegisterType("MuseScore.Palette", 1, 0, "PalettePropertiesModel"); qmlRegisterType("MuseScore.Palette", 1, 0, "PaletteCellPropertiesModel"); qmlRegisterType("MuseScore.Palette", 1, 0, "DrumsetPanelView"); qRegisterMetaType("SpecialCharactersDialog"); qRegisterMetaType("TimeSignaturePropertiesDialog"); qRegisterMetaType("EditDrumsetDialog"); ioc()->resolve(moduleName())->addSourceImportPath(palette_QML_IMPORT); } void PaletteModule::onInit(const framework::IApplication::RunMode& mode) { if (framework::IApplication::RunMode::Editor != mode) { return; } s_configuration->init(); s_actionsController->init(); s_paletteUiActions->init(); s_paletteProvider->init(); } void PaletteModule::onAllInited(const framework::IApplication::RunMode& mode) { if (framework::IApplication::RunMode::Editor != mode) { return; } //! NOTE We need to be sure that the workspaces are initialized. //! So, we loads these settings on onAllInited s_paletteWorkspaceSetup->setup(); } void PaletteModule::onDeinit() { s_paletteWorkspaceSetup.reset(); s_configuration.reset(); s_paletteUiActions.reset(); ioc()->unregisterExportIfRegistered(moduleName(), s_paletteProvider); s_paletteProvider.reset(); }