Skip to content

Commit 710634d

Browse files
committed
Fix: set default signal/image title to file name instead of relative path
Fix #165
1 parent 7203654 commit 710634d

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ See DataLab [roadmap page](https://datalab-platform.com/en/contributing/roadmap.
2020
* Fixed [Issue #162](https://github.com./DataLab-Platform/DataLab/issues/162) - View in a new window: when displaying multiple images, the item list panel should be visible
2121
* Fixed [Issue #163](https://github.com./DataLab-Platform/DataLab/issues/163) - Open from directory: expected one group per folder when loading multiple files
2222
* Fixed [Issue #164](https://github.com./DataLab-Platform/DataLab/issues/164) - Open from directory: unsupported files should be ignored when loading files recursively, to avoid warning popup dialog boxes
23+
* Fixed [Issue #165](https://github.com./DataLab-Platform/DataLab/issues/165) - When opening a file, the default signal/image title must be set to the file name, instead of the relative path to the file name
2324

2425
## DataLab Version 0.19.0 ##
2526

cdl/core/gui/panel/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,6 @@ def __load_from_file(
875875
# Create a new group if more than one object is loaded
876876
group_id = self.add_group(osp.basename(filename)).uuid
877877
for obj in objs:
878-
obj.metadata["source"] = filename
879878
if add_objects:
880879
self.add_object(obj, group_id=group_id, set_current=obj is objs[-1])
881880
self.selection_changed()

cdl/core/io/image/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from __future__ import annotations
88

99
import abc
10+
import os.path as osp
1011

1112
import numpy as np
1213

1314
from cdl.config import _
1415
from cdl.core.io.base import BaseIORegistry, FormatBase
1516
from cdl.core.model.image import ImageObj, create_image
1617
from cdl.utils.qthelpers import CallbackWorker
17-
from cdl.utils.strings import reduce_path
1818

1919

2020
class ImageIORegistry(BaseIORegistry):
@@ -43,10 +43,10 @@ def create_object(filename: str, index: int | None = None) -> ImageObj:
4343
Returns:
4444
Image object
4545
"""
46-
name = reduce_path(filename)
46+
name = osp.basename(filename)
4747
if index is not None:
4848
name += f" {index:02d}"
49-
return create_image(name)
49+
return create_image(name, metadata={"source": filename})
5050

5151
def read(
5252
self, filename: str, worker: CallbackWorker | None = None

cdl/core/io/signal/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
from __future__ import annotations
1010

1111
import abc
12+
import os.path as osp
1213

1314
import numpy as np
1415

1516
from cdl.config import _
1617
from cdl.core.io.base import BaseIORegistry, FormatBase
1718
from cdl.core.model.signal import SignalObj, create_signal
1819
from cdl.utils.qthelpers import CallbackWorker
19-
from cdl.utils.strings import reduce_path
2020

2121

2222
class SignalIORegistry(BaseIORegistry):
@@ -47,10 +47,10 @@ def create_object(filename: str, index: int | None = None) -> SignalObj:
4747
Returns:
4848
Signal object
4949
"""
50-
name = reduce_path(filename)
50+
name = osp.basename(filename)
5151
if index is not None:
5252
name += f" {index:02d}"
53-
return create_signal(name)
53+
return create_signal(name, metadata={"source": filename})
5454

5555
def create_signal(
5656
self, xydata: np.ndarray, filename: str, index: int | None = None

doc/locale/fr/LC_MESSAGES/contributing/changelog.po

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: DataLab \n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-04-08 10:22+0200\n"
10+
"POT-Creation-Date: 2025-04-08 11:05+0200\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language: fr\n"
@@ -69,9 +69,11 @@ msgstr "Correction de l'[Issue #162](https://github.com./DataLab-Platform/DataLab
6969
msgid "Fixed [Issue #163](https://github.com./DataLab-Platform/DataLab/issues/163) - Open from directory: expected one group per folder when loading multiple files"
7070
msgstr "Ceci corrige l'[Issue #163](https://github.com./DataLab-Platform/DataLab/issues/163) - Ouvrir depuis le répertoire : un groupe par dossier attendu lors du chargement de plusieurs fichiers"
7171

72-
#, fuzzy
7372
msgid "Fixed [Issue #164](https://github.com./DataLab-Platform/DataLab/issues/164) - Open from directory: unsupported files should be ignored when loading files recursively, to avoid warning popup dialog boxes"
74-
msgstr "Ceci corrige l'[Issue #163](https://github.com./DataLab-Platform/DataLab/issues/163) - Ouvrir depuis le répertoire : un groupe par dossier attendu lors du chargement de plusieurs fichiers"
73+
msgstr "Ceci corrige l'[Issue #164](https://github.com./DataLab-Platform/DataLab/issues/164) - Ouvrir depuis le répertoire : les fichiers non pris en charge doivent être ignorés lors du chargement de fichiers de manière récursive, pour éviter les boîtes de dialogue d'avertissement"
74+
75+
msgid "Fixed [Issue #165](https://github.com./DataLab-Platform/DataLab/issues/165) - When opening a file, the default signal/image title must be set to the file name, instead of the relative path to the file name"
76+
msgstr "Correction de l'[Issue #165](https://github.com./DataLab-Platform/DataLab/issues/165) - Lors de l'ouverture d'un fichier, le titre par défaut du signal/image doit être défini sur le nom du fichier, au lieu du chemin relatif au nom du fichier"
7577

7678
msgid "DataLab Version 0.19.0"
7779
msgstr "DataLab Version 0.19.0"
@@ -2212,4 +2214,3 @@ msgstr "Symétrie (verticale/horizontale)"
22122214

22132215
msgid "Console: added configurable external editor (default: VSCode) to follow the traceback links to the source code"
22142216
msgstr "Console : ajout d'un éditeur externe configurable (par défaut : VSCode) pour suivre les liens de poursuite vers le code source"
2215-

0 commit comments

Comments
 (0)