SILICON
Loading...
Searching...
No Matches
siliconWindow.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <memory>
21
22#include <QMainWindow>
23#include <ui/lifetime.hpp>
25
26#ifndef QT_NO_CONTEXTMENU
27class QContextMenuEvent;
28#endif
29
30class QDockWidget;
31class QEvent;
32class QCloseEvent;
33class QObject;
34class QPoint;
35class QResizeEvent;
36class QUndoStack;
37
38namespace SILICON::ui {
39class AboutDialog;
41class CircuitEditor;
43class LogSideView;
44class ProjectTree;
45class PropertyPanel;
48class EditorWorkspace;
52class WindowActions;
53class WindowLifetime;
54
60class SiliconWindow : public QMainWindow {
61 Q_OBJECT
62
63public:
68
70 ~SiliconWindow() override;
71
72protected:
73#ifndef QT_NO_CONTEXTMENU
78 void contextMenuEvent(QContextMenuEvent* event) override;
79#endif // QT_NO_CONTEXTMENU
80
87 bool eventFilter(QObject* watched, QEvent* event) override;
88
93 void resizeEvent(QResizeEvent* event) override;
94 void closeEvent(QCloseEvent* event) override;
95
96private slots:
98 void exportImage() {}
99
101 void about() const;
102
104 void updateStatus() const;
105
107 void selectionChanged();
108
111
116 void showProjectTreeContextMenu(const QPoint& position);
117
119 void updatePropertyDock();
120
121private:
123 void wireActions();
124
127
130
133
135 void refreshProjectUi();
136
138 QDockWidget* documentDock = nullptr;
139
141 QDockWidget* propertyDock = nullptr;
142
144 QDockWidget* logDock = nullptr;
145
152
155
156 // Declaration order is lifetime order: the session and history outlive the
157 // editors, and the document navigator remains available during scene teardown.
159 std::unique_ptr<QUndoStack> undoStack;
160 std::unique_ptr<ProjectDocumentController> documentController;
161 std::unique_ptr<EditorWorkspace> workspace;
162 std::unique_ptr<DiagramInteractionController> interactionController;
163 std::unique_ptr<ProjectFileController> fileController;
164 std::unique_ptr<WindowActions> actionSet;
165 std::unique_ptr<ArchitectureController> architectureController;
166 std::unique_ptr<WaveformController> waveformController;
167 std::unique_ptr<PropertyPanel> propertyPanel;
168 std::unique_ptr<GraphicalLogStream> graphicalLogStream;
169
171 std::unique_ptr<WindowLifetime> windowLifetime;
172 // Disconnect and discard queued callbacks before any teardown emits signals.
174};
175
176} // namespace SILICON::ui
Selects and hosts editors while preserving detached document preparation.
Project document navigator used by the SILICON editor.
void updateStatus() const
Refreshes the status bar text for the current scene mode.
void updateComponentCatalogGeometry()
Repositions and resizes the component catalog overlay.
void refreshProjectUi()
Refreshes the property dock after a project-level change.
SiliconWindow()
Constructs and initializes the SILICON editor window.
void selectionChanged()
Updates action enabled states and property UI after selection changes.
std::unique_ptr< EditorWorkspace > workspace
void contextMenuEvent(QContextMenuEvent *event) override
Opens the diagram context menu for mode and editing actions.
QDockWidget * propertyDock
Dock containing the current property editor.
std::unique_ptr< ProjectFileController > fileController
bool closeAfterSaveConfirmation
Allows the close event triggered after an accepted dirty-file prompt.
void initializeProjectTree()
Creates and wires the project tree widget shown in the project dock.
void closeEvent(QCloseEvent *event) override
void about() const
Shows the application about dialog.
bool eventFilter(QObject *watched, QEvent *event) override
Handles viewport events needed by floating child widgets.
std::unique_ptr< WindowLifetime > windowLifetime
QDockWidget * logDock
Dock containing application log output.
void projectTreeSelectionChanged()
Handles user selection changes in the project circuit tree.
void showProjectTreeContextMenu(const QPoint &position)
Shows the context menu for project-tree circuit actions.
void resizeEvent(QResizeEvent *event) override
Keeps floating overlays aligned when the main window is resized.
ComponentCatalogOverlay * componentCatalogOverlay
ProjectTree * projectTree
Borrowed handles into the workspace and Qt widget hierarchy.
std::unique_ptr< ProjectDocumentController > documentController
std::unique_ptr< WindowActions > actionSet
std::unique_ptr< PropertyPanel > propertyPanel
ScopedEventFilter viewportFilter
std::unique_ptr< DiagramInteractionController > interactionController
std::unique_ptr< WaveformController > waveformController
QDockWidget * documentDock
Dock containing the project document tree.
std::unique_ptr< QUndoStack > undoStack
void updatePropertyDock()
Rebuilds the property dock for the current selection or active circuit.
~SiliconWindow() override
Releases scoped callbacks and UI owners in dependency order.
void exportImage()
Placeholder slot for exporting the diagram as an image.
void refreshActiveDocumentUi()
Refreshes actions and docks that depend on the active document.
std::unique_ptr< ArchitectureController > architectureController
std::unique_ptr< GraphicalLogStream > graphicalLogStream
Owns main-window actions, menus, shortcuts, and their enabled state.