Krita Source Code Documentation
Loading...
Searching...
No Matches
GuidesConfig.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Grum999 <grum999@grum.fr>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#include "GuidesConfig.h"
7
8#include <QDomDocument>
9#include <QDomElement>
10
11#include "kis_guides_config.h"
12
17
19 : QObject(0)
20 , d(new Private)
21{
23}
24
26 : QObject(parent)
27 , d(new Private)
28{
30}
31
33{
34 delete d;
35}
36
37bool GuidesConfig::operator==(const GuidesConfig &other) const
38{
39 return (d->guidesConfig == other.d->guidesConfig);
40}
41
42bool GuidesConfig::operator!=(const GuidesConfig &other) const
43{
44 return !(operator==(other));
45}
46
47QColor GuidesConfig::color() const
48{
49 return d->guidesConfig->guidesColor();
50}
51
52void GuidesConfig::setColor(const QColor &color) const
53{
55}
56
58{
61 return "dashed";
62 }
64 return "dotted";
65 }
66 return "solid";
67}
68
83
85{
86 return d->guidesConfig->hasGuides();
87}
88
89bool GuidesConfig::hasSamePositionAs(const GuidesConfig &guideConfig) const
90{
91 return d->guidesConfig->hasSamePositionAs(guideConfig.guidesConfig());
92}
93
95{
96 return d->guidesConfig->showGuides();
97}
98
103
104bool GuidesConfig::fromXml(const QString &xmlContent) const
105{
106 QDomDocument doc = QDomDocument();
107 QString errorMsg {""};
108 int errorLine {0}, errorColumn {0};
109
110 if(doc.setContent(xmlContent, &errorMsg, &errorLine, &errorColumn)) {
111 return d->guidesConfig->loadFromXml(doc.documentElement());
112 }
113
114 return false;
115}
116
117QString GuidesConfig::toXml() const
118{
119 QDomDocument doc = QDomDocument();
120 QDomElement elt = d->guidesConfig->saveToXml(doc, "guides");
121 doc.appendChild(elt);
122 return doc.toString(2);
123}
124
129
131{
132 return d->guidesConfig->lockGuides();
133}
134
135void GuidesConfig::setLocked(const bool locked)
136{
138}
139
141{
142 return d->guidesConfig->snapToGuides();
143}
144
146{
148}
149
154
159
164
169
float value(const T *src, size_t ch)
bool hasSamePositionAs(const GuidesConfig &guideConfig) const
indicate if position from current guides configuration match positions from another guides configurat...
QString toXml() const
Save guides definition as an XML document.
void setColor(const QColor &color) const
Define guides color.
QList< qreal > horizontalGuides() const
The horizontal guides.
bool operator!=(const GuidesConfig &other) const
QColor color() const
Guides color.
bool fromXml(const QString &xmlContent) const
Load guides definition from an XML document.
void removeAllGuides()
Remove all guides.
void setVerticalGuides(const QList< qreal > &lines)
Set the vertical guides.
bool operator==(const GuidesConfig &other) const
void setLocked(const bool value)
Set guides lock status.
bool hasGuides() const
indicate if there's guides defined
void setVisible(const bool value)
Set guides visibility status.
QString lineType() const
Guides line type.
KisGuidesConfig guidesConfig() const
GuidesConfig(KisGuidesConfig *guidesConfig)
bool visible() const
Returns guides visibility status.
bool snap() const
Returns guide snap status.
void setHorizontalGuides(const QList< qreal > &lines)
Set the horizontal guides.
QList< qreal > verticalGuides() const
The vertical guides.
~GuidesConfig() override
bool locked() const
Returns guide lock status.
void setSnap(const bool value)
Set guides snap status.
void setLineType(const QString &lineType)
Define guides lines type.
Private * d
void setHorizontalGuideLines(const QList< qreal > &lines)
Set the positions of the horizontal guide lines.
void setShowGuides(bool value)
void setSnapToGuides(bool value)
void setGuidesColor(const QColor &value)
const QList< qreal > & verticalGuideLines() const
Returns the list of vertical guide lines.
void setLockGuides(bool value)
QDomElement saveToXml(QDomDocument &doc, const QString &tag) const
bool loadFromXml(const QDomElement &parent)
void setVerticalGuideLines(const QList< qreal > &lines)
Set the positions of the vertical guide lines.
bool hasSamePositionAs(const KisGuidesConfig &rhs) const
const QList< qreal > & horizontalGuideLines() const
Returns the list of horizontal guide lines.
LineTypeInternal guidesLineType
void setGuidesLineType(LineTypeInternal value)
KisGuidesConfig * guidesConfig