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 <QPointer>
26#include <QTimer>
27#include <QSystemTrayIcon>
28#include <QMenu>
29#include <QColor>
30#include <memory>
31#include <vector>
32#include <boost/uuid/uuid.hpp>
33#include "ores.qt/ClientManager.hpp"
34#include "ores.qt/MdiAreaWithBackground.hpp"
35#include "ores.eventing/service/event_bus.hpp"
36#include "ores.logging/make_logger.hpp"
37#include "ui_MainWindow.h"
38
39namespace Ui {
40
41class MainWindow;
42
43}
44
45namespace ores::connections::service {
46
47class connection_manager;
48
49}
50
51namespace ores::qt {
52
53class DetachableMdiSubWindow;
54class CurrencyController;
55class CountryController;
56class AccountController;
57class RoleController;
58class TenantController;
59class SystemSettingController;
60class ChangeReasonCategoryController;
61class ChangeReasonController;
62class OriginDimensionController;
63class NatureDimensionController;
64class TreatmentDimensionController;
65class CodingSchemeAuthorityTypeController;
66class DataDomainController;
67class SubjectAreaController;
68class CatalogController;
69class CodingSchemeController;
70class MethodologyController;
71class DatasetController;
72class DatasetBundleController;
73class PartyTypeController;
74class PartyStatusController;
75class PartyIdSchemeController;
76class ContactTypeController;
77class PartyController;
78class CounterpartyController;
79class BusinessCentreController;
80class BusinessUnitController;
81class BusinessUnitTypeController;
82class JobDefinitionController;
83class AppController;
84class AppVersionController;
85class ComputeDashboardController;
86class ComputeConsoleController;
87class ServiceDashboardController;
88class ReportTypeController;
89class ConcurrencyPolicyController;
90class ReportDefinitionController;
91class ReportInstanceController;
92class PortfolioController;
93class BookController;
94class BookStatusController;
95class QueueMonitorController;
96class PurposeTypeController;
97class RoundingTypeController;
98class MonetaryNatureController;
99class CurrencyMarketTierController;
100class TradeController;
101class DayCountFractionTypeController;
102class BusinessDayConventionTypeController;
103class FloatingIndexTypeController;
104class PaymentFrequencyTypeController;
105class LegTypeController;
106class InstrumentController;
107class FxInstrumentController;
108class BondInstrumentController;
109class CreditInstrumentController;
110class EquityInstrumentController;
111class CommodityInstrumentController;
112class CompositeInstrumentController;
113class ScriptedInstrumentController;
114class OreImportController;
115class PortfolioExplorerMdiWindow;
116class OrgExplorerMdiWindow;
117class ImageCache;
118class ChangeReasonCache;
119class BadgeCache;
120class DataLibrarianWindow;
121
144class MainWindow : public QMainWindow {
145 Q_OBJECT
146
147private:
148 inline static std::string_view logger_name = "ores.qt.main_window";
149
150 [[nodiscard]] static auto& lg() {
151 using namespace ores::logging;
152 static auto instance = make_logger(logger_name);
153 return instance;
154 }
155
156public:
165 explicit MainWindow(QWidget* parent = nullptr);
166
170 ~MainWindow() override;
171
175 ClientManager* getClientManager() const { return clientManager_; }
176
183 void setInstanceInfo(const QString& name, const QColor& color = QColor());
184
188 void setHttpBaseUrl(const std::string& url);
189
196 void updateWindowTitle();
197
198protected:
205 void closeEvent(QCloseEvent* event) override;
206
213 bool eventFilter(QObject* watched, QEvent* event) override;
214
215private slots:
222 void onLoginTriggered();
223
227 void onDisconnectTriggered();
228
232 void onAboutTriggered();
233
237 void onMyAccountTriggered();
238
242 void onMySessionsTriggered();
243
247 void onDetachAllTriggered();
248
257 void onDetachableWindowCreated(DetachableMdiSubWindow* window);
258
267 void onDetachableWindowDestroyed(DetachableMdiSubWindow* window);
268
275 void onWindowMenuAboutToShow();
276
277 // Protocol recording slots
284 void onRecordSessionToggled(bool checked);
285
289 void onOpenRecordingTriggered();
290
294 void onSetRecordingDirectoryTriggered();
295
302 void onConnectionBrowserTriggered();
303
309 void onConnectionConnectRequested(const boost::uuids::uuid& connectionId,
310 const QString& connectionName);
311
317 void onEnvironmentConnectRequested(const boost::uuids::uuid& environmentId,
318 const QString& environmentName);
319
320 void onModernLoginTriggered();
321
328 void onLoginSuccess(const QString& username);
329
330private:
336 void showSignUpDialog(const QString& host, int port);
337
345 void showSystemProvisionerWizard(
346 const QString& username = {}, const QString& password = {});
347
355 void showTenantOnboardingWizard();
356
364 void showTenantProvisioningWizard();
365
372 void showPartyProvisioningWizard();
373
377 struct LoginDialogOptions {
378 QString host;
379 int port = 4222;
380 QString username;
381 QString password;
382 QString connectionName;
383 bool showSavedConnections = true;
384 bool showSignUpButton = true;
385 };
386
393 void showLoginDialog();
394
403 void showLoginDialog(const LoginDialogOptions& options);
404
412 void updateMenuState();
413
420 void updateStatusBarFields();
421
429 QString buildConnectionTooltip() const;
430
437 void createControllers();
438
442 void performDisconnectCleanup();
443
451 bool initializeConnectionManager();
452
453private:
455 Ui::MainWindow* ui_;
456
458 MdiAreaWithBackground* mdiArea_;
459
461 QLabel* connectionStatusIconLabel_;
462
464 QWidget* userStatusWidget_;
465 QLabel* userStatusNameLabel_;
466
468 QWidget* serverStatusWidget_;
469 QLabel* serverStatusNameLabel_;
470
472 QWidget* tenantStatusWidget_;
473 QLabel* tenantStatusNameLabel_;
474
476 QWidget* partyStatusWidget_;
477 QLabel* partyStatusNameLabel_;
478
485 QList<QPointer<DetachableMdiSubWindow>> allDetachableWindows_;
486
488 QIcon connectedIcon_;
489
491 QIcon disconnectedIcon_;
492
494 QIcon reconnectingIcon_;
495
497 QIcon recordOffIcon_;
498
500 QIcon recordOnIcon_;
501
502 // Entity controllers
509 std::unique_ptr<CurrencyController> currencyController_;
510
517 std::unique_ptr<CountryController> countryController_;
518
525 std::unique_ptr<AccountController> accountController_;
526
533 std::unique_ptr<RoleController> roleController_;
534
541 std::unique_ptr<TenantController> tenantController_;
542
549 std::unique_ptr<SystemSettingController> systemSettingController_;
550
557 std::unique_ptr<ChangeReasonCategoryController> changeReasonCategoryController_;
558
565 std::unique_ptr<ChangeReasonController> changeReasonController_;
566
573 std::unique_ptr<OriginDimensionController> originDimensionController_;
574
581 std::unique_ptr<NatureDimensionController> natureDimensionController_;
582
589 std::unique_ptr<TreatmentDimensionController> treatmentDimensionController_;
590
597 std::unique_ptr<CodingSchemeAuthorityTypeController> codingSchemeAuthorityTypeController_;
598
605 std::unique_ptr<DataDomainController> dataDomainController_;
606
613 std::unique_ptr<SubjectAreaController> subjectAreaController_;
614
621 std::unique_ptr<CatalogController> catalogController_;
622
629 std::unique_ptr<CodingSchemeController> codingSchemeController_;
630
637 std::unique_ptr<MethodologyController> methodologyController_;
638
645 std::unique_ptr<DatasetController> datasetController_;
646
653 std::unique_ptr<DatasetBundleController> datasetBundleController_;
654
655 std::unique_ptr<PartyTypeController> partyTypeController_;
656 std::unique_ptr<PartyStatusController> partyStatusController_;
657 std::unique_ptr<PartyIdSchemeController> partyIdSchemeController_;
658 std::unique_ptr<ContactTypeController> contactTypeController_;
659 std::unique_ptr<PartyController> partyController_;
660 std::unique_ptr<CounterpartyController> counterpartyController_;
661 std::unique_ptr<BusinessCentreController> businessCentreController_;
662 std::unique_ptr<BusinessUnitController> businessUnitController_;
663 std::unique_ptr<BusinessUnitTypeController> businessUnitTypeController_;
664 std::unique_ptr<PortfolioController> portfolioController_;
665 std::unique_ptr<BookController> bookController_;
666 std::unique_ptr<BookStatusController> bookStatusController_;
667 std::unique_ptr<QueueMonitorController> queueMonitorController_;
668 std::unique_ptr<PurposeTypeController> purposeTypeController_;
669 std::unique_ptr<RoundingTypeController> roundingTypeController_;
670 std::unique_ptr<MonetaryNatureController> monetaryNatureController_;
671 std::unique_ptr<CurrencyMarketTierController> currencyMarketTierController_;
672 std::unique_ptr<TradeController> tradeController_;
673 std::unique_ptr<DayCountFractionTypeController> dayCountFractionTypeController_;
674 std::unique_ptr<BusinessDayConventionTypeController> businessDayConventionTypeController_;
675 std::unique_ptr<FloatingIndexTypeController> floatingIndexTypeController_;
676 std::unique_ptr<PaymentFrequencyTypeController> paymentFrequencyTypeController_;
677 std::unique_ptr<LegTypeController> legTypeController_;
678 std::unique_ptr<InstrumentController> instrumentController_;
679 std::unique_ptr<FxInstrumentController> fxInstrumentController_;
680 std::unique_ptr<BondInstrumentController> bondInstrumentController_;
681 std::unique_ptr<CreditInstrumentController> creditInstrumentController_;
682 std::unique_ptr<EquityInstrumentController> equityInstrumentController_;
683 std::unique_ptr<CommodityInstrumentController> commodityInstrumentController_;
684 std::unique_ptr<CompositeInstrumentController> compositeInstrumentController_;
685 std::unique_ptr<ScriptedInstrumentController> scriptedInstrumentController_;
686 std::unique_ptr<JobDefinitionController> jobDefinitionController_;
687 std::unique_ptr<AppController> appController_;
688 std::unique_ptr<AppVersionController> appVersionController_;
689 std::unique_ptr<ComputeDashboardController> computeDashboardController_;
690 std::unique_ptr<ComputeConsoleController> computeConsoleController_;
691 std::unique_ptr<ServiceDashboardController> serviceDashboardController_;
692 std::unique_ptr<ReportTypeController> reportTypeController_;
693 std::unique_ptr<ConcurrencyPolicyController> concurrencyPolicyController_;
694 std::unique_ptr<ReportDefinitionController> reportDefinitionController_;
695 std::unique_ptr<ReportInstanceController> reportInstanceController_;
696 std::unique_ptr<OreImportController> oreImportController_;
697
699 std::shared_ptr<eventing::service::event_bus> eventBus_;
700
702 ClientManager* clientManager_;
703
705 ImageCache* imageCache_;
706
708 ChangeReasonCache* changeReasonCache_;
709
711 BadgeCache* badgeCache_;
712
714 std::string username_;
715
717 std::string httpBaseUrl_;
718
720 QString party_name_;
721
723 QSystemTrayIcon* systemTrayIcon_;
724
726 QMenu* trayContextMenu_;
727
729 std::vector<eventing::service::subscription> eventSubscriptions_;
730
732 QString instanceName_;
733
735 QColor instanceColor_;
736
738 QLabel* instanceColorIndicator_;
739
741 DetachableMdiSubWindow* eventViewerWindow_;
742
744 DetachableMdiSubWindow* telemetryViewerWindow_;
745
747 std::unique_ptr<connections::service::connection_manager> connectionManager_;
748
750 DetachableMdiSubWindow* connectionBrowserWindow_{nullptr};
751
753 DetachableMdiSubWindow* dataLibrarianWindow_{nullptr};
754 DetachableMdiSubWindow* portfolioExplorerSubWindow_{nullptr};
755 DetachableMdiSubWindow* orgExplorerSubWindow_{nullptr};
756
758 DetachableMdiSubWindow* shellWindow_{nullptr};
759
761 DetachableMdiSubWindow* mySessionsWindow_{nullptr};
762
764 DetachableMdiSubWindow* myAccountWindow_{nullptr};
765
767 QString activeConnectionName_;
768
770 QString masterPassword_;
771
773 DetachableMdiSubWindow* aboutSubWindow_{nullptr};
774};
775
776}
777
778#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:112
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:144
ClientManager * getClientManager() const
Get the client manager.
Definition MainWindow.hpp:175
void updateWindowTitle()
Update the window title to reflect current state.
Definition MainWindow.cpp:2910
~MainWindow() override
Destroys the main window.
Definition MainWindow.cpp:1232
void closeEvent(QCloseEvent *event) override
Handles the close event for the main window.
Definition MainWindow.cpp:1194
bool eventFilter(QObject *watched, QEvent *event) override
Event filter to intercept tooltip events on the connection icon.
Definition MainWindow.cpp:1187
void setHttpBaseUrl(const std::string &url)
Set the HTTP base URL for compute service file uploads.
Definition MainWindow.cpp:2868
void setInstanceInfo(const QString &name, const QColor &color=QColor())
Set instance identification info for multi-instance testing.
Definition MainWindow.cpp:2878