EllipseShapeFactory.cpp 2.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/* This file is part of the KDE project
 * Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

20 21
#include "EllipseShapeFactory.h"
#include "EllipseShape.h"
22 23 24 25
#include "EllipseShapeConfigWidget.h"
#include <KoLineBorder.h>
#include <KoXmlNS.h>
#include <KoXmlReader.h>
26
#include <KoGradientBackground.h>
27 28 29 30

#include <klocale.h>


31 32
EllipseShapeFactory::EllipseShapeFactory(QObject *parent)
    : KoShapeFactory(parent, EllipseShapeId, i18n("Ellipse"))
33
{
Thomas Zander's avatar
Thomas Zander committed
34
    setToolTip(i18n( "An ellipse"));
35
    setIcon("ellipse-shape");
36
    setFamily("geometric");
37 38
    QStringList elementNames;
    elementNames << "ellipse" << "circle";
Thomas Zander's avatar
Thomas Zander committed
39 40
    setOdfElementNames(KoXmlNS::draw, elementNames);
    setLoadingPriority(1);
41 42
}

43
KoShape *EllipseShapeFactory::createDefaultShape() const
44
{
45
    EllipseShape *ellipse = new EllipseShape();
46

Thomas Zander's avatar
Thomas Zander committed
47 48
    ellipse->setBorder(new KoLineBorder(1.0));
    ellipse->setShapeId(KoPathShapeId);
49

50 51
    QRadialGradient *gradient = new QRadialGradient(QPointF(0.5,0.5), 0.5, QPointF(0.25,0.25));
    gradient->setCoordinateMode(QGradient::ObjectBoundingMode);
Thomas Zander's avatar
Thomas Zander committed
52 53 54
    gradient->setColorAt(0.0, Qt::white);
    gradient->setColorAt(1.0, Qt::green);
    ellipse->setBackground(new KoGradientBackground(gradient));
55 56 57 58

    return ellipse;
}

59
KoShape *EllipseShapeFactory::createShape(const KoProperties *params) const
60 61
{
    Q_UNUSED(params);
62
    return createDefaultShape();
63 64
}

65
bool EllipseShapeFactory::supports(const KoXmlElement &e) const
66
{
Thomas Zander's avatar
Thomas Zander committed
67 68
    return (e.localName() == "ellipse" || e.localName() == "circle")
        && e.namespaceURI() == KoXmlNS::draw;
69 70
}

71
QList<KoShapeConfigWidgetBase*> EllipseShapeFactory::createShapeOptionPanels()
72 73
{
    QList<KoShapeConfigWidgetBase*> panels;
Thomas Zander's avatar
Thomas Zander committed
74
    panels.append(new EllipseShapeConfigWidget());
75 76
    return panels;
}