Skip to content

Commit ad644ea

Browse files
committed
Add internal console status indicator to the status bar
1 parent 7a6b435 commit ad644ea

5 files changed

Lines changed: 136 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ See DataLab [roadmap page](https://datalab-platform.com/en/contributing/roadmap.
66

77
💥 New features and enhancements:
88

9+
* Internal console status indicator added to the status bar:
10+
* The status bar now features an indicator for the internal console, visible only when the console is hidden.
11+
* Clicking the indicator opens the internal console.
12+
* The icon turns red if an error or warning is logged, alerting the user to check the console.
13+
914
* New common signal/image feature:
1015
* Added two options for signal and image creation:
1116
* "Use xmin and xmax bounds from current signal when creating a new signal" (default: disabled)

datalab/gui/main.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def __init__(self, console=None, hide_on_close=False):
147147
self.__memory_warning = False
148148
self.memorystatus: status.MemoryStatus | None = None
149149

150+
self.consolestatus: status.ConsoleStatus | None = None
150151
self.console: DockableConsole | None = None
151152
self.macropanel: MacroPanel | None = None
152153

@@ -734,7 +735,7 @@ def setup(self, console: bool = False) -> None:
734735
console: True to setup console
735736
"""
736737
self.__register_plugins()
737-
self.__configure_statusbar()
738+
self.__configure_statusbar(console)
738739
self.__setup_global_actions()
739740
self.__add_signal_image_panels()
740741
self.__create_plugins_actions()
@@ -776,9 +777,17 @@ def __unregister_plugins() -> None:
776777
with qth.try_or_log_error("Unregistering plugins"):
777778
PluginRegistry.unregister_all_plugins()
778779

779-
def __configure_statusbar(self) -> None:
780-
"""Configure status bar"""
780+
def __configure_statusbar(self, console: bool) -> None:
781+
"""Configure status bar
782+
783+
Args:
784+
console: True if console is enabled
785+
"""
781786
self.statusBar().showMessage(_("Welcome to %s!") % APP_NAME, 5000)
787+
if console:
788+
# Console status
789+
self.consolestatus = status.ConsoleStatus()
790+
self.statusBar().addPermanentWidget(self.consolestatus)
782791
# Plugin status
783792
pluginstatus = status.PluginStatus()
784793
self.statusBar().addPermanentWidget(pluginstatus)
@@ -1131,6 +1140,9 @@ def __setup_console(self) -> None:
11311140
lambda txt: self.repopulate_panel_trees()
11321141
)
11331142
self.__update_console_show_mode()
1143+
self.console.exception_occurred.connect(self.consolestatus.exception_occurred)
1144+
cdock.visibilityChanged.connect(self.consolestatus.console_visibility_changed)
1145+
self.consolestatus.SIG_SHOW_CONSOLE.connect(self.console.show_console)
11341146

11351147
def __add_macro_panel(self) -> None:
11361148
"""Add macro panel"""

datalab/locale/fr/LC_MESSAGES/datalab.po

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ msgid ""
66
msgstr ""
77
"Project-Id-Version: datalab\n"
88
"Report-Msgid-Bugs-To: p.raybaut@codra.fr\n"
9-
"POT-Creation-Date: 2025-09-12 09:17+0200\n"
9+
"POT-Creation-Date: 2025-09-12 13:45+0200\n"
1010
"PO-Revision-Date: 2025-05-22 15:46+0200\n"
1111
"Last-Translator: Christophe Debonnel <c.debonnel@codra.fr>\n"
1212
"Language: fr\n"
@@ -2419,6 +2419,30 @@ msgstr "Distance minimale :"
24192419
msgid "Signal peak detection"
24202420
msgstr "Détection de pics 1D"
24212421

2422+
msgid "Internal console"
2423+
msgstr "Console interne"
2424+
2425+
msgid ""
2426+
"Click to show the internal console.\n"
2427+
"The icon will turn red if an error or warning is logged."
2428+
msgstr ""
2429+
"Cliquer pour afficher la console interne.\n"
2430+
"L'icône deviendra rouge si une erreur ou un avertissement est enregistré."
2431+
2432+
msgid ""
2433+
"Click to show the internal console.\n"
2434+
"An error or warning has been logged."
2435+
msgstr ""
2436+
"Cliquer pour afficher la console interne.\n"
2437+
"Une erreur ou un avertissement a été enregistré."
2438+
2439+
msgid ""
2440+
"Click to show the internal console.\n"
2441+
"No error or warning has been logged."
2442+
msgstr ""
2443+
"Cliquer pour afficher la console interne.\n"
2444+
"Aucune erreur ou avertissement n'a été enregistré."
2445+
24222446
msgid "Memory available:"
24232447
msgstr "Mémoire disponible :"
24242448

@@ -2690,3 +2714,4 @@ msgstr "Merci de sélectionner le fichier à importer."
26902714

26912715
msgid "Example Wizard"
26922716
msgstr "Assistant exemple"
2717+

datalab/widgets/status.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,83 @@ def update_status(self) -> None:
6161
raise NotImplementedError
6262

6363

64+
class ConsoleStatus(BaseStatus):
65+
"""Console status widget.
66+
67+
Shows a message if an error or warning has been logged to the console.
68+
Shows a button to show the console, only if the console is hidden.
69+
70+
Args:
71+
parent (QWidget): parent widget
72+
"""
73+
74+
SIG_SHOW_CONSOLE = QC.Signal()
75+
76+
def __init__(self, parent: QW.QWidget | None = None) -> None:
77+
super().__init__(None, parent)
78+
self.label.setText(_("Internal console"))
79+
self.label.setToolTip(
80+
_(
81+
"Click to show the internal console.\n"
82+
"The icon will turn red if an error or warning is logged."
83+
)
84+
)
85+
self.label.setCursor(QG.QCursor(QC.Qt.PointingHandCursor))
86+
self.label.mouseReleaseEvent = self.on_click
87+
self.ok_icon = get_std_icon("MessageBoxInformation")
88+
self.ko_icon = get_std_icon("MessageBoxWarning")
89+
self.has_errors = False
90+
self.update_status()
91+
92+
def on_click(self, event: QG.QMouseEvent) -> None:
93+
"""Handle mouse click event on label.
94+
95+
Args:
96+
event: mouse event
97+
"""
98+
if event.button() == QC.Qt.LeftButton:
99+
self.SIG_SHOW_CONSOLE.emit()
100+
101+
def console_visibility_changed(self, visible: bool) -> None:
102+
"""Handle console visibility changed event.
103+
104+
Args:
105+
visible (bool): console visibility
106+
"""
107+
if visible:
108+
# Hide this status widget when console is visible
109+
self.hide()
110+
else:
111+
self.show()
112+
self.update_status()
113+
114+
def exception_occurred(self) -> None:
115+
"""Handle exception occurred event"""
116+
self.has_errors = True
117+
self.update_status()
118+
119+
def update_status(self) -> None:
120+
"""Update status widget"""
121+
if self.has_errors:
122+
self.set_icon(self.ko_icon)
123+
self.label.setStyleSheet("color: red")
124+
self.label.setToolTip(
125+
_(
126+
"Click to show the internal console.\n"
127+
"An error or warning has been logged."
128+
)
129+
)
130+
else:
131+
self.set_icon(self.ok_icon)
132+
self.label.setStyleSheet("")
133+
self.label.setToolTip(
134+
_(
135+
"Click to show the internal console.\n"
136+
"No error or warning has been logged."
137+
)
138+
)
139+
140+
64141
class MemoryStatus(BaseStatus):
65142
"""Memory status widget.
66143

doc/locale/fr/LC_MESSAGES/changelog.po

Lines changed: 13 additions & 1 deletion
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-09-12 09:16+0200\n"
10+
"POT-Creation-Date: 2025-09-12 13:45+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"
@@ -30,6 +30,18 @@ msgstr "DataLab Version 1.0.0"
3030
msgid "💥 New features and enhancements:"
3131
msgstr "💥 Nouvelles fonctionnalités et améliorations :"
3232

33+
msgid "Internal console status indicator added to the status bar:"
34+
msgstr "Indicateur d'état de la console interne ajouté à la barre d'état :"
35+
36+
msgid "The status bar now features an indicator for the internal console, visible only when the console is hidden."
37+
msgstr "La barre d'état dispose désormais d'un indicateur pour la console interne, visible uniquement lorsque la console est masquée."
38+
39+
msgid "Clicking the indicator opens the internal console."
40+
msgstr "Cliquer sur l'indicateur ouvre la console interne."
41+
42+
msgid "The icon turns red if an error or warning is logged, alerting the user to check the console."
43+
msgstr "L'icône devient rouge si une erreur ou un avertissement est enregistré, alertant l'utilisateur à vérifier la console."
44+
3345
msgid "New common signal/image feature:"
3446
msgstr "Nouvelles fonctionnalités communes signal/image :"
3547

0 commit comments

Comments
 (0)