Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Wohlstand/OPN2BankEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Dec 1, 2020
2 parents f37283c + c98fa9c commit e334d5b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
35 changes: 18 additions & 17 deletions src/bank_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1450,40 +1450,41 @@ void BankEditor::setDrums()

void BankEditor::reloadInstrumentNames()
{
QList<QListWidgetItem *> items = ui->instruments->findItems("*", Qt::MatchWildcard);
if(ui->percussion->isChecked())
{
if(items.size() != m_bank.Ins_Percussion_box.size())
if(ui->instruments->count() != m_bank.Ins_Percussion_box.size())
setDrums();//Completely rebuild an instruments list
else
{
//Change instrument names of existing entries
for(int i = 0; i < items.size(); i++)
for(int i = 0; i < ui->instruments->count(); i++)
{
int index = items[i]->data(Qt::UserRole).toInt();
items[i]->setText(m_bank.Ins_Percussion[index].name[0] != '\0' ?
QString::fromUtf8(m_bank.Ins_Percussion[index].name) :
getInstrumentName(index, false, true));
items[i]->setForeground(m_bank.Ins_Percussion[i].is_blank ?
Qt::gray : Qt::black);
auto *it = ui->instruments->item(i);
int index = it->data(Qt::UserRole).toInt();
it->setText(m_bank.Ins_Percussion[index].name[0] != '\0' ?
QString::fromUtf8(m_bank.Ins_Percussion[index].name) :
getInstrumentName(index, false, true));
it->setForeground(m_bank.Ins_Percussion[i].is_blank ?
Qt::gray : Qt::black);
}
}
}
else
{
if(items.size() != m_bank.Ins_Melodic_box.size())
if(ui->instruments->count() != m_bank.Ins_Melodic_box.size())
setMelodic();//Completely rebuild an instruments list
else
{
//Change instrument names of existing entries
for(int i = 0; i < items.size(); i++)
for(int i = 0; i < ui->instruments->count(); i++)
{
int index = items[i]->data(Qt::UserRole).toInt();
items[i]->setText(m_bank.Ins_Melodic[index].name[0] != '\0' ?
QString::fromUtf8(m_bank.Ins_Melodic[index].name) :
getInstrumentName(index, false, false));
items[i]->setForeground(m_bank.Ins_Melodic[i].is_blank ?
Qt::gray : Qt::black);
auto *it = ui->instruments->item(i);
int index = it->data(Qt::UserRole).toInt();
it->setText(m_bank.Ins_Melodic[index].name[0] != '\0' ?
QString::fromUtf8(m_bank.Ins_Melodic[index].name) :
getInstrumentName(index, false, false));
it->setForeground(m_bank.Ins_Melodic[i].is_blank ?
Qt::gray : Qt::black);
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/proxystyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,24 @@ int BankEditor_ProxyStyle::styleHint(QStyle::StyleHint hint, const QStyleOption

for(int i=0; i < j; ++i)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
const int textWidth = qMax(
fontMetrics1.horizontalAdvance(combo->itemText(i) + "WW"),
fontMetrics2.horizontalAdvance(combo->itemText(i) + "WW")
);
#else
const int textWidth = qMax(
fontMetrics1.width(combo->itemText(i) + "WW"),
fontMetrics2.width(combo->itemText(i) + "WW")
);
#endif
if(combo->itemIcon(i).isNull())
width = qMax(width, textWidth);
else
width = qMax(width, textWidth + iconSize);
}

view->setFixedWidth(width);
view->setMinimumWidth(width);
}
} /*fallthrough*/
//Combobox fix end
Expand Down

0 comments on commit e334d5b

Please sign in to comment.