Add property to set default color/size of QuickImageProvider

This commit is contained in:
Martchus 2022-02-02 22:31:14 +01:00
parent 4e15167f51
commit 860209ce7d
2 changed files with 31 additions and 1 deletions

View File

@ -6,7 +6,7 @@ set(META_APP_AUTHOR "Martchus")
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_VERSION_MAJOR 0)
set(META_VERSION_MINOR 0)
set(META_VERSION_PATCH 2)
set(META_VERSION_PATCH 3)
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
set(META_VERSION_EXACT_SONAME ON) # while still on 0.x.x release
set(META_PUBLIC_QT_MODULES Core Gui)

View File

@ -15,6 +15,9 @@ namespace QtForkAwesome {
class Renderer;
class QT_QUICK_FORK_AWESOME_EXPORT QuickImageProvider : public QQuickImageProvider {
Q_PROPERTY(QColor defaultColor defaultColor name WRITE setDefaultColor)
Q_PROPERTY(QSize defaultColor defaultSize name WRITE setDefaultSize)
public:
QuickImageProvider(const Renderer &renderer, const QColor &defaultColor = QColor(), const QSize &defaultSize = QSize(64, 64),
QQuickImageProvider::ImageType type = QQuickImageProvider::Pixmap);
@ -26,12 +29,39 @@ public:
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override;
#endif
QColor defaultColor() const;
QSize defaultSize() const;
public Q_SLOTS:
void setDefaultColor(const QColor &color);
void setDefaultSize(const QSize &size);
private:
const Renderer &m_renderer;
QColor m_defaultColor;
QSize m_defaultSize;
};
inline QColor QuickImageProvider::defaultColor() const
{
return m_defaultColor;
}
inline QSize QuickImageProvider::defaultSize() const
{
return m_defaultSize;
}
inline void QuickImageProvider::setDefaultColor(const QColor &color)
{
m_defaultColor = color;
}
inline void QuickImageProvider::setDefaultSize(const QSize &size)
{
m_defaultSize = size;
}
} // namespace QtForkAwesome
#endif // QT_FORK_AWESOME_QUICK_IMAGE_PROVIDER