Skip to content

Commit

Permalink
Merge pull request #4448 from dmitrio95/279897-custom-tablature
Browse files Browse the repository at this point in the history
fix #279897: do not reset staff type if custom staff type happens to be selected
  • Loading branch information
anatoly-os committed Dec 20, 2018
2 parents 00e6040 + ab50492 commit 3b8346e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
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

0 comments on commit 3b8346e

Please sign in to comment.