@@ -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+
64141class MemoryStatus (BaseStatus ):
65142 """Memory status widget.
66143
0 commit comments