diff --git a/rare/utils/extra_widgets.py b/rare/utils/extra_widgets.py index 28d8b7a9..bba1a1f0 100644 --- a/rare/utils/extra_widgets.py +++ b/rare/utils/extra_widgets.py @@ -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):