From 860209ce7d5e11bbead488ef5b48eccefb7fbf73 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 2 Feb 2022 22:31:14 +0100 Subject: [PATCH] Add property to set default color/size of QuickImageProvider --- CMakeLists.txt | 2 +- qtquickforkawesome/imageprovider.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35deae8..aefeea5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/qtquickforkawesome/imageprovider.h b/qtquickforkawesome/imageprovider.h index 9731639..55c5406 100644 --- a/qtquickforkawesome/imageprovider.h +++ b/qtquickforkawesome/imageprovider.h @@ -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