Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #pragma once
24 :
25 : #include "../ishortcutscontroller.h"
26 :
27 : #include "async/asyncable.h"
28 : #include "modularity/ioc.h"
29 : #include "rcommand/icommanddispatcher.h"
30 : #include "rcommand/icommandsstate.h"
31 : #include "interactive/iinteractive.h"
32 : #include "../icommandshortcutsregister.h"
33 : #include "../ishortcutsresolver.h"
34 :
35 : namespace muse::shortcuts {
36 : class ShortcutsController : public IShortcutsController, public Contextable, public async::Asyncable
37 : {
38 : GlobalInject<ICommandShortcutsRegister> commandShortcutsRegister;
39 : ContextInject<muse::rcommand::ICommandsState> commandsState = { this };
40 : ContextInject<muse::rcommand::ICommandDispatcher> commandDispatcher = { this };
41 : ContextInject<muse::IInteractive> interactive = { this };
42 : ContextInject<IShortcutsResolver> shortcutsResolver = { this };
43 :
44 : public:
45 0 : ShortcutsController(const modularity::ContextPtr& iocCtx)
46 0 : : Contextable(iocCtx) {}
47 :
48 : void init();
49 :
50 : bool active() override;
51 : void setActive(bool active) override;
52 : async::Notification activeChanged() const override;
53 :
54 : void activate(const std::string& sequence) override;
55 :
56 : private:
57 : bool m_active = true;
58 : async::Notification m_activeChanged;
59 : };
60 : }
|