mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
make card view window max initial height configurable (#5236)
This commit is contained in:
parent
0463a6fd70
commit
a0f74134bb
7 changed files with 41 additions and 1 deletions
|
|
@ -346,11 +346,18 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
connect(&verticalCardOverlapPercentBox, SIGNAL(valueChanged(int)), &settings,
|
||||
SLOT(setStackCardOverlapPercent(int)));
|
||||
|
||||
cardViewInitialRowsMaxBox.setRange(1, 999);
|
||||
cardViewInitialRowsMaxBox.setValue(SettingsCache::instance().getCardViewInitialRowsMax());
|
||||
connect(&cardViewInitialRowsMaxBox, qOverload<int>(&QSpinBox::valueChanged), &SettingsCache::instance(),
|
||||
&SettingsCache::setCardViewInitialRowsMax);
|
||||
|
||||
auto *cardsGrid = new QGridLayout;
|
||||
cardsGrid->addWidget(&displayCardNamesCheckBox, 0, 0, 1, 2);
|
||||
cardsGrid->addWidget(&cardScalingCheckBox, 1, 0, 1, 2);
|
||||
cardsGrid->addWidget(&verticalCardOverlapPercentLabel, 2, 0, 1, 1);
|
||||
cardsGrid->addWidget(&verticalCardOverlapPercentBox, 2, 1, 1, 1);
|
||||
cardsGrid->addWidget(&cardViewInitialRowsMaxLabel, 3, 0);
|
||||
cardsGrid->addWidget(&cardViewInitialRowsMaxBox, 3, 1);
|
||||
|
||||
cardsGroupBox = new QGroupBox;
|
||||
cardsGroupBox->setLayout(cardsGrid);
|
||||
|
|
@ -448,6 +455,8 @@ void AppearanceSettingsPage::retranslateUi()
|
|||
cardScalingCheckBox.setText(tr("Scale cards on mouse over"));
|
||||
verticalCardOverlapPercentLabel.setText(
|
||||
tr("Minimum overlap percentage of cards on the stack and in vertical hand"));
|
||||
cardViewInitialRowsMaxLabel.setText(tr("Maximum initial height for card view window:"));
|
||||
cardViewInitialRowsMaxBox.setSuffix(tr(" rows"));
|
||||
|
||||
handGroupBox->setTitle(tr("Hand layout"));
|
||||
horizontalHandCheckBox.setText(tr("Display hand horizontally (wastes space)"));
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ private:
|
|||
QCheckBox cardScalingCheckBox;
|
||||
QLabel verticalCardOverlapPercentLabel;
|
||||
QSpinBox verticalCardOverlapPercentBox;
|
||||
QLabel cardViewInitialRowsMaxLabel;
|
||||
QSpinBox cardViewInitialRowsMaxBox;
|
||||
QCheckBox horizontalHandCheckBox;
|
||||
QCheckBox leftJustifiedHandCheckBox;
|
||||
QCheckBox invertVerticalCoordinateCheckBox;
|
||||
|
|
|
|||
|
|
@ -254,6 +254,16 @@ void ZoneViewWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||
scrollBar->setMaximum(totalZoneHeight - newZoneHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the max initial height from the settings.
|
||||
* The max initial height setting is given as number of rows, so we need to map it to a height.
|
||||
**/
|
||||
static qreal calcMaxInitialHeight()
|
||||
{
|
||||
const qreal cardsHeight = (SettingsCache::instance().getCardViewInitialRowsMax() + 1) * (CARD_HEIGHT / 3);
|
||||
return cardsHeight + 5; // +5 padding to make the cutoff look nicer
|
||||
}
|
||||
|
||||
void ZoneViewWidget::resizeToZoneContents()
|
||||
{
|
||||
QRectF zoneRect = zone->getOptimumRect();
|
||||
|
|
@ -265,7 +275,7 @@ void ZoneViewWidget::resizeToZoneContents()
|
|||
QSizeF maxSize(width, zoneRect.height() + extraHeight + 10);
|
||||
setMaximumSize(maxSize);
|
||||
|
||||
qreal initialZoneHeight = qMin(zoneRect.height(), 500.0);
|
||||
qreal initialZoneHeight = qMin(zoneRect.height(), calcMaxInitialHeight());
|
||||
QSizeF initialSize(width, initialZoneHeight + extraHeight + 10);
|
||||
resize(initialSize);
|
||||
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ SettingsCache::SettingsCache()
|
|||
tabGameSplitterSizes = settings->value("interface/tabgame_splittersizes").toByteArray();
|
||||
knownMissingFeatures = settings->value("interface/knownmissingfeatures", "").toString();
|
||||
useTearOffMenus = settings->value("interface/usetearoffmenus", true).toBool();
|
||||
cardViewInitialRowsMax = settings->value("interface/cardViewInitialRowsMax", 14).toInt();
|
||||
|
||||
showShortcuts = settings->value("menu/showshortcuts", true).toBool();
|
||||
displayCardNames = settings->value("cards/displaycardnames", true).toBool();
|
||||
|
|
@ -300,6 +301,12 @@ void SettingsCache::setUseTearOffMenus(bool _useTearOffMenus)
|
|||
emit useTearOffMenusChanged(useTearOffMenus);
|
||||
}
|
||||
|
||||
void SettingsCache::setCardViewInitialRowsMax(int _cardViewInitialRowsMax)
|
||||
{
|
||||
cardViewInitialRowsMax = _cardViewInitialRowsMax;
|
||||
settings->setValue("interface/cardViewInitialRowsMax", cardViewInitialRowsMax);
|
||||
}
|
||||
|
||||
void SettingsCache::setKnownMissingFeatures(const QString &_knownMissingFeatures)
|
||||
{
|
||||
knownMissingFeatures = _knownMissingFeatures;
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ private:
|
|||
QString clientVersion;
|
||||
QString knownMissingFeatures;
|
||||
bool useTearOffMenus;
|
||||
int cardViewInitialRowsMax;
|
||||
int pixmapCacheSize;
|
||||
int networkCacheSize;
|
||||
int redirectCacheTtl;
|
||||
|
|
@ -485,6 +486,7 @@ public:
|
|||
void setClientVersion(const QString &clientVersion);
|
||||
void setKnownMissingFeatures(const QString &_knownMissingFeatures);
|
||||
void setUseTearOffMenus(bool _useTearOffMenus);
|
||||
void setCardViewInitialRowsMax(int _cardViewInitialRowsMax);
|
||||
QString getClientID()
|
||||
{
|
||||
return clientID;
|
||||
|
|
@ -501,6 +503,10 @@ public:
|
|||
{
|
||||
return useTearOffMenus;
|
||||
}
|
||||
int getCardViewInitialRowsMax() const
|
||||
{
|
||||
return cardViewInitialRowsMax;
|
||||
}
|
||||
ShortcutsSettings &shortcuts() const
|
||||
{
|
||||
return *shortcutsSettings;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ SettingsCache::SettingsCache()
|
|||
void SettingsCache::setUseTearOffMenus(bool /* _useTearOffMenus */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setCardViewInitialRowsMax(int /* _cardViewInitialRowsMax */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@ SettingsCache::SettingsCache()
|
|||
void SettingsCache::setUseTearOffMenus(bool /* _useTearOffMenus */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setCardViewInitialRowsMax(int /* _cardViewInitialRowsMax */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue