mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-12 15:49:28 -08:00
Add setting to auto close card view when empty (#5502)
This commit is contained in:
@@ -561,6 +561,10 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||
connect(&playToStackCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||
&SettingsCache::setPlayToStack);
|
||||
|
||||
closeEmptyCardViewCheckBox.setChecked(SettingsCache::instance().getCloseEmptyCardView());
|
||||
connect(&closeEmptyCardViewCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||
&SettingsCache::setCloseEmptyCardView);
|
||||
|
||||
annotateTokensCheckBox.setChecked(SettingsCache::instance().getAnnotateTokens());
|
||||
connect(&annotateTokensCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||
&SettingsCache::setAnnotateTokens);
|
||||
@@ -573,8 +577,9 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||
generalGrid->addWidget(&doubleClickToPlayCheckBox, 0, 0);
|
||||
generalGrid->addWidget(&clickPlaysAllSelectedCheckBox, 1, 0);
|
||||
generalGrid->addWidget(&playToStackCheckBox, 2, 0);
|
||||
generalGrid->addWidget(&annotateTokensCheckBox, 3, 0);
|
||||
generalGrid->addWidget(&useTearOffMenusCheckBox, 4, 0);
|
||||
generalGrid->addWidget(&closeEmptyCardViewCheckBox, 3, 0);
|
||||
generalGrid->addWidget(&annotateTokensCheckBox, 4, 0);
|
||||
generalGrid->addWidget(&useTearOffMenusCheckBox, 5, 0);
|
||||
|
||||
generalGroupBox = new QGroupBox;
|
||||
generalGroupBox->setLayout(generalGrid);
|
||||
@@ -650,6 +655,7 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||
doubleClickToPlayCheckBox.setText(tr("&Double-click cards to play them (instead of single-click)"));
|
||||
clickPlaysAllSelectedCheckBox.setText(tr("&Clicking plays all selected cards (instead of just the clicked card)"));
|
||||
playToStackCheckBox.setText(tr("&Play all nonlands onto the stack (not the battlefield) by default"));
|
||||
closeEmptyCardViewCheckBox.setText(tr("Close card view window when last card is removed"));
|
||||
annotateTokensCheckBox.setText(tr("Annotate card text on tokens"));
|
||||
useTearOffMenusCheckBox.setText(tr("Use tear-off menus, allowing right click menus to persist on screen"));
|
||||
notificationsGroupBox->setTitle(tr("Notifications settings"));
|
||||
|
||||
@@ -139,6 +139,7 @@ private:
|
||||
QCheckBox doubleClickToPlayCheckBox;
|
||||
QCheckBox clickPlaysAllSelectedCheckBox;
|
||||
QCheckBox playToStackCheckBox;
|
||||
QCheckBox closeEmptyCardViewCheckBox;
|
||||
QCheckBox annotateTokensCheckBox;
|
||||
QCheckBox useTearOffMenusCheckBox;
|
||||
QCheckBox tapAnimationCheckBox;
|
||||
|
||||
@@ -348,6 +348,12 @@ void ZoneViewZone::removeCard(int position)
|
||||
|
||||
CardItem *card = cards.takeAt(position);
|
||||
card->deleteLater();
|
||||
|
||||
if (cards.isEmpty() && SettingsCache::instance().getCloseEmptyCardView()) {
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
updateCardIds(REMOVE_CARD);
|
||||
reorganizeCards();
|
||||
}
|
||||
|
||||
@@ -253,6 +253,7 @@ SettingsCache::SettingsCache()
|
||||
knownMissingFeatures = settings->value("interface/knownmissingfeatures", "").toString();
|
||||
useTearOffMenus = settings->value("interface/usetearoffmenus", true).toBool();
|
||||
cardViewInitialRowsMax = settings->value("interface/cardViewInitialRowsMax", 14).toInt();
|
||||
closeEmptyCardView = settings->value("interface/closeEmptyCardView", true).toBool();
|
||||
|
||||
showShortcuts = settings->value("menu/showshortcuts", true).toBool();
|
||||
displayCardNames = settings->value("cards/displaycardnames", true).toBool();
|
||||
@@ -341,6 +342,12 @@ void SettingsCache::setCardViewInitialRowsMax(int _cardViewInitialRowsMax)
|
||||
settings->setValue("interface/cardViewInitialRowsMax", cardViewInitialRowsMax);
|
||||
}
|
||||
|
||||
void SettingsCache::setCloseEmptyCardView(QT_STATE_CHANGED_T value)
|
||||
{
|
||||
closeEmptyCardView = value;
|
||||
settings->setValue("interface/closeEmptyCardView", closeEmptyCardView);
|
||||
}
|
||||
|
||||
void SettingsCache::setKnownMissingFeatures(const QString &_knownMissingFeatures)
|
||||
{
|
||||
knownMissingFeatures = _knownMissingFeatures;
|
||||
|
||||
@@ -159,6 +159,7 @@ private:
|
||||
QString knownMissingFeatures;
|
||||
bool useTearOffMenus;
|
||||
int cardViewInitialRowsMax;
|
||||
bool closeEmptyCardView;
|
||||
int pixmapCacheSize;
|
||||
int networkCacheSize;
|
||||
int redirectCacheTtl;
|
||||
@@ -619,6 +620,7 @@ public:
|
||||
void setKnownMissingFeatures(const QString &_knownMissingFeatures);
|
||||
void setUseTearOffMenus(bool _useTearOffMenus);
|
||||
void setCardViewInitialRowsMax(int _cardViewInitialRowsMax);
|
||||
void setCloseEmptyCardView(QT_STATE_CHANGED_T value);
|
||||
QString getClientID()
|
||||
{
|
||||
return clientID;
|
||||
@@ -639,6 +641,10 @@ public:
|
||||
{
|
||||
return cardViewInitialRowsMax;
|
||||
}
|
||||
bool getCloseEmptyCardView() const
|
||||
{
|
||||
return closeEmptyCardView;
|
||||
}
|
||||
ShortcutsSettings &shortcuts() const
|
||||
{
|
||||
return *shortcutsSettings;
|
||||
|
||||
@@ -58,6 +58,9 @@ void SettingsCache::setUseTearOffMenus(bool /* _useTearOffMenus */)
|
||||
void SettingsCache::setCardViewInitialRowsMax(int /* _cardViewInitialRowsMax */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setCloseEmptyCardView(const QT_STATE_CHANGED_T /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -62,6 +62,9 @@ void SettingsCache::setUseTearOffMenus(bool /* _useTearOffMenus */)
|
||||
void SettingsCache::setCardViewInitialRowsMax(int /* _cardViewInitialRowsMax */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setCloseEmptyCardView(QT_STATE_CHANGED_T /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user