wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
MainWindow Class Reference

The top-level application window hosting the tab bar, menus, element palette, and editor. More...

#include <MainWindow.h>

Inheritance diagram for MainWindow:
[legend]

Public Member Functions

void createNewTab ()
 Creates a new empty circuit tab.
QDir currentDir () const override
 Returns the directory of the currently active .panda file.
QFileInfo currentFile () const override
 Returns the QFileInfo of the currently active .panda file.
WorkSpacecurrentTab () const override
 Returns the currently visible WorkSpace tab, or nullptr.
QString dolphinFileName () override
 Returns the BeWavedDolphin file name associated with the current tab.
DolphinHostdolphinHost () override
bool event (QEvent *event) override
void exportToArduino (QString fileName)
 Generates Arduino sketch code for the current circuit.
void exportToSystemVerilog (QString fileName)
 Generates SystemVerilog code for the current circuit.
void exportToWaveFormFile (const QString &fileName)
 Saves the BeWavedDolphin waveform session to fileName.
void exportToWaveFormTerminal ()
 Exports the current waveform simulation to standard output (terminal).
bool hasModifiedFiles ()
 Returns true if any open workspace has unsaved changes or is a recovered autosave.
void loadPandaFile (const QString &fileName)
 Loads a .panda circuit file into the current or a new tab.
void loadTranslation (const QString &language)
 Loads and installs the Qt translation for language.
 MainWindow (const QString &fileName={}, QWidget *parent=nullptr)
 Constructs the MainWindow and optionally opens fileName on start.
void openICInTab (const QString &blobName, int icElementId, const QByteArray &blob)
 Opens an embedded IC blob for editing in a new tab.
ElementPalettepalette () const override
void populateLanguageMenu ()
 Populates the Language submenu with available translations.
void populateMenu (QSpacerItem *spacer, const QStringList &names, QLayout *layout)
 Fills layout with ElementLabel buttons from names, preceded by spacer.
void refreshICButtonsEnabled () override
void requestSave () override
void retranslateUi ()
 Re-applies all translatable strings to the UI after a language change.
void save (const QString &fileName={}) override
 Saves the current circuit to fileName (or prompts if empty).
void setDolphinFileName (const QString &fileName) override
 Associates fileName as the BeWavedDolphin file for the current tab.
void setFastMode (const bool fastMode)
 Enables or disables fast (non-antialiased) rendering for all views.
void setICButtonsVisible (bool visible) override
QString shortcutsHelpHtml () const
void show ()
 Shows the window and initializes child widget state.
void showStatusMessage (const QString &message, int timeout) override
QWidget * widget () override
 ~MainWindow () override
Public Member Functions inherited from DolphinHost
virtual ~DolphinHost ()=default
Public Member Functions inherited from MainWindowHost
virtual ~MainWindowHost ()=default

Protected Member Functions

void closeEvent (QCloseEvent *event) override

Friends

class TestMainWindowGui

Detailed Description

The top-level application window hosting the tab bar, menus, element palette, and editor.

MainWindow orchestrates the full editing workflow: it owns the tab widget (each tab is a WorkSpace), connects undo/redo stacks, handles file open/save/export, manages translations, and integrates the element palette, element editor, and IC list panel.

Definition at line 46 of file MainWindow.h.

Constructor & Destructor Documentation

◆ MainWindow()

MainWindow::MainWindow ( const QString & fileName = {},
QWidget * parent = nullptr )
explicit

◆ ~MainWindow()

MainWindow::~MainWindow ( )
override

Definition at line 450 of file MainWindow.cpp.

Member Function Documentation

◆ closeEvent()

void MainWindow::closeEvent ( QCloseEvent * event)
overrideprotected
Reimplemented from base class.

Definition at line 657 of file MainWindow.cpp.

References event().

◆ createNewTab()

void MainWindow::createNewTab ( )

Creates a new empty circuit tab.

