Custom item retranslate fix

This commit is contained in:
Jurriaan van den Berg 2026-11-02 17:06:49 +01:00
parent ba22736def
commit b3e6ecbef7
2 changed files with 21 additions and 4 deletions

View file

@ -121,6 +121,10 @@ void VisualDatabaseDisplayColorFilterWidget::retranslateUi()
modeComboBox->setItemData(3, tr("Cards being exactly of the selected colors"), Qt::ToolTipRole); modeComboBox->setItemData(3, tr("Cards being exactly of the selected colors"), Qt::ToolTipRole);
modeComboBox->setItemData(4, tr("Cards whose color identity fits within the selected colors"), Qt::ToolTipRole); modeComboBox->setItemData(4, tr("Cards whose color identity fits within the selected colors"), Qt::ToolTipRole);
if (currentMode == FilterMode::Custom) {
addCustomFilterModeItem();
}
modeComboBox->setToolTip(tr("How selected and unselected colors are combined in the filter")); modeComboBox->setToolTip(tr("How selected and unselected colors are combined in the filter"));
modeComboBox->setAccessibleName(tr("Color Filter Mode")); modeComboBox->setAccessibleName(tr("Color Filter Mode"));
@ -135,12 +139,26 @@ void VisualDatabaseDisplayColorFilterWidget::retranslateUi()
void VisualDatabaseDisplayColorFilterWidget::setFilterMode(FilterMode filterMode) void VisualDatabaseDisplayColorFilterWidget::setFilterMode(FilterMode filterMode)
{ {
const int index = modeComboBox->findData(QVariant::fromValue(filterMode)); int index = modeComboBox->findData(QVariant::fromValue(filterMode));
if (index < 0 && filterMode == FilterMode::Custom) {
index = modeComboBox->count();
addCustomFilterModeItem();
}
if (index >= 0) { if (index >= 0) {
modeComboBox->setCurrentIndex(index); modeComboBox->setCurrentIndex(index);
} }
} }
void VisualDatabaseDisplayColorFilterWidget::addCustomFilterModeItem()
{
int customIndex = modeComboBox->count();
modeComboBox->addItem(tr("Custom"), QVariant::fromValue(FilterMode::Custom));
modeComboBox->setItemData(customIndex, tr("Cards matching an unknown combination of color filters"),
Qt::ToolTipRole);
}
void VisualDatabaseDisplayColorFilterWidget::handleColorToggled(QChar color, bool active) void VisualDatabaseDisplayColorFilterWidget::handleColorToggled(QChar color, bool active)
{ {
if (active) { if (active) {
@ -277,9 +295,7 @@ void VisualDatabaseDisplayColorFilterWidget::syncWithFilterModel()
if (currentMode == FilterMode::Custom) { if (currentMode == FilterMode::Custom) {
if (customIndex < 0) { if (customIndex < 0) {
customIndex = modeComboBox->count(); customIndex = modeComboBox->count();
modeComboBox->addItem(tr("Custom"), QVariant::fromValue(FilterMode::Custom)); addCustomFilterModeItem();
modeComboBox->setItemData(customIndex, tr("Cards matching an unknown combination of color filters"),
Qt::ToolTipRole);
} }
modeComboBox->setCurrentIndex(customIndex); modeComboBox->setCurrentIndex(customIndex);
} else { } else {

View file

@ -65,6 +65,7 @@ signals:
void filterModeChanged(FilterMode filterMode); void filterModeChanged(FilterMode filterMode);
private slots: private slots:
void addCustomFilterModeItem();
void handleColorToggled(QChar color, bool active); void handleColorToggled(QChar color, bool active);
void addFilter(QChar color); void addFilter(QChar color);
void removeFilter(QChar color); void removeFilter(QChar color);