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 OreImportController;
113class PortfolioExplorerMdiWindow;
114class OrgExplorerMdiWindow;
115class ImageCache;
116class ChangeReasonCache;
117class BadgeCache;
118class DataLibrarianWindow;
119
142class MainWindow : public QMainWindow {
143 Q_OBJECT
144
145private:
146 inline static std::string_view logger_name = "ores.qt.main_window";
147
148 [[nodiscard]] static auto& lg() {
149 using namespace ores::logging;
150 static auto instance = make_logger(logger_name);
151 return instance;
152 }
153
154public:
163 explicit MainWindow(QWidget* parent = nullptr);
164
168 ~MainWindow() override;
169
173 ClientManager* getClientManager() const { return clientManager_; }
174
181 void setInstanceInfo(const QString& name, const QColor& color = QColor());
182
186 void setHttpBaseUrl(const std::string& url);
187
194 void updateWindowTitle();
195
196protected:
203 void closeEvent(QCloseEvent* event) override;
204
211 bool eventFilter(QObject* watched, QEvent* event) override;
212
213private slots:
220 void onLoginTriggered();
221
225 void onDisconnectTriggered();
226
230 void onAboutTriggered();
231
235 void onMyAccountTriggered();
236
240 void onMySessionsTriggered();
241
245 void onDetachAllTriggered();
246
255 void onDetachableWindowCreated(DetachableMdiSubWindow* window);
256
265 void onDetachableWindowDestroyed(DetachableMdiSubWindow* window);
266
273 void onWindowMenuAboutToShow();
274
275 // Protocol recording slots
282 void onRecordSessionToggled(bool checked);
283
287 void onOpenRecordingTriggered();
288
292 void onSetRecordingDirectoryTriggered();
293
300 void onConnectionBrowserTriggered();
301
307 void onConnectionConnectRequested(const boost::uuids::uuid& connectionId,
308 const QString& connectionName);
309
315 void onEnvironmentConnectRequested(const boost::uuids::uuid& environmentId,
316 const QString& environmentName);
317
318 void onModernLoginTriggered();
319
326 void onLoginSuccess(const QString& username);
327
328private:
334 void showSignUpDialog(const QString& host, int port);
335
343 void showSystemProvisionerWizard(
344 const QString& username = {}, const QString& password = {});
345
353 void showTenantOnboardingWizard();
354
362 void showTenantProvisioningWizard();
363
367 struct LoginDialogOptions {
368 QString host;
369 int port = 4222;
370 QString username;
371 QString password;
372 QString connectionName;
373 bool showSavedConnections = true;
374 bool showSignUpButton = true;
375 };
376
383 void showLoginDialog();
384
393 void showLoginDialog(const LoginDialogOptions& options);
394
402 void updateMenuState();
403
410 void updateStatusBarFields();
411
419 QString buildConnectionTooltip() const;
420
427 void createControllers();
428
432 void performDisconnectCleanup();
433
441 bool initializeConnectionManager();
442
443private:
445 Ui::MainWindow* ui_;
446
448 MdiAreaWithBackground* mdiArea_;
449
451 QLabel* connectionStatusIconLabel_;
452
454 QWidget* userStatusWidget_;
455 QLabel* userStatusNameLabel_;
456
458 QWidget* serverStatusWidget_;
459 QLabel* serverStatusNameLabel_;
460
462 QWidget* tenantStatusWidget_;
463 QLabel* tenantStatusNameLabel_;
464
466 QWidget* partyStatusWidget_;
467 QLabel* partyStatusNameLabel_;
468
475 QList<QPointer<DetachableMdiSubWindow>> allDetachableWindows_;
476
478 QIcon connectedIcon_;
479
481 QIcon disconnectedIcon_;
482
484 QIcon reconnectingIcon_;
485
487 QIcon recordOffIcon_;
488
490 QIcon recordOnIcon_;
491
492 // Entity controllers
499 std::unique_ptr<CurrencyController> currencyController_;
500
507 std::unique_ptr<CountryController> countryController_;
508
515 std::unique_ptr<AccountController> accountController_;
516
523 std::unique_ptr<RoleController> roleController_;
524
531 std::unique_ptr<TenantController> tenantController_;
532
539 std::unique_ptr<SystemSettingController> systemSettingController_;
540
547 std::unique_ptr<ChangeReasonCategoryController> changeReasonCategoryController_;
548
555 std::unique_ptr<ChangeReasonController> changeReasonController_;
556
563 std::unique_ptr<OriginDimensionController> originDimensionController_;
564
571 std::unique_ptr<NatureDimensionController> natureDimensionController_;
572
579 std::unique_ptr<TreatmentDimensionController> treatmentDimensionController_;
580
587 std::unique_ptr<CodingSchemeAuthorityTypeController> codingSchemeAuthorityTypeController_;
588
595 std::unique_ptr<DataDomainController> dataDomainController_;
596
603 std::unique_ptr<SubjectAreaController> subjectAreaController_;
604
611 std::unique_ptr<CatalogController> catalogController_;
612
619 std::unique_ptr<CodingSchemeController> codingSchemeController_;
620
627 std::unique_ptr<MethodologyController> methodologyController_;
628
635 std::unique_ptr<DatasetController> datasetController_;
636
643 std::unique_ptr<DatasetBundleController> datasetBundleController_;
644
645 std::unique_ptr<PartyTypeController> partyTypeController_;
646 std::unique_ptr<PartyStatusController> partyStatusController_;
647 std::unique_ptr<PartyIdSchemeController> partyIdSchemeController_;
648 std::unique_ptr<ContactTypeController> contactTypeController_;
649 std::unique_ptr<PartyController> partyController_;
650 std::unique_ptr<CounterpartyController> counterpartyController_;
651 std::unique_ptr<BusinessCentreController> businessCentreController_;
652 std::unique_ptr<BusinessUnitController> businessUnitController_;
653 std::unique_ptr<BusinessUnitTypeController> businessUnitTypeController_;
654 std::unique_ptr<PortfolioController> portfolioController_;
655 std::unique_ptr<BookController> bookController_;
656 std::unique_ptr<BookStatusController> bookStatusController_;
657 std::unique_ptr<QueueMonitorController> queueMonitorController_;
658 std::unique_ptr<PurposeTypeController> purposeTypeController_;
659 std::unique_ptr<RoundingTypeController> roundingTypeController_;
660 std::unique_ptr<MonetaryNatureController> monetaryNatureController_;
661 std::unique_ptr<CurrencyMarketTierController> currencyMarketTierController_;
662 std::unique_ptr<TradeController> tradeController_;
663 std::unique_ptr<DayCountFractionTypeController> dayCountFractionTypeController_;
664 std::unique_ptr<BusinessDayConventionTypeController> businessDayConventionTypeController_;
665 std::unique_ptr<FloatingIndexTypeController> floatingIndexTypeController_;
666 std::unique_ptr<PaymentFrequencyTypeController> paymentFrequencyTypeController_;
667 std::unique_ptr<LegTypeController> legTypeController_;
668 std::unique_ptr<InstrumentController> instrumentController_;
669 std::unique_ptr<FxInstrumentController> fxInstrumentController_;
670 std::unique_ptr<BondInstrumentController> bondInstrumentController_;
671 std::unique_ptr<CreditInstrumentController> creditInstrumentController_;
672 std::unique_ptr<EquityInstrumentController> equityInstrumentController_;
673 std::unique_ptr<CommodityInstrumentController> commodityInstrumentController_;
674 std::unique_ptr<JobDefinitionController> jobDefinitionController_;
675 std::unique_ptr<AppController> appController_;
676 std::unique_ptr<AppVersionController> appVersionController_;
677 std::unique_ptr<ComputeDashboardController> computeDashboardController_;
678 std::unique_ptr<ComputeConsoleController> computeConsoleController_;
679 std::unique_ptr<ServiceDashboardController> serviceDashboardController_;
680 std::unique_ptr<ReportTypeController> reportTypeController_;
681 std::unique_ptr<ConcurrencyPolicyController> concurrencyPolicyController_;
682 std::unique_ptr<ReportDefinitionController> reportDefinitionController_;
683 std::unique_ptr<ReportInstanceController> reportInstanceController_;
684 std::unique_ptr<OreImportController> oreImportController_;
685
687 std::shared_ptr<eventing::service::event_bus> eventBus_;
688
690 ClientManager* clientManager_;
691
693 ImageCache* imageCache_;
694
696 ChangeReasonCache* changeReasonCache_;
697
699 BadgeCache* badgeCache_;
700
702 std::string username_;
703
705 std::string httpBaseUrl_;
706
708 QString party_name_;
709
711 QSystemTrayIcon* systemTrayIcon_;
712
714 QMenu* trayContextMenu_;
715
717 std::vector<eventing::service::subscription> eventSubscriptions_;
718
720 QString instanceName_;
721
723 QColor instanceColor_;
724
726 QLabel* instanceColorIndicator_;
727
729 DetachableMdiSubWindow* eventViewerWindow_;
730
732 DetachableMdiSubWindow* telemetryViewerWindow_;
733
735 std::unique_ptr<connections::service::connection_manager> connectionManager_;
736
738 DetachableMdiSubWindow* connectionBrowserWindow_{nullptr};
739
741 DetachableMdiSubWindow* dataLibrarianWindow_{nullptr};
742 DetachableMdiSubWindow* portfolioExplorerSubWindow_{nullptr};
743 DetachableMdiSubWindow* orgExplorerSubWindow_{nullptr};
744
746 DetachableMdiSubWindow* shellWindow_{nullptr};
747
749 DetachableMdiSubWindow* mySessionsWindow_{nullptr};
750
752 DetachableMdiSubWindow* myAccountWindow_{nullptr};
753
755 QString activeConnectionName_;
756
758 QString masterPassword_;
759
761 DetachableMdiSubWindow* aboutSubWindow_{nullptr};
762};
763
764}
765
766#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:109
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:142
ClientManager * getClientManager() const
Get the client manager.
Definition MainWindow.hpp:173
void updateWindowTitle()
Update the window title to reflect current state.
Definition MainWindow.cpp:2862
~MainWindow() override
Destroys the main window.
Definition MainWindow.cpp:1219
void closeEvent(QCloseEvent *event) override
Handles the close event for the main window.
Definition MainWindow.cpp:1181
bool eventFilter(QObject *watched, QEvent *event) override
Event filter to intercept tooltip events on the connection icon.
Definition MainWindow.cpp:1174
void setHttpBaseUrl(const std::string &url)
Set the HTTP base URL for compute service file uploads.
Definition MainWindow.cpp:2820
void setInstanceInfo(const QString &name, const QColor &color=QColor())
Set instance identification info for multi-instance testing.
Definition MainWindow.cpp:2830