Skip to content

Commit

Permalink
fixed musescore#18427: Select first group when initializing model
Browse files Browse the repository at this point in the history
  • Loading branch information
Eism committed Jul 6, 2023
1 parent fff51ed commit 473b974
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/instrumentsscene/view/instrumentlistmodel.cpp
Expand Up @@ -30,6 +30,7 @@ using namespace mu::uicomponents;

static const QString ALL_INSTRUMENTS_GENRE_ID("ALL_INSTRUMENTS");
static const QString NONE_GROUP_ID("");
static const QString FIRST_GROUP_ID("FIRST_GROUP_ID");
static const QString INSTRUMENT_TEMPLATE_KEY("instrumentTemplate");

InstrumentListModel::InstrumentListModel(QObject* parent)
Expand Down Expand Up @@ -135,7 +136,7 @@ void InstrumentListModel::load(bool canSelectMultipleInstruments, const QString&
loadGroups();

if (currentInstrumentId.isEmpty()) {
init(COMMON_GENRE_ID, NONE_GROUP_ID);
init(COMMON_GENRE_ID, FIRST_GROUP_ID);
} else {
init(COMMON_GENRE_ID, resolveInstrumentGroupId(currentInstrumentId));
}
Expand Down Expand Up @@ -168,7 +169,13 @@ void InstrumentListModel::init(const QString& genreId, const QString& groupId)
TRACEFUNC;

setCurrentGenre(genreId);
setCurrentGroup(groupId);

QString newGroupId = groupId;
if (newGroupId == FIRST_GROUP_ID) {
newGroupId = !m_groups.empty() ? m_groups.first()->id.toQString() : NONE_GROUP_ID;
}

setCurrentGroup(newGroupId);

m_instrumentsLoadingAllowed = true;
loadInstruments();
Expand Down

0 comments on commit 473b974

Please sign in to comment.