LCOV - code coverage report
Current view: top level - src/importexport/mnx/internal - mnxconfiguration.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 75.0 % 28 21
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) 2026 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              : #include "mnxconfiguration.h"
      23              : 
      24              : #include <algorithm>
      25              : 
      26              : #include "settings.h"
      27              : 
      28              : using namespace mu;
      29              : using namespace mu::iex::mnxio;
      30              : using namespace muse;
      31              : 
      32              : static const std::string module_name("iex_mnx");
      33              : 
      34              : static const Settings::Key MNX_EXPORT_INDENT_KEY(module_name, "export/mnx/indentSpaces");
      35              : static const Settings::Key MNX_EXPORT_BEAMS_KEY(module_name, "export/mnx/exportBeams");
      36              : static const Settings::Key MNX_EXPORT_REST_POSITIONS_KEY(module_name, "export/mnx/exportRestPositions");
      37              : static const Settings::Key MNX_IMPORT_EXACT_SCHEMA_VALIDATION_KEY(module_name, "import/mnx/requireExactSchemaValidation");
      38              : 
      39            1 : void MnxConfiguration::init()
      40              : {
      41            1 :     settings()->setDefaultValue(MNX_EXPORT_INDENT_KEY, Val(4));
      42            1 :     settings()->setDefaultValue(MNX_EXPORT_BEAMS_KEY, Val(true));
      43            1 :     settings()->setDefaultValue(MNX_EXPORT_REST_POSITIONS_KEY, Val(false));
      44            1 :     settings()->setDefaultValue(MNX_IMPORT_EXACT_SCHEMA_VALIDATION_KEY, Val(true));
      45            1 : }
      46              : 
      47            0 : int MnxConfiguration::mnxIndentSpaces() const
      48              : {
      49            0 :     const int value = settings()->value(MNX_EXPORT_INDENT_KEY).toInt();
      50            0 :     return std::clamp(value, -1, 8);
      51              : }
      52              : 
      53            0 : void MnxConfiguration::setMnxIndentSpaces(int value)
      54              : {
      55            0 :     const int clamped = std::clamp(value, -1, 8);
      56            0 :     settings()->setSharedValue(MNX_EXPORT_INDENT_KEY, Val(clamped));
      57            0 : }
      58              : 
      59          131 : bool MnxConfiguration::mnxExportBeams() const
      60              : {
      61          131 :     return settings()->value(MNX_EXPORT_BEAMS_KEY).toBool();
      62              : }
      63              : 
      64          100 : void MnxConfiguration::setMnxExportBeams(bool value)
      65              : {
      66          100 :     settings()->setSharedValue(MNX_EXPORT_BEAMS_KEY, Val(value));
      67          100 : }
      68              : 
      69          131 : bool MnxConfiguration::mnxExportRestPositions() const
      70              : {
      71          131 :     return settings()->value(MNX_EXPORT_REST_POSITIONS_KEY).toBool();
      72              : }
      73              : 
      74          100 : void MnxConfiguration::setMnxExportRestPositions(bool value)
      75              : {
      76          100 :     settings()->setSharedValue(MNX_EXPORT_REST_POSITIONS_KEY, Val(value));
      77          100 : }
      78              : 
      79           85 : bool MnxConfiguration::mnxRequireExactSchemaValidation() const
      80              : {
      81           85 :     return settings()->value(MNX_IMPORT_EXACT_SCHEMA_VALIDATION_KEY).toBool();
      82              : }
      83              : 
      84          170 : void MnxConfiguration::setMnxRequireExactSchemaValidation(bool value)
      85              : {
      86          170 :     settings()->setSharedValue(MNX_IMPORT_EXACT_SCHEMA_VALIDATION_KEY, Val(value));
      87          170 : }
        

Generated by: LCOV version 2.0-1