NDEVR
API Documentation
SVGIconManager.h
1#pragma once
2#include "DLLInfo.h"
3#include "Widgets/Headers/QTIconManager.h"
4#include "Base/Headers/Buffer.hpp"
5#include <QTransform>
6#include <QIconEngine>
7class QSvgRenderer;
8namespace NDEVR
9{
14 {
19 IconEngineItem(const QTransform& transform, QSvgRenderer* render, bool draw_shadow)
21 , renderer(render)
23 {}
24 QTransform transform;
25 QSvgRenderer* renderer;
27 };
28
31 class NDEVR_IMAGES_API NDEVRSVGIconEngine : public QIconEngine
32 {
33 public:
38 NDEVRSVGIconEngine(const StringView& icon, const IconThemeSettings& theme, QIcon::Mode mode = QIcon::Mode::Normal);
44 NDEVRSVGIconEngine(const Buffer<IconEngineItem>& renderers, const StringView& icon, const IconThemeSettings& theme, QIcon::Mode mode = QIcon::Mode::Normal);
46 ~NDEVRSVGIconEngine();
52 virtual void paint(QPainter* painter, const QRect& rect, QIcon::Mode mode, QIcon::State state) override;
58 QSize actualSize(const QSize& size, QIcon::Mode mode, QIcon::State state) override;
64 virtual QPixmap pixmap(const QSize& size, QIcon::Mode mode, QIcon::State state) override;
67 QSize defaultSize();
70 virtual QIconEngine* clone(void) const override;
71
72 protected:
75 void createSVGRenderer(const QSize& size);
76 public:
77 Buffer<IconEngineItem> m_renderers;
78 Dictionary<QIcon::Mode, QPixmap> m_cached_pixmap;
79 IconThemeSettings m_icon_theme;
80 String m_icon;
81 QIcon::Mode m_override_mode;
82 mutable QSize m_default_size;
83 };
88 {
89 public:
97 QIcon createIcon(const StringView& icon, const IconThemeSettings& theme, QIcon::Mode mode = QIcon::Mode::Normal) final override;
103 bool canProcess(const StringView& icon, const IconThemeSettings& theme, QIcon::Mode mode) const final override;
104 private:
105 UUID m_id;
106 };
107}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
NDEVRIconEngine(const UUID &id)
Constructs an icon engine with the given unique identifier.
QIcon createIcon(const StringView &icon, const IconThemeSettings &theme, QIcon::Mode mode=QIcon::Mode::Normal) final override
Creates a QIcon from the given SVG icon identifier.
SVGIconEngine()
Constructs an SVGIconEngine.
bool canProcess(const StringView &icon, const IconThemeSettings &theme, QIcon::Mode mode) const final override
Checks whether this engine can process the given icon.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
@ icon
Icon identifier for the object.
QSvgRenderer * renderer
The SVG renderer for this element.
QTransform transform
The transform applied when rendering this SVG element.
bool draw_shadow
Whether to draw a drop shadow behind this element.
IconEngineItem(const QTransform &transform, QSvgRenderer *render, bool draw_shadow)
Constructs an IconEngineItem with a transform, renderer, and shadow flag.
Stores information for how to draw icons, when supported.