Skip to content

Commit

Permalink
- Tiny fix on the main options dialog (re. combo-box item history)
Browse files Browse the repository at this point in the history
  • Loading branch information
rncbc committed Aug 26, 2022
1 parent 836d784 commit 2dc6f70
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/qtractorOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,23 +969,26 @@ void qtractorOptions::saveComboBoxHistory ( QComboBox *pComboBox, int iLimit )
{
const bool bBlockSignals = pComboBox->blockSignals(true);

// Add current text as latest item...
const QString sCurrentText = pComboBox->currentText();
int iCount = pComboBox->count();

for (int i = 0; i < iCount; ++i) {
const QString& sText = pComboBox->itemText(i);
if (sText == sCurrentText) {
pComboBox->removeItem(i);
--iCount;
break;
// Add current text as latest item (if not blank)...
const QString& sCurrentText = pComboBox->currentText();
if (!sCurrentText.isEmpty()) {
for (int i = 0; i < iCount; ++i) {
const QString& sText = pComboBox->itemText(i);
if (sText == sCurrentText) {
pComboBox->removeItem(i);
--iCount;
break;
}
}
pComboBox->insertItem(0, sCurrentText);
pComboBox->setCurrentIndex(0);
++iCount;
}

while (iCount >= iLimit)
pComboBox->removeItem(--iCount);
pComboBox->insertItem(0, sCurrentText);
pComboBox->setCurrentIndex(0);
++iCount;

// Save combobox list to configuration settings file...
m_settings.beginGroup("/History/" + pComboBox->objectName());
Expand Down

0 comments on commit 2dc6f70

Please sign in to comment.