Skip to content

Commit

Permalink
added ioc context to inject. Step 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor authored and igorkorsukov committed Sep 4, 2024
1 parent 6c95106 commit f204d14
Show file tree
Hide file tree
Showing 240 changed files with 940 additions and 761 deletions.
10 changes: 5 additions & 5 deletions src/appshell/appshellmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,17 @@ std::string AppShellModule::moduleName() const

void AppShellModule::registerExports()
{
m_applicationActionController = std::make_shared<ApplicationActionController>();
m_applicationUiActions = std::make_shared<ApplicationUiActions>(m_applicationActionController);
m_appShellConfiguration = std::make_shared<AppShellConfiguration>();
m_sessionsManager = std::make_shared<SessionsManager>();
m_applicationActionController = std::make_shared<ApplicationActionController>(iocContext());
m_applicationUiActions = std::make_shared<ApplicationUiActions>(m_applicationActionController, iocContext());
m_appShellConfiguration = std::make_shared<AppShellConfiguration>(iocContext());
m_sessionsManager = std::make_shared<SessionsManager>(iocContext());

#ifdef Q_OS_MAC
m_scrollingHook = std::make_shared<MacOSScrollingHook>();
#endif

ioc()->registerExport<IAppShellConfiguration>(moduleName(), m_appShellConfiguration);
ioc()->registerExport<IStartupScenario>(moduleName(), new StartupScenario());
ioc()->registerExport<IStartupScenario>(moduleName(), new StartupScenario(iocContext()));
ioc()->registerExport<ISessionsManager>(moduleName(), m_sessionsManager);

#ifdef Q_OS_MAC
Expand Down
31 changes: 17 additions & 14 deletions src/appshell/internal/applicationactioncontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,26 @@
#include "context/iglobalcontext.h"

namespace mu::appshell {
class ApplicationActionController : public QObject, public muse::actions::Actionable, public muse::async::Asyncable
class ApplicationActionController : public QObject, public muse::Injectable, public muse::actions::Actionable, public muse::async::Asyncable
{
muse::Inject<muse::actions::IActionsDispatcher> dispatcher;
muse::Inject<muse::ui::IUiActionsRegister> actionsRegister;
muse::Inject<muse::ui::IMainWindow> mainWindow;
muse::Inject<muse::languages::ILanguagesService> languagesService;
muse::Inject<muse::IInteractive> interactive;
muse::Inject<IAppShellConfiguration> configuration;
muse::Inject<muse::mi::IMultiInstancesProvider> multiInstancesProvider;
muse::Inject<project::IProjectFilesController> projectFilesController;
muse::Inject<muse::audio::ISoundFontRepository> soundFontRepository;
muse::Inject<IStartupScenario> startupScenario;
muse::Inject<muse::IApplication> application;
muse::Inject<muse::extensions::IExtensionInstaller> extensionInstaller;
muse::Inject<context::IGlobalContext> globalContext;
muse::Inject<muse::actions::IActionsDispatcher> dispatcher = { this };
muse::Inject<muse::ui::IUiActionsRegister> actionsRegister = { this };
muse::Inject<muse::ui::IMainWindow> mainWindow = { this };
muse::Inject<muse::languages::ILanguagesService> languagesService = { this };
muse::Inject<muse::IInteractive> interactive = { this };
muse::Inject<IAppShellConfiguration> configuration = { this };
muse::Inject<muse::mi::IMultiInstancesProvider> multiInstancesProvider = { this };
muse::Inject<project::IProjectFilesController> projectFilesController = { this };
muse::Inject<muse::audio::ISoundFontRepository> soundFontRepository = { this };
muse::Inject<IStartupScenario> startupScenario = { this };
muse::Inject<muse::IApplication> application = { this };
muse::Inject<muse::extensions::IExtensionInstaller> extensionInstaller = { this };
muse::Inject<context::IGlobalContext> globalContext = { this };

public:
ApplicationActionController(const muse::modularity::ContextPtr& iocCtx)
: muse::Injectable(iocCtx) {}

void preInit();
void init();

Expand Down
4 changes: 2 additions & 2 deletions src/appshell/internal/applicationuiactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ const UiActionList ApplicationUiActions::m_actions = {
)
};

ApplicationUiActions::ApplicationUiActions(std::shared_ptr<ApplicationActionController> controller)
: m_controller(controller)
ApplicationUiActions::ApplicationUiActions(std::shared_ptr<ApplicationActionController> controller, const modularity::ContextPtr& iocCtx)
: muse::Injectable(iocCtx), m_controller(controller)
{
}

Expand Down
12 changes: 6 additions & 6 deletions src/appshell/internal/applicationuiactions.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
#include "dockwindow/idockwindowprovider.h"

namespace mu::appshell {
class ApplicationUiActions : public muse::ui::IUiActionsModule, public muse::async::Asyncable
class ApplicationUiActions : public muse::ui::IUiActionsModule, public muse::Injectable, public muse::async::Asyncable
{
muse::Inject<muse::ui::IMainWindow> mainWindow;
muse::Inject<muse::dock::IDockWindowProvider> dockWindowProvider;
muse::Inject<IAppShellConfiguration> configuration;
muse::Inject<braille::IBrailleConfiguration> brailleConfiguration;
muse::Inject<muse::ui::IMainWindow> mainWindow = { this };
muse::Inject<muse::dock::IDockWindowProvider> dockWindowProvider = { this };
muse::Inject<IAppShellConfiguration> configuration = { this };
muse::Inject<braille::IBrailleConfiguration> brailleConfiguration = { this };

public:
ApplicationUiActions(std::shared_ptr<ApplicationActionController> controller);
ApplicationUiActions(std::shared_ptr<ApplicationActionController> controller, const muse::modularity::ContextPtr& iocCtx);

void init();

Expand Down
23 changes: 13 additions & 10 deletions src/appshell/internal/appshellconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,22 @@
#include "iappshellconfiguration.h"

namespace mu::appshell {
class AppShellConfiguration : public IAppShellConfiguration, public muse::async::Asyncable
class AppShellConfiguration : public IAppShellConfiguration, public muse::Injectable, public muse::async::Asyncable
{
muse::Inject<muse::IGlobalConfiguration> globalConfiguration;
muse::Inject<muse::IApplication> application;
muse::Inject<muse::io::IFileSystem> fileSystem;
muse::Inject<muse::mi::IMultiInstancesProvider> multiInstancesProvider;
muse::Inject<muse::ui::IUiConfiguration> uiConfiguration;
muse::Inject<project::IProjectConfiguration> projectConfiguration;
muse::Inject<notation::INotationConfiguration> notationConfiguration;
muse::Inject<playback::IPlaybackConfiguration> playbackConfiguration;
muse::Inject<muse::languages::ILanguagesConfiguration> languagesConfiguration;
muse::Inject<muse::IGlobalConfiguration> globalConfiguration = { this };
muse::Inject<muse::IApplication> application = { this };
muse::Inject<muse::io::IFileSystem> fileSystem = { this };
muse::Inject<muse::mi::IMultiInstancesProvider> multiInstancesProvider = { this };
muse::Inject<muse::ui::IUiConfiguration> uiConfiguration = { this };
muse::Inject<project::IProjectConfiguration> projectConfiguration = { this };
muse::Inject<notation::INotationConfiguration> notationConfiguration = { this };
muse::Inject<playback::IPlaybackConfiguration> playbackConfiguration = { this };
muse::Inject<muse::languages::ILanguagesConfiguration> languagesConfiguration = { this };

public:
AppShellConfiguration(const muse::modularity::ContextPtr& iocCtx)
: muse::Injectable(iocCtx) {}

void init();

bool hasCompletedFirstLaunchSetup() const override;
Expand Down
15 changes: 9 additions & 6 deletions src/appshell/internal/sessionsmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@
#include "isessionsmanager.h"

namespace mu::appshell {
class SessionsManager : public ISessionsManager, public muse::async::Asyncable
class SessionsManager : public ISessionsManager, public muse::Injectable, public muse::async::Asyncable
{
muse::Inject<muse::actions::IActionsDispatcher> dispatcher;
muse::Inject<muse::mi::IMultiInstancesProvider> multiInstancesProvider;
muse::Inject<context::IGlobalContext> globalContext;
muse::Inject<project::IProjectConfiguration> projectConfiguration;
muse::Inject<IAppShellConfiguration> configuration;
muse::Inject<muse::actions::IActionsDispatcher> dispatcher = { this };
muse::Inject<muse::mi::IMultiInstancesProvider> multiInstancesProvider = { this };
muse::Inject<context::IGlobalContext> globalContext = { this };
muse::Inject<project::IProjectConfiguration> projectConfiguration = { this };
muse::Inject<IAppShellConfiguration> configuration = { this };

public:
SessionsManager(const muse::modularity::ContextPtr& iocCtx)
: muse::Injectable(iocCtx) {}

void init();
void deinit();

Expand Down
19 changes: 11 additions & 8 deletions src/appshell/internal/startupscenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@
#include "audioplugins/iregisteraudiopluginsscenario.h"

namespace mu::appshell {
class StartupScenario : public IStartupScenario, public muse::async::Asyncable
class StartupScenario : public IStartupScenario, public muse::Injectable, public muse::async::Asyncable
{
muse::Inject<muse::IInteractive> interactive;
muse::Inject<muse::actions::IActionsDispatcher> dispatcher;
muse::Inject<muse::mi::IMultiInstancesProvider> multiInstancesProvider;
muse::Inject<IAppShellConfiguration> configuration;
muse::Inject<ISessionsManager> sessionsManager;
muse::Inject<project::IProjectAutoSaver> projectAutoSaver;
muse::Inject<muse::audioplugins::IRegisterAudioPluginsScenario> registerAudioPluginsScenario;
muse::Inject<muse::IInteractive> interactive = { this };
muse::Inject<muse::actions::IActionsDispatcher> dispatcher = { this };
muse::Inject<muse::mi::IMultiInstancesProvider> multiInstancesProvider = { this };
muse::Inject<IAppShellConfiguration> configuration = { this };
muse::Inject<ISessionsManager> sessionsManager = { this };
muse::Inject<project::IProjectAutoSaver> projectAutoSaver = { this };
muse::Inject<muse::audioplugins::IRegisterAudioPluginsScenario> registerAudioPluginsScenario = { this };

public:

StartupScenario(const muse::modularity::ContextPtr& iocCtx)
: muse::Injectable(iocCtx) {}

void setStartupType(const std::optional<std::string>& type) override;

bool isStartWithNewFileAsSecondaryInstance() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Rectangle {
id: editorModel
}

Component.onCompleted: {
editorModel.init()
}

RowLayout {
id: contentRow

Expand Down
2 changes: 1 addition & 1 deletion src/appshell/view/aboutmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
using namespace mu::appshell;

AboutModel::AboutModel(QObject* parent)
: QObject(parent)
: QObject(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
{
}

Expand Down
10 changes: 5 additions & 5 deletions src/appshell/view/aboutmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
class QUrl;

namespace mu::appshell {
class AboutModel : public QObject
class AboutModel : public QObject, public muse::Injectable
{
Q_OBJECT

Inject<IAppShellConfiguration> configuration;
Inject<muse::update::IUpdateConfiguration> updateConfiguration;
Inject<muse::IGlobalConfiguration> globalConfiguration;
Inject<muse::IApplication> application;
Inject<IAppShellConfiguration> configuration = { this };
Inject<muse::update::IUpdateConfiguration> updateConfiguration = { this };
Inject<muse::IGlobalConfiguration> globalConfiguration = { this };
Inject<muse::IApplication> application = { this };

public:
explicit AboutModel(QObject* parent = nullptr);
Expand Down
26 changes: 13 additions & 13 deletions src/appshell/view/appmenumodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ class AppMenuModel : public muse::uicomponents::AbstractMenuModel
Q_OBJECT

public:
INJECT(muse::ui::IMainWindow, mainWindow)
INJECT(muse::ui::IUiActionsRegister, uiActionsRegister)
INJECT(muse::ui::INavigationController, navigationController)
INJECT(muse::ui::IUiConfiguration, uiConfiguration)
INJECT(muse::actions::IActionsDispatcher, actionsDispatcher)
INJECT(muse::workspace::IWorkspaceManager, workspacesManager)
INJECT(IAppShellConfiguration, configuration)
INJECT(project::IRecentFilesController, recentFilesController)
INJECT(IAppMenuModelHook, appMenuModelHook)
INJECT(muse::extensions::IExtensionsProvider, extensionsProvider)
INJECT(muse::update::IUpdateConfiguration, updateConfiguration)
INJECT(muse::IGlobalConfiguration, globalConfiguration)
INJECT(project::IProjectConfiguration, projectConfiguration)
muse::Inject<muse::ui::IMainWindow> mainWindow = { this };
muse::Inject<muse::ui::IUiActionsRegister> uiActionsRegister = { this };
muse::Inject<muse::ui::INavigationController> navigationController = { this };
muse::Inject<muse::ui::IUiConfiguration> uiConfiguration = { this };
muse::Inject<muse::actions::IActionsDispatcher> actionsDispatcher = { this };
muse::Inject<muse::workspace::IWorkspaceManager> workspacesManager = { this };
muse::Inject<IAppShellConfiguration> configuration = { this };
muse::Inject<project::IRecentFilesController> recentFilesController = { this };
muse::Inject<IAppMenuModelHook> appMenuModelHook = { this };
muse::Inject<muse::extensions::IExtensionsProvider> extensionsProvider = { this };
muse::Inject<muse::update::IUpdateConfiguration> updateConfiguration = { this };
muse::Inject<muse::IGlobalConfiguration> globalConfiguration = { this };
muse::Inject<project::IProjectConfiguration> projectConfiguration = { this };

public:
explicit AppMenuModel(QObject* parent = nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace mu;
using namespace mu::appshell;

FirstLaunchSetupModel::FirstLaunchSetupModel(QObject* parent)
: QObject(parent)
: QObject(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
{
m_pages = {
Page { "ThemesPage.qml", "musescore://notation" },
Expand Down
6 changes: 3 additions & 3 deletions src/appshell/view/firstlaunchsetup/firstlaunchsetupmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "iinteractive.h"

namespace mu::appshell {
class FirstLaunchSetupModel : public QObject
class FirstLaunchSetupModel : public QObject, public muse::Injectable
{
Q_OBJECT

Expand All @@ -41,8 +41,8 @@ class FirstLaunchSetupModel : public QObject
Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY currentPageChanged)
Q_PROPERTY(bool canFinish READ canFinish NOTIFY currentPageChanged)

INJECT(IAppShellConfiguration, configuration)
INJECT(muse::IInteractive, interactive)
muse::Inject<IAppShellConfiguration> configuration = { this };
muse::Inject<muse::IInteractive> interactive = { this };

public:
explicit FirstLaunchSetupModel(QObject* parent = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/appshell/view/firstlaunchsetup/themespagemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace mu::appshell;
using namespace muse::ui;

ThemesPageModel::ThemesPageModel(QObject* parent)
: QObject(parent)
: QObject(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/appshell/view/firstlaunchsetup/themespagemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "ui/iuiconfiguration.h"

namespace mu::appshell {
class ThemesPageModel : public QObject, public muse::async::Asyncable
class ThemesPageModel : public QObject, public muse::Injectable, public muse::async::Asyncable
{
Q_OBJECT

Expand All @@ -45,7 +45,7 @@ class ThemesPageModel : public QObject, public muse::async::Asyncable
Q_PROPERTY(QString currentThemeCode READ currentThemeCode WRITE setCurrentThemeCode NOTIFY themesChanged)
Q_PROPERTY(int currentAccentColorIndex READ currentAccentColorIndex WRITE setCurrentAccentColorIndex NOTIFY themesChanged)

INJECT(muse::ui::IUiConfiguration, uiConfiguration)
muse::Inject<muse::ui::IUiConfiguration> uiConfiguration = { this };

public:
explicit ThemesPageModel(QObject* parent = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/appshell/view/firstlaunchsetup/tutorialspagemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using namespace mu::appshell;

TutorialsPageModel::TutorialsPageModel(QObject* parent)
: QObject(parent)
: QObject(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/appshell/view/firstlaunchsetup/tutorialspagemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
class QUrl;

namespace mu::appshell {
class TutorialsPageModel : public QObject
class TutorialsPageModel : public QObject, public muse::Injectable
{
Q_OBJECT

Inject<muse::update::IUpdateConfiguration> updateConfiguration;
Inject<muse::update::IUpdateConfiguration> updateConfiguration = { this };

public:
explicit TutorialsPageModel(QObject* parent = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/appshell/view/internal/maintoolbarmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline QVariantMap buildItem(const QString& title, const QString& uri)
}

MainToolBarModel::MainToolBarModel(QObject* parent)
: QAbstractListModel(parent)
: QAbstractListModel(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
{
}

Expand Down
6 changes: 3 additions & 3 deletions src/appshell/view/internal/maintoolbarmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
#include "iglobalconfiguration.h"

namespace mu::appshell {
class MainToolBarModel : public QAbstractListModel, public muse::async::Asyncable
class MainToolBarModel : public QAbstractListModel, public muse::Injectable, public muse::async::Asyncable
{
Q_OBJECT

INJECT(context::IGlobalContext, context)
INJECT(muse::IGlobalConfiguration, globalConfiguration)
muse::Inject<context::IGlobalContext> context = { this };
muse::Inject<muse::IGlobalConfiguration> globalConfiguration = { this };

public:
explicit MainToolBarModel(QObject* parent = nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static const QColor versionNumberColor("#22A0F4");
static constexpr qreal versionNumberSpacing = 5.0;

LoadingScreenView::LoadingScreenView(QWidget* parent)
: QWidget(parent),
: QWidget(parent), muse::Injectable(muse::iocCtxForQWidget(this)),
m_backgroundRenderer(new QSvgRenderer(imagePath, this))
{
setAttribute(Qt::WA_TranslucentBackground);
Expand Down
8 changes: 4 additions & 4 deletions src/appshell/view/internal/splashscreen/loadingscreenview.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
class QSvgRenderer;

namespace mu::appshell {
class LoadingScreenView : public QWidget
class LoadingScreenView : public QWidget, public muse::Injectable
{
Q_OBJECT

Inject<muse::ui::IUiConfiguration> uiConfiguration;
Inject<muse::languages::ILanguagesService> languagesService;
Inject<muse::IApplication> application;
Inject<muse::ui::IUiConfiguration> uiConfiguration = { this };
Inject<muse::languages::ILanguagesService> languagesService = { this };
Inject<muse::IApplication> application = { this };

public:
explicit LoadingScreenView(QWidget* parent = nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
using namespace mu::appshell;

NewInstanceLoadingScreenView::NewInstanceLoadingScreenView(bool forNewScore, const QString& openingFileName, QWidget* parent)
: QWidget(parent)
: QWidget(parent), muse::Injectable(muse::iocCtxForQWidget(this))
{
setAttribute(Qt::WA_TranslucentBackground);

Expand Down
Loading

0 comments on commit f204d14

Please sign in to comment.