Commit f1a9af1e authored by Pino Toscano's avatar Pino Toscano
Browse files

Use a shared KDE SVG renderer (the Qt one, with support for gzip-compressed...

Use a shared KDE SVG renderer (the Qt one, with support for gzip-compressed files), and tell the graphics item to use it.
Advertise ourselves to support the image/svg+xml-compressed MIME type.
BUG: 162951

svn path=/trunk/KDE/kdegraphics/svgpart/; revision=814887
parent 1f3a7e23
......@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// KDE
#include <kactioncollection.h>
#include <kstandardaction.h>
#include <ksvgrenderer.h>
#include <kparts/genericfactory.h>
// Local
......@@ -38,6 +39,7 @@ K_EXPORT_COMPONENT_FACTORY( svgpart /*library name*/, SvgPartFactory )
SvgPart::SvgPart(QWidget* parentWidget, QObject* parent, const QStringList&)
: KParts::ReadOnlyPart(parent)
{
mRenderer = new KSvgRenderer(this);
mScene = new QGraphicsScene(this);
mView = new QGraphicsView(mScene, parentWidget);
mView->setDragMode(QGraphicsView::ScrollHandDrag);
......@@ -53,7 +55,11 @@ SvgPart::SvgPart(QWidget* parentWidget, QObject* parent, const QStringList&)
bool SvgPart::openFile() {
delete mItem;
mItem = new QGraphicsSvgItem(localFilePath());
if (!mRenderer->load(localFilePath())) {
return false;
}
mItem = new QGraphicsSvgItem();
mItem->setSharedRenderer(mRenderer);
mScene->addItem(mItem);
return true;
}
......
......@@ -35,7 +35,7 @@ Name[vi]=Phần nhúng đọc SVG
Name[x-test]=xxSvg Partxx
Name[zh_CN]=Svg 组件
Name[zh_TW]=Svg 部件
MimeType=image/svg+xml;
MimeType=image/svg+xml;image/svg+xml-compressed;
ServiceTypes=KParts/ReadOnlyPart
X-KDE-Library=svgpart
InitialPreference=12
......
......@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <kparts/part.h>
class KAboutData;
class KSvgRenderer;
class QGraphicsScene;
class QGraphicsSvgItem;
......@@ -47,6 +48,7 @@ private:
QGraphicsScene* mScene;
QGraphicsView* mView;
QGraphicsSvgItem* mItem;
KSvgRenderer* mRenderer;
qreal zoom() const;
void setZoom(qreal);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment