Fix choosing a file without saving the dir not working on windows

Apparently the data file button in the insert link tool for the comments
editor is the only place this was noticed.
This commit is contained in:
Kovid Goyal 2023-11-24 18:19:08 +05:30
parent 6259565a94
commit 9948d17edc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 2 additions and 3 deletions

View File

@ -838,7 +838,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
is_image = q in {'jpeg', 'png', 'gif', 'webp'} is_image = q in {'jpeg', 'png', 'gif', 'webp'}
d.treat_as_image.setChecked(is_image) d.treat_as_image.setChecked(is_image)
if data_dir: if data_dir:
path = os.path.relpath(path, base) path = os.path.relpath(path, base).replace(os.sep, '/')
d.url.setText(path) d.url.setText(path)
b.clicked.connect(lambda: cf()) b.clicked.connect(lambda: cf())
d.brdf = b = QPushButton(_('&Data file')) d.brdf = b = QPushButton(_('&Data file'))

View File

@ -268,8 +268,7 @@ def choose_files(window, name, title,
ans = run_file_dialog(window, title, allow_multiple=not select_only_single_file, initial_folder=initial_folder, file_types=file_types) ans = run_file_dialog(window, title, allow_multiple=not select_only_single_file, initial_folder=initial_folder, file_types=file_types)
if ans and not no_save_dir: if ans and not no_save_dir:
dynamic.set(name, os.path.dirname(ans[0])) dynamic.set(name, os.path.dirname(ans[0]))
return ans return ans or None
return None
def choose_images(window, name, title, select_only_single_file=True, formats=None): def choose_images(window, name, title, select_only_single_file=True, formats=None):