Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #279897: do not reset staff type if custom staff type happens to be selected #4448

Merged
merged 1 commit into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions mscore/instrwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ void StaffListItem::initStaffTypeCombo(bool forceRecreate)
++idx;
}
customStandardIdx = _staffTypeCombo->count();
_staffTypeCombo->addItem(tr("Custom Standard"), 0);
_staffTypeCombo->addItem(tr("Custom Standard"), CUSTOM_STAFF_TYPE_IDX);
customPercussionIdx = _staffTypeCombo->count();
_staffTypeCombo->addItem(tr("Custom Percussion"), 0);
_staffTypeCombo->addItem(tr("Custom Percussion"), CUSTOM_STAFF_TYPE_IDX);
customTablatureIdx = _staffTypeCombo->count();
_staffTypeCombo->addItem(tr("Custom Tablature"), 0);
_staffTypeCombo->addItem(tr("Custom Tablature"), CUSTOM_STAFF_TYPE_IDX);

treeWidget()->setItemWidget(this, 4, _staffTypeCombo);
connect(_staffTypeCombo, SIGNAL(currentIndexChanged(int)), SLOT(staffTypeChanged(int)) );
Expand Down Expand Up @@ -240,7 +240,20 @@ void StaffListItem::setStaffType(int idx)

const StaffType* StaffListItem::staffType() const
{
return StaffType::preset(StaffTypes((staffTypeIdx())));
int typeIdx = staffTypeIdx();
Q_ASSERT(typeIdx != CUSTOM_STAFF_TYPE_IDX);
if (typeIdx == CUSTOM_STAFF_TYPE_IDX)
typeIdx = 0;
return StaffType::preset(StaffTypes(typeIdx));
}

//---------------------------------------------------------
// staffTypeIdx
//---------------------------------------------------------

int StaffListItem::staffTypeIdx(int idx) const
{
return _staffTypeCombo->itemData(idx).toInt();
}

//---------------------------------------------------------
Expand All @@ -249,7 +262,7 @@ const StaffType* StaffListItem::staffType() const

int StaffListItem::staffTypeIdx() const
{
return _staffTypeCombo->itemData(_staffTypeCombo->currentIndex()).toInt();
return staffTypeIdx(_staffTypeCombo->currentIndex());
}

//---------------------------------------------------------
Expand All @@ -259,8 +272,11 @@ int StaffListItem::staffTypeIdx() const
void StaffListItem::staffTypeChanged(int idx)
{
// check current clef matches new staff type
int staffTypeIdx = _staffTypeCombo->itemData(idx).toInt();
const StaffType* stfType = StaffType::preset(StaffTypes(staffTypeIdx));
const int typeIdx = staffTypeIdx(idx);
if (typeIdx == CUSTOM_STAFF_TYPE_IDX) // consider it not changed
return;

const StaffType* stfType = StaffType::preset(StaffTypes(typeIdx));

PartListItem* pli = static_cast<PartListItem*>(QTreeWidgetItem::parent());
pli->updateClefs();
Expand Down
3 changes: 3 additions & 0 deletions mscore/instrwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class StaffListItem : public QObject, public QTreeWidgetItem {
static int customStandardIdx;
static int customPercussionIdx;
static int customTablatureIdx;
static constexpr int CUSTOM_STAFF_TYPE_IDX = -1000;

int staffTypeIdx(int idx) const;

private slots:
void staffTypeChanged(int);
Expand Down