88from rascal2 .dialogs .settings_dialog import SettingsDialog
99from rascal2 .dialogs .startup_dialog import PROJECT_FILES , LoadDialog , LoadR1Dialog , NewProjectDialog , StartupDialog
1010from rascal2 .settings import MDIGeometries , Settings , get_global_settings
11- from rascal2 .widgets import ControlsWidget , PlotWidget , TerminalWidget
11+ from rascal2 .widgets import ControlsWidget , PlotWidget , SlidersViewWidget , TerminalWidget
1212from rascal2 .widgets .project import ProjectWidget
1313from rascal2 .widgets .startup import StartUpWidget
1414
@@ -22,6 +22,11 @@ class MainWindowView(QtWidgets.QMainWindow):
2222
2323 def __init__ (self ):
2424 super ().__init__ ()
25+ # Public interface
26+ self .disabled_elements = []
27+ self .show_sliders = False # no one displays sliders initially except got from configuration
28+ # (not implemented yet)
29+
2530 self .setWindowTitle (MAIN_WINDOW_TITLE )
2631
2732 window_icon = QtGui .QIcon (path_for ("logo.png" ))
@@ -38,14 +43,21 @@ def __init__(self):
3843 self .plot_widget = PlotWidget (self )
3944 self .terminal_widget = TerminalWidget ()
4045 self .controls_widget = ControlsWidget (self )
46+ self .sliders_view_widget = SlidersViewWidget (self )
4147 self .project_widget = ProjectWidget (self )
4248
43- self .disabled_elements = []
49+ ## protected interface and public properties construction
50+
51+ # define menu controlling switch between table and slider views
52+ self ._sliders_menu_control_text = {
53+ "ShowSliders" : "&Show Sliders" , # if state is show sliders, click will show them
54+ "HideSliders" : "&Hide Sliders" ,
55+ } # if state is show table, click will show sliders
4456
4557 self .create_actions ()
4658
47- self . main_menu = self .menuBar ()
48- self .add_submenus (self . main_menu )
59+ main_menu = self .menuBar ()
60+ self .add_submenus (main_menu )
4961
5062 self .create_toolbar ()
5163 self .create_status_bar ()
@@ -166,6 +178,20 @@ def create_actions(self):
166178 open_help_action .triggered .connect (self .open_docs )
167179 self .open_help_action = open_help_action
168180
181+ # done this way expecting the value "show_sliders" being stored
182+ # in configuration in a future + "show_sliders" is public for this reason
183+ if self .show_sliders :
184+ # if show_sliders state is True, action will be hide
185+ show_or_hide_slider_action = QtGui .QAction (self ._sliders_menu_control_text ["HideSliders" ], self )
186+ else :
187+ # if display_sliders state is False, action will be show
188+ show_or_hide_slider_action = QtGui .QAction (self ._sliders_menu_control_text ["ShowSliders" ], self )
189+ show_or_hide_slider_action .setStatusTip ("Show or Hide Sliders" )
190+ show_or_hide_slider_action .triggered .connect (lambda : self .show_or_hide_sliders (None ))
191+ self ._show_or_hide_slider_action = show_or_hide_slider_action
192+ self ._show_or_hide_slider_action .setEnabled (False )
193+ self .disabled_elements .append (self ._show_or_hide_slider_action )
194+
169195 open_about_action = QtGui .QAction ("&About" , self )
170196 open_about_action .setStatusTip ("Report RAT version&info" )
171197 open_about_action .triggered .connect (self .open_about_info )
@@ -242,6 +268,8 @@ def add_submenus(self, main_menu: QtWidgets.QMenuBar):
242268
243269 tools_menu = main_menu .addMenu ("&Tools" )
244270 tools_menu .setObjectName ("&Tools" )
271+ tools_menu .addAction (self ._show_or_hide_slider_action )
272+ tools_menu .addSeparator ()
245273 tools_menu .addAction (self .clear_terminal_action )
246274 tools_menu .addSeparator ()
247275 tools_menu .addAction (self .setup_matlab_action )
@@ -251,6 +279,32 @@ def add_submenus(self, main_menu: QtWidgets.QMenuBar):
251279 help_menu .addAction (self .open_about_action )
252280 help_menu .addAction (self .open_help_action )
253281
282+ def show_or_hide_sliders (self , do_show_sliders = None ):
283+ """Depending on current state, show or hide sliders for
284+ table properties within Project class view.
285+
286+ Parameters:
287+ -----------
288+
289+ do_show_sliders: bool,default None
290+ if provided, sets self.show_sliders logical variable into the requested state
291+ (True/False), forcing sliders widget to appear/disappear. if None, applies not to current state.
292+ """
293+ if do_show_sliders is None :
294+ self .show_sliders = not self .show_sliders
295+ else :
296+ self .show_sliders = do_show_sliders
297+
298+ if self .show_sliders :
299+ self ._show_or_hide_slider_action .setText (self ._sliders_menu_control_text ["HideSliders" ])
300+ self .sliders_view_widget .show ()
301+ self .project_widget .setWindowTitle ("Sliders View" )
302+ self .project_widget .stacked_widget .setCurrentIndex (2 )
303+ else :
304+ self ._show_or_hide_slider_action .setText (self ._sliders_menu_control_text ["ShowSliders" ])
305+ self .sliders_view_widget .hide ()
306+ self .project_widget .show_project_view ()
307+
254308 def open_about_info (self ):
255309 """Opens about menu containing information about RASCAL gui"""
256310 self .about_dialog .update_rascal_info (self )
@@ -311,7 +365,9 @@ def setup_mdi(self):
311365 self .setCentralWidget (self .mdi )
312366
313367 def setup_mdi_widgets (self ):
314- """Performs setup of MDI widgets that relies on the Project existing."""
368+ """
369+ Performs initialization of MDI widgets that rely on the Project being defined.
370+ """
315371 self .controls_widget .setup_controls ()
316372 self .project_widget .show_project_view ()
317373 self .plot_widget .clear ()
@@ -333,7 +389,6 @@ def reset_mdi_layout(self):
333389 window .showMinimized ()
334390 else :
335391 window .showNormal ()
336-
337392 window .setGeometry (x , y , width , height )
338393
339394 def save_mdi_layout (self ):
0 commit comments