Warning, file /graphics/krita/plugins/flake/pathshapes/ellipse/EllipseShapeFactory.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2006 Thorsten Zachmann <zachmann@kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #include "EllipseShapeFactory.h"
0008 #include "EllipseShape.h"
0009 #include "EllipseShapeConfigWidget.h"
0010 #include <KoShapeStroke.h>
0011 #include <KoXmlNS.h>
0012 #include <KoGradientBackground.h>
0013 #include <KoShapeLoadingContext.h>
0014 
0015 #include <KoIcon.h>
0016 #include <klocalizedstring.h>
0017 
0018 #include "kis_pointer_utils.h"
0019 
0020 EllipseShapeFactory::EllipseShapeFactory()
0021     : KoShapeFactoryBase(EllipseShapeId, i18n("Ellipse"))
0022 {
0023     setToolTip(i18n("An ellipse"));
0024     setIconName(koIconNameCStr("ellipse-shape"));
0025     setFamily("geometric");
0026     setLoadingPriority(1);
0027 
0028     QList<QPair<QString, QStringList> > elementNamesList;
0029     elementNamesList.append(qMakePair(QString(KoXmlNS::draw), QStringList("circle")));
0030     elementNamesList.append(qMakePair(QString(KoXmlNS::draw), QStringList("ellipse")));
0031     elementNamesList.append(qMakePair(QString(KoXmlNS::svg), QStringList("circle")));
0032     elementNamesList.append(qMakePair(QString(KoXmlNS::svg), QStringList("ellipse")));
0033     elementNamesList.append(qMakePair(QString(KoXmlNS::svg), QStringList("sodipodi:arc")));
0034     elementNamesList.append(qMakePair(QString(KoXmlNS::svg), QStringList("krita:arc")));
0035     setXmlElements(elementNamesList);
0036 }
0037 
0038 KoShape *EllipseShapeFactory::createDefaultShape(KoDocumentResourceManager *) const
0039 {
0040     EllipseShape *ellipse = new EllipseShape();
0041 
0042     ellipse->setStroke(toQShared(new KoShapeStroke(1.0)));
0043     ellipse->setShapeId(KoPathShapeId);
0044 
0045     QRadialGradient *gradient = new QRadialGradient(QPointF(0.5, 0.5), 0.5, QPointF(0.25, 0.25));
0046     gradient->setCoordinateMode(QGradient::ObjectBoundingMode);
0047     gradient->setColorAt(0.0, Qt::white);
0048     gradient->setColorAt(1.0, Qt::green);
0049     ellipse->setBackground(QSharedPointer<KoGradientBackground>(new KoGradientBackground(gradient)));
0050 
0051     return ellipse;
0052 }
0053 
0054 bool EllipseShapeFactory::supports(const QDomElement &e, KoShapeLoadingContext &context) const
0055 {
0056     Q_UNUSED(context);
0057     return (e.localName() == "ellipse" || e.localName() == "circle")
0058            && e.namespaceURI() == KoXmlNS::draw;
0059 }
0060 
0061 QList<KoShapeConfigWidgetBase *> EllipseShapeFactory::createShapeOptionPanels()
0062 {
0063     QList<KoShapeConfigWidgetBase *> panels;
0064     panels.append(new EllipseShapeConfigWidget());
0065     return panels;
0066 }