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 <memory>
29#include <vector>
30#include "ores.qt/ClientManager.hpp"
31#include "ores.qt/MdiAreaWithBackground.hpp"
32#include "ores.eventing/service/event_bus.hpp"
33#include "ores.utility/log/make_logger.hpp"
34#include "ui_MainWindow.h"
35
36namespace Ui {
37
38class MainWindow;
39
40}
41
42namespace ores::qt {
43
44class DetachableMdiSubWindow;
45class CurrencyController;
46class AccountController;
47
70class MainWindow : public QMainWindow {
71 Q_OBJECT
72
73private:
74 inline static std::string_view logger_name = "ores.qt.main_window";
75
76 [[nodiscard]] static auto& lg() {
77 using namespace ores::utility::log;
78 static auto instance = make_logger(logger_name);
79 return instance;
80 }
81
82public:
91 explicit MainWindow(QWidget* parent = nullptr);
92
96 ~MainWindow() override;
97
101 ClientManager* getClientManager() const { return clientManager_; }
102
103protected:
110 void closeEvent(QCloseEvent* event) override;
111
112private slots:
119 void onLoginTriggered();
120
124 void onDisconnectTriggered();
125
129 void onAboutTriggered();
130
134 void onMyAccountTriggered();
135
139 void onDetachAllTriggered();
140
147 void onWindowMenuAboutToShow();
148
149private:
157 void updateMenuState();
158
165 void createControllers();
166
170 void performDisconnectCleanup();
171
172private:
174 Ui::MainWindow* ui_;
175
177 MdiAreaWithBackground* mdiArea_;
178
180 QLabel* connectionStatusIconLabel_;
181
188 QList<DetachableMdiSubWindow*> allDetachableWindows_;
189
191 QIcon connectedIcon_;
192
194 QIcon disconnectedIcon_;
195
197 QIcon reconnectingIcon_;
198
199 // Entity controllers
206 std::unique_ptr<CurrencyController> currencyController_;
207
214 std::unique_ptr<AccountController> accountController_;
215
217 std::shared_ptr<eventing::service::event_bus> eventBus_;
218
220 ClientManager* clientManager_;
221
223 std::string username_;
224
226 QSystemTrayIcon* systemTrayIcon_;
227
229 QMenu* trayContextMenu_;
230
232 std::vector<eventing::service::subscription> eventSubscriptions_;
233};
234
235}
236
237#endif
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:56
Main application window providing the MDI interface and entity management.
Definition MainWindow.hpp:70
ClientManager * getClientManager() const
Get the client manager.
Definition MainWindow.hpp:101
~MainWindow() override
Destroys the main window.
Definition MainWindow.cpp:291
void closeEvent(QCloseEvent *event) override
Handles the close event for the main window.
Definition MainWindow.cpp:271
Custom QMdiArea that displays a background logo when no windows are open.
Definition MdiAreaWithBackground.hpp:32