Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-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 :
23 : #include "midiremoteconfiguration.h"
24 : #include "global/settings.h"
25 :
26 : #include "log.h"
27 :
28 : using namespace muse;
29 : using namespace muse::midiremote;
30 :
31 : static const Settings::Key ADVANCE_TO_NEXT_NOTE_ON_KEY_RELEASE("midiremote", "io/midi/advanceOnRelease");
32 :
33 : static const std::string MIDIMAPPINGS_FILE_NAME("/midi_mappings.xml");
34 :
35 0 : void MidiRemoteConfiguration::init()
36 : {
37 0 : settings()->setDefaultValue(ADVANCE_TO_NEXT_NOTE_ON_KEY_RELEASE, Val(true));
38 0 : settings()->valueChanged(ADVANCE_TO_NEXT_NOTE_ON_KEY_RELEASE).onReceive(this, [this](const Val& val) {
39 0 : m_advanceToNextNoteOnKeyReleaseChanged.send(val.toBool());
40 0 : });
41 0 : }
42 :
43 0 : io::path_t MidiRemoteConfiguration::midiMappingUserAppDataPath() const
44 : {
45 0 : return globalConfiguration()->userAppDataPath() + MIDIMAPPINGS_FILE_NAME;
46 : }
47 :
48 0 : bool MidiRemoteConfiguration::advanceToNextNoteOnKeyRelease() const
49 : {
50 0 : return settings()->value(ADVANCE_TO_NEXT_NOTE_ON_KEY_RELEASE).toBool();
51 : }
52 :
53 0 : void MidiRemoteConfiguration::setAdvanceToNextNoteOnKeyRelease(bool value)
54 : {
55 0 : settings()->setSharedValue(ADVANCE_TO_NEXT_NOTE_ON_KEY_RELEASE, Val(value));
56 0 : }
57 :
58 0 : async::Channel<bool> MidiRemoteConfiguration::advanceToNextNoteOnKeyReleaseChanged() const
59 : {
60 0 : return m_advanceToNextNoteOnKeyReleaseChanged;
61 : }
|