diff --git a/README.md b/README.md index d237003..b64a694 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The search bar appears next to the [`What's this?`](https://wiki.freecad.org/Std  When using the search bar for the first time, it will contain only the tools of the workbenches which have already been loaded in FreeCAD. -To include results from other workbenches, select the first search result "Refresh list of tools" which will load all FreeCAD workbenches +To include results from other workbenches, select the first search result "Refresh cached results" which will load all FreeCAD workbenches and memorize their tools. After restarting FreeCAD, the search result will include the memorized tools, even if the workbenches have not been loaded yet. When selecting a tool from the search results, SearchBar will attempt to automatically load the workbenches which could have provided that tool. diff --git a/RefreshTools.py b/RefreshTools.py index 0f5db32..8c08dc8 100644 --- a/RefreshTools.py +++ b/RefreshTools.py @@ -93,7 +93,7 @@ def refreshToolbars(doLoadAllWorkbenches=True): def refreshToolsAction(): from PySide import QtGui - print("Refresh list of tools") + print("Refresh cached results") fw = QtGui.QApplication.focusWidget() if fw is not None: fw.clearFocus() @@ -102,7 +102,7 @@ def refreshToolsAction(): translate("SearchBar", "Load all workbenches?"), translate( "SearchBar", - 'Load all workbenches? This can cause FreeCAD to become unstable, and this "reload tools" feature contained a bug that crashed freecad systematically, so please make sure you save your work before. It\'s a good idea to restart FreeCAD after this operation.', + """Load all workbenches? This can cause FreeCAD to become unstable, and this "reload tools" feature contained a bug that crashed freecad systematically, so please make sure you save your work before. It\'s a good idea to restart FreeCAD after this operation.""", ), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No, diff --git a/ResultsRefreshTools.py b/ResultsRefreshTools.py index a4267f8..9ac924f 100644 --- a/ResultsRefreshTools.py +++ b/ResultsRefreshTools.py @@ -24,7 +24,7 @@ def refreshToolsToolTip(nfo, setParent): + "
" + translate( "SearchBar", - "Load all workbenches to refresh this list of tools. This may take a minute, depending on the number of installed workbenches.", + "Load all workbenches to refresh the cached results. This may take a minute, depending on the number of installed workbenches.", ) + "
" ) @@ -34,7 +34,7 @@ def refreshToolsResultsProvider(): return [ { "icon": genericToolIcon, - "text": "Refresh list of tools", + "text": translate("SearchBar", "Refresh cached results"), "toolTip": "", "action": {"handler": "refreshTools"}, "subitems": [], diff --git a/SearchBox.py b/SearchBox.py index 8e44b47..254a5fa 100644 --- a/SearchBox.py +++ b/SearchBox.py @@ -122,8 +122,12 @@ class SearchBox(QLineEdit): self.pendingExtraInfo = None self.currentExtraInfo = None # Connect signals and slots - self.listView.clicked.connect(lambda x: self.selectResult("select", x)) - # self.listView.selectionModel().selectionChanged.connect(self.onSelectionChanged) + self.listView.clicked.connect( + lambda x: self.selectResult("select", x) + ) # This makes all workbenches appear. TODO: findout why, a click event seems not logic + self.listView.selectionModel().selectionChanged.connect( + self.onSelectionChanged + ) # This updates the details when using the keyboard # Add custom mouse events. On windows the click events were not working for Searcbar versions 1.2.x and older. # These events and their proxies in the SearchBorLight fixes this self.listView.mousePressEvent = lambda event: self.proxyMousePressEvent(event) @@ -447,6 +451,22 @@ class SearchBox(QLineEdit): self.listView.setGeometry(x, y, w, h) self.extraInfo.setGeometry(extrax, y, extraw, h) + @staticmethod + def proxyOnSelectionChanged(self, selected, deselected): + # The list has .setSelectionMode(QAbstractItemView.SingleSelection), + # so there is always at most one index in selected.indexes() and at most one + # index in deselected.indexes() + selected = selected.indexes() + deselected = deselected.indexes() + if len(selected) > 0: + index = selected[0] + self.setExtraInfo(index) + # Poor attempt to circumvent a glitch where the extra info pane stays visible after pressing Return + if not self.listView.isHidden(): + self.showExtraInfo() + elif len(deselected) > 0: + self.hideExtraInfo() + @staticmethod def setExtraInfo(self, index): if self.currentExtraInfo == (index.row(), index.column(), index.model()): diff --git a/SearchBoxLight.py b/SearchBoxLight.py index 9a32661..2c17826 100644 --- a/SearchBoxLight.py +++ b/SearchBoxLight.py @@ -63,8 +63,8 @@ class SearchBoxLight(QtGui.QLineEdit): def keyPressEvent(self, *args, **kwargs): return self.proxyKeyPressEvent(*args, **kwargs) - # def onSelectionChanged(self, *args, **kwargs): - # return self.proxyOnSelectionChanged(*args, **kwargs) + def onSelectionChanged(self, *args, **kwargs): + return self.proxyOnSelectionChanged(*args, **kwargs) def filterModel(self, *args, **kwargs): return self.proxyFilterModel(*args, **kwargs) diff --git a/package.xml b/package.xml index c6e15d8..64bffdb 100644 --- a/package.xml +++ b/package.xml @@ -5,7 +5,7 @@