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 , SlidersViewWidget , TerminalWidget
11+ from rascal2 .widgets import ControlsWidget , PlotWidget , TerminalWidget
1212from rascal2 .widgets .project import ProjectWidget
1313from rascal2 .widgets .startup import StartUpWidget
1414
@@ -22,13 +22,8 @@ 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)
2925
3026 self .setWindowTitle (MAIN_WINDOW_TITLE )
31-
3227 window_icon = QtGui .QIcon (path_for ("logo.png" ))
3328
3429 self .undo_stack = QtGui .QUndoStack (self )
@@ -43,22 +38,12 @@ def __init__(self):
4338 self .plot_widget = PlotWidget (self )
4439 self .terminal_widget = TerminalWidget ()
4540 self .controls_widget = ControlsWidget (self )
46- self .sliders_view_widget = SlidersViewWidget (self )
4741 self .project_widget = ProjectWidget (self )
4842
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
43+ self .disabled_elements = []
5644
5745 self .create_actions ()
58-
59- main_menu = self .menuBar ()
60- self .add_submenus (main_menu )
61-
46+ self .create_menus ()
6247 self .create_toolbar ()
6348 self .create_status_bar ()
6449
@@ -172,30 +157,22 @@ def create_actions(self):
172157 self .settings_action .setEnabled (False )
173158 self .disabled_elements .append (self .settings_action )
174159
175- open_help_action = QtGui .QAction ("&Help" , self )
176- open_help_action .setStatusTip ("Open Documentation" )
177- open_help_action .setIcon (QtGui .QIcon (path_for ("help.png" )))
178- open_help_action .triggered .connect (self .open_docs )
179- self .open_help_action = open_help_action
180-
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-
195- open_about_action = QtGui .QAction ("&About" , self )
196- open_about_action .setStatusTip ("Report RAT version&info" )
197- open_about_action .triggered .connect (self .open_about_info )
198- self .open_about_action = open_about_action
160+ self .open_help_action = QtGui .QAction ("&Help" , self )
161+ self .open_help_action .setStatusTip ("Open Documentation" )
162+ self .open_help_action .setIcon (QtGui .QIcon (path_for ("help.png" )))
163+ self .open_help_action .triggered .connect (self .open_docs )
164+
165+ self .toggle_slider_action = QtGui .QAction ("Show &Sliders" , self )
166+ self .toggle_slider_action .setProperty ("show_text" , "Show &Sliders" )
167+ self .toggle_slider_action .setProperty ("hide_text" , "Hide &Sliders" )
168+ self .toggle_slider_action .setStatusTip ("Show or Hide Sliders" )
169+ self .toggle_slider_action .triggered .connect (self .toggle_sliders )
170+ self .toggle_slider_action .setEnabled (False )
171+ self .disabled_elements .append (self .toggle_slider_action )
172+
173+ self .open_about_action = QtGui .QAction ("&About" , self )
174+ self .open_about_action .setStatusTip ("Report RAT version&info" )
175+ self .open_about_action .triggered .connect (self .open_about_info )
199176
200177 self .exit_action = QtGui .QAction ("E&xit" , self )
201178 self .exit_action .setStatusTip (f"Quit { MAIN_WINDOW_TITLE } " )
@@ -231,13 +208,12 @@ def create_actions(self):
231208 self .setup_matlab_action .setStatusTip ("Set the path of the MATLAB executable" )
232209 self .setup_matlab_action .triggered .connect (lambda : self .show_settings_dialog (tab_name = "Matlab" ))
233210
234- def add_submenus (self , main_menu : QtWidgets . QMenuBar ):
211+ def create_menus (self ):
235212 """Add sub menus to the main menu bar"""
236-
213+ main_menu = self . menuBar ()
237214 main_menu .setContextMenuPolicy (QtCore .Qt .ContextMenuPolicy .PreventContextMenu )
238215
239216 file_menu = main_menu .addMenu ("&File" )
240- file_menu .setObjectName ("&File" )
241217 file_menu .addAction (self .new_project_action )
242218 file_menu .addSeparator ()
243219 file_menu .addAction (self .open_project_action )
@@ -253,56 +229,37 @@ def add_submenus(self, main_menu: QtWidgets.QMenuBar):
253229 file_menu .addAction (self .exit_action )
254230
255231 edit_menu = main_menu .addMenu ("&Edit" )
256- edit_menu .setObjectName ("&Edit" )
257232 edit_menu .addAction (self .undo_action )
258233 edit_menu .addAction (self .redo_action )
259234 edit_menu .addAction (self .undo_view_action )
260235
261236 windows_menu = main_menu .addMenu ("&Windows" )
262- windows_menu .setObjectName ("&Windows" )
263237 windows_menu .addAction (self .tile_windows_action )
264238 windows_menu .addAction (self .reset_windows_action )
265239 windows_menu .addAction (self .save_default_windows_action )
266240 windows_menu .setEnabled (False )
267241 self .disabled_elements .append (windows_menu )
268242
269243 tools_menu = main_menu .addMenu ("&Tools" )
270- tools_menu .setObjectName ("&Tools" )
271- tools_menu .addAction (self ._show_or_hide_slider_action )
244+ tools_menu .addAction (self .toggle_slider_action )
272245 tools_menu .addSeparator ()
273246 tools_menu .addAction (self .clear_terminal_action )
274247 tools_menu .addSeparator ()
275248 tools_menu .addAction (self .setup_matlab_action )
276249
277250 help_menu = main_menu .addMenu ("&Help" )
278- help_menu .setObjectName ("&Help" )
279251 help_menu .addAction (self .open_about_action )
280252 help_menu .addAction (self .open_help_action )
281253
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 )
254+ def toggle_sliders (self ):
255+ """Toggles sliders for the fitted parameters in project class view."""
256+ show_text = self .toggle_slider_action .property ("show_text" )
257+ if self .toggle_slider_action .text () == show_text :
258+ hide_text = self .toggle_slider_action .property ("hide_text" )
259+ self .toggle_slider_action .setText (hide_text )
260+ self .project_widget .show_slider_view ()
303261 else :
304- self ._show_or_hide_slider_action .setText (self ._sliders_menu_control_text ["ShowSliders" ])
305- self .sliders_view_widget .hide ()
262+ self .toggle_slider_action .setText (show_text )
306263 self .project_widget .show_project_view ()
307264
308265 def open_about_info (self ):
0 commit comments