mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-22 00:26:37 -05:00
Keep search focus when changing map list tabs
This commit is contained in:
@@ -380,7 +380,7 @@ private:
|
||||
|
||||
void updateMapList();
|
||||
void openMapListItem(const QModelIndex &index);
|
||||
void saveMapListTab(int index);
|
||||
void onMapListTabChanged(int index);
|
||||
|
||||
void displayMapProperties();
|
||||
void checkToolButtons();
|
||||
|
||||
@@ -37,6 +37,8 @@ public:
|
||||
void setFilterLocked(bool locked) { m_filterLocked = locked; }
|
||||
bool isFilterLocked() const { return m_filterLocked; }
|
||||
|
||||
void setSearchFocus();
|
||||
|
||||
signals:
|
||||
void filterCleared(MapTree*);
|
||||
void addFolderClicked();
|
||||
|
||||
@@ -454,7 +454,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::currentChanged, this, &MainWindow::saveMapListTab);
|
||||
connect(ui->mapListContainer, &QTabWidget::currentChanged, this, &MainWindow::onMapListTabChanged);
|
||||
}
|
||||
|
||||
void MainWindow::updateWindowTitle() {
|
||||
@@ -1465,8 +1465,15 @@ void MainWindow::currentMetatilesSelectionChanged() {
|
||||
scrollMetatileSelectorToSelection();
|
||||
}
|
||||
|
||||
void MainWindow::saveMapListTab(int index) {
|
||||
void MainWindow::onMapListTabChanged(int index) {
|
||||
// Save current tab for future sessions.
|
||||
porymapConfig.mapListTab = 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 = getCurrentMapListToolBar();
|
||||
if (toolbar) toolbar->setSearchFocus();
|
||||
}
|
||||
|
||||
void MainWindow::openMapListItem(const QModelIndex &index) {
|
||||
|
||||
@@ -139,3 +139,7 @@ void MapListToolBar::applyFilter(const QString &filterText) {
|
||||
void MapListToolBar::clearFilter() {
|
||||
applyFilter("");
|
||||
}
|
||||
|
||||
void MapListToolBar::setSearchFocus() {
|
||||
ui->lineEdit_filterBox->setFocus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user