API Documentation
Loading...
Searching...
No Matches
QTIconManager.h
Go to the documentation of this file.
1/**--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: QTIconManager
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Buffer.h>
35#include <NDEVR/String.h>
36#include <NDEVR/File.h>
37#include <NDEVR/Dictionary.h>
38#include <NDEVR/RGBColor.h>
39#include <NDEVR/LABColor.h>
40#include <NDEVR/Resource.h>
41#include <NDEVR/UUID.h>
42#include <qiconengine.h>
43#include <QTransform>
44#include <QIcon>
45#include <QPointer>
46class QImage;
47class QPixmap;
48class QIcon;
49class QWidget;
50namespace NDEVR
51{
52 class Log;
53 class HSBColor;
72 {
73 public:
75 : m_id(id)
76 {}
77 [[nodiscard]] virtual QIcon createIcon(const String& icon, const IconThemeSettings& theme, QIcon::Mode mode = QIcon::Mode::Normal) = 0;
78 [[nodiscard]] virtual bool canProcess(const String& icon, const IconThemeSettings& theme, QIcon::Mode mode) const = 0;
79 [[nodiscard]] UUID id() const { return m_id; }
80 private:
81 UUID m_id;
82 };
83 class NDEVR_WIDGETS_API DeferredImageIconEngine : public QIconEngine
84 {
85 public:
86 DeferredImageIconEngine(const String& icon, QIcon::Mode mode = QIcon::Mode::Normal);
88 void setIconTheme(const IconThemeSettings theme);
89 virtual void paint(QPainter* painter, const QRect& rect, QIcon::Mode mode, QIcon::State state) override;
90 virtual QPixmap pixmap(const QSize& size, QIcon::Mode mode, QIcon::State state) override;
91 virtual QIconEngine* clone(void) const override;
92 QSize actualSize(const QSize& size, QIcon::Mode mode, QIcon::State state) override;
93 public:
96 QIcon::Mode m_override_mode;
97 mutable QSize m_default_size;
98 };
100 {
101 public:
102 virtual bool canPotentiallyResolve(const String& pixmap_resource) = 0;
103 virtual QPixmap resolve(const String& pixmap_resource, QIcon::Mode mode, const QSize& requested_size, Dictionary<String, QPixmap>& pixmaps) = 0;
104 virtual UUID id() const = 0;
105 };
106
108 {
109 friend class NDEVRSVGIconEngine;
111 public:
112 //Used to set the user's icon theme. Will be saved to INI files for next session
113 static void SetLightingTheme(const IconThemeSettings& theme);
114 //Used to override the user's icon specified theme
115 static void SetOverrideTheme(IconThemeSettings* theme);
116 static void GetIconResource(const std::function<void(const String&, const QIcon&)>& on_finished, const String& icon, QIcon::Mode mode = QIcon::Mode::Normal);
117 static void GetIconResource(const std::function<void(const String&, const QIcon&)>& on_finished, const String& icon, const IconThemeSettings& theme, QIcon::Mode mode = QIcon::Mode::Normal);
118 static void GetPixmapResource(const std::function<void(const String&, const QPixmap&)>& on_finished, const String& pixmap, QIcon::Mode mode = QIcon::Mode::Normal, const QSize& requested_size = QSize());
119
120 static QIcon GetIconResourceBlocking(const String& icon, QIcon::Mode mode = QIcon::Mode::Normal);
121 static QIcon GetIconResourceBlocking(const String& icon, const IconThemeSettings& theme, QIcon::Mode mode = QIcon::Mode::Normal);
122 static QPixmap LocalPixmapResource(const String& pixmap, QIcon::Mode mode = QIcon::Mode::Normal, const QSize& requested_size = QSize());
123 static void PostIconResourceLoad(const String& id);
124 static void SetWindowIcon(const String& s, QWidget* widget);
125 static void ClearWindowIcon(QWidget* widget);
126 static Buffer<std::pair<LABColor, LABColor>> ConvertColorPalette(const Buffer<std::pair<RGBColor, RGBColor>>& palette);
127 static void ConvertColorTheme(const Buffer<std::pair<RGBColor, RGBColor>>& colors, const Buffer<File>& in, const File& out_location, bool preserve_brightness, bool preserve_alpha, Log* log = nullptr);
128 static void ConvertColorTheme(const Buffer<std::pair<RGBColor, RGBColor>>& colors, const File& in_location, const File& out_location, bool preserve_brightness, bool preserve_alpha, Log* log = nullptr);
129 static void ConvertColorTheme(const Buffer<std::pair<LABColor, LABColor>>& color, QImage& image, bool preserve_brightness, bool preserve_alpha);
130 static QImage AutoCrop(const QImage& pixmap, int margin = 0, bool preserve_ratio = false);
131 static const QPixmap& disabledPixmap(const String& icon_name);
132 static QImage FillBackground(const QImage& pixmap, RGBColor color);
133 static QImage CleanupImageForIcon(const QImage& image);
134 static const Buffer<IconThemeSettings>& iconThemes();
135 static void addIconTheme(const IconThemeSettings& theme);
136 static const IconThemeSettings& EffectiveIconTheme();
139 static IconThemeSettings OutlineIconTheme();
140 static IconThemeSettings NDEVRIconTheme();
141 static constexpr const char* NDEVRThemeLocation() { return "NDEVR Icons/"; }
142 static void AddIconEngine(NDEVRIconEngine* engine);
143 static String GetSVGPath(const String& icon, const IconThemeSettings& theme);
144 static String IconCacheLocation(const String& icon, const IconThemeSettings& theme);
145 static String ImageCacheLocation(const String& icon);
146 static void AddResolver(PixmapResolver* resolver);
147 protected:
148 static File GetImagePath(const String& icon);
149 static QIcon icon(const String& icon, QIcon::Mode mode = QIcon::Mode::Normal);
150 static QIcon icon(const String& icon, const IconThemeSettings& theme, QIcon::Mode mode = QIcon::Mode::Normal);
151 static QPixmap pixmap(const String& pixmap, QIcon::Mode mode = QIcon::Mode::Normal, const QSize& requested_size = QSize());
152 private:
153 static Dictionary<UUID, PixmapResolver*> s_resolvers;
154 static Dictionary<QWidget*, String> s_window_registered;
155 static Dictionary<String, QIcon> s_icon_dictionary;
156 static Dictionary<String, QPixmap> s_pixmap_dictionary;
157 static Dictionary<String, QPixmap> s_disabled_pixmap_dictionary;
158 static Dictionary<UUID, NDEVRIconEngine*> s_icon_engines;
159 static Buffer<IconThemeSettings> s_icon_themes;
160 };
162}
bool operator!=(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
Definition VulkanRenderObject.cpp:10
bool operator==(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
Definition VulkanRenderObject.cpp:18
#define NDEVR_WIDGETS_T_API
Definition DLLInfo.h:82
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:81
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition QTIconManager.h:84
QIcon::Mode m_override_mode
Definition QTIconManager.h:96
QSize m_default_size
Definition QTIconManager.h:97
String m_icon
Definition QTIconManager.h:95
QPixmap m_cached_pixmap
Definition QTIconManager.h:94
Definition Dictionary.h:48
Definition File.h:47
Definition Log.h:43
Definition QTIconManager.h:72
virtual QIcon createIcon(const String &icon, const IconThemeSettings &theme, QIcon::Mode mode=QIcon::Mode::Normal)=0
NDEVRIconEngine(const UUID &id)
Definition QTIconManager.h:74
UUID id() const
Definition QTIconManager.h:79
virtual bool canProcess(const String &icon, const IconThemeSettings &theme, QIcon::Mode mode) const =0
Definition QTIconManager.h:100
virtual bool canPotentiallyResolve(const String &pixmap_resource)=0
virtual UUID id() const =0
virtual QPixmap resolve(const String &pixmap_resource, QIcon::Mode mode, const QSize &requested_size, Dictionary< String, QPixmap > &pixmaps)=0
Definition QTIconManager.h:108
static Resource< IconThemeSettings > s_icon_theme
Definition QTIconManager.h:138
static Resource< IconThemeSettings * > s_overide_icon_theme
Definition QTIconManager.h:137
static constexpr const char * NDEVRThemeLocation()
Definition QTIconManager.h:141
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
Definition Toggle.h:41
Definition String.h:40
Definition StringStream.h:62
Definition UUID.h:66
Definition ACIColor.h:37
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
Definition QTIconManager.h:55
RGBColor secondary_color
Definition QTIconManager.h:62
String theme_name
Definition QTIconManager.h:58
bool blend_color
Definition QTIconManager.h:67
fltp08 pixel_size
Definition QTIconManager.h:65
String theme_icon_location
Definition QTIconManager.h:59
String theme_icon
Definition QTIconManager.h:57
RGBColor primary_color
Definition QTIconManager.h:61
RGBColor highlight_color
Definition QTIconManager.h:60
bool colorize_svgs
Definition QTIconManager.h:66
RGBColor accent_color
Definition QTIconManager.h:63
RGBColor outline_color
Definition QTIconManager.h:64