Add global renderer instance to allow accessing renderer of icon engine
This commit is contained in:
parent
45dc4c7291
commit
2fcc5debcd
|
@ -22,14 +22,11 @@ class QT_FORK_AWESOME_ICON_ENGINE_EXPORT ForkAwesomeIconEnginePlugin : public QI
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QIconEngine *create(const QString &filename = QString()) override;
|
QIconEngine *create(const QString &filename = QString()) override;
|
||||||
|
|
||||||
private:
|
|
||||||
const Renderer m_renderer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QIconEngine *ForkAwesomeIconEnginePlugin::create(const QString &file)
|
QIconEngine *ForkAwesomeIconEnginePlugin::create(const QString &file)
|
||||||
{
|
{
|
||||||
auto *const engine = new IconEngine(m_renderer);
|
auto *const engine = new IconEngine(Renderer::global());
|
||||||
if (!file.isNull()) {
|
if (!file.isNull()) {
|
||||||
engine->addFile(file, QSize(), QIcon::Normal, QIcon::Off);
|
engine->addFile(file, QSize(), QIcon::Normal, QIcon::Off);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,4 +113,13 @@ QPixmap Renderer::pixmap(Icon icon, const QSize &size, const QColor &color) cons
|
||||||
return pixmap(QChar(static_cast<IconBaseType>(icon)), size, color);
|
return pixmap(QChar(static_cast<IconBaseType>(icon)), size, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns the global instance (which is so far only used by the icon engine plugin).
|
||||||
|
*/
|
||||||
|
Renderer &Renderer::global()
|
||||||
|
{
|
||||||
|
static auto globalRenderer = Renderer();
|
||||||
|
return globalRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QtForkAwesome
|
} // namespace QtForkAwesome
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
QPixmap pixmap(QChar icon, const QSize &size, const QColor &color) const;
|
QPixmap pixmap(QChar icon, const QSize &size, const QColor &color) const;
|
||||||
QPixmap pixmap(Icon icon, const QSize &size, const QColor &color) const;
|
QPixmap pixmap(Icon icon, const QSize &size, const QColor &color) const;
|
||||||
|
|
||||||
|
static Renderer &global();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Renderer::InternalData> m_d;
|
std::unique_ptr<Renderer::InternalData> m_d;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue