mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-03-12 21:22:55 -07:00
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:
@@ -606,6 +606,10 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||
connect(&closeEmptyCardViewCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||
&SettingsCache::setCloseEmptyCardView);
|
||||
|
||||
focusCardViewSearchBarCheckBox.setChecked(SettingsCache::instance().getFocusCardViewSearchBar());
|
||||
connect(&focusCardViewSearchBarCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||
&SettingsCache::setFocusCardViewSearchBar);
|
||||
|
||||
annotateTokensCheckBox.setChecked(SettingsCache::instance().getAnnotateTokens());
|
||||
connect(&annotateTokensCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
|
||||
&SettingsCache::setAnnotateTokens);
|
||||
@@ -619,8 +623,9 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||
generalGrid->addWidget(&clickPlaysAllSelectedCheckBox, 1, 0);
|
||||
generalGrid->addWidget(&playToStackCheckBox, 2, 0);
|
||||
generalGrid->addWidget(&closeEmptyCardViewCheckBox, 3, 0);
|
||||
generalGrid->addWidget(&annotateTokensCheckBox, 4, 0);
|
||||
generalGrid->addWidget(&useTearOffMenusCheckBox, 5, 0);
|
||||
generalGrid->addWidget(&focusCardViewSearchBarCheckBox, 4, 0);
|
||||
generalGrid->addWidget(&annotateTokensCheckBox, 5, 0);
|
||||
generalGrid->addWidget(&useTearOffMenusCheckBox, 6, 0);
|
||||
|
||||
generalGroupBox = new QGroupBox;
|
||||
generalGroupBox->setLayout(generalGrid);
|
||||
@@ -725,6 +730,7 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||
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"));
|
||||
focusCardViewSearchBarCheckBox.setText(tr("Auto focus search bar when card view window is opened"));
|
||||
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"));
|
||||
|
||||
@@ -144,6 +144,7 @@ private:
|
||||
QCheckBox clickPlaysAllSelectedCheckBox;
|
||||
QCheckBox playToStackCheckBox;
|
||||
QCheckBox closeEmptyCardViewCheckBox;
|
||||
QCheckBox focusCardViewSearchBarCheckBox;
|
||||
QCheckBox annotateTokensCheckBox;
|
||||
QCheckBox useTearOffMenusCheckBox;
|
||||
QCheckBox tapAnimationCheckBox;
|
||||
|
||||
@@ -56,6 +56,11 @@ ZoneViewWidget::ZoneViewWidget(Player *_player,
|
||||
|
||||
connect(help, &QAction::triggered, this, [this] { createSearchSyntaxHelpWindow(&searchEdit); });
|
||||
|
||||
if (SettingsCache::instance().getFocusCardViewSearchBar()) {
|
||||
this->setActive(true);
|
||||
searchEdit.setFocus();
|
||||
}
|
||||
|
||||
QGraphicsProxyWidget *searchEditProxy = new QGraphicsProxyWidget;
|
||||
searchEditProxy->setWidget(&searchEdit);
|
||||
searchEditProxy->setZValue(2000000007);
|
||||
|
||||
@@ -251,6 +251,7 @@ SettingsCache::SettingsCache()
|
||||
cardViewInitialRowsMax = settings->value("interface/cardViewInitialRowsMax", 14).toInt();
|
||||
cardViewExpandedRowsMax = settings->value("interface/cardViewExpandedRowsMax", 20).toInt();
|
||||
closeEmptyCardView = settings->value("interface/closeEmptyCardView", true).toBool();
|
||||
focusCardViewSearchBar = settings->value("interface/focusCardViewSearchBar", true).toBool();
|
||||
|
||||
showShortcuts = settings->value("menu/showshortcuts", 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);
|
||||
}
|
||||
|
||||
void SettingsCache::setFocusCardViewSearchBar(QT_STATE_CHANGED_T value)
|
||||
{
|
||||
focusCardViewSearchBar = value;
|
||||
settings->setValue("interface/focusCardViewSearchBar", focusCardViewSearchBar);
|
||||
}
|
||||
|
||||
void SettingsCache::setKnownMissingFeatures(const QString &_knownMissingFeatures)
|
||||
{
|
||||
knownMissingFeatures = _knownMissingFeatures;
|
||||
|
||||
@@ -173,6 +173,7 @@ private:
|
||||
int cardViewInitialRowsMax;
|
||||
int cardViewExpandedRowsMax;
|
||||
bool closeEmptyCardView;
|
||||
bool focusCardViewSearchBar;
|
||||
int pixmapCacheSize;
|
||||
int networkCacheSize;
|
||||
int redirectCacheTtl;
|
||||
@@ -660,6 +661,7 @@ public:
|
||||
void setCardViewInitialRowsMax(int _cardViewInitialRowsMax);
|
||||
void setCardViewExpandedRowsMax(int value);
|
||||
void setCloseEmptyCardView(QT_STATE_CHANGED_T value);
|
||||
void setFocusCardViewSearchBar(QT_STATE_CHANGED_T value);
|
||||
QString getClientID()
|
||||
{
|
||||
return clientID;
|
||||
@@ -688,6 +690,10 @@ public:
|
||||
{
|
||||
return closeEmptyCardView;
|
||||
}
|
||||
bool getFocusCardViewSearchBar() const
|
||||
{
|
||||
return focusCardViewSearchBar;
|
||||
}
|
||||
ShortcutsSettings &shortcuts() const
|
||||
{
|
||||
return *shortcutsSettings;
|
||||
|
||||
@@ -64,6 +64,9 @@ void SettingsCache::setCardViewExpandedRowsMax(int /* value */)
|
||||
void SettingsCache::setCloseEmptyCardView(const QT_STATE_CHANGED_T /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setFocusCardViewSearchBar(QT_STATE_CHANGED_T /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -68,6 +68,9 @@ void SettingsCache::setCardViewExpandedRowsMax(int /* value */)
|
||||
void SettingsCache::setCloseEmptyCardView(QT_STATE_CHANGED_T /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setFocusCardViewSearchBar(QT_STATE_CHANGED_T /* value */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setKnownMissingFeatures(const QString & /* _knownMissingFeatures */)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user