get retranslateUi to work with sort options (#5208)

This commit is contained in:
RickyRister 2024-11-29 21:13:17 -08:00 committed by GitHub
parent 5ef1ca06f5
commit d2bc7f6ac0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,21 +47,12 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
QGraphicsLinearLayout *hFilterbox = new QGraphicsLinearLayout(Qt::Horizontal); QGraphicsLinearLayout *hFilterbox = new QGraphicsLinearLayout(Qt::Horizontal);
// groupBy options // groupBy options
groupBySelector.addItem(tr("Group by ---"), CardList::NoSort);
groupBySelector.addItem(tr("Group by Type"), CardList::SortByType);
groupBySelector.addItem(tr("Group by Mana Value"), CardList::SortByManaValue);
QGraphicsProxyWidget *groupBySelectorProxy = new QGraphicsProxyWidget; QGraphicsProxyWidget *groupBySelectorProxy = new QGraphicsProxyWidget;
groupBySelectorProxy->setWidget(&groupBySelector); groupBySelectorProxy->setWidget(&groupBySelector);
groupBySelectorProxy->setZValue(2000000008); groupBySelectorProxy->setZValue(2000000008);
hFilterbox->addItem(groupBySelectorProxy); hFilterbox->addItem(groupBySelectorProxy);
// sortBy options // sortBy options
sortBySelector.addItem(tr("Sort by ---"), CardList::NoSort);
sortBySelector.addItem(tr("Sort by Name"), CardList::SortByName);
sortBySelector.addItem(tr("Sort by Type"), CardList::SortByType);
sortBySelector.addItem(tr("Sort by Mana Value"), CardList::SortByManaValue);
QGraphicsProxyWidget *sortBySelectorProxy = new QGraphicsProxyWidget; QGraphicsProxyWidget *sortBySelectorProxy = new QGraphicsProxyWidget;
sortBySelectorProxy->setWidget(&sortBySelector); sortBySelectorProxy->setWidget(&sortBySelector);
sortBySelectorProxy->setZValue(2000000007); sortBySelectorProxy->setZValue(2000000007);
@ -118,6 +109,8 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
connect(zone, SIGNAL(wheelEventReceived(QGraphicsSceneWheelEvent *)), scrollBarProxy, connect(zone, SIGNAL(wheelEventReceived(QGraphicsSceneWheelEvent *)), scrollBarProxy,
SLOT(recieveWheelEvent(QGraphicsSceneWheelEvent *))); SLOT(recieveWheelEvent(QGraphicsSceneWheelEvent *)));
retranslateUi();
// only wire up sort options after creating ZoneViewZone, since it segfaults otherwise. // only wire up sort options after creating ZoneViewZone, since it segfaults otherwise.
if (numberCards < 0) { if (numberCards < 0) {
connect(&groupBySelector, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(&groupBySelector, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
@ -134,7 +127,6 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
} }
} }
retranslateUi();
setLayout(vbox); setLayout(vbox);
connect(zone, SIGNAL(optimumRectChanged()), this, SLOT(resizeToZoneContents())); connect(zone, SIGNAL(optimumRectChanged()), this, SLOT(resizeToZoneContents()));
@ -191,6 +183,26 @@ void ZoneViewWidget::processSetPileView(QT_STATE_CHANGED_T value)
void ZoneViewWidget::retranslateUi() void ZoneViewWidget::retranslateUi()
{ {
setWindowTitle(zone->getTranslatedName(false, CaseNominative)); setWindowTitle(zone->getTranslatedName(false, CaseNominative));
{ // We can't change the strings after they're put into the QComboBox, so this is our workaround
int oldIndex = sortBySelector.currentIndex();
sortBySelector.clear();
sortBySelector.addItem(tr("Sort by ---"), CardList::NoSort);
sortBySelector.addItem(tr("Sort by Name"), CardList::SortByName);
sortBySelector.addItem(tr("Sort by Type"), CardList::SortByType);
sortBySelector.addItem(tr("Sort by Mana Value"), CardList::SortByManaValue);
sortBySelector.setCurrentIndex(oldIndex);
}
{
int oldIndex = groupBySelector.currentIndex();
groupBySelector.clear();
groupBySelector.addItem(tr("Group by ---"), CardList::NoSort);
groupBySelector.addItem(tr("Group by Type"), CardList::SortByType);
groupBySelector.addItem(tr("Group by Mana Value"), CardList::SortByManaValue);
groupBySelector.setCurrentIndex(oldIndex);
}
shuffleCheckBox.setText(tr("shuffle when closing")); shuffleCheckBox.setText(tr("shuffle when closing"));
pileViewCheckBox.setText(tr("pile view")); pileViewCheckBox.setText(tr("pile view"));
} }