Maki
Formally verified low-code orchestration
Loading...
Searching...
No Matches
main_window.h
1#ifndef MAINWINDOW_H
2#define MAINWINDOW_H
3
4#include <QDir>
5#include <QMainWindow>
6#include <QStringLiteral>
7#include <oclero/qlementine.hpp>
8
9#include "compiler/pipeline_graph.h"
10#include "focus_properties.h"
11#include "json.h"
12#include "main_window_layout.h"
13#include "result.h"
14#include "widgets/notification_manager.h"
15#include "widgets/settings_manager.h"
16
17class Canvas;
18class NodeItem;
19class Pipeline;
20class SaveInfo;
21class SaveHandler;
22class HostServices;
23class PluginManager;
24class SettingsManager;
26class PluginTab;
27class PluginView;
28class QPlainTextEdit;
29class Logger;
30class LanguageManager;
31class TourGuide;
32class EdgeRouter;
33class DraggableItem;
35
36struct DocumentEvent;
37template <typename Event>
38class EventDispatcher;
39
40namespace maki
41{
42class PluginPipeline;
43}
44
49
50{
51 Q_OBJECT
52
53public:
61 explicit MainWindow(QApplication* app, oclero::qlementine::ThemeManager* themeManager, QWidget* parent = nullptr);
62
67
73 VoidResult start();
74
75private slots:
82 void onNodeSelected(const QString& nodeId, bool selected);
83
90 void onOpenFlow(std::shared_ptr<FlowSaveInfo> flow, const QString& nodeId, const maki::FocusProperties& properties);
91
97 void changeEvent(QEvent* event) override;
98
99private:
100 std::unique_ptr<SaveHandler> mSaveHandler;
101 std::unique_ptr<PluginManager> mPluginManager;
102 std::shared_ptr<SettingsManager> mSettingsManager;
103 std::shared_ptr<LanguageManager> mLanguageManager;
104 std::shared_ptr<TourGuide> mTourGuide;
105 std::shared_ptr<EventDispatcher<DocumentEvent>> mDocumentScheduler;
106
107 Pipeline* mPipeline = nullptr;
112 Logger* mLogger = nullptr;
114
115 oclero::qlementine::ThemeManager* mThemeManager;
116
117 // std::shared_ptr<SaveInfo> mStorage; /// Shared pointer to save information.
118 std::shared_ptr<EdgeRouter> mRouter;
119
120 QApplication* mApp;
121
127 Canvas* canvas() const;
128
134 Canvas* rootCanvas() const;
135
141 VoidResult loadElements();
142
149 VoidResult loadLibrary(const JSON& config, bool dataOnly);
150
158 VoidResult loadElementLibrary(const QString& name, const JSON& config, bool dataOnly);
159
163 void bind();
164
168 void bindCanvas(Canvas* canvas);
169
174
178 void bindShortcuts();
179
183 void startUI();
184
190 void onCanvasTabChanged(QWidget* widget);
191
197 void closeCanvasTab(QWidget* widget);
198
205 int libraryTypeToIndex(Types::LibraryTypes type) const;
206
213 void onThemeChanged(const AppearanceSettings& themeName, bool intialConfig);
214
218 void onSettingsChanged(bool initialSetup);
219
223 void showAboutDialog();
224
229
236 void addPluginTab(const QString& name, PluginView* view);
237
243 void removePluginTab(PluginView* view);
244
250 void addEditorTab(QPlainTextEdit* view);
251
252 void focusOn(const QString& nodeId, const QString& flowId, const maki::FocusProperties& properties);
253
254 void startTourGuide(bool runningOnStartUp);
255 std::pair<LibraryContainer*, DraggableItem*> findDraggableInPalette(const QString& nodeType) const;
256
257 // ================================================
258 // Actions
259 void onActionNew(const QString& templatePath) override;
260 void onActionLoad(const QString& filename, bool fromTemplate = false);
261 VoidResult onActionSave();
262 void onActionExit();
263 void onActionRestart();
264 void onActionSaveAs();
265 void onActionGenerate(const QString& pipelineId, bool fromScratch);
266 void onActionDeletePipeline(const QString& pipelineId);
267 void onActionEditPipeline(const QString& pipelineId);
268 void onActionRenamePipeline(const QString& pipelineId);
270 void onFileLoaded(const QString& file, const SaveInfo& info, const QString& error, bool fromTemplate);
271 VoidResult loadLastSession();
272
273 void createFlow(const QString& ownerNodeId);
274}; // namespace qlementclassMainWindow:public MainWindowLayout
275
276#endif // MAINWINDOW_H
The Canvas class represents the main drawing area for nodes and transitions.
Definition canvas.h:35
A draggable item in a graphical scene.
Definition draggable.h:21
Definition edge_router.h:11
Definition event_dispatcher.h:16
Interface for a document.
Definition host_services.h:22
A class representing a JSON object.
Definition json.h:16
Manages application language switching and translation loading.
Definition language_manager.h:20
A custom QGraphicsView for managing a library of nodes.
Definition library_container.h:12
Logger class that handles logging functionality.
Definition logger.h:18
MainWindowLayout(QWidget *parent=nullptr)
Constructs a new MainWindowLayout object.
Definition main_window_layout.cpp:44
VoidResult loadLibrary(const JSON &config, bool dataOnly)
Loads a library based on the provided configuration.
Definition main_window.cpp:1251
void onActionLoad(const QString &filename, bool fromTemplate=false)
Handles new action.
Definition main_window.cpp:1667
std::shared_ptr< TourGuide > mTourGuide
Language manager shared pointer.
Definition main_window.h:104
maki::PluginPipeline * mPluginPipeline
Pointer to the logger.
Definition main_window.h:113
void bind()
Binds signals and slots for the application.
Definition main_window.cpp:713
void onActionEditPipeline(const QString &pipelineId)
Handles pipeline deletion.
Definition main_window.cpp:1554
NotificationManager * mNotificationManager
Pointer to the plugin tab.
Definition main_window.h:111
void onActionSaveAs()
Handles restart action.
Definition main_window.cpp:1647
Logger * mLogger
Pointer to the notification manager.
Definition main_window.h:112
void changeEvent(QEvent *event) override
Handles change events.
Definition main_window.cpp:958
void onFileLoaded(const QString &file, const SaveInfo &info, const QString &error, bool fromTemplate)
Handles log level change action.
Definition main_window.cpp:1694
VoidResult loadElements()
Loads elements into the application.
Definition main_window.cpp:1212
void onActionDeletePipeline(const QString &pipelineId)
Handles generate action.
Definition main_window.cpp:1467
void onActionLogLevelChanged()
Handles generate action.
std::shared_ptr< EventDispatcher< DocumentEvent > > mDocumentScheduler
Language manager shared pointer.
Definition main_window.h:105
std::shared_ptr< LanguageManager > mLanguageManager
Settings manager shared pointer.
Definition main_window.h:103
void showAboutDialog()
Shows the about dialog.
Definition main_window.cpp:1964
void onThemeChanged(const AppearanceSettings &themeName, bool intialConfig)
Handles theme change events.
Definition main_window.cpp:582
void onOpenFlow(std::shared_ptr< FlowSaveInfo > flow, const QString &nodeId, const maki::FocusProperties &properties)
Handles open flow events.
Definition main_window.cpp:1840
void unbindCanvas(Canvas *canvas)
Unbinds signals and slots for the canvas.
Definition main_window.cpp:982
void onSettingsChanged(bool initialSetup)
Handles settings change events.
Definition main_window.cpp:627
void onCanvasTabChanged(QWidget *widget)
Handles changes in the canvas tab.
Definition main_window.cpp:1769
Canvas * mActiveCanvas
Pointer to the host services.
Definition main_window.h:109
void bindShortcuts()
Binds shortcuts to actions.
Definition main_window.cpp:991
void startUI()
Starts the user interface.
Definition main_window.cpp:693
PluginTab * mPluginTab
Pointer to the active canvas.
Definition main_window.h:110
Pipeline * mPipeline
Language manager shared pointer.
Definition main_window.h:107
void addEditorTab(QPlainTextEdit *view)
Adds an editor tab with the specified view.
Definition main_window.cpp:1930
void addBrowserTab()
Adds a browser tab to the application.
Canvas * rootCanvas() const
Returns the root canvas.
Definition main_window.cpp:1203
VoidResult start()
Starts the application.
Definition main_window.cpp:113
std::shared_ptr< EdgeRouter > mRouter
Pointer to the theme manager.
Definition main_window.h:118
void onActionRenamePipeline(const QString &pipelineId)
Handles generate action.
Definition main_window.cpp:1508
void onActionRestart()
Handles exit action.
Definition main_window.cpp:1393
void onActionExit()
Handles save action.
Definition main_window.cpp:1388
std::unique_ptr< PluginManager > mPluginManager
Handler for saving data.
Definition main_window.h:101
MainWindow(QApplication *app, oclero::qlementine::ThemeManager *themeManager, QWidget *parent=nullptr)
Constructs a new MainWindow object.
Definition main_window.cpp:96
std::shared_ptr< SettingsManager > mSettingsManager
Manager for plugins.
Definition main_window.h:102
VoidResult loadElementLibrary(const QString &name, const JSON &config, bool dataOnly)
Loads an element library based on the provided name and configuration.
Definition main_window.cpp:1273
void onActionGenerate(const QString &pipelineId, bool fromScratch)
Handles save as action.
Definition main_window.cpp:1408
VoidResult onActionSave()
Handles load action with a specified file name.
Definition main_window.cpp:1617
Canvas * canvas() const
Pointer to the QApplication instance.
Definition main_window.cpp:1198
void addPluginTab(const QString &name, PluginView *view)
Adds a plugin tab with the specified name and view.
Definition main_window.cpp:1919
void onNodeSelected(const QString &nodeId, bool selected)
Handles node selection events.
Definition main_window.cpp:1750
void removePluginTab(PluginView *view)
Removes a plugin tab with the specified name.
Definition main_window.cpp:1925
void closeCanvasTab(QWidget *widget)
Closes a canvas tab at the specified index.
Definition main_window.cpp:1808
void bindCanvas(Canvas *canvas)
Binds signals and slots for the canvas.
Definition main_window.cpp:968
HostServices * mHostServices
Pointer to the pipeline.
Definition main_window.h:108
int libraryTypeToIndex(Types::LibraryTypes type) const
Converts a library type to its corresponding index.
Definition main_window.cpp:1948
Represents a graphical node item in a flowchart.
Definition node.h:28
Manages the lifecycle and positioning of notification toasts.
Definition notification_manager.h:23
Executes and manages a sequence of external processes.
Definition pipeline.h:22
Manages plugins and their associated functionality.
Definition plugin_manager.h:27
Tab manager responsible for integrating plugin-provided views into the UI.
Definition plugin_tab.h:25
Custom QGraphicsView for plugin functionality.
Definition plugin_view.h:11
Handles saving and loading of diagrams.
Definition save_handler.h:18
Represents a save information object that implements IDocument.
Definition save_info.h:27
Manages application settings and provides access to them.
Definition settings_manager.h:142
Definition tour_guide.h:51
Definition plugin_pipeline.h:19
Contains UI helper widgets and layout grouping utilities used by MAKI.
Definition macros.h:9
Holds appearance settings.
Definition settings_manager.h:50
Definition document_event.h:49
Definition focus_properties.h:19