MainView¶
- class poriscope.views.main_view.MainView(available_plugins: Dict[str, List[str]])¶
Bases:
QMainWindow,WalkthroughMixinApp-shell main window: hosts the menu bar, sidebar navigation, and the stacked pages for each instantiated analysis tab, and exposes the signals MainController relays to instantiate tabs/plugins, open Settings, and run the app-wide walkthrough.
- add_text_to_display(text: str, source: str) None¶
Method to dynamically add text to the QTextEdit and scroll to bottom
- cancel_walkthrough() None¶
Tear down any active walkthrough or milestone overlay.
switch_to_pagerefuses to move while a walkthrough or milestone is active, so anything that returns the window to a known page has to clear this first or be silently ignored - leaving the user on a page that may no longer exist, with a stale title.
- clear_sidebar_highlight() None¶
Uncheck whichever sidebar/menu button is currently highlighted, as none are on a fresh launch.
- close_help_window() None¶
Close the floating Help window if it is open, as none is on a fresh launch.
- close_settings_page() None¶
Detach the Settings widget from its page wrapper, if it is currently open.
self.settings_windowis a MainView-level singleton created once in__init__, not a per-open instance the way an analysis tab’s view is.add_pagereparents it as a Qt child of a disposable page wrapper, so destroying that wrapper (e.g. viaremove_pages_except) without detaching first would destroy the singleton along with it - leaving every other reference to it (set_data_server,set_user_plugin_location,set_logging_level, and the reopen path itself, all guarded only with anis not Nonecheck) pointing at a deleted C++ object. Detaching first keeps it alive and reusable the next time Settings is opened -add_pagebuilds it a fresh wrapper either way, the same as if Settings had never been opened.
- get_current_view() str¶
Abstract method to get the name of the current view.
Subclasses must override this to return the current view name.
- Returns:
The name of the view currently displayed.
- Return type:
- Raises:
NotImplementedError – Always, unless overridden by a subclass.
- get_milestone_step(view_name: str) Tuple[str, str, QWidget] | None¶
Return the label, description, and highlight widget for the given view.
- get_walkthrough_steps() List[Tuple[str, str, str, Callable[[], QWidget | List[QWidget]]]]¶
Abstract method to retrieve the walkthrough steps for the current view.
Subclasses must override this to return a list of walkthrough steps, each a (title, description, view name, widget getter) tuple.
- Returns:
The ordered walkthrough steps for this view.
- Return type:
List[WalkthroughStep]
- Raises:
NotImplementedError – Always, unless overridden by a subclass.
Handles clicks on the menu items and switches to the correct view page.
- launch_walkthrough() None¶
Starts the walkthrough process from the appropriate view. Skips to the relevant section depending on the current view.
- launch_walkthrough_if_needed() None¶
Helper method to check the current view and launch walkthrough if eligible.
- on_abort_analysis_click() None¶
Ask MainController to stop running operations in every open analysis tab.
This used to emit a
kill_all_workerssignal that was connected to nothing - MetaController connects the identically-named signal on a tab’s MetaView, which is a different object - and it hard-coded"RawDataController"as the recipient, so even had it been connected it would only ever have reached one tab. The menu item logged a line and did nothing.
- on_reset_session_button_click() None¶
Confirm, then ask for the workspace to be returned to a fresh start.
Confirmed because it closes every open tab and deletes every configured plugin. The saved session files are untouched, so Restore Session brings the workspace back - but only until something replaces it. plugin_history .json is a live mirror rewritten on every plugin or tab change, and the in-memory history is empty after a reset, so the next thing the user sets up overwrites what Restore would have read. That is equally true after launching the application, and is not introduced here; the prompt states the condition rather than the code papering over it.
Dynamically generates a dropdown menu when MainController responds.
- refresh_available_plugins(available_plugins: Dict[str, List[str]]) None¶
Replace the plugin lists behind the menus and rebuild the menu bar.
The menus are built once from the list handed in at construction, so a re-scan is invisible until they are rebuilt. Rebuilding is the whole menu bar rather than the plugin submenus alone: the submenus are created inline by
setup_menubarand are not held anywhere that would let them be refilled individually.
- remove_pages_except(keep: Sequence[str]) None¶
Remove every registered page except those named, and reindex the rest.
Used to return the window to its just-launched state without restarting. Anything not named to keep is destroyed along with its wrapper - see
close_settings_page()first if Settings’ page is among them, since its widget is a reusable singleton rather than something disposable.Reindexing is not optional.
self.pagescaches each page’s index into the QStackedWidget, and the stack renumbers whatever follows a widget it removes - so without rebuilding the map, every page after the first removal would switch to the wrong widget. Indices are re-derived from the stack itself, matching on the wrapper’s objectName, rather than being arithmetic guesses about what shifted.- Parameters:
keep (Sequence[str]) – Page names to leave in place.
- reset_sidebar_layout() None¶
Collapse the sidebar back to its default icon-only layout, as it is on a fresh launch.
- resizeEvent(event: QResizeEvent) None¶
Ensures that the text display container always takes 20% of the screen width.
event : QResizeEvent
The event containing the new and old window sizes. It is automatically created and dispatched by Qt’s event system whenever a widget (such as a QMainWindow) is resized.
- show_milestone_step(previous_view: str) None¶
Show milestone StepDialog after a walkthrough finishes.
- show_walkthrough_intro(current_view: str = '') None¶
Displays the initial tutorial intro dialog.
- Parameters:
current_view (str) – Identifier of the current view.