Add setting to auto focus search bar when opening card view window (#5906)

* add new setting

* implement thing

* Rename setting

* fix build failure
This commit is contained in:
RickyRister 2025-05-04 17:09:11 -07:00 committed by ebbit1q
parent 7532d87892
commit 2f784dd997
7 changed files with 33 additions and 2 deletions

View file

@ -606,6 +606,10 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
connect(&closeEmptyCardViewCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(), connect(&closeEmptyCardViewCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setCloseEmptyCardView); &SettingsCache::setCloseEmptyCardView);
focusCardViewSearchBarCheckBox.setChecked(SettingsCache::instance().getFocusCardViewSearchBar());
connect(&focusCardViewSearchBarCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setFocusCardViewSearchBar);
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);
@ -619,8 +623,9 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
generalGrid->addWidget(&clickPlaysAllSelectedCheckBox, 1, 0); generalGrid->addWidget(&clickPlaysAllSelectedCheckBox, 1, 0);
generalGrid->addWidget(&playToStackCheckBox, 2, 0); generalGrid->addWidget(&playToStackCheckBox, 2, 0);
generalGrid->addWidget(&closeEmptyCardViewCheckBox, 3, 0); generalGrid->addWidget(&closeEmptyCardViewCheckBox, 3, 0);
generalGrid->addWidget(&annotateTokensCheckBox, 4, 0); generalGrid->addWidget(&focusCardViewSearchBarCheckBox, 4, 0);
generalGrid->addWidget(&useTearOffMenusCheckBox, 5, 0); generalGrid->addWidget(&annotateTokensCheckBox, 5, 0);
generalGrid->addWidget(&useTearOffMenusCheckBox, 6, 0);
generalGroupBox = new QGroupBox; generalGroupBox = new QGroupBox;
generalGroupBox->setLayout(generalGrid); generalGroupBox->setLayout(generalGrid);
@ -725,6 +730,7 @@ void UserInterfaceSettingsPage::retranslateUi()
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")); closeEmptyCardViewCheckBox.setText(tr("Close card view window when last card is removed"));
focusCardViewSearchBarCheckBox.setText(tr("Auto focus search bar when card view window is opened"));
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

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

View file

@ -56,6 +56,11 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(&searchEdit); }); connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(&searchEdit); });
if (SettingsCache::instance().getFocusCardViewSearchBar()) {
this->setActive(true);
searchEdit.setFocus();
}
QGraphicsProxyWidget *searchEditProxy = new QGraphicsProxyWidget; QGraphicsProxyWidget *searchEditProxy = new QGraphicsProxyWidget;
searchEditProxy->setWidget(&searchEdit); searchEditProxy->setWidget(&searchEdit);
searchEditProxy->setZValue(2000000007); searchEditProxy->setZValue(2000000007);

View file

@ -251,6 +251,7 @@ SettingsCache::SettingsCache()
cardViewInitialRowsMax = settings->value("interface/cardViewInitialRowsMax", 14).toInt(); cardViewInitialRowsMax = settings->value("interface/cardViewInitialRowsMax", 14).toInt();
cardViewExpandedRowsMax = settings->value("interface/cardViewExpandedRowsMax", 20).toInt(); cardViewExpandedRowsMax = settings->value("interface/cardViewExpandedRowsMax", 20).toInt();
closeEmptyCardView = settings->value("interface/closeEmptyCardView", true).toBool(); closeEmptyCardView = settings->value("interface/closeEmptyCardView", true).toBool();
focusCardViewSearchBar = settings->value("interface/focusCardViewSearchBar", 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();
@ -360,6 +361,12 @@ void SettingsCache::setCloseEmptyCardView(QT_STATE_CHANGED_T value)
settings->setValue("interface/closeEmptyCardView", closeEmptyCardView); settings->setValue("interface/closeEmptyCardView", closeEmptyCardView);
} }
void SettingsCache::setFocusCardViewSearchBar(QT_STATE_CHANGED_T value)
{
focusCardViewSearchBar = value;
settings->setValue("interface/focusCardViewSearchBar", focusCardViewSearchBar);
}
void SettingsCache::setKnownMissingFeatures(const QString &_knownMissingFeatures) void SettingsCache::setKnownMissingFeatures(const QString &_knownMissingFeatures)
{ {
knownMissingFeatures = _knownMissingFeatures; knownMissingFeatures = _knownMissingFeatures;

View file

@ -173,6 +173,7 @@ private:
int cardViewInitialRowsMax; int cardViewInitialRowsMax;
int cardViewExpandedRowsMax; int cardViewExpandedRowsMax;
bool closeEmptyCardView; bool closeEmptyCardView;
bool focusCardViewSearchBar;
int pixmapCacheSize; int pixmapCacheSize;
int networkCacheSize; int networkCacheSize;
int redirectCacheTtl; int redirectCacheTtl;
@ -660,6 +661,7 @@ public:
void setCardViewInitialRowsMax(int _cardViewInitialRowsMax); void setCardViewInitialRowsMax(int _cardViewInitialRowsMax);
void setCardViewExpandedRowsMax(int value); void setCardViewExpandedRowsMax(int value);
void setCloseEmptyCardView(QT_STATE_CHANGED_T value); void setCloseEmptyCardView(QT_STATE_CHANGED_T value);
void setFocusCardViewSearchBar(QT_STATE_CHANGED_T value);
QString getClientID() QString getClientID()
{ {
return clientID; return clientID;
@ -688,6 +690,10 @@ public:
{ {
return closeEmptyCardView; return closeEmptyCardView;
} }
bool getFocusCardViewSearchBar() const
{
return focusCardViewSearchBar;
}
ShortcutsSettings &shortcuts() const ShortcutsSettings &shortcuts() const
{ {
return *shortcutsSettings; return *shortcutsSettings;

View file

@ -64,6 +64,9 @@ void SettingsCache::setCardViewExpandedRowsMax(int /* value */)
void SettingsCache::setCloseEmptyCardView(const QT_STATE_CHANGED_T /* value */) void SettingsCache::setCloseEmptyCardView(const QT_STATE_CHANGED_T /* value */)
{ {
} }
void SettingsCache::setFocusCardViewSearchBar(QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */) void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
{ {
} }

View file

@ -68,6 +68,9 @@ void SettingsCache::setCardViewExpandedRowsMax(int /* value */)
void SettingsCache::setCloseEmptyCardView(QT_STATE_CHANGED_T /* value */) void SettingsCache::setCloseEmptyCardView(QT_STATE_CHANGED_T /* value */)
{ {
} }
void SettingsCache::setFocusCardViewSearchBar(QT_STATE_CHANGED_T /* value */)
{
}
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */) void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
{ {
} }