From b1b8bc32e23ddfb9437cc6b80bf4416dab25c285 Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Sun, 29 Nov 2020 00:40:38 +0300 Subject: [PATCH 1/3] Fixed the glitch at combo-boxes --- src/proxystyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proxystyle.cpp b/src/proxystyle.cpp index 5eeab5c..c0b649c 100644 --- a/src/proxystyle.cpp +++ b/src/proxystyle.cpp @@ -88,7 +88,7 @@ int BankEditor_ProxyStyle::styleHint(QStyle::StyleHint hint, const QStyleOption width = qMax(width, textWidth + iconSize); } - view->setFixedWidth(width); + view->setMinimumWidth(width); } } /*fallthrough*/ //Combobox fix end From 4e369d1f209cb8a63ecc1c13fa31b1cf32f75114 Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Sun, 29 Nov 2020 00:44:44 +0300 Subject: [PATCH 2/3] proxystyle: Fixed the deprecation warning --- src/proxystyle.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/proxystyle.cpp b/src/proxystyle.cpp index c0b649c..6e3b0c9 100644 --- a/src/proxystyle.cpp +++ b/src/proxystyle.cpp @@ -78,10 +78,17 @@ 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 From c98fa9c55e59f6d9beab68e5622466827bc8860e Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Sun, 29 Nov 2020 01:12:01 +0300 Subject: [PATCH 3/3] Fixed the unnecessary instruments list rebuild The true reason of the issue #103 --- src/bank_editor.cpp | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/bank_editor.cpp b/src/bank_editor.cpp index e97557c..806a068 100644 --- a/src/bank_editor.cpp +++ b/src/bank_editor.cpp @@ -1418,40 +1418,41 @@ void BankEditor::setDrums() void BankEditor::reloadInstrumentNames() { - QList 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); } } }