Commit 606df61b authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Port to new KPluginMetaData-based KParts API

parent 6081d28a
......@@ -21,7 +21,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMSetupVersion)
include(FeatureSummary)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Widgets Svg)
......
add_definitions(-DTRANSLATION_DOMAIN="svgpart")
ecm_setup_version(${SVGPART_VERSION}
VARIABLE_PREFIX SVGPART
VERSION_HEADER svgpart_version.h
)
if(${KF5_VERSION} VERSION_LESS 5.77.0)
include(ECMSetupVersion)
ecm_setup_version(${SVGPART_VERSION}
VARIABLE_PREFIX SVGPART
VERSION_HEADER svgpart_version.h
)
endif()
configure_file(svgpart.desktop ${CMAKE_CURRENT_BINARY_DIR}/svgpart.desktop @ONLY)
set(svgpart_SRCS
svgbrowserextension.cpp
......@@ -15,9 +20,9 @@ qt5_add_resources(svgpart_SRCS
)
add_library(svgpart MODULE ${svgpart_SRCS})
kcoreaddons_desktop_to_json(svgpart svgpart.desktop)
kcoreaddons_desktop_to_json(svgpart ${CMAKE_CURRENT_BINARY_DIR}/svgpart.desktop)
target_link_libraries(svgpart Qt5::Widgets Qt5::Svg KF5::CoreAddons KF5::Parts)
install(TARGETS svgpart DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/parts)
install(FILES svgpart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/svgpart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
......@@ -7,10 +7,15 @@
#include "svgpart.h"
#include "svgbrowserextension.h"
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 77, 0)
#include "svgpart_version.h"
#endif
// KF
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#else
#include <KAboutData>
#endif
#include <KLocalizedString>
#include <KActionCollection>
#include <KStandardAction>
......@@ -26,7 +31,7 @@
#include <QScrollBar>
#include <QTimer>
#if KCOREADDONS_VERSION < QT_VERSION_CHECK(5, 77, 0)
static KAboutData createAboutData()
{
KAboutData aboutData(QStringLiteral("svgpart"), i18n("SVG Part"),
......@@ -36,18 +41,28 @@ static KAboutData createAboutData()
i18n("Copyright 2007, Aurélien Gâteau <aurelien.gateau@free.fr>"));
return aboutData;
}
#endif
//Factory Code
K_PLUGIN_FACTORY_WITH_JSON(SvgPartFactory, "svgpart.json",
registerPlugin<SvgPart>();)
SvgPart::SvgPart(QWidget* parentWidget, QObject* parent, const QVariantList&)
SvgPart::SvgPart(QWidget* parentWidget, QObject* parent,
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData, const QVariantList&)
#else
const QVariantList&)
#endif
: KParts::ReadOnlyPart(parent)
, mItem(nullptr)
, m_browserExtension(new SvgBrowserExtension(this))
{
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
setMetaData(metaData);
#else
setComponentData(createAboutData());
#endif
mRenderer = new QSvgRenderer(this);
mScene = new QGraphicsScene(this);
......
......@@ -60,8 +60,16 @@ Name[vi]=Phần nhúng đọc SVG
Name[x-test]=xxSvg Partxx
Name[zh_CN]=Svg 组件
Name[zh_TW]=Svg 部件
Comment=A KPart to display SVG images
MimeType=image/svg+xml;image/svg+xml-compressed;
ServiceTypes=KParts/ReadOnlyPart
X-KDE-Library=kf5/parts/svgpart
InitialPreference=12
Icon=image-svg+xml
X-KDE-PluginInfo-Name=svgpart
X-KDE-PluginInfo-Version=@svgpart_VERSION@
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-Copyright=Copyright 2007 Aurélien Gâteau
X-KDE-PluginInfo-Author=Aurélien Gâteau
X-KDE-PluginInfo-Email=aurelien.gateau@free.fr
......@@ -9,9 +9,10 @@
// KF
#include <KParts/ReadOnlyPart>
#include <kcoreaddons_version.h>
class SvgBrowserExtension;
class KPluginMetaData;
class QGraphicsScene;
class QGraphicsSvgItem;
class QGraphicsView;
......@@ -22,7 +23,11 @@ class SvgPart : public KParts::ReadOnlyPart
Q_OBJECT
public:
#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
SvgPart(QWidget* parentWidget, QObject* parent, const KPluginMetaData& metaData, const QVariantList&);
#else
SvgPart(QWidget* parentWidget, QObject* parent, const QVariantList&);
#endif
bool openUrl(const QUrl& url) override;
bool closeUrl() override;
......
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