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
30namespace ores::qt {
31
35enum class Icon {
36 Add,
37 ArrowClockwise,
38 ArrowDownload,
39 ArrowLeft,
40 ArrowNext,
41 ArrowPrevious,
42 ArrowRight,
43 ArrowRotateCounterclockwise,
44 ArrowSync,
45 ArrowTrending,
46 Book,
47 BookOpen,
48 // Calendar icons for scheduling operations
52 BookOpenFilled, // filled variant: trading books (active state)
53 Briefcase,
54 BriefcaseFilled, // filled variant: real portfolios (active state)
55 Building,
56 BuildingBank,
57 BuildingSkyscraper,
58 Chart,
59 ChartMultiple,
60 Checkmark,
61 Classification,
62 Clock,
63 Code,
64 ContactCard,
65 Copy,
66 Currency,
67 Database,
68 Delete,
69 DeleteDismiss,
70 Dismiss,
71 DocumentCode,
72 DocumentTable,
73 Edit,
74 Error,
75 ExportCsv,
76 ExportFpml,
77 ExportOre,
78 Flag,
79 Folder,
80 FolderOpen,
81 Globe,
82 Handshake,
83 History,
84 Histogram,
85 ImportCsv,
86 ImportFpml,
87 ImportOre,
88 Info,
89 Key,
90 KeyMultiple,
91 Keyboard,
92 Library,
93 LockClosed,
94 LockOpen,
95 NoteEdit,
96 Notepad,
97 Open,
98 Organization,
99 PasswordReset,
100 PeopleTeam,
101 Person,
102 PersonAccounts,
103 PersonAdd,
104 PlugConnected,
105 PlugConnectedFilled,
106 PlugDisconnected,
107 Publish,
108 Question,
109 Record,
110 RecordFilled,
111 Save,
112 Server,
113 ServerLink,
114 ServerLinkFilled,
115 Settings,
116 Star,
117 Table,
118 Tag,
119 TasksApp,
120 Terminal,
121 Wand,
122 Warning
123};
124
128enum class IconTheme {
129 FluentUIRegular,
130 FluentUIFilled,
131 SolarizedLinear,
132 SolarizedBold
133};
134
139public:
140 // Common icon colors
141 static inline const QColor DefaultIconColor{220, 220, 220};
142 static inline const QColor ConnectedColor{100, 200, 100};
143 static inline const QColor DisconnectedColor{200, 100, 100};
144 static inline const QColor ReconnectingColor{230, 180, 80};
145 static inline const QColor RecordingOnColor{220, 80, 80};
146 static inline const QColor DisabledIconColor{100, 100, 100};
147
148private:
149 static inline IconTheme currentTheme_{IconTheme::FluentUIRegular};
150 inline static std::string_view logger_name = "ores.qt.icon_utils";
151
152 static auto& lg() {
153 using namespace ores::logging;
154 static auto instance = make_logger(logger_name);
155 return instance;
156 }
157
158public:
163 static void setTheme(IconTheme theme) { currentTheme_ = theme; }
164
169 static IconTheme currentTheme() { return currentTheme_; }
170
176 static QString iconPath(Icon icon);
177
184 static QIcon createRecoloredIcon(Icon icon, const QColor& color);
185
197 static QIcon createRecoloredIcon(const QString& svgPath, const QColor& color);
198
208 static QIcon svgDataToIcon(const std::string& svg_data);
209
217 static QPixmap svgDataToPixmap(const std::string& svg_data, int height);
218};
219
220}
221
222#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Icon
Enumeration of available application icons by semantic function.
Definition IconUtils.hpp:35
@ 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:128
Utility class for icon manipulation operations.
Definition IconUtils.hpp:138
static QPixmap svgDataToPixmap(const std::string &svg_data, int height)
Renders SVG data to a QPixmap at specified height, preserving aspect ratio.
Definition IconUtils.cpp:201
static void setTheme(IconTheme theme)
Sets the global icon theme.
Definition IconUtils.hpp:163
static QIcon createRecoloredIcon(Icon icon, const QColor &color)
Creates a recolored version of a semantic icon using the current global theme.
Definition IconUtils.cpp:153
static QIcon svgDataToIcon(const std::string &svg_data)
Renders SVG data to a QIcon preserving aspect ratio.
Definition IconUtils.cpp:234
static IconTheme currentTheme()
Gets the current global icon theme.
Definition IconUtils.hpp:169
static QString iconPath(Icon icon)
Gets the resource path for a semantic icon using the current global theme.
Definition IconUtils.cpp:130