File indexing completed on 2024-05-12 15:59:08

0001 /*
0002  *  SPDX-License-Identifier: GPL-3.0-or-later
0003  */
0004 
0005 #include "Swatch.h"
0006 
0007 #include <KisSwatch.h>
0008 #include <KoColor.h>
0009 
0010 struct Swatch::Private {
0011     KisSwatch swatch;
0012 };
0013 
0014 Swatch::Swatch(const KisSwatch &kisSwatch)
0015     : d(new Private)
0016 {
0017     d->swatch = kisSwatch;
0018 }
0019 
0020 Swatch::Swatch()
0021     : d(new Private)
0022 {
0023 
0024 }
0025 
0026 Swatch::~Swatch()
0027 {
0028     delete d;
0029 }
0030 
0031 Swatch::Swatch(const Swatch &rhs)
0032     : d(new Private)
0033 {
0034     d->swatch = rhs.d->swatch;
0035 }
0036 
0037 Swatch &Swatch::operator=(const Swatch &rhs)
0038 {
0039     if (&rhs == this) return *this;
0040     d->swatch = rhs.d->swatch;
0041     return *this;
0042 }
0043 
0044 QString Swatch::name() const
0045 {
0046     return d->swatch.name();
0047 }
0048 
0049 void Swatch::setName(const QString &name)
0050 {
0051     d->swatch.setName(name);
0052 }
0053 
0054 QString Swatch::id() const
0055 {
0056     return d->swatch.id();
0057 }
0058 void Swatch::setId(const QString &id)
0059 {
0060     d->swatch.setId(id);
0061 }
0062 
0063 ManagedColor *Swatch::color() const
0064 {
0065     ManagedColor *c = new ManagedColor(d->swatch.color());
0066     return c;
0067 }
0068 void Swatch::setColor(ManagedColor *color)
0069 {
0070     d->swatch.setColor(color->color());
0071 }
0072 
0073 bool Swatch::spotColor() const
0074 {
0075     return d->swatch.spotColor();
0076 }
0077 void Swatch::setSpotColor(bool spotColor)
0078 {
0079     d->swatch.setSpotColor(spotColor);
0080 }
0081 
0082 bool Swatch::isValid() const
0083 {
0084     return d->swatch.isValid();
0085 }
0086 
0087 KisSwatch Swatch::kisSwatch() const
0088 {
0089     return d->swatch;
0090 }