Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
main_window.h
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#ifndef MAINWINDOW_H
5#define MAINWINDOW_H
6
7#include <QDir>
8#include <QMainWindow>
9#include <QStringLiteral>
10#include <oclero/qlementine.hpp>
11
12#include "compiler/pipeline_graph.h"
13#include "config_table.h"
14#include "focus_properties.h"
15#include "json.h"
16#include "main_window_layout.h"
17#include "result.h"
18#include "widgets/notification_manager.h"
19#include "widgets/settings_manager.h"
20
21class Flow;
22class Canvas;
23class NodeItem;
24class Pipeline;
25class Generator;
26class SaveInfo;
27class SaveHandler;
28class HostServices;
29class PluginManager;
30class SettingsManager;
32class PluginTab;
33class PluginView;
34class QPlainTextEdit;
35class Logger;
36class LanguageManager;
37class EdgeRouter;
38
39namespace maki
40{
41class PluginPipeline;
42}
43
48{
49 Q_OBJECT
50
51public:
59 explicit MainWindow(QApplication* app, oclero::qlementine::ThemeManager* themeManager, QWidget* parent = nullptr);
60
65
71 VoidResult start();
72
73private slots:
80 void onNodeSelected(NodeItem* node, bool selected);
81
87 void onNodeAdded(NodeItem* node);
88
95 void onNodeRemoved(const QString& nodeId, const QString& parentId);
96
102 void onNodeModified(NodeItem* node);
103
110 void onOpenFlow(Flow* flow, const QString& nodeId, const maki::FocusProperties& properties);
111
118 void onFlowAdded(Flow* flow, NodeItem* node);
119
126 void onFlowRemoved(const QString& flowId, NodeItem* node);
127
133 void changeEvent(QEvent* event) override;
134
135private:
136 std::unique_ptr<SaveHandler> mSaveHandler;
137 std::unique_ptr<PluginManager> mPluginManager;
138 std::shared_ptr<ConfigurationTable> mConfigTable;
139 std::shared_ptr<SettingsManager> mSettingsManager;
140 std::shared_ptr<LanguageManager> mLanguageManager;
141
142 Pipeline* mPipeline = nullptr;
148 Logger* mLogger = nullptr;
150
151 oclero::qlementine::ThemeManager* mThemeManager;
152
153 std::shared_ptr<SaveInfo> mStorage;
154 std::shared_ptr<EdgeRouter> mRouter;
155
156 QApplication* mApp;
157
163 Canvas* canvas() const;
164
170 Canvas* rootCanvas() const;
171
177 VoidResult loadElements();
178
185 VoidResult loadLibrary(const JSON& config, bool dataOnly);
186
194 VoidResult loadElementLibrary(const QString& name, const JSON& config, bool dataOnly);
195
199 void bind();
200
204 void bindCanvas();
205
209 void unbindCanvas();
210
214 void bindShortcuts();
215
219 void startUI();
220
226 void onCanvasTabChanged(int index);
227
233 void closeCanvasTab(int index);
234
241 int libraryTypeToIndex(Types::LibraryTypes type) const;
242
249 void onThemeChanged(const AppearanceSettings& themeName, bool intialConfig);
250
254 void onSettingsChanged();
255
259 void showAboutDialog();
260
265
272 void addPluginTab(const QString& name, PluginView* view);
273
279 void removePluginTab(PluginView* view);
280
286 void addEditorTab(QPlainTextEdit* view);
287
288 // ================================================
289 // Actions
290 void onActionNew(const QString& templatePath) override;
291 void onActionLoad(const QString& filename, bool fromTemplate = false);
292 VoidResult onActionSave();
293 void onActionExit();
294 void onActionRestart();
295 void onActionSaveAs();
296 void onActionGenerate(const QString& pipelineId, bool fromScratch);
297 void onActionDeletePipeline(const QString& pipelineId);
298 void onActionEditPipeline(const QString& pipelineId);
299 void onActionRenamePipeline(const QString& pipelineId);
301 void onFileLoaded(const QString& file, const SaveInfo& info, const QString& error, bool fromTemplate);
302 VoidResult loadLastSession();
303}; // namespace qlementclassMainWindow:public MainWindowLayout
304
305#endif // MAINWINDOW_H
The Canvas class represents the main drawing area for nodes and transitions.
Definition canvas.h:29
Definition edge_router.h:11
Represents a flow in the system.
Definition flow.h:17
Handles code generation and simulation workflows using generator plugins.
Definition generator.h:25
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
Logger class that handles logging functionality.
Definition logger.h:18
MainWindowLayout(QWidget *parent=nullptr)
Constructs a new MainWindowLayout object.
Definition main_window_layout.cpp:45
void onSettingsChanged()
Handles settings change events.
Definition main_window.cpp:251
VoidResult loadLibrary(const JSON &config, bool dataOnly)
Loads a library based on the provided configuration.
Definition main_window.cpp:863
void onFlowRemoved(const QString &flowId, NodeItem *node)
Handles flow removal events.
Definition main_window.cpp:1644
void onActionLoad(const QString &filename, bool fromTemplate=false)
Handles new action.
Definition main_window.cpp:1285
void onFlowAdded(Flow *flow, NodeItem *node)
Handles flow addition events.
Definition main_window.cpp:1638
maki::PluginPipeline * mPluginPipeline
Pointer to the logger.
Definition main_window.h:149
void bind()
Binds signals and slots for the application.
Definition main_window.cpp:329
void onNodeRemoved(const QString &nodeId, const QString &parentId)
Handles node removal events.
Definition main_window.cpp:1402
void onActionEditPipeline(const QString &pipelineId)
Handles pipeline deletion.
Definition main_window.cpp:1169
NotificationManager * mNotificationManager
Pointer to the plugin tab.
Definition main_window.h:147
void onActionSaveAs()
Handles restart action.
Definition main_window.cpp:1265
Logger * mLogger
Pointer to the notification manager.
Definition main_window.h:148
void changeEvent(QEvent *event) override
Handles change events.
Definition main_window.cpp:595
void onFileLoaded(const QString &file, const SaveInfo &info, const QString &error, bool fromTemplate)
Handles log level change action.
Definition main_window.cpp:1312
std::shared_ptr< SaveInfo > mStorage
Pointer to the theme manager.
Definition main_window.h:153
VoidResult loadElements()
Loads elements into the application.
Definition main_window.cpp:824
void onActionDeletePipeline(const QString &pipelineId)
Handles generate action.
Definition main_window.cpp:1079
void closeCanvasTab(int index)
Closes a canvas tab at the specified index.
Definition main_window.cpp:1469
void onNodeSelected(NodeItem *node, bool selected)
Handles node selection events.
Definition main_window.cpp:1372
void onActionLogLevelChanged()
Handles generate action.
std::shared_ptr< LanguageManager > mLanguageManager
Settings manager shared pointer.
Definition main_window.h:140
void showAboutDialog()
Shows the about dialog.
Definition main_window.cpp:1684
void onThemeChanged(const AppearanceSettings &themeName, bool intialConfig)
Handles theme change events.
Definition main_window.cpp:206
void onNodeModified(NodeItem *node)
Handles node modification events.
Definition main_window.cpp:1408
void onCanvasTabChanged(int index)
Handles changes in the canvas tab.
Definition main_window.cpp:1419
Canvas * mActiveCanvas
Pointer to the host services.
Definition main_window.h:145
void bindShortcuts()
Binds shortcuts to actions.
Definition main_window.cpp:627
void startUI()
Starts the user interface.
Definition main_window.cpp:305
PluginTab * mPluginTab
Pointer to the active canvas.
Definition main_window.h:146
Pipeline * mPipeline
Language manager shared pointer.
Definition main_window.h:142
void addEditorTab(QPlainTextEdit *view)
Adds an editor tab with the specified view.
Definition main_window.cpp:1621
void addBrowserTab()
Adds a browser tab to the application.
Canvas * rootCanvas() const
Returns the root canvas.
Definition main_window.cpp:818
VoidResult start()
Starts the application.
Definition main_window.cpp:88
void onNodeAdded(NodeItem *node)
Handles node addition events.
Definition main_window.cpp:1390
std::shared_ptr< ConfigurationTable > mConfigTable
Manager for plugins.
Definition main_window.h:138
std::shared_ptr< EdgeRouter > mRouter
Shared pointer to save information.
Definition main_window.h:154
void onActionRenamePipeline(const QString &pipelineId)
Handles generate action.
Definition main_window.cpp:1121
void onOpenFlow(Flow *flow, const QString &nodeId, const maki::FocusProperties &properties)
Handles open flow events.
Definition main_window.cpp:1528
void onActionRestart()
Handles exit action.
Definition main_window.cpp:1005
void onActionExit()
Handles save action.
Definition main_window.cpp:1000
std::unique_ptr< PluginManager > mPluginManager
Handler for saving data.
Definition main_window.h:137
void unbindCanvas()
Unbinds signals and slots for the canvas.
Definition main_window.cpp:616
MainWindow(QApplication *app, oclero::qlementine::ThemeManager *themeManager, QWidget *parent=nullptr)
Constructs a new MainWindow object.
Definition main_window.cpp:76
std::shared_ptr< SettingsManager > mSettingsManager
Configuration table shared pointer.
Definition main_window.h:139
Generator * mGenerator
Pointer to the pipeline.
Definition main_window.h:143
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:885
void onActionGenerate(const QString &pipelineId, bool fromScratch)
Handles save as action.
Definition main_window.cpp:1020
void bindCanvas()
Binds signals and slots for the canvas.
Definition main_window.cpp:605
VoidResult onActionSave()
Handles load action with a specified file name.
Definition main_window.cpp:1235
Canvas * canvas() const
Pointer to the QApplication instance.
Definition main_window.cpp:813
void addPluginTab(const QString &name, PluginView *view)
Adds a plugin tab with the specified name and view.
Definition main_window.cpp:1608
void removePluginTab(PluginView *view)
Removes a plugin tab with the specified name.
Definition main_window.cpp:1614
HostServices * mHostServices
Pointer to the generator.
Definition main_window.h:144
int libraryTypeToIndex(Types::LibraryTypes type) const
Converts a library type to its corresponding index.
Definition main_window.cpp:1668
Represents a graphical node item in a flowchart.
Definition node.h:26
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:25
Manages application settings and provides access to them.
Definition settings_manager.h:140
Definition plugin_pipeline.h:19
Contains UI helper widgets and layout grouping utilities used by MAKI.
Definition generator.h:10
Holds appearance settings.
Definition settings_manager.h:49
Definition focus_properties.h:17