LCOV - code coverage report
Current view: top level - muse/framework/dockwindow_v2/internal - dockcommandsstate.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 81.8 % 22 18
Test Date: 2026-11-05 04:07:02

            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 "dockcommandsstate.h"
      24              : 
      25              : #include "../dockcommands.h"
      26              : #include "thirdparty/kors_logger/src/log_base.h"
      27              : 
      28              : using namespace muse;
      29              : using namespace muse::rcommand;
      30              : using namespace muse::dock;
      31              : 
      32            6 : std::string DockCommandsState::moduleName() const
      33              : {
      34           12 :     return "dock";
      35              : }
      36              : 
      37            3 : void DockCommandsState::init()
      38              : {
      39            3 :     m_moduleRegister = commandsRegister()->moduleRegister(moduleName());
      40            3 :     IF_ASSERT_FAILED(m_moduleRegister) {
      41            0 :         return;
      42              :     }
      43              : 
      44            3 :     updateCommandStates();
      45              : }
      46              : 
      47            0 : void DockCommandsState::deinit()
      48              : {
      49            0 : }
      50              : 
      51            3 : void DockCommandsState::updateCommandStates(const std::vector<Command>& commands)
      52              : {
      53            3 :     IF_ASSERT_FAILED(m_moduleRegister) {
      54            0 :         return;
      55              :     }
      56              : 
      57            3 :     const auto& commandList = commands.empty() ? m_moduleRegister->commandList() : commands;
      58              : 
      59           15 :     for (const auto& command : commandList) {
      60           12 :         CommandState newState = commandState(command);
      61           12 :         if (m_commandStates[command] != newState) {
      62           12 :             m_commandStates[command] = newState;
      63           12 :             m_commandStateChanged.send(command, newState);
      64              :         }
      65              :     }
      66              : }
      67              : 
      68           12 : CommandState DockCommandsState::commandState(const Command& command) const
      69              : {
      70              :     UNUSED(command);
      71           12 :     return CommandState(true, false);
      72              : }
      73              : 
      74            3 : async::Channel<Command, CommandState> DockCommandsState::commandStateChanged() const
      75              : {
      76            3 :     return m_commandStateChanged;
      77              : }
        

Generated by: LCOV version 2.0-1