Krita Source Code Documentation
Loading...
Searching...
No Matches
KisColorSelectorConfiguration.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Wolthera van Hovell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KIS_COLOR_SELECTOR_CONFIGURATION_H
7#define KIS_COLOR_SELECTOR_CONFIGURATION_H
8
9#include <QString>
10#include <QStringList>
11#include <boost/operators.hpp>
12
13#include "kritawidgets_export.h"
14
15class KRITAWIDGETS_EXPORT KisColorSelectorConfiguration
16 : public boost::equality_comparable<KisColorSelectorConfiguration> {
17
18public:
19
20 enum Type {Ring, Square, Wheel, Triangle, Slider};
21 enum Parameters {H, hsvS, V, hslS, L, SL, SV, SV2, hsvSH, hslSH, VH, LH, SI, SY, hsiSH, hsySH, I, Y, IH, YH, hsiS, hsyS, Hluma};
22
27
28 KisColorSelectorConfiguration(Type mainT = Triangle, Type subT = Ring, Parameters mainTP = SL, Parameters subTP = H)
29 : mainType(mainT)
30 , subType(subT)
31 , mainTypeParameter(mainTP)
32 , subTypeParameter(subTP)
33 {
34 }
35
37 {
38 readString(string);
39 }
40
41 QString toString() const
42 {
43 return QString("%1|%2|%3|%4").arg(mainType).arg(subType).arg(mainTypeParameter).arg(subTypeParameter);
44 }
45 void readString(QString string)
46 {
47 QStringList strili = string.split('|');
48 if(strili.length()!=4) return;
49
50 int imt=strili.at(0).toInt();
51 int ist=strili.at(1).toInt();
52 int imtp=strili.at(2).toInt();
53 int istp=strili.at(3).toInt();
54
55 // Makes sure that Type and Parameters are within bounds.
56 if(imt>Slider || ist>Slider || imtp>Hluma || istp>Hluma)
57 return;
58
59 mainType = Type(imt);
60 subType = Type(ist);
61 mainTypeParameter = Parameters(imtp);
62 subTypeParameter = Parameters(istp);
63 }
64
66 {
68 ret.readString(string);
69 return ret;
70 }
71
73 {
74 return (mainType == rhs.mainType &&
75 subType == rhs.subType &&
76 mainTypeParameter == rhs.mainTypeParameter &&
77 subTypeParameter == rhs.subTypeParameter);
78 }
79};
80
81#endif
KisColorSelectorConfiguration(Type mainT=Triangle, Type subT=Ring, Parameters mainTP=SL, Parameters subTP=H)
static KisColorSelectorConfiguration fromString(QString string)
bool operator==(const KisColorSelectorConfiguration &rhs) const