commit
779aeacd99
|
@ -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.
|
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
|
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
|
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.
|
have provided that tool.
|
||||||
|
|
|
@ -93,7 +93,7 @@ def refreshToolbars(doLoadAllWorkbenches=True):
|
||||||
def refreshToolsAction():
|
def refreshToolsAction():
|
||||||
from PySide import QtGui
|
from PySide import QtGui
|
||||||
|
|
||||||
print("Refresh list of tools")
|
print("Refresh cached results")
|
||||||
fw = QtGui.QApplication.focusWidget()
|
fw = QtGui.QApplication.focusWidget()
|
||||||
if fw is not None:
|
if fw is not None:
|
||||||
fw.clearFocus()
|
fw.clearFocus()
|
||||||
|
@ -102,7 +102,7 @@ def refreshToolsAction():
|
||||||
translate("SearchBar", "Load all workbenches?"),
|
translate("SearchBar", "Load all workbenches?"),
|
||||||
translate(
|
translate(
|
||||||
"SearchBar",
|
"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.Yes,
|
||||||
QtGui.QMessageBox.No,
|
QtGui.QMessageBox.No,
|
||||||
|
|
|
@ -24,7 +24,7 @@ def refreshToolsToolTip(nfo, setParent):
|
||||||
+ "<p>"
|
+ "<p>"
|
||||||
+ translate(
|
+ translate(
|
||||||
"SearchBar",
|
"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.",
|
||||||
)
|
)
|
||||||
+ "</p>"
|
+ "</p>"
|
||||||
)
|
)
|
||||||
|
@ -34,7 +34,7 @@ def refreshToolsResultsProvider():
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"icon": genericToolIcon,
|
"icon": genericToolIcon,
|
||||||
"text": "Refresh list of tools",
|
"text": translate("SearchBar", "Refresh cached results"),
|
||||||
"toolTip": "",
|
"toolTip": "",
|
||||||
"action": {"handler": "refreshTools"},
|
"action": {"handler": "refreshTools"},
|
||||||
"subitems": [],
|
"subitems": [],
|
||||||
|
|
24
SearchBox.py
24
SearchBox.py
|
@ -122,8 +122,12 @@ class SearchBox(QLineEdit):
|
||||||
self.pendingExtraInfo = None
|
self.pendingExtraInfo = None
|
||||||
self.currentExtraInfo = None
|
self.currentExtraInfo = None
|
||||||
# Connect signals and slots
|
# Connect signals and slots
|
||||||
self.listView.clicked.connect(lambda x: self.selectResult("select", x))
|
self.listView.clicked.connect(
|
||||||
# self.listView.selectionModel().selectionChanged.connect(self.onSelectionChanged)
|
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.
|
# 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
|
# These events and their proxies in the SearchBorLight fixes this
|
||||||
self.listView.mousePressEvent = lambda event: self.proxyMousePressEvent(event)
|
self.listView.mousePressEvent = lambda event: self.proxyMousePressEvent(event)
|
||||||
|
@ -447,6 +451,22 @@ class SearchBox(QLineEdit):
|
||||||
self.listView.setGeometry(x, y, w, h)
|
self.listView.setGeometry(x, y, w, h)
|
||||||
self.extraInfo.setGeometry(extrax, y, extraw, 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
|
@staticmethod
|
||||||
def setExtraInfo(self, index):
|
def setExtraInfo(self, index):
|
||||||
if self.currentExtraInfo == (index.row(), index.column(), index.model()):
|
if self.currentExtraInfo == (index.row(), index.column(), index.model()):
|
||||||
|
|
|
@ -63,8 +63,8 @@ class SearchBoxLight(QtGui.QLineEdit):
|
||||||
def keyPressEvent(self, *args, **kwargs):
|
def keyPressEvent(self, *args, **kwargs):
|
||||||
return self.proxyKeyPressEvent(*args, **kwargs)
|
return self.proxyKeyPressEvent(*args, **kwargs)
|
||||||
|
|
||||||
# def onSelectionChanged(self, *args, **kwargs):
|
def onSelectionChanged(self, *args, **kwargs):
|
||||||
# return self.proxyOnSelectionChanged(*args, **kwargs)
|
return self.proxyOnSelectionChanged(*args, **kwargs)
|
||||||
|
|
||||||
def filterModel(self, *args, **kwargs):
|
def filterModel(self, *args, **kwargs):
|
||||||
return self.proxyFilterModel(*args, **kwargs)
|
return self.proxyFilterModel(*args, **kwargs)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<description>Adds a search bar widget for tools, document objects, and preferences</description>
|
<description>Adds a search bar widget for tools, document objects, and preferences</description>
|
||||||
|
|
||||||
<version>1.3.1.2</version>
|
<version>1.3.2</version>
|
||||||
|
|
||||||
<date>2022-06-01</date>
|
<date>2022-06-01</date>
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
<content>
|
<content>
|
||||||
<workbench>
|
<workbench>
|
||||||
<name>SearchBar</name>
|
<name>SearchBar</name>
|
||||||
<icon>Resource/Icons/Tango-System-search.svg</icon>
|
<icon>Tango-System-search.svg</icon>
|
||||||
<subdirectory>./</subdirectory>
|
<subdirectory>./</subdirectory>
|
||||||
<tag>search</tag>
|
<tag>search</tag>
|
||||||
<tag>widget</tag>
|
<tag>widget</tag>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user