diff --git a/datalab/config/options.py b/datalab/config/options.py index bb6d16336..92ae930b1 100644 --- a/datalab/config/options.py +++ b/datalab/config/options.py @@ -153,7 +153,10 @@ def __init__(self) -> None: category="main", default=True, expected_type=bool, - description="If True, show the welcome page at startup.", + description=( + "If True, show the welcome page at startup and whenever the " + "current signal or image panel is empty." + ), ) self.v020_plugins_warning_ignore = TypedOptionField( self, diff --git a/datalab/gui/main.py b/datalab/gui/main.py index f28814918..9d126fee8 100644 --- a/datalab/gui/main.py +++ b/datalab/gui/main.py @@ -770,8 +770,7 @@ def execute_post_show_actions(self) -> None: if not execenv.unattended: if not Conf.welcome_on_startup.get(): self.docks[self.welcomepanel].hide() - elif not any(len(p) for p in (self.signalpanel, self.imagepanel)): - self.show_welcome_page() + self.__raise_view_dock(self.tabwidget.currentWidget()) # Auto-start WebAPI server if environment variable is set if os.environ.get("DATALAB_WEBAPI_ENABLED") == "1": try: @@ -1247,6 +1246,9 @@ def _setup_panels(self) -> None: panel.objview.SIG_SELECTION_CHANGED.connect( functools.partial(self.__raise_view_dock, panel) ) + panel.SIG_OBJECT_REMOVED.connect( + functools.partial(self.__raise_view_dock, panel) + ) panel.setup_panel() def _setup_central_widget(self) -> None: @@ -1624,20 +1626,24 @@ def __update_actions(self, update_other_data_panel: bool = False) -> None: def __tab_index_changed(self, index: int) -> None: """Switch from signal to image mode, or vice-versa""" - dock = self.docks[self.tabwidget.widget(index)] - dock.raise_() + self.__raise_view_dock(self.tabwidget.widget(index)) self.__update_actions() def __raise_view_dock(self, panel: BaseDataPanel) -> None: """Bring the panel view dock to the front, if the panel is the current tab + An empty panel shows the welcome page instead, unless it is disabled. + Args: panel: signal or image panel """ # The guard matters because selection changes are also emitted for the # panel that is not currently shown (see __update_actions). if self.tabwidget.currentWidget() is panel: - self.docks[panel].raise_() + if len(panel) == 0 and Conf.welcome_on_startup.get(): + self.show_welcome_page() + else: + self.docks[panel].raise_() def __update_generic_menu(self, menu: QW.QMenu | None = None) -> None: """Update menu before showing up -- Generic method""" diff --git a/datalab/gui/settings.py b/datalab/gui/settings.py index ba59a042f..115922bfc 100644 --- a/datalab/gui/settings.py +++ b/datalab/gui/settings.py @@ -33,10 +33,11 @@ class MainSettings(gds.DataSet): ) welcome_on_startup = gds.BoolItem( "", - _("Show welcome page on startup"), + _("Show welcome page when the current panel is empty"), help=_( "The welcome page gathers the main actions to get started " - "(create or open data, guided tour, documentation...)." + "(create or open data, guided tour, documentation...). It is shown " + "at startup and whenever the current signal or image panel is empty." ), ) process_isolation_enabled = gds.BoolItem( diff --git a/datalab/gui/welcome.py b/datalab/gui/welcome.py index 0aa476e24..c1692f871 100644 --- a/datalab/gui/welcome.py +++ b/datalab/gui/welcome.py @@ -142,7 +142,9 @@ def __init__( self.entries: dict[str, WelcomeEntry] = {} self.start_title = self.__create_section_title("") self.columns_layout = QW.QBoxLayout(QW.QBoxLayout.LeftToRight) - self.startup_checkbox = QW.QCheckBox(_("Show welcome page on startup")) + self.startup_checkbox = QW.QCheckBox( + _("Show welcome page when the current panel is empty") + ) self.startup_checkbox.setChecked(Conf.welcome_on_startup.get()) self.startup_checkbox.toggled.connect(Conf.welcome_on_startup.set) self.__setup_ui() diff --git a/datalab/locale/fr/LC_MESSAGES/datalab.po b/datalab/locale/fr/LC_MESSAGES/datalab.po index a432b1268..9f7ef6631 100644 --- a/datalab/locale/fr/LC_MESSAGES/datalab.po +++ b/datalab/locale/fr/LC_MESSAGES/datalab.po @@ -4159,11 +4159,11 @@ msgstr "Aucun contour n'a été trouvé pour la plage de niveaux sélectionnée. msgid "Show contour plot..." msgstr "Afficher le tracé de contours..." -msgid "Show welcome page on startup" -msgstr "Afficher la page d'accueil au démarrage" +msgid "Show welcome page when the current panel is empty" +msgstr "Afficher la page d'accueil lorsque le panneau courant est vide" -msgid "The welcome page gathers the main actions to get started (create or open data, guided tour, documentation...)." -msgstr "La page d'accueil rassemble les principales actions pour bien démarrer (créer ou ouvrir des données, visite guidée, documentation...)." +msgid "The welcome page gathers the main actions to get started (create or open data, guided tour, documentation...). It is shown at startup and whenever the current signal or image panel is empty." +msgstr "La page d'accueil rassemble les principales actions pour bien démarrer (créer ou ouvrir des données, visite guidée, documentation...). Elle est affichée au démarrage et chaque fois que le panneau signal ou image courant est vide." msgid "Welcome" msgstr "Accueil" diff --git a/datalab/tests/features/common/welcome_unit_test.py b/datalab/tests/features/common/welcome_unit_test.py index 888a4e57d..6726c304d 100644 --- a/datalab/tests/features/common/welcome_unit_test.py +++ b/datalab/tests/features/common/welcome_unit_test.py @@ -6,7 +6,9 @@ from __future__ import annotations +import numpy as np from qtpy import QtWidgets as QW +from sigima.objects import create_signal import datalab from datalab.config import Conf, _ @@ -106,3 +108,38 @@ def create_gaussian(menu: QW.QMenu, *_args) -> None: assert Conf.welcome_on_startup.get() is (not initial) finally: Conf.welcome_on_startup.set(initial) + + +def test_welcome_page_follows_empty_current_panel() -> None: + """The welcome page replaces the view of an empty current panel""" + x = np.linspace(0.0, 1.0, 10) + with datalab_test_app_context(console=False) as win: + docks = [win.docks[win.welcomepanel]] + docks += [win.docks[panel] for panel in (win.signalpanel, win.imagepanel)] + welcome_dock, signal_dock, image_dock = docks + + def front_dock() -> QW.QDockWidget: + QW.QApplication.processEvents() + (dock,) = [dock for dock in docks if is_in_front(dock)] + return dock + + assert front_dock() is welcome_dock + win.signalpanel.add_object(create_signal("Signal 1", x, x)) + assert front_dock() is signal_dock + win.set_current_panel("image") + assert front_dock() is welcome_dock + win.set_current_panel("signal") + assert front_dock() is signal_dock + win.signalpanel.remove_all_objects() + assert front_dock() is welcome_dock + + # A closed welcome page is opened again when the current panel is empty + win.signalpanel.add_object(create_signal("Signal 2", x, x)) + welcome_dock.close() + win.set_current_panel("image") + assert welcome_dock.isVisible() and front_dock() is welcome_dock + + Conf.welcome_on_startup.set(False) + win.set_current_panel("signal") + win.set_current_panel("image") + assert front_dock() is image_dock diff --git a/doc/features/common/overview.rst b/doc/features/common/overview.rst index d8161e05c..3f793091d 100644 --- a/doc/features/common/overview.rst +++ b/doc/features/common/overview.rst @@ -36,8 +36,7 @@ panel (see :ref:`about_macros`) and the :ref:`ai_assistant`. Welcome page ^^^^^^^^^^^^ -When DataLab starts with an empty workspace, a **Welcome** page is shown next to -the signal and image views. It gathers the main actions to get started: +A **Welcome** page is shown next to the signal and image views when DataLab starts, and whenever the current signal or image panel is empty (for example after switching to an empty panel or deleting its last object). It gathers the main actions to get started: - create a signal or an image from a template, open signal or image files, browse an HDF5 file, open a previously saved HDF5 workspace, or import text @@ -46,13 +45,7 @@ the signal and image views. It gathers the main actions to get started: - ask the :ref:`ai_assistant`, take the guided tour, run the demo, read the online documentation, or browse the release notes of the running version. -The Welcome page is a regular dockable panel: as soon as a signal or an image is -created or opened, the corresponding view is brought to the front, and the -Welcome page remains available as a tab. It may be closed like any other panel, -and reopened at any time from the "Welcome page" entry of the "?" (Help) menu or -from the "View" menu. The "Show welcome page on startup" check box, at the bottom -of the page, controls whether the page is shown when DataLab starts (this option -is also available in the :ref:`settings`). +The Welcome page is a regular dockable panel: as soon as a signal or an image is created or opened, the corresponding view is brought to the front, and the Welcome page remains available as a tab. It may be closed like any other panel, and reopened at any time from the "Welcome page" entry of the "?" (Help) menu or from the "View" menu; it is also reopened automatically when the current panel becomes empty. The "Show welcome page when the current panel is empty" check box, at the bottom of the page, controls this automatic display, including at startup (this option is also available in the :ref:`settings`). .. _command_palette: diff --git a/doc/features/common/settings.rst b/doc/features/common/settings.rst index 4e4c8de57..c19ff2af4 100644 --- a/doc/features/common/settings.rst +++ b/doc/features/common/settings.rst @@ -23,9 +23,8 @@ The General settings tab contains main window and general feature settings: **Color mode** Choose the color mode for the application interface (e.g., light, dark, or auto). -**Show welcome page on startup** - When enabled (default), the welcome page is shown when DataLab starts with an empty - workspace (see :ref:`welcome_page`). +**Show welcome page when the current panel is empty** + When enabled (default), the welcome page is shown when DataLab starts and whenever the current signal or image panel is empty (see :ref:`welcome_page`). **Process isolation** When enabled, each computation runs in a separate process, preventing the application diff --git a/doc/locale/fr/LC_MESSAGES/features/common/overview.po b/doc/locale/fr/LC_MESSAGES/features/common/overview.po index dbcbe2641..838414ec7 100644 --- a/doc/locale/fr/LC_MESSAGES/features/common/overview.po +++ b/doc/locale/fr/LC_MESSAGES/features/common/overview.po @@ -39,8 +39,8 @@ msgstr "D'autres panneaux sont disponibles sous forme de widgets ancrables, et p msgid "Welcome page" msgstr "Page d'accueil" -msgid "When DataLab starts with an empty workspace, a **Welcome** page is shown next to the signal and image views. It gathers the main actions to get started:" -msgstr "Lorsque DataLab démarre avec un espace de travail vide, une page d'**Accueil** est affichée à côté des vues signal et image. Elle rassemble les principales actions pour bien démarrer :" +msgid "A **Welcome** page is shown next to the signal and image views when DataLab starts, and whenever the current signal or image panel is empty (for example after switching to an empty panel or deleting its last object). It gathers the main actions to get started:" +msgstr "Une page d'**Accueil** est affichée à côté des vues signal et image au démarrage de DataLab, et chaque fois que le panneau signal ou image courant est vide (par exemple après le passage à un panneau vide ou la suppression de son dernier objet). Elle rassemble les principales actions pour bien démarrer :" msgid "create a signal or an image from a template, open signal or image files, browse an HDF5 file, open a previously saved HDF5 workspace, or import text data (CSV, TSV, ...) with the import wizard. When needed, a menu lets you choose between signals and images;" msgstr "créer un signal ou une image à partir d'un modèle, ouvrir des fichiers de signaux ou d'images, parcourir un fichier HDF5, ouvrir un espace de travail HDF5 précédemment enregistré, ou importer des données texte (CSV, TSV, ...) avec l'assistant d'importation. Si nécessaire, un menu permet de choisir entre signaux et images ;" @@ -48,8 +48,8 @@ msgstr "créer un signal ou une image à partir d'un modèle, ouvrir des fichier msgid "ask the :ref:`ai_assistant`, take the guided tour, run the demo, read the online documentation, or browse the release notes of the running version." msgstr "interroger l':ref:`ai_assistant`, suivre la visite guidée, lancer la démo, lire la documentation en ligne, ou consulter les notes de version de la version en cours d'exécution." -msgid "The Welcome page is a regular dockable panel: as soon as a signal or an image is created or opened, the corresponding view is brought to the front, and the Welcome page remains available as a tab. It may be closed like any other panel, and reopened at any time from the \"Welcome page\" entry of the \"?\" (Help) menu or from the \"View\" menu. The \"Show welcome page on startup\" check box, at the bottom of the page, controls whether the page is shown when DataLab starts (this option is also available in the :ref:`settings`)." -msgstr "La page d'accueil est un panneau ancrable comme les autres : dès qu'un signal ou une image est créé ou ouvert, la vue correspondante passe au premier plan, et la page d'accueil reste disponible sous forme d'onglet. Elle peut être fermée comme n'importe quel autre panneau, et rouverte à tout moment depuis l'entrée « Page d'accueil » du menu « ? » (Aide) ou depuis le menu « Affichage ». La case à cocher « Afficher la page d'accueil au démarrage », en bas de la page, détermine si la page est affichée au démarrage de DataLab (cette option est également disponible dans les :ref:`settings`)." +msgid "The Welcome page is a regular dockable panel: as soon as a signal or an image is created or opened, the corresponding view is brought to the front, and the Welcome page remains available as a tab. It may be closed like any other panel, and reopened at any time from the \"Welcome page\" entry of the \"?\" (Help) menu or from the \"View\" menu; it is also reopened automatically when the current panel becomes empty. The \"Show welcome page when the current panel is empty\" check box, at the bottom of the page, controls this automatic display, including at startup (this option is also available in the :ref:`settings`)." +msgstr "La page d'accueil est un panneau ancrable comme les autres : dès qu'un signal ou une image est créé ou ouvert, la vue correspondante passe au premier plan, et la page d'accueil reste disponible sous forme d'onglet. Elle peut être fermée comme n'importe quel autre panneau, et rouverte à tout moment depuis l'entrée « Page d'accueil » du menu « ? » (Aide) ou depuis le menu « Affichage » ; elle est aussi rouverte automatiquement lorsque le panneau courant devient vide. La case à cocher « Afficher la page d'accueil lorsque le panneau courant est vide », en bas de la page, détermine cet affichage automatique, y compris au démarrage (cette option est également disponible dans les :ref:`settings`)." msgid "Command palette" msgstr "Palette de commandes" diff --git a/doc/locale/fr/LC_MESSAGES/features/common/settings.po b/doc/locale/fr/LC_MESSAGES/features/common/settings.po index 1664bfd70..f2e5579af 100644 --- a/doc/locale/fr/LC_MESSAGES/features/common/settings.po +++ b/doc/locale/fr/LC_MESSAGES/features/common/settings.po @@ -36,11 +36,11 @@ msgstr "**Mode couleur**" msgid "Choose the color mode for the application interface (e.g., light, dark, or auto)." msgstr "Choisir le mode couleur de l'interface de l'application (par exemple, clair, sombre ou automatique)." -msgid "**Show welcome page on startup**" -msgstr "**Afficher la page d'accueil au démarrage**" +msgid "**Show welcome page when the current panel is empty**" +msgstr "**Afficher la page d'accueil lorsque le panneau courant est vide**" -msgid "When enabled (default), the welcome page is shown when DataLab starts with an empty workspace (see :ref:`welcome_page`)." -msgstr "Lorsque cette option est activée (par défaut), la page d'accueil est affichée lorsque DataLab démarre avec un espace de travail vide (voir :ref:`welcome_page`)." +msgid "When enabled (default), the welcome page is shown when DataLab starts and whenever the current signal or image panel is empty (see :ref:`welcome_page`)." +msgstr "Lorsque cette option est activée (par défaut), la page d'accueil est affichée au démarrage de DataLab et chaque fois que le panneau signal ou image courant est vide (voir :ref:`welcome_page`)." msgid "**Process isolation**" msgstr "**Isolation des processus**" diff --git a/doc/locale/fr/LC_MESSAGES/release_notes/release_1.04.po b/doc/locale/fr/LC_MESSAGES/release_notes/release_1.04.po index 8eaa4aad3..b4f86cb74 100644 --- a/doc/locale/fr/LC_MESSAGES/release_notes/release_1.04.po +++ b/doc/locale/fr/LC_MESSAGES/release_notes/release_1.04.po @@ -24,14 +24,14 @@ msgstr "✨ Nouvelles fonctionnalités" msgid "**Welcome page:**" msgstr "**Page d'accueil :**" -msgid "A new **Welcome** page, similar to the one of DataLab-Web, is shown at startup when the workspace is empty. It gathers the main actions to get started: create a signal or an image, open files, browse an HDF5 file, open an HDF5 workspace, import text data, ask the AI Assistant, take the guided tour, run the demo, read the documentation or browse the release notes" -msgstr "Une nouvelle page d'**Accueil**, semblable à celle de DataLab-Web, est affichée au démarrage lorsque l'espace de travail est vide. Elle rassemble les principales actions pour bien démarrer : créer un signal ou une image, ouvrir des fichiers, parcourir un fichier HDF5, ouvrir un espace de travail HDF5, importer des données texte, interroger l'assistant IA, suivre la visite guidée, lancer la démo, lire la documentation ou consulter les notes de version" +msgid "A new **Welcome** page, similar to the one of DataLab-Web, is shown at startup and whenever the current signal or image panel is empty. It gathers the main actions to get started: create a signal or an image, open files, browse an HDF5 file, open an HDF5 workspace, import text data, ask the AI Assistant, take the guided tour, run the demo, read the documentation or browse the release notes" +msgstr "Une nouvelle page d'**Accueil**, semblable à celle de DataLab-Web, est affichée au démarrage et chaque fois que le panneau signal ou image courant est vide. Elle rassemble les principales actions pour bien démarrer : créer un signal ou une image, ouvrir des fichiers, parcourir un fichier HDF5, ouvrir un espace de travail HDF5, importer des données texte, interroger l'assistant IA, suivre la visite guidée, lancer la démo, lire la documentation ou consulter les notes de version" msgid "The page is a dockable panel, tabbed with the signal and image views: it remains available after data is created or opened, and can be reopened at any time from the **?** menu (**Welcome page**) or from the **View** menu" msgstr "La page est un panneau ancrable, en onglet avec les vues signal et image : elle reste disponible après la création ou l'ouverture de données, et peut être rouverte à tout moment depuis le menu **?** (**Page d'accueil**) ou depuis le menu **Affichage**" -msgid "A **Show welcome page on startup** option, available on the page itself and in the General settings, controls whether the page is shown at startup" -msgstr "Une option **Afficher la page d'accueil au démarrage**, disponible sur la page elle-même et dans les paramètres généraux, détermine si la page est affichée au démarrage" +msgid "A **Show welcome page when the current panel is empty** option, available on the page itself and in the General settings, controls whether the page is shown automatically, including at startup" +msgstr "Une option **Afficher la page d'accueil lorsque le panneau courant est vide**, disponible sur la page elle-même et dans les paramètres généraux, détermine si la page est affichée automatiquement, y compris au démarrage" msgid "**Brightness and contrast:**" msgstr "**Luminosité et contraste :**" diff --git a/doc/release_notes/release_1.04.md b/doc/release_notes/release_1.04.md index d07c66545..e9c41f959 100644 --- a/doc/release_notes/release_1.04.md +++ b/doc/release_notes/release_1.04.md @@ -6,9 +6,9 @@ **Welcome page:** -* A new **Welcome** page, similar to the one of DataLab-Web, is shown at startup when the workspace is empty. It gathers the main actions to get started: create a signal or an image, open files, browse an HDF5 file, open an HDF5 workspace, import text data, ask the AI Assistant, take the guided tour, run the demo, read the documentation or browse the release notes +* A new **Welcome** page, similar to the one of DataLab-Web, is shown at startup and whenever the current signal or image panel is empty. It gathers the main actions to get started: create a signal or an image, open files, browse an HDF5 file, open an HDF5 workspace, import text data, ask the AI Assistant, take the guided tour, run the demo, read the documentation or browse the release notes * The page is a dockable panel, tabbed with the signal and image views: it remains available after data is created or opened, and can be reopened at any time from the **?** menu (**Welcome page**) or from the **View** menu -* A **Show welcome page on startup** option, available on the page itself and in the General settings, controls whether the page is shown at startup +* A **Show welcome page when the current panel is empty** option, available on the page itself and in the General settings, controls whether the page is shown automatically, including at startup **Brightness and contrast:**