Fix map list search bar stealing keyboard focus
Some checks failed
Build Porymap / build-linux (, 5.14.2) (push) Has been cancelled
Build Porymap / build-linux (, 6.8.*) (push) Has been cancelled
Build Porymap / build-linux (minimal, 5.14.2) (push) Has been cancelled
Build Porymap / build-macos (macos-15-intel) (push) Has been cancelled
Build Porymap / build-macos (macos-latest) (push) Has been cancelled
Build Porymap / build-static-windows (push) Has been cancelled

This commit is contained in:
GriffinR
2026-05-03 21:39:08 -04:00
parent 567e168bd5
commit a4b8dd70e6
3 changed files with 13 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
- Fix the tool tips for the tileset selectors always listing the same tileset size.
- Fix not being able to minimize/maximize some windows.
- Fix some menu items under `Tools` not being disabled when their corresponding button is disabled.
- Fix the map list search bar stealing keyboard focus whenever a map layout was opened.
## [6.3.1] - 2026-04-12
### Added

View File

@@ -406,6 +406,7 @@ private:
void updateMapList();
void openMapListItem(const QModelIndex &index);
void setMapListTab(int index);
void onMapListTabClicked(int index);
QString getActiveItemName();
void recordMapNavigation(const QString &itemName);
void resetMapNavigation();

View File

@@ -605,7 +605,7 @@ void MainWindow::initMapList() {
connect(ui->mapListToolBar_Locations, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewLocationDialog);
connect(ui->mapListToolBar_Layouts, &MapListToolBar::addFolderClicked, this, &MainWindow::openNewLayoutDialog);
connect(ui->mapListContainer, &QTabWidget::tabBarClicked, this, &MainWindow::setMapListTab);
connect(ui->mapListContainer, &QTabWidget::tabBarClicked, this, &MainWindow::onMapListTabClicked);
}
void MainWindow::updateWindowTitle() {
@@ -1878,6 +1878,16 @@ void MainWindow::currentMetatilesSelectionChanged() {
scrollMetatileSelectorToSelection();
}
void MainWindow::onMapListTabClicked(int index) {
setMapListTab(index);
// After changing a map list tab the old tab's search widget can keep focus, which isn't helpful
// (and might be a little confusing to the user, because they don't know that each search bar is secretly a separate object).
// When we change tabs we'll automatically focus in on the search bar. This should also make finding maps a little quicker.
auto toolbar = getMapListToolBar(index);
if (toolbar) toolbar->setSearchFocus();
}
void MainWindow::setMapListTab(int index) {
auto newToolbar = getMapListToolBar(index);
auto oldToolbar = getMapListToolBar(ui->mapListContainer->currentIndex());
@@ -1885,11 +1895,6 @@ void MainWindow::setMapListTab(int index) {
if (newToolbar && oldToolbar && newToolbar != oldToolbar) {
newToolbar->applyFilter(oldToolbar->filterText());
}
// After changing a map list tab the old tab's search widget can keep focus, which isn't helpful
// (and might be a little confusing to the user, because they don't know that each search bar is secretly a separate object).
// When we change tabs we'll automatically focus in on the search bar. This should also make finding maps a little quicker.
if (newToolbar) newToolbar->setSearchFocus();
}
void MainWindow::openMapListItem(const QModelIndex &index) {