LCOV - code coverage report
Current view: top level - src/notation/internal - notationconfiguration.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 633 0
Test Date: 2026-11-19 04:14:36

            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) 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              : #include "notationconfiguration.h"
      23              : 
      24              : #include "engraving/dom/mscore.h"
      25              : 
      26              : #include "io/path.h"
      27              : #include "settings.h"
      28              : 
      29              : #include "notationtypes.h"
      30              : 
      31              : using namespace mu;
      32              : using namespace mu::notation;
      33              : using namespace muse;
      34              : using namespace muse::async;
      35              : using namespace muse::draw;
      36              : using namespace muse::ui;
      37              : 
      38              : static const std::string module_name("notation");
      39              : 
      40              : static const Settings::Key LIGHT_SCORE_BACKGROUND_COLOR(module_name, "ui/canvas/background/lightTheme_score_background_color");
      41              : static const Settings::Key DARK_SCORE_BACKGROUND_COLOR(module_name, "ui/canvas/background/darkTheme_score_background_color");
      42              : static const Settings::Key HC_BLACK_SCORE_BACKGROUND_COLOR(module_name, "ui/canvas/background/hc_black_score_background_color");
      43              : static const Settings::Key HC_WHITE_SCORE_BACKGROUND_COLOR(module_name, "ui/canvas/background/hc_white_score_background_color");
      44              : static const Settings::Key BACKGROUND_WALLPAPER_PATH(module_name, "ui/canvas/background/wallpaper");
      45              : static const Settings::Key BACKGROUND_USE_COLOR(module_name, "ui/canvas/background/useColor");
      46              : 
      47              : static const Settings::Key FOREGROUND_COLOR(module_name, "ui/canvas/foreground/color");
      48              : static const Settings::Key INVERTED_FOREGROUND_COLOR(module_name, "ui/canvas/foreground/invertedColor");
      49              : static const Settings::Key FOREGROUND_WALLPAPER_PATH(module_name, "ui/canvas/foreground/wallpaper");
      50              : static const Settings::Key FOREGROUND_USE_COLOR(module_name, "ui/canvas/foreground/useColor");
      51              : 
      52              : // TODO(5.0): replace "engraving" with module_name
      53              : static const Settings::Key INVERT_SCORE_COLOR("engraving", "engraving/scoreColorInversion");
      54              : static const Settings::Key ONLY_INVERT_IN_DARK_THEME(module_name, "ui/canvas/onlyInvertInDarkTheme");
      55              : 
      56              : static const Settings::Key NOTE_INPUT_PREVIEW_COLOR(module_name, "ui/canvas/noteInputPreviewColor");
      57              : 
      58              : static const Settings::Key USE_NOTE_INPUT_CURSOR_IN_INPUT_BY_DURATION(module_name,
      59              :                                                                       "ui/canvas/useNoteInputCursorInInputByDuration");
      60              : 
      61              : static const Settings::Key THIN_NOTE_INPUT_CURSOR(module_name, "ui/canvas/thinNoteInputCursor");
      62              : 
      63              : static const Settings::Key ENABLE_JIANPU(module_name, "notation/enableJianpu");
      64              : 
      65              : static const Settings::Key SELECTION_PROXIMITY(module_name, "ui/canvas/misc/selectionProximity");
      66              : 
      67              : static const Settings::Key DEFAULT_ZOOM_TYPE(module_name, "ui/canvas/zoomDefaultType");
      68              : static const Settings::Key DEFAULT_ZOOM(module_name, "ui/canvas/zoomDefaultLevel");
      69              : static const Settings::Key KEYBOARD_ZOOM_PRECISION(module_name, "ui/canvas/zoomPrecisionKeyboard");
      70              : static const Settings::Key MOUSE_ZOOM_PRECISION(module_name, "ui/canvas/zoomPrecisionMouse");
      71              : 
      72              : static const Settings::Key CURRENT_AUTOMATION_LANE(module_name, "notation/automation/currentLane");
      73              : 
      74              : static const Settings::Key USER_STYLES_PATH(module_name, "application/paths/myStyles");
      75              : static const Settings::Key USER_MUSIC_FONTS_PATH(module_name, "application/paths/myMusicFonts");
      76              : 
      77              : static const Settings::Key DEFAULT_NOTE_INPUT_METHOD(module_name, "score/defaultInputMethod");
      78              : 
      79              : static const Settings::Key ADD_ACCIDENTAL_ARTICULATIONS_DOTS_TO_NEXT_NOTE_ENTERED(module_name,
      80              :                                                                                   "score/addAccidentalDotsArticulationsToNextNoteEntered");
      81              : static const Settings::Key TUPLET_COMMANDS_SELECTED_DURATION_AS(module_name, "score/tupletCommandsSelectedDurationAs");
      82              : 
      83              : static const Settings::Key IS_MIDI_INPUT_ENABLED(module_name, "io/midi/enableInput");
      84              : static const Settings::Key START_NOTE_INPUT_AT_SELECTED_NOTE_REST_WHEN_PRESSING_MIDI_KEY(module_name,
      85              :                                                                                          "score/startNoteInputAtSelectionWhenPressingMidiKey");
      86              : static const Settings::Key USE_MIDI_INPUT_WRITTEN_PITCH(module_name, "io/midi/useWrittenPitch");
      87              : static const Settings::Key IS_AUTOMATICALLY_PAN_ENABLED(module_name, "application/playback/panPlayback");
      88              : static const Settings::Key IS_PLAY_REPEATS_ENABLED(module_name, "application/playback/playRepeats");
      89              : static const Settings::Key IS_PLAY_CHORD_SYMBOLS_ENABLED(module_name, "application/playback/playChordSymbols");
      90              : static const Settings::Key IS_PLAY_PREVIEW_NOTES_IN_INPUT_BY_DURATION_ENABLED(module_name,
      91              :                                                                               "application/playback/playPreviewNotesInInputByDuration");
      92              : static const Settings::Key PLAY_PREVIEW_NOTES_WITH_SCORE_DYNAMICS(module_name, "application/playback/playPreviewNotesWithScoreDynamics");
      93              : static const Settings::Key IS_METRONOME_ENABLED(module_name, "application/playback/metronomeEnabled");
      94              : static const Settings::Key IS_COUNT_IN_ENABLED(module_name, "application/playback/countInEnabled");
      95              : 
      96              : static const Settings::Key IS_CANVAS_ORIENTATION_VERTICAL_KEY(module_name, "ui/canvas/scroll/verticalOrientation");
      97              : 
      98              : static const Settings::Key COLOR_NOTES_OUTSIDE_OF_USABLE_PITCH_RANGE(module_name, "score/note/warnPitchRange");
      99              : static const Settings::Key WARN_GUITAR_BENDS(module_name, "score/note/warnGuitarBends");
     100              : static const Settings::Key REALTIME_DELAY(module_name, "io/midi/realtimeDelay");
     101              : static const Settings::Key USE_MIDI_VELOCITY_AND_DURATION_DURING_NOTE_INPUT(module_name,
     102              :                                                                             "io/midi/useMidiVelocityAndDurationDuringNoteInput");
     103              : static const Settings::Key NOTE_DEFAULT_PLAY_DURATION(module_name, "score/note/defaultPlayDuration");
     104              : 
     105              : static const Settings::Key USER_INSTRUMENTS_PATH(module_name, "application/paths/userInstruments");
     106              : 
     107              : static const Settings::Key IS_SNAPPED_TO_VERTICAL_GRID_KEY(module_name,  "ui/application/raster/isSnappedToVerticalGrid");
     108              : static const Settings::Key IS_SNAPPED_TO_HORIZONTAL_GRID_KEY(module_name,  "ui/application/raster/isSnappedToHorizontalGrid");
     109              : static const Settings::Key HORIZONTAL_GRID_SIZE_KEY(module_name,  "ui/application/raster/horizontal");
     110              : static const Settings::Key VERTICAL_GRID_SIZE_KEY(module_name,  "ui/application/raster/vertical");
     111              : 
     112              : static const Settings::Key STYLE_FILE_IMPORT_PATH_KEY(module_name, "import/style/styleFile");
     113              : 
     114              : static constexpr int DEFAULT_GRID_SIZE_SPATIUM = 2;
     115              : 
     116              : static const std::string BY_NOTE_NAME_INPUT_METHOD("BY_NOTE_NAME");
     117              : 
     118              : static const std::map<NoteInputMethod, std::string> NOTE_INPUT_METHOD_TO_STR {
     119              :     { NoteInputMethod::BY_NOTE_NAME, BY_NOTE_NAME_INPUT_METHOD },
     120              :     { NoteInputMethod::BY_DURATION, "BY_DURATION" },
     121              :     { NoteInputMethod::REPITCH, "REPITCH" },
     122              :     { NoteInputMethod::RHYTHM, "RHYTHM" },
     123              :     { NoteInputMethod::REALTIME_AUTO, "REALTIME_AUTO" },
     124              :     { NoteInputMethod::REALTIME_MANUAL, "REALTIME_MANUAL" },
     125              :     { NoteInputMethod::TIMEWISE, "TIMEWISE" },
     126              : };
     127              : 
     128            0 : void NotationConfiguration::init()
     129              : {
     130            0 :     engravingConfiguration()->displayedDefaultColorChanged().onReceive(this, [this](bool inverted, const Color&) {
     131            0 :         if (inverted == shouldInvertScore()) {
     132            0 :             m_notationColorChanged.notify();
     133              :         }
     134            0 :     });
     135              : 
     136            0 :     settings()->setDefaultValue(BACKGROUND_USE_COLOR, Val(true));
     137            0 :     settings()->valueChanged(BACKGROUND_USE_COLOR).onReceive(nullptr, [this](const Val&) {
     138            0 :         m_backgroundChanged.notify();
     139            0 :     });
     140              : 
     141            0 :     if (uiConfiguration()) {
     142            0 :         uiConfiguration()->currentThemeChanged().onNotify(this, [this]() {
     143            0 :             m_backgroundChanged.notify();
     144            0 :             if (scoreInversionEnabled() && isOnlyInvertInDarkTheme()) {
     145            0 :                 m_foregroundChanged.notify();
     146            0 :                 m_notationColorChanged.notify();
     147              :             }
     148            0 :         });
     149              :     }
     150              : 
     151            0 :     settings()->setDefaultValue(LIGHT_SCORE_BACKGROUND_COLOR, Val(QColor("#BCC1CC")));
     152            0 :     settings()->valueChanged(LIGHT_SCORE_BACKGROUND_COLOR).onReceive(nullptr, [this](const Val&) {
     153            0 :         m_backgroundChanged.notify();
     154            0 :     });
     155              : 
     156            0 :     settings()->setDefaultValue(DARK_SCORE_BACKGROUND_COLOR, Val(QColor("#27272B")));
     157            0 :     settings()->valueChanged(DARK_SCORE_BACKGROUND_COLOR).onReceive(nullptr, [this](const Val&) {
     158            0 :         m_backgroundChanged.notify();
     159            0 :     });
     160              : 
     161            0 :     settings()->setDefaultValue(HC_BLACK_SCORE_BACKGROUND_COLOR, Val(QColor("#000000")));
     162            0 :     settings()->valueChanged(HC_BLACK_SCORE_BACKGROUND_COLOR).onReceive(nullptr, [this](const Val&) {
     163            0 :         m_backgroundChanged.notify();
     164            0 :     });
     165              : 
     166            0 :     settings()->setDefaultValue(HC_WHITE_SCORE_BACKGROUND_COLOR, Val(QColor("#000000")));
     167            0 :     settings()->valueChanged(HC_WHITE_SCORE_BACKGROUND_COLOR).onReceive(nullptr, [this](const Val&) {
     168            0 :         m_backgroundChanged.notify();
     169            0 :     });
     170              : 
     171            0 :     settings()->setDefaultValue(BACKGROUND_WALLPAPER_PATH, Val());
     172            0 :     settings()->valueChanged(BACKGROUND_WALLPAPER_PATH).onReceive(nullptr, [this](const Val&) {
     173            0 :         m_backgroundChanged.notify();
     174            0 :     });
     175              : 
     176            0 :     settings()->setDefaultValue(FOREGROUND_USE_COLOR, Val(true));
     177            0 :     settings()->valueChanged(FOREGROUND_USE_COLOR).onReceive(nullptr, [this](const Val&) {
     178            0 :         m_foregroundChanged.notify();
     179            0 :     });
     180              : 
     181            0 :     settings()->setDefaultValue(FOREGROUND_COLOR, Val(QColor("#f9f9f9")));
     182            0 :     settings()->valueChanged(FOREGROUND_COLOR).onReceive(nullptr, [this](const Val&) {
     183            0 :         m_foregroundChanged.notify();
     184            0 :     });
     185              : 
     186            0 :     settings()->setDefaultValue(INVERTED_FOREGROUND_COLOR, Val(QColor("#141416")));
     187            0 :     settings()->valueChanged(INVERTED_FOREGROUND_COLOR).onReceive(nullptr, [this](const Val&) {
     188            0 :         m_foregroundChanged.notify();
     189            0 :     });
     190              : 
     191            0 :     settings()->setDefaultValue(INVERT_SCORE_COLOR, Val(false));
     192            0 :     settings()->valueChanged(INVERT_SCORE_COLOR).onReceive(nullptr, [this](const Val&) {
     193            0 :         m_scoreInversionChanged.notify();
     194            0 :         m_foregroundChanged.notify();
     195            0 :         m_notationColorChanged.notify();
     196            0 :     });
     197              : 
     198            0 :     settings()->setDefaultValue(ONLY_INVERT_IN_DARK_THEME, Val(false));
     199            0 :     settings()->valueChanged(ONLY_INVERT_IN_DARK_THEME).onReceive(nullptr, [this](const Val&) {
     200            0 :         m_isOnlyInvertInDarkThemeChanged.notify();
     201            0 :         if (scoreInversionEnabled()) {
     202            0 :             m_foregroundChanged.notify();
     203            0 :             m_notationColorChanged.notify();
     204              :         }
     205            0 :     });
     206              : 
     207            0 :     settings()->setDefaultValue(NOTE_INPUT_PREVIEW_COLOR, Val(selectionColor()));
     208            0 :     settings()->setCanBeManuallyEdited(NOTE_INPUT_PREVIEW_COLOR, true);
     209            0 :     settings()->setDescription(NOTE_INPUT_PREVIEW_COLOR, muse::trc("notation", "Note input preview note color"));
     210              : 
     211            0 :     settings()->setDefaultValue(USE_NOTE_INPUT_CURSOR_IN_INPUT_BY_DURATION, Val(false));
     212            0 :     settings()->valueChanged(USE_NOTE_INPUT_CURSOR_IN_INPUT_BY_DURATION).onReceive(nullptr, [this](const Val&) {
     213            0 :         m_useNoteInputCursorInInputByDurationChanged.notify();
     214            0 :     });
     215              : 
     216            0 :     settings()->setDefaultValue(THIN_NOTE_INPUT_CURSOR, Val(false)); // accessible via DevTools/Settings
     217              : 
     218            0 :     settings()->setDefaultValue(ENABLE_JIANPU, Val(false));
     219              : 
     220            0 :     settings()->setDefaultValue(FOREGROUND_WALLPAPER_PATH, Val());
     221            0 :     settings()->valueChanged(FOREGROUND_WALLPAPER_PATH).onReceive(nullptr, [this](const Val&) {
     222            0 :         m_foregroundChanged.notify();
     223            0 :     });
     224              : 
     225            0 :     settings()->setDefaultValue(DEFAULT_ZOOM_TYPE, Val(ZoomType::Percentage));
     226            0 :     settings()->valueChanged(DEFAULT_ZOOM_TYPE).onReceive(this, [this](const Val&) {
     227            0 :         m_defaultZoomChanged.notify();
     228            0 :     });
     229            0 :     settings()->setDefaultValue(DEFAULT_ZOOM, Val(100));
     230            0 :     settings()->valueChanged(DEFAULT_ZOOM).onReceive(this, [this](const Val&) {
     231            0 :         m_defaultZoomChanged.notify();
     232            0 :     });
     233            0 :     settings()->setDefaultValue(KEYBOARD_ZOOM_PRECISION, Val(2));
     234            0 :     settings()->setDefaultValue(MOUSE_ZOOM_PRECISION, Val(6));
     235            0 :     settings()->valueChanged(MOUSE_ZOOM_PRECISION).onReceive(this, [this](const Val&) {
     236            0 :         m_mouseZoomPrecisionChanged.notify();
     237            0 :     });
     238              : 
     239            0 :     settings()->setDefaultValue(CURRENT_AUTOMATION_LANE, Val(AutomationLane::Dynamics));
     240            0 :     settings()->valueChanged(CURRENT_AUTOMATION_LANE).onReceive(this, [this](const Val&) {
     241            0 :         m_currentAutomationLaneChanged.notify();
     242            0 :     });
     243              : 
     244            0 :     settings()->setDefaultValue(USER_STYLES_PATH, Val(globalConfiguration()->userDataPath() + "/Styles"));
     245            0 :     settings()->valueChanged(USER_STYLES_PATH).onReceive(nullptr, [this](const Val& val) {
     246            0 :         m_userStylesPathChanged.send(val.toPath());
     247            0 :     });
     248              : 
     249            0 :     if (!userStylesPath().empty()) {
     250            0 :         fileSystem()->makePath(userStylesPath());
     251              : 
     252              : #if !defined(Q_OS_LINUX)
     253              :         // Create shortcut or symlink to global styles folder. Doesn't overwrite an existing file
     254              :         // or link, which means it won't work on Linux because the global styles folder is inside
     255              :         // the AppImage, and the AppImage mountpoint changes on each run. TODO: Check for existing
     256              :         // link, read it, and if necessary update it. This would make it work on Linux too.
     257              :         fileSystem()->makeLink(
     258              :             globalConfiguration()->appDataPath() + "/styles",
     259              :             userStylesPath() + "/Built-in styles"
     260              :             );
     261              : #endif
     262              :     }
     263              : 
     264            0 :     settings()->setDefaultValue(USER_MUSIC_FONTS_PATH, Val(io::path_t {}));
     265            0 :     settings()->valueChanged(USER_MUSIC_FONTS_PATH).onReceive(this, [this](const Val& val) {
     266            0 :         m_userMusicFontsPathChanged.send(val.toString());
     267            0 :     });
     268              : 
     269            0 :     settings()->setDefaultValue(DEFAULT_NOTE_INPUT_METHOD, Val(BY_NOTE_NAME_INPUT_METHOD));
     270            0 :     settings()->valueChanged(DEFAULT_NOTE_INPUT_METHOD).onReceive(this, [this](const Val&) {
     271            0 :         m_defaultNoteInputMethodChanged.notify();
     272            0 :     });
     273              : 
     274            0 :     settings()->setDefaultValue(ADD_ACCIDENTAL_ARTICULATIONS_DOTS_TO_NEXT_NOTE_ENTERED, Val(true));
     275            0 :     settings()->valueChanged(ADD_ACCIDENTAL_ARTICULATIONS_DOTS_TO_NEXT_NOTE_ENTERED).onReceive(this, [this](const Val&) {
     276            0 :         m_addAccidentalDotsArticulationsToNextNoteEnteredChanged.notify();
     277            0 :     });
     278              : 
     279            0 :     settings()->setDefaultValue(TUPLET_COMMANDS_SELECTED_DURATION_AS, Val(engraving::TupletSelectedDuration::SUBDIVISION));
     280            0 :     settings()->valueChanged(TUPLET_COMMANDS_SELECTED_DURATION_AS).onReceive(this, [this](const Val&) {
     281            0 :         m_tupletCommandsSelectedDurationAsChanged.notify();
     282            0 :     });
     283              : 
     284            0 :     settings()->setDefaultValue(SELECTION_PROXIMITY, Val(2));
     285            0 :     settings()->valueChanged(SELECTION_PROXIMITY).onReceive(this, [this](const Val& val) {
     286            0 :         m_selectionProximityChanged.send(val.toInt());
     287            0 :     });
     288              : 
     289            0 :     settings()->setDefaultValue(IS_MIDI_INPUT_ENABLED, Val(true));
     290            0 :     settings()->valueChanged(IS_MIDI_INPUT_ENABLED).onReceive(this, [this](const Val&) {
     291            0 :         m_isMidiInputEnabledChanged.notify();
     292            0 :     });
     293              : 
     294            0 :     settings()->setDefaultValue(START_NOTE_INPUT_AT_SELECTED_NOTE_REST_WHEN_PRESSING_MIDI_KEY, Val(true));
     295            0 :     settings()->valueChanged(START_NOTE_INPUT_AT_SELECTED_NOTE_REST_WHEN_PRESSING_MIDI_KEY).onReceive(this, [this](const Val&) {
     296            0 :         m_startNoteInputAtSelectedNoteRestWhenPressingMidiKeyChanged.notify();
     297            0 :     });
     298              : 
     299            0 :     settings()->setDefaultValue(IS_AUTOMATICALLY_PAN_ENABLED, Val(true));
     300            0 :     settings()->valueChanged(IS_AUTOMATICALLY_PAN_ENABLED).onReceive(this, [this](const Val&) {
     301            0 :         m_isAutomaticallyPanEnabledChanged.notify();
     302            0 :     });
     303              : 
     304            0 :     settings()->setDefaultValue(IS_PLAY_REPEATS_ENABLED, Val(true));
     305              : 
     306            0 :     settings()->setDefaultValue(IS_METRONOME_ENABLED, Val(false));
     307            0 :     settings()->valueChanged(IS_METRONOME_ENABLED).onReceive(this, [this](const Val&) {
     308            0 :         m_isMetronomeEnabledChanged.notify();
     309            0 :     });
     310              : 
     311            0 :     settings()->setDefaultValue(IS_COUNT_IN_ENABLED, Val(false));
     312            0 :     settings()->valueChanged(IS_COUNT_IN_ENABLED).onReceive(this, [this](const Val&) {
     313            0 :         m_isCountInEnabledChanged.notify();
     314            0 :     });
     315              : 
     316            0 :     settings()->setDefaultValue(IS_PLAY_CHORD_SYMBOLS_ENABLED, Val(true));
     317            0 :     settings()->valueChanged(IS_PLAY_CHORD_SYMBOLS_ENABLED).onReceive(nullptr, [this](const Val&) {
     318            0 :         m_isPlayChordSymbolsChanged.notify();
     319            0 :     });
     320              : 
     321            0 :     settings()->setDefaultValue(IS_PLAY_PREVIEW_NOTES_IN_INPUT_BY_DURATION_ENABLED, Val(true));
     322            0 :     settings()->valueChanged(IS_PLAY_PREVIEW_NOTES_IN_INPUT_BY_DURATION_ENABLED).onReceive(nullptr, [this](const Val&) {
     323            0 :         m_isPlayNotesPreviewInInputByDurationChanged.notify();
     324            0 :     });
     325              : 
     326            0 :     settings()->setDefaultValue(PLAY_PREVIEW_NOTES_WITH_SCORE_DYNAMICS, Val(true));
     327            0 :     settings()->valueChanged(PLAY_PREVIEW_NOTES_WITH_SCORE_DYNAMICS).onReceive(nullptr, [this](const Val&) {
     328            0 :         m_playPreviewNotesWithScoreDynamicsChanged.notify();
     329            0 :     });
     330              : 
     331            0 :     settings()->setDefaultValue(IS_CANVAS_ORIENTATION_VERTICAL_KEY, Val(false));
     332            0 :     settings()->valueChanged(IS_CANVAS_ORIENTATION_VERTICAL_KEY).onReceive(nullptr, [this](const Val&) {
     333            0 :         m_canvasOrientationChanged.send(canvasOrientation().val);
     334            0 :     });
     335              : 
     336            0 :     settings()->setDefaultValue(COLOR_NOTES_OUTSIDE_OF_USABLE_PITCH_RANGE, Val(true));
     337            0 :     settings()->valueChanged(COLOR_NOTES_OUTSIDE_OF_USABLE_PITCH_RANGE).onReceive(this, [this](const Val& val) {
     338            0 :         m_colorNotesOutsideOfUsablePitchRangeChanged.send(val.toBool());
     339            0 :     });
     340            0 :     settings()->setDefaultValue(WARN_GUITAR_BENDS, Val(true));
     341            0 :     settings()->valueChanged(WARN_GUITAR_BENDS).onReceive(this, [this](const Val& val) {
     342            0 :         m_warnGuitarBendsChanged.send(val.toBool());
     343            0 :     });
     344            0 :     settings()->setDefaultValue(REALTIME_DELAY, Val(750));
     345            0 :     settings()->valueChanged(REALTIME_DELAY).onReceive(this, [this](const Val& val) {
     346            0 :         m_delayBetweenNotesInRealTimeModeMillisecondsChanged.send(val.toInt());
     347            0 :     });
     348              : 
     349            0 :     settings()->setDefaultValue(USE_MIDI_VELOCITY_AND_DURATION_DURING_NOTE_INPUT, Val(true));
     350            0 :     settings()->valueChanged(USE_MIDI_VELOCITY_AND_DURATION_DURING_NOTE_INPUT).onReceive(this, [this](const Val& val) {
     351            0 :         m_useMidiVelocityAndDurationDuringNoteInputChanged.send(val.toBool());
     352            0 :     });
     353              : 
     354            0 :     settings()->setDefaultValue(NOTE_DEFAULT_PLAY_DURATION, Val(500));
     355            0 :     settings()->valueChanged(NOTE_DEFAULT_PLAY_DURATION).onReceive(this, [this](const Val& val) {
     356            0 :         m_notePlayDurationMillisecondsChanged.send(val.toInt());
     357            0 :     });
     358              : 
     359            0 :     settings()->setDefaultValue(STYLE_FILE_IMPORT_PATH_KEY, Val(""));
     360            0 :     settings()->valueChanged(STYLE_FILE_IMPORT_PATH_KEY).onReceive(this, [this](const Val& val) {
     361            0 :         m_styleFileImportPathChanged.send(val.toString());
     362            0 :     });
     363              : 
     364            0 :     settings()->setDefaultValue(USER_INSTRUMENTS_PATH, Val(""));
     365            0 :     settings()->valueChanged(USER_INSTRUMENTS_PATH).onReceive(nullptr, [this](const Val& val) {
     366            0 :         m_userInstrumentsFolderChanged.send(val.toPath());
     367            0 :     });
     368              : 
     369            0 :     settings()->setDefaultValue(HORIZONTAL_GRID_SIZE_KEY, Val(DEFAULT_GRID_SIZE_SPATIUM));
     370            0 :     settings()->setDefaultValue(VERTICAL_GRID_SIZE_KEY, Val(DEFAULT_GRID_SIZE_SPATIUM));
     371              : 
     372            0 :     settings()->setDefaultValue(USE_MIDI_INPUT_WRITTEN_PITCH, Val(true));
     373            0 :     m_midiInputUseWrittenPitch.val = settings()->value(USE_MIDI_INPUT_WRITTEN_PITCH).toBool();
     374            0 :     settings()->valueChanged(USE_MIDI_INPUT_WRITTEN_PITCH).onReceive(this, [this](const Val& val) {
     375            0 :         m_midiInputUseWrittenPitch.set(val.toBool());
     376            0 :     });
     377              : 
     378            0 :     mu::engraving::MScore::warnPitchRange = colorNotesOutsideOfUsablePitchRange();
     379            0 :     mu::engraving::MScore::warnGuitarBends = warnGuitarBends();
     380              : 
     381              :     // Restore stored grid size values
     382            0 :     mu::engraving::MScore::setHRaster(settings()->value(HORIZONTAL_GRID_SIZE_KEY).toInt());
     383            0 :     mu::engraving::MScore::setVRaster(settings()->value(VERTICAL_GRID_SIZE_KEY).toInt());
     384            0 : }
     385              : 
     386            0 : QColor NotationConfiguration::notationColor() const
     387              : {
     388            0 :     return engravingConfiguration()->displayedDefaultColor(shouldInvertScore()).toQColor();
     389              : }
     390              : 
     391            0 : void NotationConfiguration::setNotationColor(const QColor& color)
     392              : {
     393            0 :     engravingConfiguration()->setDisplayedDefaultColor(color, shouldInvertScore());
     394            0 : }
     395              : 
     396            0 : muse::async::Notification NotationConfiguration::notationColorChanged() const
     397              : {
     398            0 :     return m_notationColorChanged;
     399              : }
     400              : 
     401            0 : void NotationConfiguration::resetNotationColor()
     402              : {
     403            0 :     engravingConfiguration()->resetDisplayedDefaultColors();
     404            0 : }
     405              : 
     406            0 : QColor NotationConfiguration::backgroundColor() const
     407              : {
     408            0 :     if (uiConfiguration()->currentTheme().codeKey == LIGHT_THEME_CODE) {
     409            0 :         return settings()->value(LIGHT_SCORE_BACKGROUND_COLOR).toQColor();
     410            0 :     } else if (uiConfiguration()->currentTheme().codeKey == DARK_THEME_CODE) {
     411            0 :         return settings()->value(DARK_SCORE_BACKGROUND_COLOR).toQColor();
     412            0 :     } else if (uiConfiguration()->currentTheme().codeKey == HIGH_CONTRAST_BLACK_THEME_CODE) {
     413            0 :         return settings()->value(HC_BLACK_SCORE_BACKGROUND_COLOR).toQColor();
     414              :     } else {
     415            0 :         return settings()->value(HC_WHITE_SCORE_BACKGROUND_COLOR).toQColor();
     416              :     }
     417              : }
     418              : 
     419            0 : void NotationConfiguration::setBackgroundColor(const QColor& color)
     420              : {
     421            0 :     if (uiConfiguration()->currentTheme().codeKey == LIGHT_THEME_CODE) {
     422            0 :         settings()->setSharedValue(LIGHT_SCORE_BACKGROUND_COLOR, Val(color));
     423            0 :     } else if (uiConfiguration()->currentTheme().codeKey == DARK_THEME_CODE) {
     424            0 :         settings()->setSharedValue(DARK_SCORE_BACKGROUND_COLOR, Val(color));
     425            0 :     } else if (uiConfiguration()->currentTheme().codeKey == HIGH_CONTRAST_BLACK_THEME_CODE) {
     426            0 :         settings()->setSharedValue(HC_BLACK_SCORE_BACKGROUND_COLOR, Val(color));
     427              :     } else {
     428            0 :         settings()->setSharedValue(HC_WHITE_SCORE_BACKGROUND_COLOR, Val(color));
     429              :     }
     430            0 : }
     431              : 
     432            0 : muse::io::path_t NotationConfiguration::backgroundWallpaperPath() const
     433              : {
     434            0 :     return settings()->value(BACKGROUND_WALLPAPER_PATH).toString();
     435              : }
     436              : 
     437            0 : const QPixmap& NotationConfiguration::backgroundWallpaper() const
     438              : {
     439            0 :     muse::io::path_t path = backgroundWallpaperPath();
     440              : 
     441            0 :     static QPixmap wallpaper;
     442            0 :     static muse::io::path_t lastPath;
     443              : 
     444            0 :     if (path.empty()) {
     445            0 :         wallpaper = QPixmap();
     446            0 :     } else if (path != lastPath) {
     447            0 :         wallpaper = QPixmap(path.toQString());
     448              :     }
     449              : 
     450            0 :     lastPath = path;
     451              : 
     452            0 :     return wallpaper;
     453            0 : }
     454              : 
     455            0 : void NotationConfiguration::setBackgroundWallpaperPath(const muse::io::path_t& path)
     456              : {
     457            0 :     settings()->setSharedValue(BACKGROUND_WALLPAPER_PATH, Val(path.toStdString()));
     458            0 : }
     459              : 
     460            0 : bool NotationConfiguration::backgroundUseColor() const
     461              : {
     462            0 :     return settings()->value(BACKGROUND_USE_COLOR).toBool();
     463              : }
     464              : 
     465            0 : void NotationConfiguration::setBackgroundUseColor(bool value)
     466              : {
     467            0 :     settings()->setSharedValue(BACKGROUND_USE_COLOR, Val(value));
     468            0 : }
     469              : 
     470            0 : void NotationConfiguration::resetBackground()
     471              : {
     472            0 :     settings()->setSharedValue(LIGHT_SCORE_BACKGROUND_COLOR, settings()->defaultValue(LIGHT_SCORE_BACKGROUND_COLOR));
     473            0 :     settings()->setSharedValue(DARK_SCORE_BACKGROUND_COLOR, settings()->defaultValue(DARK_SCORE_BACKGROUND_COLOR));
     474            0 :     settings()->setSharedValue(HC_BLACK_SCORE_BACKGROUND_COLOR, settings()->defaultValue(HC_BLACK_SCORE_BACKGROUND_COLOR));
     475            0 :     settings()->setSharedValue(HC_WHITE_SCORE_BACKGROUND_COLOR, settings()->defaultValue(HC_WHITE_SCORE_BACKGROUND_COLOR));
     476              : 
     477            0 :     settings()->setSharedValue(BACKGROUND_USE_COLOR, settings()->defaultValue(BACKGROUND_USE_COLOR));
     478              : 
     479            0 :     settings()->setSharedValue(BACKGROUND_WALLPAPER_PATH, settings()->defaultValue(BACKGROUND_WALLPAPER_PATH));
     480            0 : }
     481              : 
     482            0 : muse::async::Notification NotationConfiguration::backgroundChanged() const
     483              : {
     484            0 :     return m_backgroundChanged;
     485              : }
     486              : 
     487            0 : QColor NotationConfiguration::foregroundColor() const
     488              : {
     489            0 :     if (shouldInvertScore()) {
     490            0 :         return settings()->value(INVERTED_FOREGROUND_COLOR).toQColor();
     491              :     }
     492              : 
     493            0 :     return settings()->value(FOREGROUND_COLOR).toQColor();
     494              : }
     495              : 
     496            0 : void NotationConfiguration::setForegroundColor(const QColor& color)
     497              : {
     498            0 :     if (shouldInvertScore()) {
     499            0 :         settings()->setSharedValue(INVERTED_FOREGROUND_COLOR, Val(color));
     500              :     } else {
     501            0 :         settings()->setSharedValue(FOREGROUND_COLOR, Val(color));
     502              :     }
     503            0 : }
     504              : 
     505            0 : muse::io::path_t NotationConfiguration::foregroundWallpaperPath() const
     506              : {
     507            0 :     return settings()->value(FOREGROUND_WALLPAPER_PATH).toString();
     508              : }
     509              : 
     510            0 : const QPixmap& NotationConfiguration::foregroundWallpaper() const
     511              : {
     512            0 :     muse::io::path_t path = foregroundWallpaperPath();
     513              : 
     514            0 :     static QPixmap wallpaper;
     515            0 :     static muse::io::path_t lastPath;
     516              : 
     517            0 :     if (path.empty()) {
     518            0 :         wallpaper = QPixmap();
     519            0 :     } else if (path != lastPath) {
     520            0 :         wallpaper = QPixmap(path.toQString());
     521              :     }
     522              : 
     523            0 :     lastPath = path;
     524              : 
     525            0 :     return wallpaper;
     526            0 : }
     527              : 
     528            0 : void NotationConfiguration::setForegroundWallpaperPath(const muse::io::path_t& path)
     529              : {
     530            0 :     return settings()->setSharedValue(FOREGROUND_WALLPAPER_PATH, Val(path.toStdString()));
     531              : }
     532              : 
     533            0 : bool NotationConfiguration::foregroundUseColor() const
     534              : {
     535            0 :     return settings()->value(FOREGROUND_USE_COLOR).toBool();
     536              : }
     537              : 
     538            0 : void NotationConfiguration::setForegroundUseColor(bool value)
     539              : {
     540            0 :     settings()->setSharedValue(FOREGROUND_USE_COLOR, Val(value));
     541            0 : }
     542              : 
     543            0 : void NotationConfiguration::resetForeground()
     544              : {
     545            0 :     settings()->setSharedValue(FOREGROUND_COLOR, settings()->defaultValue(FOREGROUND_COLOR));
     546            0 :     settings()->setSharedValue(INVERTED_FOREGROUND_COLOR, settings()->defaultValue(INVERTED_FOREGROUND_COLOR));
     547            0 :     settings()->setSharedValue(FOREGROUND_USE_COLOR, settings()->defaultValue(FOREGROUND_USE_COLOR));
     548            0 :     settings()->setSharedValue(FOREGROUND_WALLPAPER_PATH, settings()->defaultValue(FOREGROUND_WALLPAPER_PATH));
     549            0 :     settings()->setSharedValue(INVERT_SCORE_COLOR, settings()->defaultValue(INVERT_SCORE_COLOR));
     550            0 :     settings()->setSharedValue(ONLY_INVERT_IN_DARK_THEME, settings()->defaultValue(ONLY_INVERT_IN_DARK_THEME));
     551            0 : }
     552              : 
     553            0 : muse::async::Notification NotationConfiguration::foregroundChanged() const
     554              : {
     555            0 :     return m_foregroundChanged;
     556              : }
     557              : 
     558            0 : muse::io::path_t NotationConfiguration::wallpapersDefaultDirPath() const
     559              : {
     560            0 :     return globalConfiguration()->appDataPath() + "/wallpapers";
     561              : }
     562              : 
     563            0 : bool NotationConfiguration::shouldInvertScore() const
     564              : {
     565            0 :     if (scoreInversionEnabled()) {
     566            0 :         return !isOnlyInvertInDarkTheme() || (uiConfiguration() && uiConfiguration()->isDarkMode());
     567              :     }
     568            0 :     return false;
     569              : }
     570              : 
     571            0 : bool NotationConfiguration::scoreInversionEnabled() const
     572              : {
     573            0 :     return settings()->value(INVERT_SCORE_COLOR).toBool();
     574              : }
     575              : 
     576            0 : void NotationConfiguration::setScoreInversionEnabled(bool value)
     577              : {
     578            0 :     settings()->setSharedValue(INVERT_SCORE_COLOR, Val(value));
     579            0 : }
     580              : 
     581            0 : muse::async::Notification NotationConfiguration::scoreInversionChanged() const
     582              : {
     583            0 :     return m_scoreInversionChanged;
     584              : }
     585              : 
     586            0 : bool NotationConfiguration::isOnlyInvertInDarkTheme() const
     587              : {
     588            0 :     return settings()->value(ONLY_INVERT_IN_DARK_THEME).toBool();
     589              : }
     590              : 
     591            0 : void NotationConfiguration::setOnlyInvertInDarkTheme(bool value)
     592              : {
     593            0 :     settings()->setSharedValue(ONLY_INVERT_IN_DARK_THEME, Val(value));
     594            0 : }
     595              : 
     596            0 : muse::async::Notification NotationConfiguration::isOnlyInvertInDarkThemeChanged() const
     597              : {
     598            0 :     return m_isOnlyInvertInDarkThemeChanged;
     599              : }
     600              : 
     601            0 : QColor NotationConfiguration::borderColor() const
     602              : {
     603            0 :     if (uiConfiguration()->isHighContrast()) {
     604            0 :         return QColorConstants::White;
     605              :     } else {
     606            0 :         return QColor(0, 0, 0, 102);
     607              :     }
     608              : }
     609              : 
     610            0 : int NotationConfiguration::borderWidth() const
     611              : {
     612            0 :     if (uiConfiguration()->isHighContrast()) {
     613            0 :         return 10;
     614              :     } else {
     615            0 :         return 1;
     616              :     }
     617              : }
     618              : 
     619            0 : QColor NotationConfiguration::playbackCursorColor() const
     620              : {
     621            0 :     QColor color = selectionColor();
     622            0 :     color.setAlpha(178);
     623            0 :     return color;
     624              : }
     625              : 
     626            0 : int NotationConfiguration::cursorOpacity() const
     627              : {
     628            0 :     return 50;
     629              : }
     630              : 
     631            0 : bool NotationConfiguration::thinNoteInputCursor() const
     632              : {
     633            0 :     return settings()->value(THIN_NOTE_INPUT_CURSOR).toBool();
     634              : }
     635              : 
     636            0 : bool NotationConfiguration::enableJianpu() const
     637              : {
     638            0 :     return settings()->value(ENABLE_JIANPU).toBool();
     639              : }
     640              : 
     641            0 : QColor NotationConfiguration::loopMarkerColor() const
     642              : {
     643            0 :     return QColor(0x2456AA);
     644              : }
     645              : 
     646            0 : QColor NotationConfiguration::selectionColor(engraving::voice_idx_t voiceIndex) const
     647              : {
     648            0 :     return engravingConfiguration()->selectionColor(voiceIndex).toQColor();
     649              : }
     650              : 
     651            0 : QColor NotationConfiguration::highlightSelectionColor(engraving::voice_idx_t voiceIndex) const
     652              : {
     653            0 :     return engravingConfiguration()->highlightSelectionColor(voiceIndex).toQColor();
     654              : }
     655              : 
     656            0 : QColor NotationConfiguration::dropRectColor() const
     657              : {
     658            0 :     QColor color = selectionColor();
     659            0 :     color.setAlpha(80);
     660            0 :     return color;
     661              : }
     662              : 
     663            0 : muse::draw::Color NotationConfiguration::noteInputPreviewColor() const
     664              : {
     665            0 :     return settings()->value(NOTE_INPUT_PREVIEW_COLOR).toQColor();
     666              : }
     667              : 
     668            0 : bool NotationConfiguration::useNoteInputCursorInInputByDuration() const
     669              : {
     670            0 :     return settings()->value(USE_NOTE_INPUT_CURSOR_IN_INPUT_BY_DURATION).toBool();
     671              : }
     672              : 
     673            0 : void NotationConfiguration::setUseNoteInputCursorInInputByDuration(bool use)
     674              : {
     675            0 :     settings()->setSharedValue(USE_NOTE_INPUT_CURSOR_IN_INPUT_BY_DURATION, Val(use));
     676            0 : }
     677              : 
     678            0 : muse::async::Notification NotationConfiguration::useNoteInputCursorInInputByDurationChanged() const
     679              : {
     680            0 :     return m_useNoteInputCursorInInputByDurationChanged;
     681              : }
     682              : 
     683            0 : int NotationConfiguration::selectionProximity() const
     684              : {
     685            0 :     return settings()->value(SELECTION_PROXIMITY).toInt();
     686              : }
     687              : 
     688            0 : void NotationConfiguration::setSelectionProximity(int proximity)
     689              : {
     690            0 :     settings()->setSharedValue(SELECTION_PROXIMITY, Val(proximity));
     691            0 : }
     692              : 
     693            0 : Channel<int> NotationConfiguration::selectionProximityChanged() const
     694              : {
     695            0 :     return m_selectionProximityChanged;
     696              : }
     697              : 
     698            0 : ZoomType NotationConfiguration::defaultZoomType() const
     699              : {
     700            0 :     return settings()->value(DEFAULT_ZOOM_TYPE).toEnum<ZoomType>();
     701              : }
     702              : 
     703            0 : void NotationConfiguration::setDefaultZoomType(ZoomType zoomType)
     704              : {
     705            0 :     settings()->setSharedValue(DEFAULT_ZOOM_TYPE, Val(zoomType));
     706            0 : }
     707              : 
     708            0 : int NotationConfiguration::defaultZoom() const
     709              : {
     710            0 :     return settings()->value(DEFAULT_ZOOM).toInt();
     711              : }
     712              : 
     713            0 : void NotationConfiguration::setDefaultZoom(int zoomPercentage)
     714              : {
     715            0 :     settings()->setSharedValue(DEFAULT_ZOOM, Val(zoomPercentage));
     716            0 : }
     717              : 
     718            0 : Notification NotationConfiguration::defaultZoomChanged() const
     719              : {
     720            0 :     return m_defaultZoomChanged;
     721              : }
     722              : 
     723            0 : QList<int> NotationConfiguration::possibleZoomPercentageList() const
     724              : {
     725              :     return {
     726              :         5, 10, 15, 25, 50, 75, 100, 150, 200, 400, 800, 1600
     727            0 :     };
     728              : }
     729              : 
     730            0 : AutomationLane NotationConfiguration::currentAutomationLane() const
     731              : {
     732            0 :     return settings()->value(CURRENT_AUTOMATION_LANE).toEnum<AutomationLane>();
     733              : }
     734              : 
     735            0 : void NotationConfiguration::setCurrentAutomationLane(AutomationLane lane)
     736              : {
     737            0 :     settings()->setSharedValue(CURRENT_AUTOMATION_LANE, Val(lane));
     738            0 : }
     739              : 
     740            0 : Notification NotationConfiguration::currentAutomationLaneChanged() const
     741              : {
     742            0 :     return m_currentAutomationLaneChanged;
     743              : }
     744              : 
     745            0 : int NotationConfiguration::mouseZoomPrecision() const
     746              : {
     747            0 :     return settings()->value(MOUSE_ZOOM_PRECISION).toInt();
     748              : }
     749              : 
     750            0 : void NotationConfiguration::setMouseZoomPrecision(int precision)
     751              : {
     752            0 :     settings()->setSharedValue(MOUSE_ZOOM_PRECISION, Val(precision));
     753            0 : }
     754              : 
     755            0 : Notification NotationConfiguration::mouseZoomPrecisionChanged() const
     756              : {
     757            0 :     return m_mouseZoomPrecisionChanged;
     758              : }
     759              : 
     760            0 : std::string NotationConfiguration::fontFamily() const
     761              : {
     762            0 :     return uiConfiguration()->fontFamily();
     763              : }
     764              : 
     765            0 : int NotationConfiguration::fontSize() const
     766              : {
     767            0 :     return uiConfiguration()->fontSize(FontSizeType::BODY);
     768              : }
     769              : 
     770            0 : muse::io::path_t NotationConfiguration::userStylesPath() const
     771              : {
     772            0 :     return settings()->value(USER_STYLES_PATH).toPath();
     773              : }
     774              : 
     775            0 : void NotationConfiguration::setUserStylesPath(const muse::io::path_t& path)
     776              : {
     777            0 :     settings()->setSharedValue(USER_STYLES_PATH, Val(path));
     778            0 : }
     779              : 
     780            0 : muse::async::Channel<muse::io::path_t> NotationConfiguration::userStylesPathChanged() const
     781              : {
     782            0 :     return m_userStylesPathChanged;
     783              : }
     784              : 
     785            0 : muse::io::path_t NotationConfiguration::defaultStyleFilePath() const
     786              : {
     787            0 :     return engravingConfiguration()->defaultStyleFilePath();
     788              : }
     789              : 
     790            0 : void NotationConfiguration::setDefaultStyleFilePath(const muse::io::path_t& path)
     791              : {
     792            0 :     engravingConfiguration()->setDefaultStyleFilePath(path.toQString());
     793            0 : }
     794              : 
     795            0 : async::Channel<muse::io::path_t> NotationConfiguration::defaultStyleFilePathChanged() const
     796              : {
     797            0 :     return engravingConfiguration()->defaultStyleFilePathChanged();
     798              : }
     799              : 
     800            0 : muse::io::path_t NotationConfiguration::partStyleFilePath() const
     801              : {
     802            0 :     return engravingConfiguration()->partStyleFilePath();
     803              : }
     804              : 
     805            0 : void NotationConfiguration::setPartStyleFilePath(const muse::io::path_t& path)
     806              : {
     807            0 :     engravingConfiguration()->setPartStyleFilePath(path.toQString());
     808            0 : }
     809              : 
     810            0 : async::Channel<muse::io::path_t> NotationConfiguration::partStyleFilePathChanged() const
     811              : {
     812            0 :     return engravingConfiguration()->partStyleFilePathChanged();
     813              : }
     814              : 
     815            0 : muse::io::path_t NotationConfiguration::userMusicFontsPath() const
     816              : {
     817            0 :     return settings()->value(USER_MUSIC_FONTS_PATH).toPath();
     818              : }
     819              : 
     820            0 : void NotationConfiguration::setUserMusicFontsPath(const muse::io::path_t& path)
     821              : {
     822            0 :     settings()->setSharedValue(USER_MUSIC_FONTS_PATH, Val(path));
     823            0 : }
     824              : 
     825            0 : muse::async::Channel<muse::io::path_t> NotationConfiguration::userMusicFontsPathChanged() const
     826              : {
     827            0 :     return m_userMusicFontsPathChanged;
     828              : }
     829              : 
     830            0 : NoteInputMethod NotationConfiguration::defaultNoteInputMethod() const
     831              : {
     832            0 :     std::string str = settings()->value(DEFAULT_NOTE_INPUT_METHOD).toString();
     833            0 :     return muse::key(NOTE_INPUT_METHOD_TO_STR, str, NoteInputMethod::BY_NOTE_NAME);
     834            0 : }
     835              : 
     836            0 : void NotationConfiguration::setDefaultNoteInputMethod(NoteInputMethod method)
     837              : {
     838            0 :     std::string str = muse::value(NOTE_INPUT_METHOD_TO_STR, method);
     839            0 :     settings()->setSharedValue(DEFAULT_NOTE_INPUT_METHOD, Val(str));
     840            0 : }
     841              : 
     842            0 : async::Notification NotationConfiguration::defaultNoteInputMethodChanged() const
     843              : {
     844            0 :     return m_defaultNoteInputMethodChanged;
     845              : }
     846              : 
     847            0 : bool NotationConfiguration::addAccidentalDotsArticulationsToNextNoteEntered() const
     848              : {
     849            0 :     return settings()->value(ADD_ACCIDENTAL_ARTICULATIONS_DOTS_TO_NEXT_NOTE_ENTERED).toBool();
     850              : }
     851              : 
     852            0 : void NotationConfiguration::setAddAccidentalDotsArticulationsToNextNoteEntered(bool value)
     853              : {
     854            0 :     settings()->setSharedValue(ADD_ACCIDENTAL_ARTICULATIONS_DOTS_TO_NEXT_NOTE_ENTERED, Val(value));
     855            0 : }
     856              : 
     857            0 : muse::async::Notification NotationConfiguration::addAccidentalDotsArticulationsToNextNoteEnteredChanged() const
     858              : {
     859            0 :     return m_addAccidentalDotsArticulationsToNextNoteEnteredChanged;
     860              : }
     861              : 
     862            0 : engraving::TupletSelectedDuration NotationConfiguration::tupletCommandsSelectedDurationAs() const
     863              : {
     864            0 :     return settings()->value(TUPLET_COMMANDS_SELECTED_DURATION_AS).toEnum<engraving::TupletSelectedDuration>();
     865              : }
     866              : 
     867            0 : void NotationConfiguration::setTupletCommandsSelectedDurationAs(engraving::TupletSelectedDuration selectedDurationAs)
     868              : {
     869            0 :     settings()->setSharedValue(TUPLET_COMMANDS_SELECTED_DURATION_AS, Val(selectedDurationAs));
     870            0 : }
     871              : 
     872            0 : muse::async::Notification NotationConfiguration::tupletCommandsSelectedDurationAsChanged() const
     873              : {
     874            0 :     return m_tupletCommandsSelectedDurationAsChanged;
     875              : }
     876              : 
     877            0 : bool NotationConfiguration::isMidiInputEnabled() const
     878              : {
     879            0 :     return settings()->value(IS_MIDI_INPUT_ENABLED).toBool();
     880              : }
     881              : 
     882            0 : void NotationConfiguration::setIsMidiInputEnabled(bool enabled)
     883              : {
     884            0 :     settings()->setSharedValue(IS_MIDI_INPUT_ENABLED, Val(enabled));
     885            0 : }
     886              : 
     887            0 : async::Notification NotationConfiguration::isMidiInputEnabledChanged() const
     888              : {
     889            0 :     return m_isMidiInputEnabledChanged;
     890              : }
     891              : 
     892            0 : bool NotationConfiguration::startNoteInputAtSelectedNoteRestWhenPressingMidiKey() const
     893              : {
     894            0 :     return settings()->value(START_NOTE_INPUT_AT_SELECTED_NOTE_REST_WHEN_PRESSING_MIDI_KEY).toBool();
     895              : }
     896              : 
     897            0 : void NotationConfiguration::setStartNoteInputAtSelectedNoteRestWhenPressingMidiKey(bool value)
     898              : {
     899            0 :     settings()->setSharedValue(START_NOTE_INPUT_AT_SELECTED_NOTE_REST_WHEN_PRESSING_MIDI_KEY, Val(value));
     900            0 : }
     901              : 
     902            0 : async::Notification NotationConfiguration::startNoteInputAtSelectedNoteRestWhenPressingMidiKeyChanged() const
     903              : {
     904            0 :     return m_startNoteInputAtSelectedNoteRestWhenPressingMidiKeyChanged;
     905              : }
     906              : 
     907            0 : bool NotationConfiguration::isAutomaticallyPanEnabled() const
     908              : {
     909            0 :     return settings()->value(IS_AUTOMATICALLY_PAN_ENABLED).toBool();
     910              : }
     911              : 
     912            0 : void NotationConfiguration::setIsAutomaticallyPanEnabled(bool enabled)
     913              : {
     914            0 :     settings()->setSharedValue(IS_AUTOMATICALLY_PAN_ENABLED, Val(enabled));
     915            0 : }
     916              : 
     917            0 : Notification NotationConfiguration::isAutomaticallyPanEnabledChanged() const
     918              : {
     919            0 :     return m_isAutomaticallyPanEnabledChanged;
     920              : }
     921              : 
     922            0 : bool NotationConfiguration::isPlayRepeatsEnabled() const
     923              : {
     924            0 :     return settings()->value(IS_PLAY_REPEATS_ENABLED).toBool();
     925              : }
     926              : 
     927            0 : void NotationConfiguration::setIsPlayRepeatsEnabled(bool enabled)
     928              : {
     929            0 :     settings()->setSharedValue(IS_PLAY_REPEATS_ENABLED, Val(enabled));
     930            0 :     m_isPlayRepeatsChanged.notify();
     931            0 : }
     932              : 
     933            0 : Notification NotationConfiguration::isPlayRepeatsChanged() const
     934              : {
     935            0 :     return m_isPlayRepeatsChanged;
     936              : }
     937              : 
     938            0 : bool NotationConfiguration::isPlayChordSymbolsEnabled() const
     939              : {
     940            0 :     return settings()->value(IS_PLAY_CHORD_SYMBOLS_ENABLED).toBool();
     941              : }
     942              : 
     943            0 : void NotationConfiguration::setIsPlayChordSymbolsEnabled(bool enabled)
     944              : {
     945            0 :     settings()->setSharedValue(IS_PLAY_CHORD_SYMBOLS_ENABLED, Val(enabled));
     946            0 : }
     947              : 
     948            0 : muse::async::Notification NotationConfiguration::isPlayChordSymbolsChanged() const
     949              : {
     950            0 :     return m_isPlayChordSymbolsChanged;
     951              : }
     952              : 
     953            0 : bool NotationConfiguration::isPlayPreviewNotesInInputByDuration() const
     954              : {
     955            0 :     return settings()->value(IS_PLAY_PREVIEW_NOTES_IN_INPUT_BY_DURATION_ENABLED).toBool();
     956              : }
     957              : 
     958            0 : void NotationConfiguration::setIsPlayPreviewNotesInInputByDuration(bool play)
     959              : {
     960            0 :     settings()->setSharedValue(IS_PLAY_PREVIEW_NOTES_IN_INPUT_BY_DURATION_ENABLED, Val(play));
     961            0 : }
     962              : 
     963            0 : muse::async::Notification NotationConfiguration::isPlayPreviewNotesInInputByDurationChanged() const
     964              : {
     965            0 :     return m_isPlayNotesPreviewInInputByDurationChanged;
     966              : }
     967              : 
     968            0 : bool NotationConfiguration::playPreviewNotesWithScoreDynamics() const
     969              : {
     970            0 :     return settings()->value(PLAY_PREVIEW_NOTES_WITH_SCORE_DYNAMICS).toBool();
     971              : }
     972              : 
     973            0 : void NotationConfiguration::setPlayPreviewNotesWithScoreDynamics(bool use)
     974              : {
     975            0 :     settings()->setSharedValue(PLAY_PREVIEW_NOTES_WITH_SCORE_DYNAMICS, Val(use));
     976            0 : }
     977              : 
     978            0 : muse::async::Notification NotationConfiguration::playPreviewNotesWithScoreDynamicsChanged() const
     979              : {
     980            0 :     return m_playPreviewNotesWithScoreDynamicsChanged;
     981              : }
     982              : 
     983            0 : bool NotationConfiguration::isMetronomeEnabled() const
     984              : {
     985            0 :     return settings()->value(IS_METRONOME_ENABLED).toBool();
     986              : }
     987              : 
     988            0 : void NotationConfiguration::setIsMetronomeEnabled(bool enabled)
     989              : {
     990            0 :     settings()->setSharedValue(IS_METRONOME_ENABLED, Val(enabled));
     991            0 : }
     992              : 
     993            0 : muse::async::Notification NotationConfiguration::isMetronomeEnabledChanged() const
     994              : {
     995            0 :     return m_isMetronomeEnabledChanged;
     996              : }
     997              : 
     998            0 : bool NotationConfiguration::isCountInEnabled() const
     999              : {
    1000            0 :     return settings()->value(IS_COUNT_IN_ENABLED).toBool();
    1001              : }
    1002              : 
    1003            0 : void NotationConfiguration::setIsCountInEnabled(bool enabled)
    1004              : {
    1005            0 :     settings()->setSharedValue(IS_COUNT_IN_ENABLED, Val(enabled));
    1006            0 : }
    1007              : 
    1008            0 : Notification NotationConfiguration::isCountInEnabledChanged() const
    1009              : {
    1010            0 :     return m_isCountInEnabledChanged;
    1011              : }
    1012              : 
    1013            0 : ValCh<muse::Orientation> NotationConfiguration::canvasOrientation() const
    1014              : {
    1015            0 :     ValCh<muse::Orientation> orientation;
    1016            0 :     orientation.ch = m_canvasOrientationChanged;
    1017            0 :     bool isVertical = settings()->value(IS_CANVAS_ORIENTATION_VERTICAL_KEY).toBool();
    1018            0 :     orientation.val = isVertical ? muse::Orientation::Vertical : muse::Orientation::Horizontal;
    1019              : 
    1020            0 :     return orientation;
    1021            0 : }
    1022              : 
    1023            0 : void NotationConfiguration::setCanvasOrientation(muse::Orientation orientation)
    1024              : {
    1025            0 :     bool isVertical = orientation == muse::Orientation::Vertical;
    1026            0 :     mu::engraving::MScore::setVerticalOrientation(isVertical);
    1027              : 
    1028            0 :     settings()->setSharedValue(IS_CANVAS_ORIENTATION_VERTICAL_KEY, Val(isVertical));
    1029            0 : }
    1030              : 
    1031            0 : bool NotationConfiguration::colorNotesOutsideOfUsablePitchRange() const
    1032              : {
    1033            0 :     return settings()->value(COLOR_NOTES_OUTSIDE_OF_USABLE_PITCH_RANGE).toBool();
    1034              : }
    1035              : 
    1036            0 : void NotationConfiguration::setColorNotesOutsideOfUsablePitchRange(bool value)
    1037              : {
    1038            0 :     mu::engraving::MScore::warnPitchRange = value;
    1039            0 :     settings()->setSharedValue(COLOR_NOTES_OUTSIDE_OF_USABLE_PITCH_RANGE, Val(value));
    1040            0 : }
    1041              : 
    1042            0 : async::Channel<bool> NotationConfiguration::colorNotesOutsideOfUsablePitchRangeChanged() const
    1043              : {
    1044            0 :     return m_colorNotesOutsideOfUsablePitchRangeChanged;
    1045              : }
    1046              : 
    1047            0 : bool NotationConfiguration::warnGuitarBends() const
    1048              : {
    1049            0 :     return settings()->value(WARN_GUITAR_BENDS).toBool();
    1050              : }
    1051              : 
    1052            0 : void NotationConfiguration::setWarnGuitarBends(bool value)
    1053              : {
    1054            0 :     mu::engraving::MScore::warnGuitarBends = value;
    1055            0 :     settings()->setSharedValue(WARN_GUITAR_BENDS, Val(value));
    1056            0 : }
    1057              : 
    1058            0 : async::Channel<bool> NotationConfiguration::warnGuitarBendsChanged() const
    1059              : {
    1060            0 :     return m_warnGuitarBendsChanged;
    1061              : }
    1062              : 
    1063            0 : int NotationConfiguration::delayBetweenNotesInRealTimeModeMilliseconds() const
    1064              : {
    1065            0 :     return settings()->value(REALTIME_DELAY).toInt();
    1066              : }
    1067              : 
    1068            0 : void NotationConfiguration::setDelayBetweenNotesInRealTimeModeMilliseconds(int delayMs)
    1069              : {
    1070            0 :     settings()->setSharedValue(REALTIME_DELAY, Val(delayMs));
    1071            0 : }
    1072              : 
    1073            0 : async::Channel<int> NotationConfiguration::delayBetweenNotesInRealTimeModeMillisecondsChanged() const
    1074              : {
    1075            0 :     return m_delayBetweenNotesInRealTimeModeMillisecondsChanged;
    1076              : }
    1077              : 
    1078            0 : bool NotationConfiguration::useMidiVelocityAndDurationDuringNoteInput() const
    1079              : {
    1080            0 :     return settings()->value(USE_MIDI_VELOCITY_AND_DURATION_DURING_NOTE_INPUT).toBool();
    1081              : }
    1082              : 
    1083            0 : void NotationConfiguration::setUseMidiVelocityAndDurationDuringNoteInput(bool use)
    1084              : {
    1085            0 :     settings()->setSharedValue(USE_MIDI_VELOCITY_AND_DURATION_DURING_NOTE_INPUT, Val(use));
    1086            0 : }
    1087              : 
    1088            0 : muse::async::Channel<bool> NotationConfiguration::useMidiVelocityAndDurationDuringNoteInputChanged() const
    1089              : {
    1090            0 :     return m_useMidiVelocityAndDurationDuringNoteInputChanged;
    1091              : }
    1092              : 
    1093            0 : int NotationConfiguration::notePlayDurationMilliseconds() const
    1094              : {
    1095            0 :     return settings()->value(NOTE_DEFAULT_PLAY_DURATION).toInt();
    1096              : }
    1097              : 
    1098            0 : void NotationConfiguration::setNotePlayDurationMilliseconds(int durationMs)
    1099              : {
    1100            0 :     settings()->setSharedValue(NOTE_DEFAULT_PLAY_DURATION, Val(durationMs));
    1101            0 : }
    1102              : 
    1103            0 : async::Channel<int> NotationConfiguration::notePlayDurationMillisecondsChanged() const
    1104              : {
    1105            0 :     return m_notePlayDurationMillisecondsChanged;
    1106              : }
    1107              : 
    1108            0 : void NotationConfiguration::setTemplateModeEnabled(std::optional<bool> enabled)
    1109              : {
    1110            0 :     mu::engraving::MScore::saveTemplateMode = enabled ? enabled.value() : false;
    1111            0 : }
    1112              : 
    1113            0 : void NotationConfiguration::setTestModeEnabled(std::optional<bool> enabled)
    1114              : {
    1115            0 :     mu::engraving::MScore::testMode = enabled ? enabled.value() : false;
    1116            0 : }
    1117              : 
    1118            0 : muse::io::path_t NotationConfiguration::instrumentsXmlPath() const
    1119              : {
    1120            0 :     return ":/engraving/instruments/instruments.xml";
    1121              : }
    1122              : 
    1123            0 : muse::io::path_t NotationConfiguration::scoreOrdersXmlPath() const
    1124              : {
    1125            0 :     return ":/engraving/instruments/orders.xml";
    1126              : }
    1127              : 
    1128            0 : muse::io::path_t NotationConfiguration::userInstrumentsFolder() const
    1129              : {
    1130            0 :     return settings()->value(USER_INSTRUMENTS_PATH).toPath();
    1131              : }
    1132              : 
    1133            0 : muse::io::paths_t NotationConfiguration::userInstrumentsAndScoreOrdersPaths() const
    1134              : {
    1135            0 :     muse::io::paths_t paths;
    1136              : 
    1137              :     // Scan user instruments folder for XML files
    1138            0 :     muse::io::path_t folder = userInstrumentsFolder();
    1139            0 :     if (!folder.empty()) {
    1140            0 :         RetVal<io::paths_t> userFiles = fileSystem()->scanFiles(folder, { "*.xml" }, io::ScanMode::FilesInCurrentDir);
    1141            0 :         if (userFiles.ret) {
    1142            0 :             for (const io::path_t& file : userFiles.val) {
    1143            0 :                 paths.push_back(file);
    1144              :             }
    1145              :         }
    1146            0 :     }
    1147              : 
    1148            0 :     return paths;
    1149            0 : }
    1150              : 
    1151            0 : void NotationConfiguration::setUserInstrumentsFolder(const muse::io::path_t& path)
    1152              : {
    1153            0 :     settings()->setSharedValue(USER_INSTRUMENTS_PATH, Val(path));
    1154            0 : }
    1155              : 
    1156            0 : muse::async::Channel<muse::io::path_t> NotationConfiguration::userInstrumentsFolderChanged() const
    1157              : {
    1158            0 :     return m_userInstrumentsFolderChanged;
    1159              : }
    1160              : 
    1161            0 : muse::io::path_t NotationConfiguration::stringTuningsPresetsPath() const
    1162              : {
    1163            0 :     return ":/engraving/instruments/string_tunings_presets.json";
    1164              : }
    1165              : 
    1166            0 : bool NotationConfiguration::isSnappedToGrid(muse::Orientation gridOrientation) const
    1167              : {
    1168            0 :     switch (gridOrientation) {
    1169            0 :     case muse::Orientation::Horizontal: return settings()->value(IS_SNAPPED_TO_HORIZONTAL_GRID_KEY).toBool();
    1170            0 :     case muse::Orientation::Vertical: return settings()->value(IS_SNAPPED_TO_VERTICAL_GRID_KEY).toBool();
    1171              :     }
    1172              : 
    1173            0 :     return false;
    1174              : }
    1175              : 
    1176            0 : void NotationConfiguration::setIsSnappedToGrid(muse::Orientation gridOrientation, bool isSnapped)
    1177              : {
    1178            0 :     switch (gridOrientation) {
    1179            0 :     case muse::Orientation::Horizontal:
    1180            0 :         settings()->setSharedValue(IS_SNAPPED_TO_HORIZONTAL_GRID_KEY, Val(isSnapped));
    1181            0 :         break;
    1182            0 :     case muse::Orientation::Vertical:
    1183            0 :         settings()->setSharedValue(IS_SNAPPED_TO_VERTICAL_GRID_KEY, Val(isSnapped));
    1184            0 :         break;
    1185              :     }
    1186            0 : }
    1187              : 
    1188            0 : int NotationConfiguration::gridSizeSpatium(muse::Orientation gridOrientation) const
    1189              : {
    1190            0 :     switch (gridOrientation) {
    1191            0 :     case muse::Orientation::Horizontal: return settings()->value(HORIZONTAL_GRID_SIZE_KEY).toInt();
    1192            0 :     case muse::Orientation::Vertical: return settings()->value(VERTICAL_GRID_SIZE_KEY).toInt();
    1193              :     }
    1194              : 
    1195            0 :     return DEFAULT_GRID_SIZE_SPATIUM;
    1196              : }
    1197              : 
    1198            0 : void NotationConfiguration::setGridSize(muse::Orientation gridOrientation, int sizeSpatium)
    1199              : {
    1200            0 :     switch (gridOrientation) {
    1201            0 :     case muse::Orientation::Horizontal:
    1202            0 :         mu::engraving::MScore::setHRaster(sizeSpatium);
    1203            0 :         settings()->setSharedValue(HORIZONTAL_GRID_SIZE_KEY, Val(sizeSpatium));
    1204            0 :         break;
    1205            0 :     case muse::Orientation::Vertical:
    1206            0 :         mu::engraving::MScore::setVRaster(sizeSpatium);
    1207            0 :         settings()->setSharedValue(VERTICAL_GRID_SIZE_KEY, Val(sizeSpatium));
    1208            0 :         break;
    1209              :     }
    1210            0 : }
    1211              : 
    1212            0 : bool NotationConfiguration::needToShowMScoreError(const std::string& errorKey) const
    1213              : {
    1214            0 :     Settings::Key key(module_name, "ui/dialogs/needToShowMScoreError/" + errorKey);
    1215              : 
    1216            0 :     settings()->setDefaultValue(key, Val(true));
    1217              : 
    1218            0 :     return settings()->value(key).toBool();
    1219            0 : }
    1220              : 
    1221            0 : void NotationConfiguration::setNeedToShowMScoreError(const std::string& errorKey, bool show)
    1222              : {
    1223            0 :     Settings::Key key(module_name, "ui/dialogs/needToShowMScoreError/" + errorKey);
    1224            0 :     settings()->setSharedValue(key, Val(show));
    1225            0 : }
    1226              : 
    1227            0 : ValCh<bool> NotationConfiguration::midiUseWrittenPitch() const
    1228              : {
    1229            0 :     return m_midiInputUseWrittenPitch;
    1230              : }
    1231              : 
    1232            0 : void NotationConfiguration::setMidiUseWrittenPitch(bool useWrittenPitch)
    1233              : {
    1234            0 :     settings()->setSharedValue(USE_MIDI_INPUT_WRITTEN_PITCH, Val(useWrittenPitch));
    1235            0 : }
    1236              : 
    1237            0 : muse::io::path_t NotationConfiguration::styleFileImportPath() const
    1238              : {
    1239            0 :     return settings()->value(STYLE_FILE_IMPORT_PATH_KEY).toString();
    1240              : }
    1241              : 
    1242            0 : void NotationConfiguration::setStyleFileImportPath(const muse::io::path_t& path)
    1243              : {
    1244            0 :     settings()->setSharedValue(STYLE_FILE_IMPORT_PATH_KEY, Val(path.toStdString()));
    1245            0 : }
    1246              : 
    1247            0 : async::Channel<std::string> NotationConfiguration::styleFileImportPathChanged() const
    1248              : {
    1249            0 :     return m_styleFileImportPathChanged;
    1250              : }
        

Generated by: LCOV version 2.0-1