Add wrapper for PahEdit edit function to accept "~" as $HOME
This commit is contained in:
parent
d077e2bc24
commit
3c148d8093
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue