21#include <initializer_list>
39using namespace SILICON::core;
50 for (QAction* action : actions) {
52 action->setEnabled(enabled);
98 auto* newMenu =
fileMenu->addMenu(
Icon(
"file"), tr(
"New &Document"));
100 newMenu->addAction(
documents.newCodeFile);
101 newMenu->addAction(
documents.newArchitecture);
102 newMenu->addAction(
documents.newBinaryFile);
131 toolBar->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
158 if (!
circuit.editSubcircuitShape)
161 circuit.editSubcircuitShape->setVisible(active);
162 circuit.editSubcircuitShape->setEnabled(active);
166std::optional<SILICON::project::DocumentType>
176 const auto* document =
177 session.projectContext.documents().find(
session.activeDocumentPath);
179 : std::vector<const DocumentConverter*>{};
180 const auto available =
184 documents.codeConversion->setVisible(!converters.empty());
185 documents.codeConversion->setEnabled(available != 0);
187 !converters.empty() && available == 0
189 converters.front()->unavailableReason.data(),
190 static_cast<qsizetype
>(converters.front()->unavailableReason.size()))
192 if (converters.size() == 1) {
195 }
else if (!converters.empty()) {
196 documents.codeConversion->setText(tr(
"Convert..."));
199 const bool nonGraphical = type
207 circuit.selectAll->setEnabled(type
220 const bool diagram = type
224 const bool catalogVisible = diagram &&
circuit.openComponentCatalog->isEnabled();
225 const bool shapeVisible =
circuit.editSubcircuitShape->isVisible()
226 &&
circuit.editSubcircuitShape->isEnabled();
227 const bool conversionVisible =
245 if (action->isEnabled())
251 if (catalogVisible || shapeVisible || conversionVisible || buildVisible) {
257 if (conversionVisible)
272 tr(
"Circuit"), tr(
"Create a new circuit document"));
275 tr(
"Code File..."), tr(
"Create an empty source-code document"));
277 tr(
"Create a SISL instruction format"));
280 tr(
"Binary File..."), tr(
"Create a fixed-size raw binary document"));
282 tr(
"Open an existing silicon file"));
286 tr(
"Export the circuit as an image"));
290 tr(
"Cut the current selection's contents to the clipboard"));
294 tr(
"Paste the clipboard's contents into the current selection"));
299 tr(
"Automatically place components and reroute wires"));
301 makeAction(&
window, tr(
"&Center view"), tr(
"Center the view on the circuit"));
303 tr(
"Delete selected components"));
305 tr(
"Show the application's about box"));
307 tr(
"Edit application settings"));
322 waveform.toggleTrace->setCheckable(
true);
330 tr(
"Edit the active circuit shape"));
331 circuit.editSubcircuitShape->setVisible(
false);
332 circuit.editSubcircuitShape->setEnabled(
false);
334 documents.codeConversion->setVisible(
false);
335 documents.codeConversion->setEnabled(
false);
337 tr(
"Compile the current SISL instruction format"));
339 tr(
"Visualize SISL instruction formats"));
340 circuit.setComponentPlacingMode =
351 const auto state =
workspace.activeEditState();
352 circuit.rotate->setEnabled(state.canRotate);
353 edit.cut->setEnabled(state.canCut);
354 edit.copy->setEnabled(state.canCopy);
355 edit.paste->setEnabled(state.canPaste);
356 edit.remove->setEnabled(state.canDelete);
Selects and hosts editors while preserving detached document preparation.
void pasteActiveDocument()
void redoActiveDocument()
void copyActiveDocument()
void editStateChanged()
Emitted when the active editor's editing availability may have changed.
void undoActiveDocument()
void deleteInActiveDocument()
void historyStateChanged()
Emitted when the active editor's undo/redo availability may have changed.
void activeEditorChanged()
WaveformActions waveform
Commands owned by the waveform viewer.
std::optional< SILICON::project::DocumentType > activeDocumentType() const noexcept
QToolBar * toolBar
Main toolbar containing edit, mode, and simulation actions.
QAction * diagramToolsSeparator
WindowActions(QMainWindow &window, ProjectSession &session, EditorWorkspace &workspace)
ArchitectureActions architecture
Commands owned by the architecture subsystem.
DocumentActions documents
Commands owned by the project document workflow.
void updateSubcircuitShapeAction()
EditorWorkspace & workspace
void refreshActiveEditorActions()
CircuitActions circuit
Commands owned by the circuit editor.
QAction * documentToolsSeparator
QMenu * editMenu
Edit menu.
ProjectActions project
Commands owned by the project and application shell.
void updateHistoryActions()
EditActions edit
Commands owned by the active editor, whatever its kind.
static void setActionsEnabled(std::initializer_list< QAction * > actions, bool enabled)
QMenu * helpMenu
Help menu.
void updateDocumentActionVisibility()
QMenu * fileMenu
File menu.
constexpr DocumentCategory categoryOf(const DocumentType type)
std::optional< DocumentType > documentTypeForPath(const std::string_view path)
QAction * makeAction(QObject *parent, const QIcon &icon, const QString &text, const QString &statusTip)
QIcon categoryIcon(const SILICON::project::DocumentType type)
std::vector< const DocumentConverter * > documentConvertersFor(const DocumentType source)
QString documentTypeName(SILICON::project::DocumentType type)