1 /*
2 * Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation;
7 * either version 2, or (at your option) any later version of the License.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; see the file COPYING. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include "WebShapeFactory.h"
21
22 #include <QWebPage>
23 #include <QWebFrame>
24
25 #include <KLocalizedString>
26
27 #include <KoIcon.h>
28 #include <KoProperties.h>
29
30 #include "WebShape.h"
31
WebShapeFactory()32 WebShapeFactory::WebShapeFactory()
33 : KoShapeFactoryBase(WEBSHAPEID,
34 i18n("Web Shape"))
35 {
36 setToolTip(i18n("A web shape"));
37 setIconName(koIconName("applications-internet"));
38 setXmlElementNames("http://kde.org/braindump", QStringList("web"));
39 }
40
createDefaultShape(KoDocumentResourceManager * documentResources) const41 KoShape *WebShapeFactory::createDefaultShape(KoDocumentResourceManager *documentResources) const
42 {
43 Q_UNUSED(documentResources);
44 WebShape* fooShape = new WebShape();
45 fooShape->setShapeId(WEBSHAPEID);
46 // set defaults
47 return fooShape;
48 }
49
createShape(const KoProperties * params,KoDocumentResourceManager * documentResources) const50 KoShape *WebShapeFactory::createShape(const KoProperties *params, KoDocumentResourceManager *documentResources) const
51 {
52 Q_UNUSED(documentResources);
53 WebShape* fooShape = new WebShape();
54 if(params->contains("url")) {
55 fooShape->setUrl(params->property("url").toUrl());
56 }
57 fooShape->setShapeId(WEBSHAPEID);
58 // use the params
59 return fooShape;
60 }
61
supports(const KoXmlElement & e,KoShapeLoadingContext &) const62 bool WebShapeFactory::supports(const KoXmlElement& e, KoShapeLoadingContext& /*context*/) const
63 {
64 return (e.localName() == "web" && e.namespaceURI() == "http://kde.org/braindump");
65 }
66
createShapeOptionPanels()67 QList<KoShapeConfigWidgetBase*> WebShapeFactory::createShapeOptionPanels()
68 {
69 QList<KoShapeConfigWidgetBase*> answer;
70 return answer;
71 }
72