mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
fix sort order not immediately being set
This commit is contained in:
parent
0f249aadbe
commit
6fe9bd91c5
1 changed files with 8 additions and 3 deletions
|
|
@ -20,15 +20,18 @@ VisualDeckStorageSortWidget::VisualDeckStorageSortWidget(VisualDeckStorageWidget
|
||||||
sortComboBox = new QComboBox(this);
|
sortComboBox = new QComboBox(this);
|
||||||
layout->addWidget(sortComboBox);
|
layout->addWidget(sortComboBox);
|
||||||
|
|
||||||
|
// Need to retranslateUi first so that the sortComboBox actually has entries and doesn't get its currentIndex
|
||||||
|
// immediately capped to 0 when we try to set it
|
||||||
|
retranslateUi();
|
||||||
|
|
||||||
// Set the current sort order
|
// Set the current sort order
|
||||||
sortComboBox->setCurrentIndex(SettingsCache::instance().getVisualDeckStorageSortingOrder());
|
sortComboBox->setCurrentIndex(SettingsCache::instance().getVisualDeckStorageSortingOrder());
|
||||||
|
sortOrder = static_cast<SortOrder>(sortComboBox->currentIndex());
|
||||||
|
|
||||||
// Connect sorting change signal to refresh the file list
|
// Connect sorting change signal to refresh the file list
|
||||||
connect(sortComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
connect(sortComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
&VisualDeckStorageSortWidget::updateSortOrder);
|
&VisualDeckStorageSortWidget::updateSortOrder);
|
||||||
connect(this, &VisualDeckStorageSortWidget::sortOrderChanged, parent, &VisualDeckStorageWidget::updateSortOrder);
|
connect(this, &VisualDeckStorageSortWidget::sortOrderChanged, parent, &VisualDeckStorageWidget::updateSortOrder);
|
||||||
|
|
||||||
retranslateUi();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualDeckStorageSortWidget::retranslateUi()
|
void VisualDeckStorageSortWidget::retranslateUi()
|
||||||
|
|
@ -36,6 +39,8 @@ void VisualDeckStorageSortWidget::retranslateUi()
|
||||||
// Block signals to avoid triggering unnecessary updates while changing text
|
// Block signals to avoid triggering unnecessary updates while changing text
|
||||||
sortComboBox->blockSignals(true);
|
sortComboBox->blockSignals(true);
|
||||||
|
|
||||||
|
int oldIndex = sortComboBox->currentIndex();
|
||||||
|
|
||||||
// Clear and repopulate the ComboBox with translated items
|
// Clear and repopulate the ComboBox with translated items
|
||||||
sortComboBox->clear();
|
sortComboBox->clear();
|
||||||
sortComboBox->addItem(tr("Sort Alphabetically (Deck Name)"), ByName);
|
sortComboBox->addItem(tr("Sort Alphabetically (Deck Name)"), ByName);
|
||||||
|
|
@ -44,7 +49,7 @@ void VisualDeckStorageSortWidget::retranslateUi()
|
||||||
sortComboBox->addItem(tr("Sort by Last Loaded"), ByLastLoaded);
|
sortComboBox->addItem(tr("Sort by Last Loaded"), ByLastLoaded);
|
||||||
|
|
||||||
// Restore the current index
|
// Restore the current index
|
||||||
sortComboBox->setCurrentIndex(SettingsCache::instance().getVisualDeckStorageSortingOrder());
|
sortComboBox->setCurrentIndex(oldIndex);
|
||||||
|
|
||||||
// Re-enable signals
|
// Re-enable signals
|
||||||
sortComboBox->blockSignals(false);
|
sortComboBox->blockSignals(false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue