diff --git a/libs/libkis/Document.h b/libs/libkis/Document.h --- a/libs/libkis/Document.h +++ b/libs/libkis/Document.h @@ -190,6 +190,22 @@ */ bool setColorSpace(const QString &colorModel, const QString &colorDepth, const QString &colorProfile); + /** + * @brief backGroundColor returns the current background color of the document. The color will + * also include the opacity. + * + * @return QColor + */ + QColor backGroundColor(); + + /** + * @brief setBackGroundColor sets the background color of the document. It will trigger a projection + * also. + * + * @param color A QColor that matches the document's colorModel. + * @return bool + */ + bool setBackGroundColor(const QColor &color); /** * @brief documentInfo creates and XML document representing document and author information. diff --git a/libs/libkis/Document.cpp b/libs/libkis/Document.cpp --- a/libs/libkis/Document.cpp +++ b/libs/libkis/Document.cpp @@ -52,8 +52,10 @@ #include #include #include +#include #include +#include #include #include #include @@ -197,6 +199,28 @@ return true; } +QColor Document::backGroundColor() +{ + if (!d->document) return QColor(); + if (!d->document->image()) return QColor(); + + const KoColor color = d->document->image()->defaultProjectionColor(); + return color.toQColor(); +} + +bool Document::setBackGroundColor(const QColor &color) +{ + if (!d->document) return false; + if (!d->document->image()) return false; + + KoColor background = KoColor(color, d->document->image()->colorSpace()); + d->document->image()->setDefaultProjectionColor(background); + + d->document->image()->setModified(); + d->document->image()->initialRefreshGraph(); + + return true; +} QString Document::documentInfo() const { diff --git a/plugins/extensions/pykrita/sip/krita/Document.sip b/plugins/extensions/pykrita/sip/krita/Document.sip --- a/plugins/extensions/pykrita/sip/krita/Document.sip +++ b/plugins/extensions/pykrita/sip/krita/Document.sip @@ -26,6 +26,8 @@ QString colorProfile() const; bool setColorProfile(const QString &colorProfile); bool setColorSpace(const QString &value, const QString &colorDepth, const QString &colorProfile); + QColor backGroundColor(); + bool setBackGroundColor(const QColor &color); QString documentInfo() const; void setDocumentInfo(const QString &document); QString fileName() const;