Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 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 : #include "multiwindowscommandsstate.h"
24 :
25 : #include "../multiwindowscommands.h"
26 :
27 : using namespace muse;
28 : using namespace muse::rcommand;
29 : using namespace muse::mi;
30 :
31 0 : std::string MultiWindowsCommandsState::moduleName() const
32 : {
33 0 : return "multiwindows";
34 : }
35 :
36 0 : void MultiWindowsCommandsState::init()
37 : {
38 0 : m_moduleRegister = commandsRegister()->moduleRegister(moduleName());
39 0 : IF_ASSERT_FAILED(m_moduleRegister) {
40 0 : return;
41 : }
42 :
43 0 : updateCommandStates();
44 : }
45 :
46 0 : void MultiWindowsCommandsState::deinit()
47 : {
48 0 : }
49 :
50 0 : void MultiWindowsCommandsState::updateCommandStates(const std::vector<Command>& commands)
51 : {
52 0 : IF_ASSERT_FAILED(m_moduleRegister) {
53 0 : return;
54 : }
55 :
56 0 : const auto& commandList = commands.empty() ? m_moduleRegister->commandList() : commands;
57 :
58 0 : for (const auto& command : commandList) {
59 0 : CommandState newState = commandState(command);
60 0 : if (m_commandStates[command] != newState) {
61 0 : m_commandStates[command] = newState;
62 0 : m_commandStateChanged.send(command, newState);
63 : }
64 : }
65 : }
66 :
67 0 : CommandState MultiWindowsCommandsState::commandState(const Command&) const
68 : {
69 0 : return CommandState(true, false);
70 : }
71 :
72 0 : async::Channel<Command, CommandState> MultiWindowsCommandsState::commandStateChanged() const
73 : {
74 0 : return m_commandStateChanged;
75 : }
|