Make F6 switch to search tab if it's already open
The action tools_filesearch
(“Search and replace in files”, bound to F6 by default) opens the Search and Replace tab, but if the tab is already open it just does nothing.
This PR makes the action switch to the Search and Replace tab if it is already open.
What appears to have happened is that
-
LokalizeMainWindow::showFileSearch
has theactivate
argument, defaulting to true - We connect the menu item to
LokalizeMainWindow::showFileSearch
on theQAction::triggered
signal (lokalizemainwindow.cpp#L512) - The
QAction::triggered
signal also includeschecked
, which is true if the action is checkable and checked, false otherwise. As the menu item is not checkable, this is always false. - The
checked
value gets passed toLokalizeMainWindow::showFileSearch
as it's also a boolean. - So
LokalizeMainWindow::showFileSearch
always gets called with an explicit false argument when run through the menu. It still activates the tab in the code path creating the tab, but not if the tab doesn't need to be created.
This PR creates a new wrapper function that just calls LokalizeMainWindow::showFileSearch
without accepting the signal's parameters[1]. I've made it call LokalizeMainWindow::showFileSearch
with an explicit true for good measure to make it more clear that this isn't just unnecessary indirection.
[1]:
The signals and slots mechanism is type safe: The signature of a signal must match the signature of the receiving slot. (In fact a slot may have a shorter signature than the signal it receives because it can ignore extra arguments.)