1
0
Fork 0
mirror of synced 2024-06-26 18:20:50 +12:00

Add wrapper for PahEdit edit function to accept "~" as $HOME

This commit is contained in:
Dummerle 2022-03-15 20:34:39 +01:00
parent d077e2bc24
commit 3c148d8093
No known key found for this signature in database
GPG key ID: AB68CC59CA39F2F1

View file

@ -318,6 +318,9 @@ class PathEdit(IndicatorLineEdit):
self.compl_model.setIconProvider(PathEditIconProvider())
self.compl_model.setRootPath(path)
self.completer.setModel(self.compl_model)
edit_func = self._wrap_edit_function(edit_func)
super(PathEdit, self).__init__(
text=path,
placeholder=placeholder,
@ -357,6 +360,13 @@ class PathEdit(IndicatorLineEdit):
self.line_edit.setText(names[0])
self.compl_model.setRootPath(names[0])
def _wrap_edit_function(self, edit_function: Callable[[str], Tuple[bool, str, str]]):
if edit_function:
return lambda text: edit_function(os.path.expanduser(text)
if text.startswith("~") else text)
else:
return edit_function
class SideTabBar(QTabBar):
def __init__(self, parent=None):