LCOV - code coverage report
Current view: top level - muse/framework/audio/main/internal - audiocommandsstate.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 30 0
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 "audiocommandsstate.h"
      24              : 
      25              : #include "audioactionscontroller.h"
      26              : 
      27              : #include "../audiocommands.h"
      28              : #include "log.h"
      29              : 
      30              : using namespace muse;
      31              : using namespace muse::rcommand;
      32              : using namespace muse::audio;
      33              : 
      34            0 : std::string AudioCommandsState::moduleName() const
      35              : {
      36            0 :     return "audio";
      37              : }
      38              : 
      39            0 : void AudioCommandsState::init()
      40              : {
      41            0 :     m_moduleRegister = commandsRegister()->moduleRegister(moduleName());
      42            0 :     IF_ASSERT_FAILED(m_moduleRegister) {
      43            0 :         return;
      44              :     }
      45              : 
      46            0 :     m_controller->modeChanged().onNotify(this, [this]() {
      47            0 :         updateCommandStates();
      48            0 :     });
      49              : 
      50            0 :     updateCommandStates();
      51              : }
      52              : 
      53            0 : void AudioCommandsState::deinit()
      54              : {
      55            0 :     m_controller->modeChanged().disconnect(this);
      56            0 : }
      57              : 
      58            0 : void AudioCommandsState::updateCommandStates(const std::vector<Command>& commands)
      59              : {
      60            0 :     IF_ASSERT_FAILED(m_moduleRegister) {
      61            0 :         return;
      62              :     }
      63              : 
      64            0 :     const auto& commandList = commands.empty() ? m_moduleRegister->commandList() : commands;
      65              : 
      66            0 :     for (const auto& command : commandList) {
      67            0 :         CommandState newState = commandState(command);
      68            0 :         if (m_commandStates[command] != newState) {
      69            0 :             m_commandStates[command] = newState;
      70            0 :             m_commandStateChanged.send(command, newState);
      71              :         }
      72              :     }
      73              : }
      74              : 
      75            0 : CommandState AudioCommandsState::commandState(const Command& command) const
      76              : {
      77            0 :     if (command == AUDIO_DEV_USE_DRIVER_MODE_COMMAND) {
      78            0 :         return CommandState(true, m_controller->mode() == workmode::DriverMode);
      79            0 :     } else if (command == AUDIO_DEV_USE_HYBRID_MODE_COMMAND) {
      80            0 :         return CommandState(true, m_controller->mode() == workmode::HybridMode);
      81              :     }
      82            0 :     return CommandState(true, false);
      83              : }
      84              : 
      85            0 : async::Channel<Command, CommandState> AudioCommandsState::commandStateChanged() const
      86              : {
      87            0 :     return m_commandStateChanged;
      88              : }
        

Generated by: LCOV version 2.0-1