mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
rename and refactor some stuff in ZoneViewWidget (#5213)
* fix QComboBox creation order in retranslateUi * move bottom row creation closer to where it's used * rename QGraphicsLinearLayout variables hFilterbox and hPilebox don't make much sense now * add comment about #5204
This commit is contained in:
parent
70559d32df
commit
b92047bc3f
1 changed files with 22 additions and 17 deletions
|
|
@ -43,22 +43,22 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
|||
|
||||
// If the number is < 0, then it means that we can give the option to make the area sorted
|
||||
if (numberCards < 0) {
|
||||
QGraphicsLinearLayout *hPilebox = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
QGraphicsLinearLayout *hFilterbox = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
// top row
|
||||
QGraphicsLinearLayout *hTopRow = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
|
||||
// groupBy options
|
||||
QGraphicsProxyWidget *groupBySelectorProxy = new QGraphicsProxyWidget;
|
||||
groupBySelectorProxy->setWidget(&groupBySelector);
|
||||
groupBySelectorProxy->setZValue(2000000008);
|
||||
hFilterbox->addItem(groupBySelectorProxy);
|
||||
hTopRow->addItem(groupBySelectorProxy);
|
||||
|
||||
// sortBy options
|
||||
QGraphicsProxyWidget *sortBySelectorProxy = new QGraphicsProxyWidget;
|
||||
sortBySelectorProxy->setWidget(&sortBySelector);
|
||||
sortBySelectorProxy->setZValue(2000000007);
|
||||
hFilterbox->addItem(sortBySelectorProxy);
|
||||
hTopRow->addItem(sortBySelectorProxy);
|
||||
|
||||
vbox->addItem(hFilterbox);
|
||||
vbox->addItem(hTopRow);
|
||||
|
||||
// line
|
||||
QGraphicsProxyWidget *lineProxy = new QGraphicsProxyWidget;
|
||||
|
|
@ -68,20 +68,23 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
|||
lineProxy->setWidget(line);
|
||||
vbox->addItem(lineProxy);
|
||||
|
||||
// bottom row
|
||||
QGraphicsLinearLayout *hBottomRow = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||
|
||||
// pile view options
|
||||
QGraphicsProxyWidget *pileViewProxy = new QGraphicsProxyWidget;
|
||||
pileViewProxy->setWidget(&pileViewCheckBox);
|
||||
hPilebox->addItem(pileViewProxy);
|
||||
hBottomRow->addItem(pileViewProxy);
|
||||
|
||||
// shuffle options
|
||||
if (_origZone->getIsShufflable() && numberCards == -1) {
|
||||
shuffleCheckBox.setChecked(true);
|
||||
QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget;
|
||||
shuffleProxy->setWidget(&shuffleCheckBox);
|
||||
hPilebox->addItem(shuffleProxy);
|
||||
hBottomRow->addItem(shuffleProxy);
|
||||
}
|
||||
|
||||
vbox->addItem(hPilebox);
|
||||
vbox->addItem(hBottomRow);
|
||||
}
|
||||
|
||||
extraHeight = vbox->sizeHint(Qt::PreferredSize).height();
|
||||
|
|
@ -133,6 +136,8 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
|||
connect(zone, SIGNAL(beingDeleted()), this, SLOT(zoneDeleted()));
|
||||
zone->initializeCards(cardList);
|
||||
|
||||
// QLabel sizes aren't taken into account until the widget is rendered.
|
||||
// Force refresh after 1ms to fix glitchy rendering with long QLabels.
|
||||
auto *lastResizeBeforeVisibleTimer = new QTimer(this);
|
||||
connect(lastResizeBeforeVisibleTimer, &QTimer::timeout, this, [=] {
|
||||
resizeToZoneContents();
|
||||
|
|
@ -185,6 +190,15 @@ void ZoneViewWidget::retranslateUi()
|
|||
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 = 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);
|
||||
}
|
||||
|
||||
{
|
||||
int oldIndex = sortBySelector.currentIndex();
|
||||
sortBySelector.clear();
|
||||
sortBySelector.addItem(tr("Sort by ---"), CardList::NoSort);
|
||||
|
|
@ -194,15 +208,6 @@ void ZoneViewWidget::retranslateUi()
|
|||
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"));
|
||||
pileViewCheckBox.setText(tr("pile view"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue