mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 08:52:19 -07:00
Minor fixes to search
Took 13 minutes
This commit is contained in:
parent
8072eef462
commit
622e661499
4 changed files with 37 additions and 21 deletions
|
|
@ -154,7 +154,11 @@ void DlgSettings::setupUi()
|
||||||
connect(searchResultsView, &QListView::clicked, this, &DlgSettings::onSearchResultClicked);
|
connect(searchResultsView, &QListView::clicked, this, &DlgSettings::onSearchResultClicked);
|
||||||
|
|
||||||
connect(&SettingsCache::instance(), &SettingsCache::themeChanged, this, [this] {
|
connect(&SettingsCache::instance(), &SettingsCache::themeChanged, this, [this] {
|
||||||
searchDelegate->setPageIcons(pageIconResources());
|
const QStringList icons = pageIconResources();
|
||||||
|
for (int i = 0; i < tabButtons.size() && i < icons.size(); ++i) {
|
||||||
|
tabButtons[i]->setIcon(QPixmap(icons[i]));
|
||||||
|
}
|
||||||
|
searchDelegate->setPageIcons(icons);
|
||||||
searchResultsView->viewport()->update();
|
searchResultsView->viewport()->update();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -391,9 +395,13 @@ void DlgSettings::navigateToSearchResult(const QModelIndex &index)
|
||||||
|
|
||||||
// Scroll to the widget, focus it, and flash to highlight it
|
// Scroll to the widget, focus it, and flash to highlight it
|
||||||
if (entry.widget) {
|
if (entry.widget) {
|
||||||
QScrollArea *scrollArea = qobject_cast<QScrollArea *>(pagesWidget->currentWidget());
|
QWidget *widget = entry.widget;
|
||||||
if (scrollArea) {
|
while (widget) {
|
||||||
scrollArea->ensureWidgetVisible(entry.widget);
|
if (auto *scrollArea = qobject_cast<QScrollArea *>(widget)) {
|
||||||
|
scrollArea->ensureWidgetVisible(entry.widget);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
widget = widget->parentWidget();
|
||||||
}
|
}
|
||||||
entry.widget->setFocus();
|
entry.widget->setFocus();
|
||||||
flashWidget(entry.widget);
|
flashWidget(entry.widget);
|
||||||
|
|
@ -423,8 +431,10 @@ bool DlgSettings::eventFilter(QObject *watched, QEvent *event)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) {
|
} else if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) {
|
||||||
if (searchActive && searchResultsView->currentIndex().isValid()) {
|
if (searchActive) {
|
||||||
navigateToSearchResult(searchResultsView->currentIndex());
|
if (searchResultsView->currentIndex().isValid()) {
|
||||||
|
navigateToSearchResult(searchResultsView->currentIndex());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (keyEvent->key() == Qt::Key_Down) {
|
} else if (keyEvent->key() == Qt::Key_Down) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include "settings_search_model.h"
|
#include "settings_search_model.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
@ -56,8 +55,8 @@ static bool isValidSettingLabel(const QLabel *label)
|
||||||
* @brief Finds the control associated with a setting label
|
* @brief Finds the control associated with a setting label
|
||||||
*
|
*
|
||||||
* Uses the explicit buddy if set, otherwise the widget in the cell (or slot)
|
* Uses the explicit buddy if set, otherwise the widget in the cell (or slot)
|
||||||
* immediately following the label within the same layout. Falls back to the
|
* immediately following the label within the same layout. Returns nullptr when
|
||||||
* label itself when no obvious control is found.
|
* no obvious control is found.
|
||||||
*/
|
*/
|
||||||
static QWidget *controlForLabel(QLabel *label, QLayout *containingLayout)
|
static QWidget *controlForLabel(QLabel *label, QLayout *containingLayout)
|
||||||
{
|
{
|
||||||
|
|
@ -92,14 +91,16 @@ static QWidget *controlForLabel(QLabel *label, QLayout *containingLayout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return label;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Builds the extended search text for an entry
|
* @brief Builds the extended search text for an entry
|
||||||
*
|
*
|
||||||
* Combines the group title, label, and any extra searchable text derived from
|
* Combines the group title, label, and any extra searchable text derived from
|
||||||
* the associated control (tooltip, placeholder, prefix/suffix, combo text).
|
* the associated control (placeholder, prefix/suffix, tooltip). Combo values
|
||||||
|
* and numeric tooltips are excluded since they change at runtime and would
|
||||||
|
* make the search index stale.
|
||||||
*/
|
*/
|
||||||
static QString buildFullSearchText(const QString &groupTitle, const QString &cleanLabel, QWidget *control)
|
static QString buildFullSearchText(const QString &groupTitle, const QString &cleanLabel, QWidget *control)
|
||||||
{
|
{
|
||||||
|
|
@ -110,11 +111,13 @@ static QString buildFullSearchText(const QString &groupTitle, const QString &cle
|
||||||
} else if (auto *spinBox = qobject_cast<QSpinBox *>(control)) {
|
} else if (auto *spinBox = qobject_cast<QSpinBox *>(control)) {
|
||||||
parts.append(spinBox->prefix());
|
parts.append(spinBox->prefix());
|
||||||
parts.append(spinBox->suffix());
|
parts.append(spinBox->suffix());
|
||||||
} else if (auto *comboBox = qobject_cast<QComboBox *>(control)) {
|
|
||||||
parts.append(comboBox->currentText());
|
|
||||||
}
|
}
|
||||||
if (!control->toolTip().isEmpty()) {
|
if (!control->toolTip().isEmpty()) {
|
||||||
parts.append(control->toolTip());
|
bool isNumeric = false;
|
||||||
|
control->toolTip().toInt(&isNumeric);
|
||||||
|
if (!isNumeric) {
|
||||||
|
parts.append(control->toolTip());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parts.removeAll(QString());
|
parts.removeAll(QString());
|
||||||
|
|
@ -176,15 +179,16 @@ QList<SettingsSearchEntry> AbstractSettingsPage::autoDetectSearchEntries(QWidget
|
||||||
QWidget *control = widget;
|
QWidget *control = widget;
|
||||||
if (auto *labelWidget = qobject_cast<QLabel *>(widget)) {
|
if (auto *labelWidget = qobject_cast<QLabel *>(widget)) {
|
||||||
control = controlForLabel(labelWidget, pair.second);
|
control = controlForLabel(labelWidget, pair.second);
|
||||||
|
if (!control) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsSearchEntry entry;
|
entries.append(SettingsSearchEntry{.pageIndex = pageIndex,
|
||||||
entry.pageIndex = pageIndex;
|
.groupTitle = groupTitle,
|
||||||
entry.groupTitle = groupTitle;
|
.widgetLabel = cleanLabel,
|
||||||
entry.widgetLabel = cleanLabel;
|
.fullSearchText = buildFullSearchText(groupTitle, cleanLabel, control),
|
||||||
entry.widget = control;
|
.widget = control});
|
||||||
entry.fullSearchText = buildFullSearchText(groupTitle, cleanLabel, control);
|
|
||||||
entries.append(entry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ MessagesSettingsPage::MessagesSettingsPage()
|
||||||
highlightNotice->addWidget(&hexHighlightLabel, 1, 2);
|
highlightNotice->addWidget(&hexHighlightLabel, 1, 2);
|
||||||
highlightNotice->addWidget(customAlertString, 0, 0);
|
highlightNotice->addWidget(customAlertString, 0, 0);
|
||||||
highlightNotice->addWidget(&customAlertStringLabel, 1, 0);
|
highlightNotice->addWidget(&customAlertStringLabel, 1, 0);
|
||||||
|
customAlertStringLabel.setBuddy(customAlertString);
|
||||||
highlightGroupBox = new QGroupBox;
|
highlightGroupBox = new QGroupBox;
|
||||||
highlightGroupBox->setLayout(highlightNotice);
|
highlightGroupBox->setLayout(highlightNotice);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@ void ShortcutSettingsPage::retranslateUi()
|
||||||
currentActionGroupLabel->setText(tr("Section:"));
|
currentActionGroupLabel->setText(tr("Section:"));
|
||||||
currentActionLabel->setText(tr("Action:"));
|
currentActionLabel->setText(tr("Action:"));
|
||||||
currentShortcutLabel->setText(tr("Shortcut:"));
|
currentShortcutLabel->setText(tr("Shortcut:"));
|
||||||
|
editShortcutGroupBox->setTitle(tr("Shortcut editor"));
|
||||||
editTextBox->retranslateUi();
|
editTextBox->retranslateUi();
|
||||||
faqLabel->setText(QString("<a href='%1'>%2</a>").arg(WIKI_CUSTOM_SHORTCUTS).arg(tr("How to set custom shortcuts")));
|
faqLabel->setText(QString("<a href='%1'>%2</a>").arg(WIKI_CUSTOM_SHORTCUTS).arg(tr("How to set custom shortcuts")));
|
||||||
btnResetAll->setText(tr("Restore all default shortcuts"));
|
btnResetAll->setText(tr("Restore all default shortcuts"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue