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 Book,
46 Checkmark,
47 Clock,
48 Code,
49 Currency,
50 Database,
51 Delete,
52 DeleteDismiss,
53 Dismiss,
54 DocumentCode,
55 DocumentTable,
56 Edit,
57 Error,
58 ExportCsv,
59 ExportFpml,
60 ExportOre,
61 Flag,
62 Folder,
63 FolderOpen,
64 Globe,
65 History,
66 Histogram,
67 ImportCsv,
68 ImportFpml,
69 ImportOre,
70 Info,
71 Key,
72 KeyMultiple,
73 Library,
74 LockClosed,
75 LockOpen,
76 NoteEdit,
77 Open,
78 PasswordReset,
79 Person,
80 PersonAccounts,
81 PersonAdd,
82 PlugConnected,
83 PlugConnectedFilled,
84 PlugDisconnected,
85 Publish,
86 Question,
87 Record,
88 RecordFilled,
89 Save,
90 Server,
91 ServerLink,
92 ServerLinkFilled,
93 Settings,
94 Star,
95 Table,
96 Tag,
97 Wand,
98 Warning
99};
100
104enum class IconTheme {
105 FluentUIRegular,
106 FluentUIFilled,
107 SolarizedLinear,
108 SolarizedBold
109};
110
115public:
116 // Common icon colors
117 static inline const QColor DefaultIconColor{220, 220, 220};
118 static inline const QColor ConnectedColor{100, 200, 100};
119 static inline const QColor DisconnectedColor{200, 100, 100};
120 static inline const QColor ReconnectingColor{230, 180, 80};
121 static inline const QColor RecordingOnColor{220, 80, 80};
122 static inline const QColor DisabledIconColor{100, 100, 100};
123
124private:
125 static inline IconTheme currentTheme_{IconTheme::FluentUIRegular};
126 inline static std::string_view logger_name = "ores.qt.icon_utils";
127
128 static auto& lg() {
129 using namespace ores::logging;
130 static auto instance = make_logger(logger_name);
131 return instance;
132 }
133
134public:
139 static void setTheme(IconTheme theme) { currentTheme_ = theme; }
140
145 static IconTheme currentTheme() { return currentTheme_; }
146
152 static QString iconPath(Icon icon);
153
160 static QIcon createRecoloredIcon(Icon icon, const QColor& color);
161
173 static QIcon createRecoloredIcon(const QString& svgPath, const QColor& color);
174
184 static QIcon svgDataToIcon(const std::string& svg_data);
185
193 static QPixmap svgDataToPixmap(const std::string& svg_data, int height);
194};
195
196}
197
198#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Icon
Enumeration of available application icons by semantic function.
Definition IconUtils.hpp:35
IconTheme
Enumeration of available icon themes/styles.
Definition IconUtils.hpp:104
Utility class for icon manipulation operations.
Definition IconUtils.hpp:114
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:178
static void setTheme(IconTheme theme)
Sets the global icon theme.
Definition IconUtils.hpp:139
static QIcon createRecoloredIcon(Icon icon, const QColor &color)
Creates a recolored version of a semantic icon using the current global theme.
Definition IconUtils.cpp:130
static QIcon svgDataToIcon(const std::string &svg_data)
Renders SVG data to a QIcon preserving aspect ratio.
Definition IconUtils.cpp:211
static IconTheme currentTheme()
Gets the current global icon theme.
Definition IconUtils.hpp:145
static QString iconPath(Icon icon)
Gets the resource path for a semantic icon using the current global theme.
Definition IconUtils.cpp:107