MuseScore/src/appshell/appshellmodule.cpp

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

174 lines
7.6 KiB
C++
Raw Normal View History

/*
* 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 <https://www.gnu.org/licenses/>.
*/
2020-04-25 18:50:24 +02:00
#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"
#include "ui/iuiactionsregister.h"
#include "ui/iinteractiveuriregister.h"
2020-07-28 16:12:28 +02:00
#include "internal/applicationuiactions.h"
2021-02-02 17:22:45 +01:00
#include "internal/applicationactioncontroller.h"
2021-02-09 16:49:48 +01:00
#include "internal/appshellconfiguration.h"
2021-06-18 09:43:46 +02:00
#include "internal/startupscenario.h"
2021-12-07 21:37:48 +01:00
#include "internal/applicationactioncontroller.h"
2022-01-14 15:22:47 +01:00
#include "internal/sessionsmanager.h"
#include "view/devtools/settingslistmodel.h"
2021-02-09 16:49:48 +01:00
#include "view/appmenumodel.h"
#include "view/mainwindowtitleprovider.h"
2021-02-24 15:48:08 +01:00
#include "view/notationpagemodel.h"
2021-06-01 13:02:03 +02:00
#include "view/notationstatusbarmodel.h"
2021-02-28 17:38:18 +01:00
#include "view/aboutmodel.h"
#include "view/firstlaunchsetup/firstlaunchsetupmodel.h"
#include "view/firstlaunchsetup/themespagemodel.h"
#include "view/preferences/preferencesmodel.h"
#include "view/preferences/generalpreferencesmodel.h"
#include "view/preferences/updatepreferencesmodel.h"
#include "view/preferences/appearancepreferencesmodel.h"
#include "view/preferences/programmestartpreferencesmodel.h"
#include "view/preferences/folderspreferencesmodel.h"
#include "view/preferences/noteinputpreferencesmodel.h"
#include "view/preferences/advancedpreferencesmodel.h"
#include "view/preferences/canvaspreferencesmodel.h"
#include "view/preferences/scorepreferencesmodel.h"
#include "view/preferences/importpreferencesmodel.h"
#include "view/preferences/iopreferencesmodel.h"
#include "view/preferences/commonaudioapiconfigurationmodel.h"
#include "view/framelesswindow/framelesswindowmodel.h"
#include "view/publish/publishtoolbarmodel.h"
2021-12-09 17:33:30 +01:00
#include "view/windowdroparea.h"
2021-05-21 16:15:18 +02:00
#include "view/dockwindow/docksetup.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-06-29 16:52:02 +02:00
using namespace mu::modularity;
2021-01-18 08:15:02 +01:00
using namespace mu::ui;
using namespace mu::dock;
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<ApplicationUiActions> s_applicationUiActions = std::make_shared<ApplicationUiActions>(s_applicationActionController);
2021-02-09 16:49:48 +01:00
static std::shared_ptr<AppShellConfiguration> s_appShellConfiguration = std::make_shared<AppShellConfiguration>();
2022-01-14 15:22:47 +01:00
static std::shared_ptr<SessionsManager> s_sessionsManager = std::make_shared<SessionsManager>();
2021-02-02 17:22:45 +01:00
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()
{
DockSetup::registerExports();
2021-02-09 16:49:48 +01:00
ioc()->registerExport<IAppShellConfiguration>(moduleName(), s_appShellConfiguration);
2021-12-09 17:33:30 +01:00
ioc()->registerExport<IApplicationActionController>(moduleName(), s_applicationActionController);
2021-06-18 09:43:46 +02:00
ioc()->registerExport<IStartupScenario>(moduleName(), new StartupScenario());
2022-01-14 15:22:47 +01:00
ioc()->registerExport<ISessionsManager>(moduleName(), s_sessionsManager);
2021-02-09 16:49:48 +01:00
}
2020-07-28 16:12:28 +02:00
void AppShellModule::resolveImports()
{
auto ar = ioc()->resolve<ui::IUiActionsRegister>(moduleName());
2021-02-02 17:22:45 +01:00
if (ar) {
ar->reg(s_applicationUiActions);
2021-02-02 17:22:45 +01:00
}
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"));
2021-11-18 16:39:10 +01:00
ir->registerUri(Uri("musescore://firstLaunchSetup"),
ContainerMeta(ContainerType::QmlDialog, "FirstLaunchSetup/FirstLaunchSetupDialog.qml"));
ir->registerUri(Uri("musescore://preferences"), ContainerMeta(ContainerType::QmlDialog, "Preferences/PreferencesDialog.qml"));
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()
{
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");
qmlRegisterType<AppearancePreferencesModel>("MuseScore.Preferences", 1, 0, "AppearancePreferencesModel");
qmlRegisterType<ProgrammeStartPreferencesModel>("MuseScore.Preferences", 1, 0, "ProgrammeStartPreferencesModel");
2021-03-19 21:06:21 +01:00
qmlRegisterType<FoldersPreferencesModel>("MuseScore.Preferences", 1, 0, "FoldersPreferencesModel");
qmlRegisterType<NoteInputPreferencesModel>("MuseScore.Preferences", 1, 0, "NoteInputPreferencesModel");
2021-03-26 15:04:18 +01:00
qmlRegisterType<AdvancedPreferencesModel>("MuseScore.Preferences", 1, 0, "AdvancedPreferencesModel");
2021-03-24 12:56:53 +01:00
qmlRegisterType<CanvasPreferencesModel>("MuseScore.Preferences", 1, 0, "CanvasPreferencesModel");
2021-03-28 17:49:50 +02:00
qmlRegisterType<ScorePreferencesModel>("MuseScore.Preferences", 1, 0, "ScorePreferencesModel");
2021-03-30 11:24:18 +02:00
qmlRegisterType<ImportPreferencesModel>("MuseScore.Preferences", 1, 0, "ImportPreferencesModel");
2021-04-01 10:57:20 +02:00
qmlRegisterType<IOPreferencesModel>("MuseScore.Preferences", 1, 0, "IOPreferencesModel");
2021-04-01 16:39:28 +02:00
qmlRegisterType<CommonAudioApiConfigurationModel>("MuseScore.Preferences", 1, 0, "CommonAudioApiConfigurationModel");
2021-12-03 11:52:59 +01:00
qmlRegisterType<AppMenuModel>("MuseScore.AppShell", 1, 0, "AppMenuModel");
qmlRegisterType<MainWindowTitleProvider>("MuseScore.AppShell", 1, 0, "MainWindowTitleProvider");
2021-02-28 17:38:18 +01:00
qmlRegisterType<NotationPageModel>("MuseScore.AppShell", 1, 0, "NotationPageModel");
2021-06-01 13:02:03 +02:00
qmlRegisterType<NotationStatusBarModel>("MuseScore.AppShell", 1, 0, "NotationStatusBarModel");
2021-02-28 17:38:18 +01:00
qmlRegisterType<AboutModel>("MuseScore.AppShell", 1, 0, "AboutModel");
qmlRegisterType<FirstLaunchSetupModel>("MuseScore.AppShell", 1, 0, "FirstLaunchSetupModel");
qmlRegisterType<ThemesPageModel>("MuseScore.AppShell", 1, 0, "ThemesPageModel");
qmlRegisterType<FramelessWindowModel>("MuseScore.AppShell", 1, 0, "FramelessWindowModel");
qmlRegisterType<PublishToolBarModel>("MuseScore.AppShell", 1, 0, "PublishToolBarModel");
2021-12-09 17:33:30 +01:00
qmlRegisterType<WindowDropArea>("MuseScore.Ui", 1, 0, "WindowDropArea");
2020-04-25 18:50:24 +02:00
}
2021-02-02 17:22:45 +01:00
void AppShellModule::onInit(const IApplication::RunMode&)
{
DockSetup::onInit();
2021-02-24 15:48:08 +01:00
s_appShellConfiguration->init();
2021-02-09 16:49:48 +01:00
s_applicationActionController->init();
s_applicationUiActions->init();
2022-01-14 15:22:47 +01:00
s_sessionsManager->init();
}
void AppShellModule::onDeinit()
{
s_sessionsManager->deinit();
2021-02-02 17:22:45 +01:00
}