Qt ForkAwesome 0.1.0
Library that bundles ForkAwesome for use within Qt applications
renderer.h
Go to the documentation of this file.
1#ifndef QT_FORK_AWESOME_RENDERER
2#define QT_FORK_AWESOME_RENDERER
3
4#include "./global.h"
5#include "./iconfwd.h"
6
7#include <QString>
8
9#include <memory>
10
11QT_FORWARD_DECLARE_CLASS(QByteArray)
12QT_FORWARD_DECLARE_CLASS(QColor)
13QT_FORWARD_DECLARE_CLASS(QPainter)
14QT_FORWARD_DECLARE_CLASS(QRect)
15QT_FORWARD_DECLARE_CLASS(QSize)
16QT_FORWARD_DECLARE_CLASS(QPixmap)
17QT_FORWARD_DECLARE_CLASS(QIcon)
18
19namespace QtForkAwesome {
20
22 struct InternalData;
23
24public:
25 explicit Renderer(const QString &fontFileName = QString());
26 explicit Renderer(const QByteArray &fontData);
27 ~Renderer();
28
29 operator bool() const;
30 void render(QChar character, QPainter *painter, const QRect &rect, const QColor &color) const;
31 void render(Icon icon, QPainter *painter, const QRect &rect, const QColor &color) const;
32
33 QPixmap pixmap(QChar icon, const QSize &size, const QColor &color) const;
34 QPixmap pixmap(Icon icon, const QSize &size, const QColor &color) const;
35
36 void addThemeOverride(QChar character, const QString &iconNameInTheme);
37 void addThemeOverride(Icon icon, const QString &iconNameInTheme);
38 void addOverride(QChar character, const QIcon &override);
39 void addOverride(Icon icon, const QIcon &override);
40 void clearOverrides();
41
42 static Renderer &global();
43
44private:
45 std::unique_ptr<Renderer::InternalData> m_d;
46};
47
51inline void Renderer::render(Icon icon, QPainter *painter, const QRect &rect, const QColor &color) const
52{
53 render(QChar(static_cast<IconBaseType>(icon)), painter, rect, color);
54}
55
59inline void Renderer::addThemeOverride(Icon icon, const QString &iconNameInTheme)
60{
61 addThemeOverride(QChar(static_cast<IconBaseType>(icon)), iconNameInTheme);
62}
63
67inline void Renderer::addOverride(Icon icon, const QIcon &override)
68{
69 addOverride(QChar(static_cast<IconBaseType>(icon)), override);
70}
71
72} // namespace QtForkAwesome
73
74#endif // QT_FORK_AWESOME_RENDERER
Allows rendering a QtForkAwesome::Icon (or an arbitrary QChar using an arbitrary font file).
Definition: renderer.h:21
#define QT_FORK_AWESOME_EXPORT
Marks the symbol to be exported by the qtforkawesome library.
Contains classes provided by the QtForkAwesome library.
Definition: renderer.h:19
Icon
The Icon enum specifies a ForkAwesome icon for calling QtForkAwesome::Renderer::render().
Definition: icon.h:11
std::remove_reference_t< decltype(QChar().unicode())> IconBaseType
Definition: iconfwd.h:10