ORE Studio 0.0.4
Loading...
Searching...
No Matches
IconUtils.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2024-2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 *
20 */
21#ifndef ORES_QT_ICON_UTILS_HPP
22#define ORES_QT_ICON_UTILS_HPP
23
24#include <QIcon>
25#include <QColor>
26#include <QString>
27#include <optional>
28#include "ores.logging/make_logger.hpp"
29#include "ores.qt/export.hpp"
30
31namespace ores::qt {
32
36enum class Icon {
37 Add,
38 ArrowClockwise,
39 ArrowDownload,
40 ArrowLeft,
41 ArrowNext,
42 ArrowPrevious,
43 ArrowRight,
44 ArrowRotateCounterclockwise,
45 ArrowSync,
46 ArrowTrending,
47 Book,
48 BookOpen,
49 // Calendar icons for scheduling operations
53 BookOpenFilled, // filled variant: trading books (active state)
54 Briefcase,
55 BriefcaseFilled, // filled variant: real portfolios (active state)
56 Building,
57 BuildingBank,
58 BuildingSkyscraper,
59 Chart,
60 ChartMultiple,
61 Checkmark,
62 Classification,
63 Clock,
64 Code,
65 ContactCard,
66 Copy,
67 Currency,
68 Database,
69 Delete,
70 DeleteDismiss,
71 Dismiss,
72 DocumentCode,
73 DocumentTable,
74 Edit,
75 Error,
76 ExportCsv,
77 ExportFpml,
78 ExportOre,
79 Flag,
80 Folder,
81 FolderOpen,
82 Globe,
83 Handshake,
84 History,
85 Histogram,
86 ImportCsv,
87 ImportFpml,
88 ImportOre,
89 Info,
90 Key,
91 KeyMultiple,
92 Keyboard,
93 Library,
94 LockClosed,
95 LockOpen,
96 NoteEdit,
97 Notepad,
98 Open,
99 Organization,
100 PasswordReset,
101 PeopleTeam,
102 Person,
103 PersonAccounts,
104 PersonAdd,
105 PlugConnected,
106 PlugConnectedFilled,
107 PlugDisconnected,
108 Publish,
109 Question,
110 Record,
111 RecordFilled,
112 Save,
113 Server,
114 ServerLink,
115 ServerLinkFilled,
116 Settings,
117 Star,
118 Table,
119 Tag,
120 TasksApp,
121 Terminal,
122 Wand,
123 Warning
124};
125
129enum class IconTheme {
130 FluentUIRegular,
131 FluentUIFilled,
132 SolarizedLinear,
133 SolarizedBold
134};
135
139class ORES_QT_API IconUtils {
140public:
141 // Common icon colors
142 static inline const QColor DefaultIconColor{220, 220, 220};
143 static inline const QColor ConnectedColor{100, 200, 100};
144 static inline const QColor DisconnectedColor{200, 100, 100};
145 static inline const QColor ReconnectingColor{230, 180, 80};
146 static inline const QColor RecordingOnColor{220, 80, 80};
147 static inline const QColor DisabledIconColor{100, 100, 100};
148
149private:
150 static inline IconTheme currentTheme_{IconTheme::FluentUIRegular};
151 inline static std::string_view logger_name = "ores.qt.icon_utils";
152
153 static auto& lg() {
154 using namespace ores::logging;
155 static auto instance = make_logger(logger_name);
156 return instance;
157 }
158
159public:
164 static void setTheme(IconTheme theme) { currentTheme_ = theme; }
165
170 static IconTheme currentTheme() { return currentTheme_; }
171
177 static QString iconPath(Icon icon);
178
185 static QIcon createRecoloredIcon(Icon icon, const QColor& color);
186
198 static QIcon createRecoloredIcon(const QString& svgPath, const QColor& color);
199
209 static QIcon svgDataToIcon(const std::string& svg_data);
210
218 static QPixmap svgDataToPixmap(const std::string& svg_data, int height);
219};
220
221}
222
223#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Icon
Enumeration of available application icons by semantic function.
Definition IconUtils.hpp:36
@ CalendarClock
Scheduled jobs / scheduler concept (calendar with clock)
@ CalendarCancel
Unschedule a job (calendar with X)
@ CalendarAdd
Schedule a new job (calendar with +)
IconTheme
Enumeration of available icon themes/styles.
Definition IconUtils.hpp:129
Utility class for icon manipulation operations.
Definition IconUtils.hpp:139
static void setTheme(IconTheme theme)
Sets the global icon theme.
Definition IconUtils.hpp:164
static IconTheme currentTheme()
Gets the current global icon theme.
Definition IconUtils.hpp:170