ORE Studio 0.0.4
Loading...
Searching...
No Matches
MainWindow.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2024 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_QT_MAIN_WINDOW_HPP
21#define ORES_QT_MAIN_WINDOW_HPP
22
23#include <QMainWindow>
24#include <QLabel>
25#include <QTimer>
26#include <QSystemTrayIcon>
27#include <QMenu>
28#include <QColor>
29#include <memory>
30#include <vector>
31#include <boost/uuid/uuid.hpp>
32#include "ores.qt/ClientManager.hpp"
33#include "ores.qt/MdiAreaWithBackground.hpp"
34#include "ores.eventing/service/event_bus.hpp"
35#include "ores.logging/make_logger.hpp"
36#include "ui_MainWindow.h"
37
38namespace Ui {
39
40class MainWindow;
41
42}
43
44namespace ores::connections::service {
45
46class connection_manager;
47
48}
49
50namespace ores::qt {
51
52class DetachableMdiSubWindow;
53class CurrencyController;
54class CountryController;
55class AccountController;
56class RoleController;
57class FeatureFlagController;
58class ChangeReasonCategoryController;
59class ChangeReasonController;
60class OriginDimensionController;
61class NatureDimensionController;
62class TreatmentDimensionController;
63class CodingSchemeAuthorityTypeController;
64class DataDomainController;
65class SubjectAreaController;
66class CatalogController;
67class CodingSchemeController;
68class MethodologyController;
69class DatasetController;
70class DatasetBundleController;
71class ImageCache;
72class ChangeReasonCache;
73class DataLibrarianWindow;
74
97class MainWindow : public QMainWindow {
98 Q_OBJECT
99
100private:
101 inline static std::string_view logger_name = "ores.qt.main_window";
102
103 [[nodiscard]] static auto& lg() {
104 using namespace ores::logging;
105 static auto instance = make_logger(logger_name);
106 return instance;
107 }
108
109public:
118 explicit MainWindow(QWidget* parent = nullptr);
119
123 ~MainWindow() override;
124
128 ClientManager* getClientManager() const { return clientManager_; }
129
136 void setInstanceInfo(const QString& name, const QColor& color = QColor());
137
144 void updateWindowTitle();
145
146protected:
153 void closeEvent(QCloseEvent* event) override;
154
155private slots:
162 void onLoginTriggered();
163
167 void onDisconnectTriggered();
168
172 void onAboutTriggered();
173
177 void onMyAccountTriggered();
178
182 void onMySessionsTriggered();
183
187 void onDetachAllTriggered();
188
197 void onDetachableWindowCreated(DetachableMdiSubWindow* window);
198
207 void onDetachableWindowDestroyed(DetachableMdiSubWindow* window);
208
215 void onWindowMenuAboutToShow();
216
217 // Protocol recording slots
224 void onRecordSessionToggled(bool checked);
225
229 void onOpenRecordingTriggered();
230
234 void onSetRecordingDirectoryTriggered();
235
242 void onConnectionBrowserTriggered();
243
249 void onConnectionConnectRequested(const boost::uuids::uuid& environmentId,
250 const QString& connectionName);
251
252 void onModernLoginTriggered();
253
260 void onLoginSuccess(const QString& username);
261
262private:
268 void showSignUpDialog(const QString& host, int port);
269
278 void showSystemProvisionerWizard(const std::vector<BootstrapBundleInfo>& bundles);
279
283 struct LoginDialogOptions {
284 QString host;
285 int port = 5433;
286 QString username;
287 QString password;
288 QString connectionName;
289 bool showSavedConnections = true;
290 bool showSignUpButton = true;
291 };
292
299 void showLoginDialog();
300
309 void showLoginDialog(const LoginDialogOptions& options);
310
318 void updateMenuState();
319
326 void createControllers();
327
331 void performDisconnectCleanup();
332
340 bool initializeConnectionManager();
341
342private:
344 Ui::MainWindow* ui_;
345
347 MdiAreaWithBackground* mdiArea_;
348
350 QLabel* connectionStatusIconLabel_;
351
358 QList<DetachableMdiSubWindow*> allDetachableWindows_;
359
361 QIcon connectedIcon_;
362
364 QIcon disconnectedIcon_;
365
367 QIcon reconnectingIcon_;
368
370 QIcon recordOffIcon_;
371
373 QIcon recordOnIcon_;
374
375 // Entity controllers
382 std::unique_ptr<CurrencyController> currencyController_;
383
390 std::unique_ptr<CountryController> countryController_;
391
398 std::unique_ptr<AccountController> accountController_;
399
406 std::unique_ptr<RoleController> roleController_;
407
414 std::unique_ptr<FeatureFlagController> featureFlagController_;
415
422 std::unique_ptr<ChangeReasonCategoryController> changeReasonCategoryController_;
423
430 std::unique_ptr<ChangeReasonController> changeReasonController_;
431
438 std::unique_ptr<OriginDimensionController> originDimensionController_;
439
446 std::unique_ptr<NatureDimensionController> natureDimensionController_;
447
454 std::unique_ptr<TreatmentDimensionController> treatmentDimensionController_;
455
462 std::unique_ptr<CodingSchemeAuthorityTypeController> codingSchemeAuthorityTypeController_;
463
470 std::unique_ptr<DataDomainController> dataDomainController_;
471
478 std::unique_ptr<SubjectAreaController> subjectAreaController_;
479
486 std::unique_ptr<CatalogController> catalogController_;
487
494 std::unique_ptr<CodingSchemeController> codingSchemeController_;
495
502 std::unique_ptr<MethodologyController> methodologyController_;
503
510 std::unique_ptr<DatasetController> datasetController_;
511
518 std::unique_ptr<DatasetBundleController> datasetBundleController_;
519
521 std::shared_ptr<eventing::service::event_bus> eventBus_;
522
524 ClientManager* clientManager_;
525
527 ImageCache* imageCache_;
528
530 ChangeReasonCache* changeReasonCache_;
531
533 std::string username_;
534
536 QSystemTrayIcon* systemTrayIcon_;
537
539 QMenu* trayContextMenu_;
540
542 std::vector<eventing::service::subscription> eventSubscriptions_;
543
545 QString instanceName_;
546
548 QColor instanceColor_;
549
551 QLabel* instanceColorIndicator_;
552
554 DetachableMdiSubWindow* eventViewerWindow_;
555
557 DetachableMdiSubWindow* telemetryViewerWindow_;
558
560 std::unique_ptr<connections::service::connection_manager> connectionManager_;
561
563 DetachableMdiSubWindow* connectionBrowserWindow_{nullptr};
564
566 DetachableMdiSubWindow* dataLibrarianWindow_{nullptr};
567
569 QString activeConnectionName_;
570
572 QString masterPassword_;
573};
574
575}
576
577#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
QMdiSubWindow that can be detached to become a floating window.
Definition DetachableMdiSubWindow.hpp:39
Main application window providing the MDI interface and entity management.
Definition MainWindow.hpp:97
ClientManager * getClientManager() const
Get the client manager.
Definition MainWindow.hpp:128
void updateWindowTitle()
Update the window title to reflect current state.
Definition MainWindow.cpp:1459
~MainWindow() override
Destroys the main window.
Definition MainWindow.cpp:682
void closeEvent(QCloseEvent *event) override
Handles the close event for the main window.
Definition MainWindow.cpp:647
void setInstanceInfo(const QString &name, const QColor &color=QColor())
Set instance identification info for multi-instance testing.
Definition MainWindow.cpp:1428