Skip to content

Commit f872bf6

Browse files
committed
Let user specify custom instruments XML in Preferences > Folders
Replacing the fields for instruments / score order XML files in Preferences > Score.
1 parent 11a8961 commit f872bf6

16 files changed

+225
-442
lines changed

src/appshell/appshell.qrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
<file>qml/Preferences/internal/NoteInput/VoiceAssignmentSection.qml</file>
9191
<file>qml/Preferences/internal/NoteInput/NoteColorsSection.qml</file>
9292
<file>qml/Preferences/internal/NoteInput/FretboardDiagramsSection.qml</file>
93-
<file>qml/Preferences/internal/DefaultFilesSection.qml</file>
93+
<file>qml/Preferences/internal/DefaultStyleSection.qml</file>
9494
<file>qml/Preferences/internal/AutomaticUpdateSection.qml</file>
9595
<file>qml/platform/win/AppTitleBar.qml</file>
9696
<file>qml/DevTools/MPE/ArticulationsProfileEditorView.qml</file>

src/appshell/qml/Preferences/ScorePreferencesPage.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PreferencesPage {
3737
scorePreferencesModel.load()
3838
}
3939

40-
DefaultFilesSection {
40+
DefaultStyleSection {
4141
width: parent.width
4242

4343
model: scorePreferencesModel

src/appshell/qml/Preferences/internal/DefaultFilesSection.qml

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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
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+
import QtQuick 2.15
23+
import QtQuick.Layouts 1.15
24+
25+
import Muse.Ui 1.0
26+
import Muse.UiComponents 1.0
27+
import MuseScore.Preferences 1.0
28+
29+
BaseSection {
30+
id: root
31+
32+
title: qsTrc("appshell/preferences", "Default style")
33+
34+
navigation.direction: NavigationPanel.Both
35+
36+
property ScorePreferencesModel model: null
37+
38+
GridLayout {
39+
width: parent.width
40+
columns: 2
41+
columnSpacing: root.columnSpacing
42+
rowSpacing: 4
43+
44+
StyledTextLabel {
45+
id: styleLabel
46+
Layout.preferredWidth: root.columnWidth
47+
text: qsTrc("appshell/preferences/score", "Style for full score")
48+
horizontalAlignment: Text.AlignLeft
49+
}
50+
51+
FilePicker {
52+
Layout.fillWidth: true
53+
54+
dialogTitle: qsTrc("appshell/preferences/score", "Choose default style for full score")
55+
filter: qsTrc("appshell/preferences/score", "MuseScore style file") + " (*.mss)"
56+
dir: root.model ? root.model.defaultStylePath : ""
57+
path: root.model ? root.model.defaultStylePath : ""
58+
59+
navigation: root.navigation
60+
navigationRowOrderStart: 0
61+
pathFieldTitle: styleLabel.text
62+
63+
onPathEdited: function(newPath) {
64+
if (root.model) {
65+
root.model.defaultStylePath = newPath
66+
}
67+
}
68+
}
69+
70+
StyledTextLabel {
71+
id: partStyleLabel
72+
Layout.preferredWidth: root.columnWidth
73+
text: qsTrc("appshell/preferences", "Style for parts")
74+
horizontalAlignment: Text.AlignLeft
75+
}
76+
77+
FilePicker {
78+
Layout.fillWidth: true
79+
80+
dialogTitle: qsTrc("appshell/preferences", "Choose default style for parts")
81+
filter: qsTrc("appshell/preferences", "MuseScore style file") + " (*.mss)"
82+
dir: root.model ? root.model.defaultPartStylePath : ""
83+
path: root.model ? root.model.defaultPartStylePath : ""
84+
85+
navigation: root.navigation
86+
navigationRowOrderStart: 1
87+
pathFieldTitle: partStyleLabel.text
88+
89+
onPathEdited: function(newPath) {
90+
if (root.model) {
91+
root.model.defaultPartStylePath = newPath
92+
}
93+
}
94+
}
95+
}
96+
}

src/appshell/view/preferences/folderspreferencesmodel.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ void FoldersPreferencesModel::load()
9595
FolderType::Styles, muse::qtrc("appshell/preferences", "Styles"), notationConfiguration()->userStylesPath().toQString(),
9696
notationConfiguration()->userStylesPath().toQString()
9797
},
98+
{
99+
FolderType::Instruments, muse::qtrc("appshell/preferences", "Instruments and score orders"),
100+
notationConfiguration()->userInstrumentsFolder().toQString(),
101+
notationConfiguration()->userInstrumentsFolder().toQString()
102+
},
98103
{
99104
FolderType::Templates, muse::qtrc("appshell/preferences", "Templates"), projectConfiguration()->userTemplatesPath().toQString(),
100105
projectConfiguration()->userTemplatesPath().toQString()
@@ -136,6 +141,10 @@ void FoldersPreferencesModel::setupConnections()
136141
setFolderPaths(FolderType::Styles, path.toQString());
137142
});
138143

144+
notationConfiguration()->userInstrumentsFolderChanged().onReceive(this, [this](const muse::io::path_t& path) {
145+
setFolderPaths(FolderType::Instruments, path.toQString());
146+
});
147+
139148
projectConfiguration()->userTemplatesPathChanged().onReceive(this, [this](const muse::io::path_t& path) {
140149
setFolderPaths(FolderType::Templates, path.toQString());
141150
});
@@ -171,6 +180,11 @@ void FoldersPreferencesModel::saveFolderPaths(FoldersPreferencesModel::FolderTyp
171180
notationConfiguration()->setUserStylesPath(folderPath);
172181
break;
173182
}
183+
case FolderType::Instruments: {
184+
muse::io::path_t folderPath = paths.toStdString();
185+
notationConfiguration()->setUserInstrumentsFolder(folderPath);
186+
break;
187+
}
174188
case FolderType::Templates: {
175189
muse::io::path_t folderPath = paths.toStdString();
176190
projectConfiguration()->setUserTemplatesPath(folderPath);

src/appshell/view/preferences/folderspreferencesmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class FoldersPreferencesModel : public QAbstractListModel, public muse::Injectab
6868
Undefined,
6969
Scores,
7070
Styles,
71+
Instruments,
7172
Templates,
7273
Plugins,
7374
SoundFonts,

0 commit comments

Comments
 (0)