Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Improve Python API - Swatch
Grum 999066da4332ce6
diff --git a/libs/libkis/Swatch.cpp b/libs/libkis/Swatch.cppindex 57f3426b6a..6ec8d9ff31 100644--- a/libs/libkis/Swatch.cpp+++ b/libs/libkis/Swatch.cpp@@ -11,14 +11,16 @@ struct Swatch::Private {KisSwatch swatch;};-Swatch::Swatch(const KisSwatch &kisSwatch)- : d(new Private)+Swatch::Swatch(const KisSwatch &kisSwatch, QObject *parent)+ : QObject(parent)+ , d(new Private){d->swatch = kisSwatch;}-Swatch::Swatch()- : d(new Private)+Swatch::Swatch(QObject *parent)+ : QObject(parent)+ , d(new Private){}@@ -28,8 +30,9 @@ Swatch::~Swatch()delete d;}-Swatch::Swatch(const Swatch &rhs)- : d(new Private)+Swatch::Swatch(const Swatch &rhs, QObject *parent)+ : QObject(parent)+ , d(new Private){d->swatch = rhs.d->swatch;}@@ -41,6 +44,16 @@ Swatch &Swatch::operator=(const Swatch &rhs)return *this;}+bool Swatch::operator==(const Swatch &other) const+{+ return (d->swatch == other.d->swatch);+}++bool Swatch::operator!=(const Swatch &other) const+{+ return !(operator==(other));+}+QString Swatch::name() const{return d->swatch.name();diff --git a/libs/libkis/Swatch.h b/libs/libkis/Swatch.hindex 5512cb93b5..e8faf76b5c 100644--- a/libs/libkis/Swatch.h+++ b/libs/libkis/Swatch.h@@ -18,18 +18,24 @@ class KisSwatch;* A Swatch is a single color that is part of a palette, that has a name* and an id. A Swatch color can be a spot color.*/-class KRITALIBKIS_EXPORT Swatch+class KRITALIBKIS_EXPORT Swatch : public QObject{+ Q_OBJECT+private:friend class Palette;friend class PaletteView;- Swatch(const KisSwatch &kisSwatch);+ Swatch(const KisSwatch &kisSwatch, QObject *parent = 0);public:- Swatch();+ explicit Swatch(QObject *parent = 0);virtual ~Swatch();- Swatch(const Swatch &rhs);+ Swatch(const Swatch &rhs, QObject *parent = 0);Swatch &operator=(const Swatch &rhs);+ bool operator==(const Swatch &other) const;+ bool operator!=(const Swatch &other) const;++public Q_SLOTS:QString name() const;void setName(const QString &name);diff --git a/plugins/extensions/pykrita/sip/krita/Swatch.sip b/plugins/extensions/pykrita/sip/krita/Swatch.sipindex 08eecda2a1..3e8d1800e3 100644--- a/plugins/extensions/pykrita/sip/krita/Swatch.sip+++ b/plugins/extensions/pykrita/sip/krita/Swatch.sip@@ -3,9 +3,25 @@ class Swatch%TypeHeaderCode#include "Swatch.h"%End++%ConvertToSubClassCode+ // Need to add sub class conversion, otherwise a Swatch passed to a Signal is provided as a QObject instead of+ // a Swatch object+ // (not sure why, but explicit conversion here fix the problem)+ Swatch* mc = qobject_cast<Swatch*>(sipCpp);+ sipType = 0;+ if (mc) {+ sipType = sipType_Swatch;+ }+%End+Swatch(const Swatch & __0);public:Swatch();+ bool operator==(const Swatch &other) const;+ bool operator!=(const Swatch &other) const;++public Q_SLOTS:QString name() const;void setName(const QString &name);QString id() const;