Definition at line 456 of file MainWindow.cpp.

Referenced by MainWindow().

◆ currentDir()

QDir MainWindow::currentDir ( ) const
overridevirtual

Returns the directory of the currently active .panda file.

Implements DolphinHost.

Definition at line 723 of file MainWindow.cpp.

◆ currentFile()

QFileInfo MainWindow::currentFile ( ) const
overridevirtual

Returns the QFileInfo of the currently active .panda file.

Implements DolphinHost.

Definition at line 713 of file MainWindow.cpp.

◆ currentTab()

WorkSpace * MainWindow::currentTab ( ) const
overridevirtual

Returns the currently visible WorkSpace tab, or nullptr.

Implements MainWindowHost.

Definition at line 770 of file MainWindow.cpp.

Referenced by main(), MainWindow(), refreshICButtonsEnabled(), and setFastMode().

◆ dolphinFileName()

QString MainWindow::dolphinFileName ( )
overridevirtual

Returns the BeWavedDolphin file name associated with the current tab.

Implements DolphinHost.

Definition at line 1281 of file MainWindow.cpp.

◆ dolphinHost()

DolphinHost * MainWindow::dolphinHost ( )
overridevirtual
Reimplemented from base class. MainWindowHost — this window's DolphinHost facet.

Implements MainWindowHost.

Definition at line 733 of file MainWindow.cpp.

◆ event()

bool MainWindow::event ( QEvent * event)
override
Reimplemented from base class.

Definition at line 1346 of file MainWindow.cpp.

References event().

Referenced by closeEvent(), and event().

◆ exportToArduino()

void MainWindow::exportToArduino ( QString fileName)

Generates Arduino sketch code for the current circuit.

Parameters
fileNameOutput .ino file path.

Definition at line 865 of file MainWindow.cpp.

Referenced by main().

◆ exportToSystemVerilog()

void MainWindow::exportToSystemVerilog ( QString fileName)

Generates SystemVerilog code for the current circuit.

Parameters
fileNameOutput .sv file path.

Definition at line 870 of file MainWindow.cpp.

◆ exportToWaveFormFile()

void MainWindow::exportToWaveFormFile ( const QString & fileName)

Saves the BeWavedDolphin waveform session to fileName.

Parameters
fileNameOutput .dolphin file path.

Definition at line 875 of file MainWindow.cpp.

Referenced by main().

◆ exportToWaveFormTerminal()

void MainWindow::exportToWaveFormTerminal ( )

Exports the current waveform simulation to standard output (terminal).

Definition at line 880 of file MainWindow.cpp.

Referenced by main().

◆ hasModifiedFiles()

bool MainWindow::hasModifiedFiles ( )

Returns true if any open workspace has unsaved changes or is a recovered autosave.

Definition at line 718 of file MainWindow.cpp.

◆ loadPandaFile()

void MainWindow::loadPandaFile ( const QString & fileName)

Loads a .panda circuit file into the current or a new tab.

Parameters
fileNameAbsolute path to the .panda file.

Definition at line 552 of file MainWindow.cpp.

Referenced by main(), and MainWindow().

◆ loadTranslation()

void MainWindow::loadTranslation ( const QString & language)

Loads and installs the Qt translation for language.

Parameters
languageBCP-47 language code.

Definition at line 1025 of file MainWindow.cpp.

◆ openICInTab()

void MainWindow::openICInTab ( const QString & blobName,
int icElementId,
const QByteArray & blob )

Opens an embedded IC blob for editing in a new tab.

Definition at line 557 of file MainWindow.cpp.

◆ palette()

ElementPalette * MainWindow::palette ( ) const
overridevirtual
Reimplemented from base class. MainWindowHost — the element palette panel.

Implements MainWindowHost.

Definition at line 738 of file MainWindow.cpp.

◆ populateLanguageMenu()

void MainWindow::populateLanguageMenu ( )

Populates the Language submenu with available translations.

