Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Reformat tabs -> spaces

parent 8b4fcfe7
......@@ -17,8 +17,8 @@ find_package(KF5 REQUIRED COMPONENTS CoreAddons Parts)
add_definitions(-DTRANSLATION_DOMAIN="svgpart")
set(svgpart_SRCS
svgpart.cpp
)
svgpart.cpp
)
add_library(svgpart MODULE ${svgpart_SRCS})
......
......@@ -14,7 +14,6 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// Qt
......@@ -35,79 +34,86 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
static KAboutData createAboutData()
{
KAboutData aboutData( QStringLiteral("svgpart"), i18n("SVG Part"),
"1.0", i18n("A KPart to display SVG images"),
KAboutLicense::KAboutLicense::GPL,
i18n("Copyright 2007, Aurélien Gâteau <aurelien.gateau@free.fr>"));
return aboutData;
KAboutData aboutData(QStringLiteral("svgpart"), i18n("SVG Part"),
"1.0", i18n("A KPart to display SVG images"),
KAboutLicense::KAboutLicense::GPL,
i18n("Copyright 2007, Aurélien Gâteau <aurelien.gateau@free.fr>"));
return aboutData;
}
//Factory Code
K_PLUGIN_FACTORY( SvgPartFactory, registerPlugin< SvgPart >(); )
K_PLUGIN_FACTORY(SvgPartFactory, registerPlugin<SvgPart>();)
SvgPart::SvgPart(QWidget* parentWidget, QObject* parent, const QVariantList&)
: KParts::ReadOnlyPart(parent)
: KParts::ReadOnlyPart(parent)
{
setComponentData(createAboutData());
mRenderer = new QSvgRenderer(this);
mScene = new QGraphicsScene(this);
mView = new QGraphicsView(mScene, parentWidget);
mView->setFrameStyle(QFrame::NoFrame);
mView->setDragMode(QGraphicsView::ScrollHandDrag);
mItem = 0;
setWidget(mView);
KStandardAction::actualSize(this, SLOT(zoomActualSize()), actionCollection());
KStandardAction::zoomIn(this, SLOT(zoomIn()), actionCollection());
KStandardAction::zoomOut(this, SLOT(zoomOut()), actionCollection());
setXMLFile("svgpart.rc");
setComponentData(createAboutData());
mRenderer = new QSvgRenderer(this);
mScene = new QGraphicsScene(this);
mView = new QGraphicsView(mScene, parentWidget);
mView->setFrameStyle(QFrame::NoFrame);
mView->setDragMode(QGraphicsView::ScrollHandDrag);
mItem = 0;
setWidget(mView);
KStandardAction::actualSize(this, SLOT(zoomActualSize()), actionCollection());
KStandardAction::zoomIn(this, SLOT(zoomIn()), actionCollection());
KStandardAction::zoomOut(this, SLOT(zoomOut()), actionCollection());
setXMLFile("svgpart.rc");
}
bool SvgPart::openFile() {
if (!mRenderer->load(localFilePath())) {
return false;
}
mItem = new QGraphicsSvgItem();
mItem->setSharedRenderer(mRenderer);
mScene->addItem(mItem);
return true;
bool SvgPart::openFile()
{
if (!mRenderer->load(localFilePath())) {
return false;
}
mItem = new QGraphicsSvgItem();
mItem->setSharedRenderer(mRenderer);
mScene->addItem(mItem);
return true;
}
bool SvgPart::closeUrl() {
delete mItem;
mItem = 0;
return KParts::ReadOnlyPart::closeUrl();
bool SvgPart::closeUrl()
{
delete mItem;
mItem = 0;
return KParts::ReadOnlyPart::closeUrl();
}
void SvgPart::zoomIn() {
setZoom(zoom() * 2);
void SvgPart::zoomIn()
{
setZoom(zoom() * 2);
}
void SvgPart::zoomOut() {
setZoom(zoom() / 2);
void SvgPart::zoomOut()
{
setZoom(zoom() / 2);
}
void SvgPart::zoomActualSize() {
setZoom(1.0);
void SvgPart::zoomActualSize()
{
setZoom(1.0);
}
qreal SvgPart::zoom() const {
return mView->matrix().m11();
qreal SvgPart::zoom() const
{
return mView->matrix().m11();
}
void SvgPart::setZoom(qreal value) {
QMatrix matrix;
matrix.scale(value, value);
mView->setMatrix(matrix);
void SvgPart::setZoom(qreal value)
{
QMatrix matrix;
matrix.scale(value, value);
mView->setMatrix(matrix);
}
#include "svgpart.moc"
......@@ -14,43 +14,45 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef SVGPART_H
#define SVGPART_H
// KDE
#include <kparts/readonlypart.h>
class QGraphicsScene;
class QGraphicsSvgItem;
class QGraphicsView;
class QSvgRenderer;
class SvgPart : public KParts::ReadOnlyPart {
Q_OBJECT
class SvgPart : public KParts::ReadOnlyPart
{
Q_OBJECT
public:
SvgPart(QWidget* parentWidget, QObject* parent, const QVariantList&);
SvgPart(QWidget* parentWidget, QObject* parent, const QVariantList&);
virtual bool closeUrl();
virtual bool closeUrl();
protected:
virtual bool openFile() Q_DECL_OVERRIDE;
virtual bool openFile();
private Q_SLOTS:
void zoomActualSize();
void zoomIn();
void zoomOut();
void zoomActualSize();
void zoomIn();
void zoomOut();
private:
QGraphicsScene* mScene;
QGraphicsView* mView;
QGraphicsSvgItem* mItem;
QSvgRenderer* mRenderer;
qreal zoom() const;
void setZoom(qreal value);
qreal zoom() const;
void setZoom(qreal);
private:
QGraphicsScene* mScene;
QGraphicsView* mView;
QGraphicsSvgItem* mItem;
QSvgRenderer* mRenderer;
};
#endif /* SVGPART_H */
<!DOCTYPE kpartgui>
<kpartgui name="SvgPart" version="2">
<MenuBar>
<Menu name="view"><text>&amp;View</text>
<Action name="view_actual_size"/>
<Menu name="view"><text>&amp;View</text>
<Action name="view_actual_size"/>
<!--
<Action name="view_zoom_to_fit"/>
<Action name="view_zoom_to_fit"/>
-->
<Action name="view_zoom_in"/>
<Action name="view_zoom_out"/>
</Menu>
<Action name="view_zoom_in"/>
<Action name="view_zoom_out"/>
</Menu>
</MenuBar>
<ToolBar name="mainToolBar"><text>Main Toolbar</text>
<Action name="view_actual_size"/>
<Action name="view_actual_size"/>
<!--
<Action name="view_zoom_to_fit"/>
<Action name="view_zoom_to_fit"/>
-->
<Action name="view_zoom_in"/>
<Action name="view_zoom_out"/>
<Action name="view_zoom_in"/>
<Action name="view_zoom_out"/>
</ToolBar>
</kpartgui>
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