Skip to content

Commit 3601da4

Browse files
committed
Moved "Make/Undo Soloist" button to instrument line to make room for order names.
Form will show initial "soloist" status and implements soloist toggling.
1 parent 22981b4 commit 3601da4

File tree

6 files changed

+81
-39
lines changed

6 files changed

+81
-39
lines changed

src/instruments/qml/MuseScore/Instruments/ChooseInstrumentsPage.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ Rectangle {
220220
onOrderChanged: {
221221
instrumentsModel.selectOrderType(id)
222222
}
223+
224+
onSoloistChanged: {
225+
instrumentsModel.toggleSoloist(id)
226+
}
223227
}
224228

225229
SeparatorLine {

src/instruments/qml/MuseScore/Instruments/internal/SelectedInstrumentsView.qml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,24 @@ Item {
4343

4444
signal unselectInstrumentRequested(string id)
4545
signal orderChanged(string id)
46+
signal soloistChanged(string id)
4647

4748
function scrollViewToEnd() {
4849
instrumentsView.positionViewAtEnd()
4950
}
5051

52+
function soloistsButtonText(soloist) {
53+
return soloist ? qsTrc("instruments", "Undo soloist") : qsTrc("instruments", "Make soloist")
54+
}
55+
56+
function instrumentName(data) {
57+
var name = data.name
58+
if (data.soloist) {
59+
name = qsTrc("instruments", "Soloist: ") + name
60+
}
61+
return name
62+
}
63+
5164
NavigationPanel {
5265
id: navPanel
5366
name: "SelectedInstrumentsView"
@@ -99,17 +112,6 @@ Item {
99112
}
100113
}
101114

102-
FlatButton {
103-
Layout.preferredWidth: width
104-
105-
navigation.name: "Make soloist"
106-
navigation.panel: navPanel
107-
navigation.row: 2
108-
109-
enabled: root.isInstrumentSelected
110-
text: qsTrc("instruments", "Make soloist")
111-
}
112-
113115
FlatButton {
114116
Layout.preferredWidth: width
115117

@@ -163,10 +165,25 @@ Item {
163165
anchors.verticalCenter: parent.verticalCenter
164166

165167
horizontalAlignment: Text.AlignLeft
166-
text: modelData.name
168+
text: instrumentName(modelData)
167169
font: ui.theme.bodyBoldFont
168170
}
169171

172+
FlatButton {
173+
anchors.right: parent.right
174+
anchors.leftMargin: 4
175+
anchors.rightMargin: 4
176+
anchors.verticalCenter: parent.verticalCenter
177+
178+
visible: root.currentInstrumentIndex === index
179+
180+
text: soloistsButtonText(modelData.soloist)
181+
182+
onClicked: {
183+
soloistChanged(modelData.id)
184+
}
185+
}
186+
170187
onClicked: {
171188
root.currentInstrumentIndex = model.index
172189
}

src/instruments/view/instrumentlistmodel.cpp

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static const QString NAME_KEY("name");
3636
static const QString TRANSPOSITIONS_KEY("transpositions");
3737
static const QString GROUP_ID("groupId");
3838
static const QString CONFIG_KEY("config");
39+
static const QString SOLOIST_KEY("soloist");
40+
static const QString PART_KEY("part");
3941

4042
InstrumentListModel::InstrumentListModel(QObject* parent)
4143
: QObject(parent)
@@ -90,10 +92,10 @@ void InstrumentListModel::initSelectedInstruments(const IDList& selectedPartIds)
9092

9193
SelectedInstrumentInfo info;
9294

93-
info.partId = partId;
94-
info.partName = part->partName();
95-
96-
info.id = QString();
95+
info.id = partId;
96+
info.part = true;
97+
info.name = part->partName();
98+
info.soloist = part->soloist();
9799
info.config = Instrument();
98100

99101
m_selectedInstruments << info;
@@ -276,8 +278,7 @@ void InstrumentListModel::selectInstrument(const QString& instrumentId, const QS
276278
SelectedInstrumentInfo info;
277279
info.part = false;
278280
info.id = codeKey;
279-
info.partId = QString();
280-
info.partName = QString();
281+
info.name = QString();
281282
info.transposition = templ.transposition;
282283
info.config = templ.instrument;
283284

@@ -289,9 +290,16 @@ void InstrumentListModel::selectInstrument(const QString& instrumentId, const QS
289290
emit selectedInstrumentsChanged();
290291
}
291292

292-
void InstrumentListModel::makeSoloist(const QString&)
293+
void InstrumentListModel::toggleSoloist(const QString& instrumentId)
293294
{
294-
NOT_IMPLEMENTED;
295+
for (int i = 0; i < m_selectedInstruments.count(); ++i) {
296+
if (m_selectedInstruments[i].id == instrumentId) {
297+
SelectedInstrumentInfo info = m_selectedInstruments[i];
298+
m_selectedInstruments[i].soloist = !m_selectedInstruments[i].soloist;
299+
emit selectedInstrumentsChanged();
300+
return;
301+
}
302+
}
295303
}
296304

297305
void InstrumentListModel::unselectInstrument(const QString& instrumentId)
@@ -347,23 +355,29 @@ QVariantList InstrumentListModel::selectedInstruments() const
347355
QVariantList result;
348356

349357
for (const SelectedInstrumentInfo& instrument: m_selectedInstruments) {
350-
QString instrumentId = instrument.id;
351-
QString instrumentName = instrument.partName;
352-
353-
if (instrumentName.isEmpty()) {
354-
instrumentName = instrument.config.name;
358+
QString id = instrument.id;
359+
QString name = instrument.name;
360+
bool soloist = instrument.soloist;
361+
bool part = instrument.part;
362+
363+
if (!part) {
364+
id = instrument.id;
365+
name = instrument.config.name;
366+
soloist = false;
355367
Transposition _transposition = instrument.transposition;
356368
if (_transposition.isValid()) {
357-
instrumentName = instrumentName.replace(_transposition.name + " ", "")
369+
name = name.replace(_transposition.name + " ", "")
358370
.replace(" in " + _transposition.name, "");
359371

360-
instrumentName = QString("%1 (%2)").arg(instrumentName, _transposition.name);
372+
name = QString("%1 (%2)").arg(name, _transposition.name);
361373
}
362374
}
363375

364376
QVariantMap obj;
365-
obj[ID_KEY] = instrumentId;
366-
obj[NAME_KEY] = instrumentName;
377+
obj[PART_KEY] = part;
378+
obj[ID_KEY] = id;
379+
obj[NAME_KEY] = name;
380+
obj[SOLOIST_KEY] = soloist;
367381
obj[CONFIG_KEY] = QVariant::fromValue(instrument.config);
368382

369383
result << obj;

src/instruments/view/instrumentlistmodel.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class InstrumentListModel : public QObject, public async::Asyncable
6060
Q_INVOKABLE void selectInstrument(const QString& instrumentId, const QString& transpositionId = QString());
6161
Q_INVOKABLE void unselectInstrument(const QString& instrumentId);
6262
Q_INVOKABLE void swapSelectedInstruments(int firstIndex, int secondIndex);
63-
Q_INVOKABLE void makeSoloist(const QString& instrumentId);
63+
Q_INVOKABLE void toggleSoloist(const QString& instrumentId);
6464

6565
Q_INVOKABLE void setSearchText(const QString& text);
6666

@@ -110,8 +110,9 @@ class InstrumentListModel : public QObject, public async::Asyncable
110110
struct SelectedInstrumentInfo
111111
{
112112
QString id;
113-
QString partId;
114-
QString partName;
113+
QString name;
114+
bool soloist;
115+
bool part;
115116
Transposition transposition;
116117
Instrument config;
117118

src/notation/internal/notationparts.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void NotationParts::setParts(const mu::instruments::PartInstrumentList& parts)
133133
{
134134
removeMissingParts(parts);
135135
appendNewParts(parts);
136+
updateSoloist(parts);
136137

137138
sortParts(parts);
138139

@@ -715,12 +716,6 @@ void NotationParts::doRemoveParts(const IDList& partsIds)
715716
for (const ID& partId: partsIds) {
716717
score()->cmdRemovePart(part(partId));
717718
}
718-
719-
for (Ms::Excerpt* excerpt : masterScore()->excerpts()) {
720-
if (excerpt->partScore()->staves().size() == 0) {
721-
masterScore()->undo(new Ms::RemoveExcerpt(excerpt));
722-
}
723-
}
724719
}
725720

726721
void NotationParts::removeInstruments(const IDList& instrumentIds, const ID& fromPartId)
@@ -1233,7 +1228,7 @@ void NotationParts::removeMissingParts(const PartInstrumentList& parts)
12331228

12341229
for (const Part* part: partList()) {
12351230
if (partIds.contains(part->id())) {
1236-
continue;
1231+
continue;
12371232
}
12381233
partsToRemove << part->id();
12391234

@@ -1252,13 +1247,23 @@ void NotationParts::appendNewParts(const PartInstrumentList& parts)
12521247
Part* part = new Part(score());
12531248

12541249
part->setPartName(pi.instrument.name);
1250+
part->setSoloist(pi.soloist);
12551251
part->setInstrument(InstrumentsConverter::convertInstrument(pi.instrument));
12561252

12571253
score()->undo(new Ms::InsertPart(part, lastStaffIndex()));
12581254
appendStaves(part, pi.instrument);
12591255
}
12601256
}
12611257

1258+
void NotationParts::updateSoloist(const PartInstrumentList& parts)
1259+
{
1260+
for (const PartInstrument& pi: parts) {
1261+
if (pi.part) {
1262+
part(pi.partId)->setSoloist(pi.soloist);
1263+
}
1264+
}
1265+
}
1266+
12621267
void NotationParts::sortParts(const PartInstrumentList& parts)
12631268
{
12641269
Q_ASSERT(score()->parts().size() == static_cast<int>(parts.size()));

src/notation/internal/notationparts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class NotationParts : public INotationParts, public async::Asyncable
151151

152152
void removeMissingParts(const instruments::PartInstrumentList& parts);
153153
void appendNewParts(const instruments::PartInstrumentList& parts);
154+
void updateSoloist(const instruments::PartInstrumentList& parts);
154155
void sortParts(const instruments::PartInstrumentList& parts);
155156

156157
IDList allInstrumentsIds() const;

0 commit comments

Comments
 (0)