Definition at line 1030 of file MainWindow.cpp.

References Settings::language().

◆ populateMenu()

void MainWindow::populateMenu ( QSpacerItem * spacer,
const QStringList & names,
QLayout * layout )

Fills layout with ElementLabel buttons from names, preceded by spacer.

Parameters
spacerSpacer item to insert before the buttons.
namesElement type names to add.
layoutTarget layout.

Definition at line 1081 of file MainWindow.cpp.

References ElementFactory::pixmap(), and ElementFactory::textToType().

◆ refreshICButtonsEnabled()

void MainWindow::refreshICButtonsEnabled ( )
overridevirtual
Reimplemented from base class. MainWindowHost — re-evaluates the Add-IC button enabled state.

Implements MainWindowHost.

Definition at line 704 of file MainWindow.cpp.

References currentTab(), and WorkSpace::fileInfo().

◆ requestSave()

void MainWindow::requestSave ( )
overridevirtual
Reimplemented from base class. MainWindowHost — saves the current tab (triggers the Save action).

Implements MainWindowHost.

Definition at line 743 of file MainWindow.cpp.

◆ retranslateUi()

void MainWindow::retranslateUi ( )

Re-applies all translatable strings to the UI after a language change.

Definition at line 977 of file MainWindow.cpp.

◆ save()

void MainWindow::save ( const QString & fileName = {})
overridevirtual

Saves the current circuit to fileName (or prompts if empty).

Parameters
fileNameAbsolute path; empty triggers a Save-As dialog.

Implements DolphinHost.

Definition at line 477 of file MainWindow.cpp.

◆ setDolphinFileName()

void MainWindow::setDolphinFileName ( const QString & fileName)
overridevirtual

Associates fileName as the BeWavedDolphin file for the current tab.

Parameters
fileNamePath to the .dolphin file.

Implements DolphinHost.

Definition at line 1286 of file MainWindow.cpp.

◆ setFastMode()

void MainWindow::setFastMode ( const bool fastMode)

Enables or disables fast (non-antialiased) rendering for all views.

Parameters
fastModetrue to use fast rendering.

Definition at line 461 of file MainWindow.cpp.

References currentTab(), GraphicsView::setFastMode(), and WorkSpace::view().

◆ setICButtonsVisible()

void MainWindow::setICButtonsVisible ( bool visible)
overridevirtual
Reimplemented from base class. MainWindowHost — shows/hides the IC management tool buttons.

Implements MainWindowHost.

Definition at line 697 of file MainWindow.cpp.

◆ shortcutsHelpHtml()

QString MainWindow::shortcutsHelpHtml ( ) const

Rich-text body of the "Shortcuts and Tips" dialog, generated from this window's actions so the list can never drift from the real key bindings and picks up any action added later. Public so GUI tests can assert its completeness without opening a modal dialog.

Definition at line 585 of file MainWindow.cpp.

◆ show()

void MainWindow::show ( )

Shows the window and initializes child widget state.

Definition at line 482 of file MainWindow.cpp.

References Application::interactiveMode, qCDebug, Settings::setWelcomeTourShown(), and Settings::welcomeTourShown().

◆ showStatusMessage()

void MainWindow::showStatusMessage ( const QString & message,
int timeout )
overridevirtual
Reimplemented from base class. MainWindowHost — shows message in the status bar for timeout ms.

Implements MainWindowHost.

Definition at line 748 of file MainWindow.cpp.

◆ widget()

QWidget * MainWindow::widget ( )
overridevirtual
Reimplemented from base class. MainWindowHost — parent widget for controller-spawned dialogs.

Implements MainWindowHost.

Definition at line 728 of file MainWindow.cpp.

◆ TestMainWindowGui

friend class TestMainWindowGui
friend

Definition at line 49 of file MainWindow.h.

References TestMainWindowGui.

Referenced by TestMainWindowGui.


The documentation for this class was generated from the following files: