Add setting to auto close card view when empty (#5502)

This commit is contained in:
RickyRister 2025-01-20 19:08:01 -08:00 committed by GitHub
parent aeb1b9fb4f
commit 97fdf11c8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 34 additions and 2 deletions

View file

@ -561,6 +561,10 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
connect(&playToStackCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), connect(&playToStackCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setPlayToStack); &SettingsCache::setPlayToStack);
closeEmptyCardViewCheckBox.setChecked(SettingsCache::instance().getCloseEmptyCardView());
connect(&closeEmptyCardViewCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setCloseEmptyCardView);
annotateTokensCheckBox.setChecked(SettingsCache::instance().getAnnotateTokens()); annotateTokensCheckBox.setChecked(SettingsCache::instance().getAnnotateTokens());
connect(&annotateTokensCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), connect(&annotateTokensCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setAnnotateTokens); &SettingsCache::setAnnotateTokens);
@ -573,8 +577,9 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
generalGrid->addWidget(&doubleClickToPlayCheckBox, 0, 0); generalGrid->addWidget(&doubleClickToPlayCheckBox, 0, 0);
generalGrid->addWidget(&clickPlaysAllSelectedCheckBox, 1, 0); generalGrid->addWidget(&clickPlaysAllSelectedCheckBox, 1, 0);
generalGrid->addWidget(&playToStackCheckBox, 2, 0); generalGrid->addWidget(&playToStackCheckBox, 2, 0);
generalGrid->addWidget(&annotateTokensCheckBox, 3, 0); generalGrid->addWidget(&closeEmptyCardViewCheckBox, 3, 0);
generalGrid->addWidget(&useTearOffMenusCheckBox, 4, 0); generalGrid->addWidget(&annotateTokensCheckBox, 4, 0);
generalGrid->addWidget(&useTearOffMenusCheckBox, 5, 0);
generalGroupBox = new QGroupBox; generalGroupBox = new QGroupBox;
generalGroupBox->setLayout(generalGrid); generalGroupBox->setLayout(generalGrid);
@ -650,6 +655,7 @@ void UserInterfaceSettingsPage::retranslateUi()
doubleClickToPlayCheckBox.setText(tr("&Double-click cards to play them (instead of single-click)")); 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)")); 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")); 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")); annotateTokensCheckBox.setText(tr("Annotate card text on tokens"));
useTearOffMenusCheckBox.setText(tr("Use tear-off menus, allowing right click menus to persist on screen")); useTearOffMenusCheckBox.setText(tr("Use tear-off menus, allowing right click menus to persist on screen"));
notificationsGroupBox->setTitle(tr("Notifications settings")); notificationsGroupBox->setTitle(tr("Notifications settings"));

View file

@ -139,6 +139,7 @@ private:
QCheckBox doubleClickToPlayCheckBox; QCheckBox doubleClickToPlayCheckBox;
QCheckBox clickPlaysAllSelectedCheckBox; QCheckBox clickPlaysAllSelectedCheckBox;
QCheckBox playToStackCheckBox; QCheckBox playToStackCheckBox;
QCheckBox closeEmptyCardViewCheckBox;
QCheckBox annotateTokensCheckBox; QCheckBox annotateTokensCheckBox;
QCheckBox useTearOffMenusCheckBox; QCheckBox useTearOffMenusCheckBox;
QCheckBox tapAnimationCheckBox; QCheckBox tapAnimationCheckBox;

View file

@ -348,6 +348,12 @@ void ZoneViewZone::removeCard(int position)
CardItem *card = cards.takeAt(position); CardItem *card = cards.takeAt(position);
card->deleteLater(); card->deleteLater();
if (cards.isEmpty() && SettingsCache::instance().getCloseEmptyCardView()) {
deleteLater();
return;
}
updateCardIds(REMOVE_CARD); updateCardIds(REMOVE_CARD);
reorganizeCards(); reorganizeCards();
} }

View file

@ -253,6 +253,7 @@ SettingsCache::SettingsCache()
knownMissingFeatures = settings->value("interface/knownmissingfeatures", "").toString(); knownMissingFeatures = settings->value("interface/knownmissingfeatures", "").toString();
useTearOffMenus = settings->value("interface/usetearoffmenus", true).toBool(); useTearOffMenus = settings->value("interface/usetearoffmenus", true).toBool();
cardViewInitialRowsMax = settings->value("interface/cardViewInitialRowsMax", 14).toInt(); cardViewInitialRowsMax = settings->value("interface/cardViewInitialRowsMax", 14).toInt();
closeEmptyCardView = settings->value("interface/closeEmptyCardView", true).toBool();
showShortcuts = settings->value("menu/showshortcuts", true).toBool(); showShortcuts = settings->value("menu/showshortcuts", true).toBool();
displayCardNames = settings->value("cards/displaycardnames", true).toBool(); displayCardNames = settings->value("cards/displaycardnames", true).toBool();
@ -341,6 +342,12 @@ void SettingsCache::setCardViewInitialRowsMax(int _cardViewInitialRowsMax)
settings->setValue("interface/cardViewInitialRowsMax", 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) void SettingsCache::setKnownMissingFeatures(const QString &_knownMissingFeatures)
{ {
knownMissingFeatures = _knownMissingFeatures; knownMissingFeatures = _knownMissingFeatures;

View file

@ -159,6 +159,7 @@ private:
QString knownMissingFeatures; QString knownMissingFeatures;
bool useTearOffMenus; bool useTearOffMenus;
int cardViewInitialRowsMax; int cardViewInitialRowsMax;
bool closeEmptyCardView;
int pixmapCacheSize; int pixmapCacheSize;
int networkCacheSize; int networkCacheSize;
int redirectCacheTtl; int redirectCacheTtl;
@ -619,6 +620,7 @@ public:
void setKnownMissingFeatures(const QString &_knownMissingFeatures); void setKnownMissingFeatures(const QString &_knownMissingFeatures);
void setUseTearOffMenus(bool _useTearOffMenus); void setUseTearOffMenus(bool _useTearOffMenus);
void setCardViewInitialRowsMax(int _cardViewInitialRowsMax); void setCardViewInitialRowsMax(int _cardViewInitialRowsMax);
void setCloseEmptyCardView(QT_STATE_CHANGED_T value);
QString getClientID() QString getClientID()
{ {
return clientID; return clientID;
@ -639,6 +641,10 @@ public:
{ {
return cardViewInitialRowsMax; return cardViewInitialRowsMax;
} }
bool getCloseEmptyCardView() const
{
return closeEmptyCardView;
}
ShortcutsSettings &shortcuts() const ShortcutsSettings &shortcuts() const
{ {
return *shortcutsSettings; return *shortcutsSettings;

View file

@ -58,6 +58,9 @@ void SettingsCache::setUseTearOffMenus(bool /* _useTearOffMenus */)
void SettingsCache::setCardViewInitialRowsMax(int /* _cardViewInitialRowsMax */) void SettingsCache::setCardViewInitialRowsMax(int /* _cardViewInitialRowsMax */)
{ {
} }
void SettingsCache::setCloseEmptyCardView(const QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */) void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
{ {
} }

View file

@ -62,6 +62,9 @@ void SettingsCache::setUseTearOffMenus(bool /* _useTearOffMenus */)
void SettingsCache::setCardViewInitialRowsMax(int /* _cardViewInitialRowsMax */) void SettingsCache::setCardViewInitialRowsMax(int /* _cardViewInitialRowsMax */)
{ {
} }
void SettingsCache::setCloseEmptyCardView(QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */) void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
{ {
} }