From a4b8dd70e66753686c2211b64e0c9067b27ee111 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sun, 3 May 2026 21:39:08 -0400 Subject: [PATCH] Fix map list search bar stealing keyboard focus --- CHANGELOG.md | 1 + include/mainwindow.h | 1 + src/mainwindow.cpp | 17 +++++++++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfc99454..72fc8028 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/include/mainwindow.h b/include/mainwindow.h index 96a0f913..1cd1abad 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -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(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c932fa5f..af37c520 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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) {