MuseScore/src/appshell/appshellmodule.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

148 lines
6.1 KiB
C++
Raw Normal View History

2020-04-25 18:50:24 +02:00
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 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 2.
//
// 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, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "appshellmodule.h"
2020-06-19 16:50:30 +02:00
#include <QQmlEngine>
2020-04-25 18:50:24 +02:00
2020-07-28 16:12:28 +02:00
#include "modularity/ioc.h"
2021-02-02 17:22:45 +01:00
#include "actions/iactionsregister.h"
#include "ui/iinteractiveuriregister.h"
2021-03-12 23:08:21 +01:00
#include "uicomponents/imenucontrollersregister.h"
2020-07-28 16:12:28 +02:00
2021-02-02 17:22:45 +01:00
#include "internal/applicationactions.h"
#include "internal/applicationactioncontroller.h"
2021-02-09 16:49:48 +01:00
#include "internal/appshellconfiguration.h"
2021-02-24 15:48:08 +01:00
#include "internal/notationpagestate.h"
#include "view/devtools/settingslistmodel.h"
#include "view/dockwindow/docksetup.h"
2021-02-09 16:49:48 +01:00
#include "view/appmenumodel.h"
2021-02-24 15:48:08 +01:00
#include "view/notationpagemodel.h"
2021-02-28 17:38:18 +01:00
#include "view/aboutmodel.h"
#include "view/filemenucontroller.h"
#include "view/editmenucontroller.h"
#include "view/viewmenucontroller.h"
#include "view/formatmenucontroller.h"
#include "view/toolsmenucontroller.h"
#include "view/helpmenucontroller.h"
#include "view/preferencesmodel.h"
2021-03-18 13:20:08 +01:00
#include "view/generalpreferencesmodel.h"
2021-03-19 10:50:42 +01:00
#include "view/updatepreferencesmodel.h"
2020-04-25 18:50:24 +02:00
using namespace mu::appshell;
2020-07-28 16:12:28 +02:00
using namespace mu::framework;
2021-01-18 08:15:02 +01:00
using namespace mu::ui;
2021-03-12 23:08:21 +01:00
using namespace mu::uicomponents;
2020-04-25 18:50:24 +02:00
2021-02-09 16:49:48 +01:00
static std::shared_ptr<ApplicationActionController> s_applicationActionController = std::make_shared<ApplicationActionController>();
static std::shared_ptr<AppShellConfiguration> s_appShellConfiguration = std::make_shared<AppShellConfiguration>();
2021-02-24 15:48:08 +01:00
static std::shared_ptr<NotationPageState> s_notationPageState = std::make_shared<NotationPageState>();
2021-02-02 17:22:45 +01:00
static std::shared_ptr<FileMenuController> s_fileMenuController = std::make_shared<FileMenuController>();
static std::shared_ptr<EditMenuController> s_editMenuController = std::make_shared<EditMenuController>();
static std::shared_ptr<ViewMenuController> s_viewMenuController = std::make_shared<ViewMenuController>();
static std::shared_ptr<FormatMenuController> s_formatMenuController = std::make_shared<FormatMenuController>();
static std::shared_ptr<ToolsMenuController> s_toolsMenuController = std::make_shared<ToolsMenuController>();
static std::shared_ptr<HelpMenuController> s_helpMenuController = std::make_shared<HelpMenuController>();
2020-04-25 18:50:24 +02:00
static void appshell_init_qrc()
{
Q_INIT_RESOURCE(appshell);
}
AppShellModule::AppShellModule()
{
}
std::string AppShellModule::moduleName() const
{
return "appshell";
}
2021-02-09 16:49:48 +01:00
void AppShellModule::registerExports()
{
ioc()->registerExport<IAppShellConfiguration>(moduleName(), s_appShellConfiguration);
ioc()->registerExport<IApplicationActionController>(moduleName(), s_applicationActionController);
2021-02-24 15:48:08 +01:00
ioc()->registerExport<INotationPageState>(moduleName(), s_notationPageState);
2021-02-09 16:49:48 +01:00
}
2020-07-28 16:12:28 +02:00
void AppShellModule::resolveImports()
{
2021-02-09 16:49:48 +01:00
auto ar = ioc()->resolve<actions::IActionsRegister>(moduleName());
2021-02-02 17:22:45 +01:00
if (ar) {
ar->reg(std::make_shared<ApplicationActions>());
}
auto ir = ioc()->resolve<IInteractiveUriRegister>(moduleName());
if (ir) {
ir->registerUri(Uri("musescore://home"), ContainerMeta(ContainerType::PrimaryPage));
ir->registerUri(Uri("musescore://notation"), ContainerMeta(ContainerType::PrimaryPage));
ir->registerUri(Uri("musescore://sequencer"), ContainerMeta(ContainerType::PrimaryPage));
ir->registerUri(Uri("musescore://publish"), ContainerMeta(ContainerType::PrimaryPage));
ir->registerUri(Uri("musescore://devtools"), ContainerMeta(ContainerType::PrimaryPage));
2021-02-28 17:38:18 +01:00
ir->registerUri(Uri("musescore://about/musescore"), ContainerMeta(ContainerType::QmlDialog, "AboutDialog.qml"));
ir->registerUri(Uri("musescore://about/musicxml"), ContainerMeta(ContainerType::QmlDialog, "AboutMusicXMLDialog.qml"));
ir->registerUri(Uri("musescore://preferences"), ContainerMeta(ContainerType::QmlDialog, "Preferences/PreferencesDialog.qml"));
2020-07-28 16:12:28 +02:00
}
2021-03-12 23:08:21 +01:00
auto mcr = ioc()->resolve<IMenuControllersRegister>(moduleName());
if (mcr) {
mcr->registerController(MenuType::File, s_fileMenuController);
mcr->registerController(MenuType::Edit, s_editMenuController);
mcr->registerController(MenuType::View, s_viewMenuController);
mcr->registerController(MenuType::Format, s_formatMenuController);
mcr->registerController(MenuType::Tools, s_toolsMenuController);
mcr->registerController(MenuType::Help, s_helpMenuController);
}
2020-07-28 16:12:28 +02:00
}
2020-04-25 18:50:24 +02:00
void AppShellModule::registerResources()
{
appshell_init_qrc();
}
void AppShellModule::registerUiTypes()
{
dock::DockSetup::registerQmlTypes();
2020-06-11 15:31:02 +02:00
qmlRegisterType<SettingListModel>("MuseScore.Preferences", 1, 0, "SettingListModel");
qmlRegisterType<PreferencesModel>("MuseScore.Preferences", 1, 0, "PreferencesModel");
2021-03-18 13:20:08 +01:00
qmlRegisterType<GeneralPreferencesModel>("MuseScore.Preferences", 1, 0, "GeneralPreferencesModel");
2021-03-19 10:50:42 +01:00
qmlRegisterType<UpdatePreferencesModel>("MuseScore.Preferences", 1, 0, "UpdatePreferencesModel");
2021-02-09 16:49:48 +01:00
qmlRegisterType<AppMenuModel>("MuseScore.AppMenu", 1, 0, "AppMenuModel");
2021-02-28 17:38:18 +01:00
qmlRegisterType<NotationPageModel>("MuseScore.AppShell", 1, 0, "NotationPageModel");
qmlRegisterType<AboutModel>("MuseScore.AppShell", 1, 0, "AboutModel");
2020-04-25 18:50:24 +02:00
}
2021-02-02 17:22:45 +01:00
void AppShellModule::onInit(const IApplication::RunMode&)
{
2021-02-24 15:48:08 +01:00
s_appShellConfiguration->init();
2021-02-09 16:49:48 +01:00
s_applicationActionController->init();
2021-02-24 15:48:08 +01:00
s_notationPageState->init();
s_fileMenuController->init();
s_editMenuController->init();
s_viewMenuController->init();
s_formatMenuController->init();
s_toolsMenuController->init();
s_helpMenuController->init();
2021-02-02 17:22:45 +01:00
}