Commit ff672c77 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau Committed by David Faure
Browse files

Port to new KPluginMetaData-based KParts API

parent bfd6ddf5
add_definitions(-DTRANSLATION_DOMAIN=\"fsview\")
set(fsview_VERSION 0.1)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
......@@ -33,10 +35,12 @@ install(TARGETS fsview ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
########### next target ###############
configure_file(fsview_part.desktop ${CMAKE_CURRENT_BINARY_DIR}/fsview_part.desktop)
set(fsviewpart_PART_SRCS fsview_part.cpp ${libfsview_SRCS})
add_library(fsviewpart MODULE ${fsviewpart_PART_SRCS})
kcoreaddons_desktop_to_json(fsviewpart fsview_part.desktop)
kcoreaddons_desktop_to_json(fsviewpart ${CMAKE_CURRENT_BINARY_DIR}/fsview_part.desktop)
target_link_libraries(fsviewpart KF5::Parts KF5::IconThemes)
......@@ -45,7 +49,7 @@ install(TARGETS fsviewpart DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/parts)
########### install files ###############
install( FILES fsview_part.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/fsview_part.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
install( FILES fsview_part.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/fsview )
ecm_qt_install_logging_categories(EXPORT fsview DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
......
......@@ -30,7 +30,11 @@
#include <kfileitem.h>
#include <kpluginfactory.h>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#else
#include <kaboutdata.h>
#endif
#include <kprotocolmanager.h>
#include <kio/copyjob.h>
......@@ -89,14 +93,21 @@ void FSJob::progressSlot(int percent, int dirs, const QString &cDir)
FSViewPart::FSViewPart(QWidget *parentWidget,
QObject *parent,
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData,
#endif
const QList<QVariant> & /* args */)
: KParts::ReadOnlyPart(parent)
{
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
setMetaData(metaData);
#else
KAboutData aboutData(QStringLiteral("fsview"), i18n("FSView"), QStringLiteral("0.1"),
i18n("Filesystem Viewer"),
KAboutLicense::GPL,
i18n("(c) 2002, Josef Weidendorfer"));
setComponentData(aboutData);
#endif
_view = new FSView(new Inode(), parentWidget);
_view->setWhatsThis(i18n("<p>This is the FSView plugin, a graphical "
......@@ -202,6 +213,16 @@ FSViewPart::~FSViewPart()
_view->saveFSOptions();
}
QString FSViewPart::componentName() const
{
// also the part ui.rc file is in the program folder
// TODO: change the component name to "fsviewpart" by removing this method and
// adapting the folder where the file is placed.
// Needs a way to also move any potential custom user ui.rc files
// from fsview/fsview_part.rc to fsviewpart/fsview_part.rc
return QStringLiteral("fsview");
}
void FSViewPart::showInfo()
{
QString info;
......
......@@ -127,3 +127,10 @@ X-KDE-Library=kf5/parts/fsviewpart
Type=Service
Icon=fsview
DocPath=konq-plugins/fsview/index.html
X-KDE-PluginInfo-Name=fsviewpart
X-KDE-PluginInfo-Version=@fsview_VERSION@
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-Copyright=Copyright 2002 Josef Weidendorfer
X-KDE-PluginInfo-Author=Josef Weidendorfer
X-KDE-PluginInfo-Email=
......@@ -23,6 +23,7 @@
#ifndef FSVIEW_PART_H
#define FSVIEW_PART_H
#include <kparts_version.h>
#include <kparts/part.h>
#include <kparts/browserextension.h>
#include <kio/jobclasses.h>
......@@ -89,8 +90,11 @@ class FSViewPart : public KParts::ReadOnlyPart
Q_PROPERTY(bool supportsUndo READ supportsUndo)
public:
FSViewPart(QWidget *parentWidget,
QObject *parent, const QList<QVariant> &args);
QObject *parent,
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData,
#endif
const QList<QVariant> &args);
~FSViewPart() override;
bool supportsUndo() const
......@@ -103,6 +107,11 @@ public:
return _view;
}
/**
* Return custom componentName for KXMLGUIClient, as for historical reasons the plugin id is not used
*/
QString componentName() const override;
public slots:
void updateActions();
void contextMenu(TreeMapItem *, const QPoint &);
......
......@@ -5,10 +5,14 @@
########### next target ###############
add_definitions(-DTRANSLATION_DOMAIN=\"khtmlsettingsplugin\")
set(khtmlsetting_VERSION 3.3)
configure_file(khtmlsettingsplugin.desktop ${CMAKE_CURRENT_BINARY_DIR}/khtmlsettingsplugin.desktop)
set(khtmlsettingsplugin_PART_SRCS settingsplugin.cpp )
add_library(khtmlsettingsplugin MODULE ${khtmlsettingsplugin_PART_SRCS})
kcoreaddons_desktop_to_json(khtmlsettingsplugin khtmlsettingsplugin.desktop)
target_link_libraries(khtmlsettingsplugin KF5::Parts)
......@@ -18,7 +22,15 @@ install(TARGETS khtmlsettingsplugin DESTINATION ${KDE_INSTALL_PLUGINDIR} )
########### install files ###############
install( FILES khtmlsettingsplugin.rc khtmlsettingsplugin.desktop DESTINATION ${KDE_INSTALL_DATADIR}/khtml/kpartplugins )
install( FILES khtmlsettingsplugin.rc khtmlsettingsplugin.desktop DESTINATION ${KDE_INSTALL_DATADIR}/kwebkitpart/kpartplugins )
install( FILES khtmlsettingsplugin.rc khtmlsettingsplugin.desktop DESTINATION ${KDE_INSTALL_DATADIR}/webenginepart/kpartplugins )
install(
FILES khtmlsettingsplugin.rc ${CMAKE_CURRENT_BINARY_DIR}/khtmlsettingsplugin.desktop
DESTINATION ${KDE_INSTALL_DATADIR}/khtml/kpartplugins
)
install(
FILES khtmlsettingsplugin.rc ${CMAKE_CURRENT_BINARY_DIR}/khtmlsettingsplugin.desktop
DESTINATION ${KDE_INSTALL_DATADIR}/kwebkitpart/kpartplugins
)
install(
FILES khtmlsettingsplugin.rc ${CMAKE_CURRENT_BINARY_DIR}/khtmlsettingsplugin.desktop
DESTINATION ${KDE_INSTALL_DATADIR}/webenginepart/kpartplugins
)
......@@ -3,12 +3,13 @@ X-KDE-Library=khtmlsettingsplugin
X-KDE-PluginInfo-Author=Carsten Pfeiffer
X-KDE-PluginInfo-Email=pfeiffer@kde.org
X-KDE-PluginInfo-Name=khtmlsettingsplugin
X-KDE-PluginInfo-Version=3.3
X-KDE-PluginInfo-Version=@khtmlsetting_VERSION@
X-KDE-PluginInfo-Website=
X-KDE-PluginInfo-Category=Tools
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Name=KHTML Settings
Name=HTML Settings
Name[ar]=إعدادات KHTML
Name[ast]=Axustes de KHTML
Name[bg]=Настройки на KHTML
......@@ -70,7 +71,7 @@ Name[wa]=Apontiaedjes KHTML
Name[x-test]=xxKHTML Settingsxx
Name[zh_CN]=KHTML 设置
Name[zh_TW]=KHTML 設定
Comment=A fast way to change the KHTML settings
Comment=A fast way to change the HTML settings
Comment[ar]=طريقة سريعة لتغير إعدادات KHTML
Comment[ast]=Un mou rápidu de camudar los axustes de KHTML
Comment[bg]=Бърз начин за промяна настройките на KHTML
......
......@@ -26,7 +26,11 @@
#include <QMenu>
#include <kprotocolmanager.h>
#include <kpluginfactory.h>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#else
#include <kaboutdata.h>
#endif
#include <ktoggleaction.h>
#include <kactioncollection.h>
#include <kselectaction.h>
......@@ -43,13 +47,20 @@
#include <QDBusMessage>
#include <QDBusReply>
K_PLUGIN_FACTORY(SettingsPluginFactory, registerPlugin<SettingsPlugin>();)
K_PLUGIN_CLASS_WITH_JSON(SettingsPlugin, "khtmlsettingsplugin.json")
SettingsPlugin::SettingsPlugin(QObject *parent,
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData,
#endif
const QVariantList &)
: KParts::Plugin(parent), mConfig(nullptr)
{
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
setMetaData(metaData);
#else
setComponentData(KAboutData(QStringLiteral("khtmlsettingsplugin"), i18n("HTML Settings"), QStringLiteral("1.0")));
#endif
KActionMenu *menu = new KActionMenu(QIcon::fromTheme(QStringLiteral("configure")), i18n("HTML Settings"), actionCollection());
actionCollection()->addAction(QStringLiteral("action menu"), menu);
#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
......
......@@ -20,6 +20,7 @@
#ifndef SETTINGS_PLUGIN
#define SETTINGS_PLUGIN
#include <kparts_version.h>
#include <kparts/plugin.h>
class KConfig;
......@@ -29,6 +30,9 @@ class SettingsPlugin : public KParts::Plugin
Q_OBJECT
public:
SettingsPlugin(QObject *parent,
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData,
#endif
const QVariantList &);
~SettingsPlugin() override;
......
......@@ -29,6 +29,10 @@ install(TARGETS konqsidebarplugin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} )
########### konq_sidebar plugin: contains the KParts used by konqueror ###############
set(konq_sidebar_VERSION 0.2)
configure_file(konq_sidebartng.desktop ${CMAKE_CURRENT_BINARY_DIR}/konq_sidebartng.desktop)
set(konq_sidebar_PART_SRCS
sidebar_part.cpp
sidebar_widget.cpp
......@@ -37,7 +41,7 @@ set(konq_sidebar_PART_SRCS
)
add_library(konq_sidebar MODULE ${konq_sidebar_PART_SRCS} ${sidebar_DEBUG_SRCS})
kcoreaddons_desktop_to_json(konq_sidebar konq_sidebartng.desktop)
kcoreaddons_desktop_to_json(konq_sidebar ${CMAKE_CURRENT_BINARY_DIR}/konq_sidebartng.desktop)
target_link_libraries(konq_sidebar KF5::Parts KF5::Konq konqsidebarplugin KF5::KCMUtils KF5::IconThemes)
......@@ -45,6 +49,6 @@ install(TARGETS konq_sidebar DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/parts)
########### install files ###############
install( FILES konq_sidebartng.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/konq_sidebartng.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
install( FILES konqsidebartngrc DESTINATION ${KDE_INSTALL_CONFDIR} )
install( FILES konqsidebarplugin.h DESTINATION ${KDE_INSTALL_INCLUDEDIR} COMPONENT Devel )
......@@ -83,3 +83,10 @@ Name[wa]=Bår di costé
Name[x-test]=xxSidebarxx
Name[zh_CN]=侧边栏
Name[zh_TW]=邊列
X-KDE-PluginInfo-Name=konq_sidebar
X-KDE-PluginInfo-Version=@konq_sidebar_VERSION@
X-KDE-PluginInfo-License=GPL v2+
X-KDE-PluginInfo-Copyright=
X-KDE-PluginInfo-Authors=Joseph Wenninger,David Faure,Raphael Rosch
X-KDE-PluginInfo-Emails=jowenn@kde.org,faure@kde.org,kde-dev@insaner.com
......@@ -15,7 +15,12 @@
* *
***************************************************************************/
#include "sidebar_part.h"
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#else
#include <kaboutdata.h>
#endif
#include <QApplication>
......@@ -25,14 +30,22 @@
K_PLUGIN_CLASS_WITH_JSON(KonqSidebarPart, "konq_sidebartng.json")
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
KonqSidebarPart::KonqSidebarPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData& metaData, const QVariantList &)
#else
KonqSidebarPart::KonqSidebarPart(QWidget *parentWidget, QObject *parent, const QVariantList &)
#endif
: KParts::ReadOnlyPart(parent)
{
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
setMetaData(metaData);
#else
KAboutData aboutData("konqsidebartng", i18n("Extended Sidebar"), "0.2");
aboutData.addAuthor(i18n("Joseph Wenninger"), "", "jowenn@kde.org");
aboutData.addAuthor(i18n("David Faure"), "", "faure@kde.org");
aboutData.addAuthor(i18n("Raphael Rosch"), "", "kde-dev@insaner.com");
setComponentData(aboutData);
#endif
QString currentProfile = parentWidget->window()->property("currentProfile").toString();
if (currentProfile.isEmpty()) {
......
......@@ -17,6 +17,7 @@
#ifndef KONQSIDEBARPART_H
#define KONQSIDEBARPART_H
#include <kparts_version.h>
#include <kparts/part.h>
#include <kparts/browserextension.h>
#include <QPointer>
......@@ -78,7 +79,11 @@ public:
/**
* Default constructor
*/
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
KonqSidebarPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData& metaData, const QVariantList &);
#else
KonqSidebarPart(QWidget *parentWidget, QObject *parent, const QVariantList &);
#endif
/**
* Destructor
......
......@@ -27,7 +27,12 @@
#include <kxmlguifactory.h>
#include <kconfig.h>
#include "konqdebug.h"
#include <kparts_version.h>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#else
#include <KAboutData>
#endif
#include <KLocalizedString>
#include <kparts/plugin.h>
#include <kplugininfo.h>
......@@ -74,9 +79,13 @@ KonqExtensionManager::KonqExtensionManager(QWidget *parent, KonqMainWindow *main
d->pluginSelector->addPlugins(QStringLiteral("konqueror"), i18n("Extensions"), QStringLiteral("Extensions"), KSharedConfig::openConfig());
if (activePart) {
KAboutData componentData = activePart->componentData();
d->pluginSelector->addPlugins(componentData.componentName(), i18n("Extensions"), QStringLiteral("Tools"));
d->pluginSelector->addPlugins(componentData.componentName(), i18n("Extensions"), QStringLiteral("Statusbar"));
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const QString pluginId = activePart->metaData().pluginId();
#else
const QString pluginId = activePart->componentData().componentName();
#endif
d->pluginSelector->addPlugins(pluginId, i18n("Extensions"), QStringLiteral("Tools"));
d->pluginSelector->addPlugins(pluginId, i18n("Extensions"), QStringLiteral("Statusbar"));
}
d->buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Apply);
......
......@@ -58,6 +58,7 @@
#include <konqsettings.h>
#include <kwidgetsaddons_version.h>
#include <kparts_version.h>
#include <kbookmarkmanager.h>
#include <klineedit.h>
#include <kzip.h>
......@@ -95,6 +96,9 @@
#include <QLineEdit>
#include <QNetworkProxy>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#endif
#include <kaboutdata.h>
#include <ktoolbar.h>
#include <konqbookmarkmenu.h>
......@@ -218,7 +222,12 @@ KonqMainWindow::KonqMainWindow(const QUrl &initialURL)
Qt::QueuedConnection); // Queued so that we don't delete the action from the code that triggered it.
// This has to be called before any action is created for this mainwindow
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KAboutData applicationData = KAboutData::applicationData();
setComponentName(applicationData.componentName(), applicationData.displayName());
#else
setComponentData(KAboutData::applicationData(), false /*don't load plugins yet*/);
#endif
m_pViewManager = new KonqViewManager(this);
......@@ -1975,7 +1984,11 @@ void KonqMainWindow::slotViewCompleted(KonqView *view)
void KonqMainWindow::slotPartActivated(KParts::Part *part)
{
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
qCDebug(KONQUEROR_LOG) << part << (part ? part->metaData().pluginId() : QString());
#else
qCDebug(KONQUEROR_LOG) << part << (part ? part->componentData().componentName() : QLatin1String(""));
#endif
KonqView *newView = nullptr;
KonqView *oldView = m_currentView;
......
......@@ -23,11 +23,29 @@
#include <KIO/Job>
#include <KParts/BrowserExtension>
#include <KPluginMetaData>
#include <QTest>
#include <QObject>
#include <QSignalSpy>
#include <QWebEngineView>
#include <QJsonDocument>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
namespace {
KPluginMetaData dummyMetaData()
{
QJsonObject jo = QJsonDocument::fromJson(
"{ \"KPlugin\": {\n"
" \"Id\": \"webenginepart\",\n"
" \"Name\": \"WebEngine\",\n"
" \"Version\": \"0.1\"\n"
"}\n}").object();
return KPluginMetaData(jo, QString());
}
}
#endif
class WebEnginePartApiTest : public QObject
{
......@@ -49,7 +67,11 @@ void WebEnginePartApiTest::initTestCase()
void WebEnginePartApiTest::shouldHaveBrowserExtension()
{
// GIVEN
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
WebEnginePart part(nullptr, nullptr, dummyMetaData());
#else
WebEnginePart part;
#endif
// WHEN
KParts::BrowserExtension *ext = KParts::BrowserExtension::childObject(&part);
......@@ -61,7 +83,11 @@ void WebEnginePartApiTest::shouldHaveBrowserExtension()
void WebEnginePartApiTest::shouldEmitStartedAndCompleted()
{
// GIVEN
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
WebEnginePart part(nullptr, nullptr, dummyMetaData());
#else
WebEnginePart part;
#endif
QSignalSpy spyStarted(&part, &KParts::ReadOnlyPart::started);
QSignalSpy spyCompleted(&part, SIGNAL(completed(bool)));
QSignalSpy spySetWindowCaption(&part, &KParts::ReadOnlyPart::setWindowCaption);
......@@ -84,7 +110,11 @@ void WebEnginePartApiTest::shouldEmitStartedAndCompleted()
void WebEnginePartApiTest::shouldEmitSetWindowCaption()
{
// GIVEN
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
WebEnginePart part(nullptr, nullptr, dummyMetaData());
#else
WebEnginePart part;
#endif
QSignalSpy spyStarted(&part, &KParts::ReadOnlyPart::started);
QSignalSpy spyCompleted(&part, SIGNAL(completed(bool)));
QSignalSpy spySetWindowCaption(&part, &KParts::ReadOnlyPart::setWindowCaption);
......@@ -103,7 +133,11 @@ void WebEnginePartApiTest::shouldEmitSetWindowCaption()
void WebEnginePartApiTest::shouldEmitOpenUrlNotifyOnClick()
{
// GIVEN
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
WebEnginePart part(nullptr, nullptr, dummyMetaData());
#else
WebEnginePart part;
#endif
QSignalSpy spyStarted(&part, &KParts::ReadOnlyPart::started);
QSignalSpy spyCompleted(&part, SIGNAL(completed(bool)));
QSignalSpy spySetWindowCaption(&part, &KParts::ReadOnlyPart::setWindowCaption);
......
......@@ -52,7 +52,11 @@
#include <KIO/Global>
#include <KActionCollection>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#else
#include <KAboutData>
#endif
#include <KUrlLabel>
#include <KMessageBox>
#include <KStringHandler>
......@@ -107,6 +111,9 @@ void WebEnginePart::initWebEngineUrlSchemes()
}
WebEnginePart::WebEnginePart(QWidget *parentWidget, QObject *parent,
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData,
#endif
const QByteArray& cachedHistory, const QStringList& /*args*/)
:KParts::ReadOnlyPart(parent),
m_emitOpenUrlNotify(true),
......@@ -126,6 +133,9 @@ WebEnginePart::WebEnginePart(QWidget *parentWidget, QObject *parent,
prof->installUrlSchemeHandler("tar", new WebEnginePartKIOHandler(prof));
}
static WebEnginePartCookieJar s_cookieJar(prof, nullptr);
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
setMetaData(metaData);
#else
KAboutData about = KAboutData(QStringLiteral("webenginepart"),
i18nc("Program Name", "WebEnginePart"),
/*version*/ QStringLiteral("1.3.0"),
......@@ -144,6 +154,7 @@ WebEnginePart::WebEnginePart(QWidget *parentWidget, QObject *parent,
about.setProductName("webenginepart/general");
// KComponentData componentData(&about);
setComponentData(about, false /*don't load plugins yet*/);
#endif
#if 0
// NOTE: If the application does not set its version number, we automatically
......
......@@ -85,3 +85,11 @@ X-KDE-Default-UserAgent=Mozilla/5.0 (%PLATFORM%; %SECURITY%; %OSNAME% %OSVERSION
X-KDE-ServiceTypes=KParts/ReadOnlyPart,Browser/View
X-KDE-Library=kf5/parts/webenginepart
InitialPreference=12
X-KDE-PluginInfo-Name=webenginepart
X-KDE-PluginInfo-Version=1.3.0
X-KDE-PluginInfo-License=LGPL
X-KDE-PluginInfo-Copyright=Copyright 2009-2010 Dawit Alemayehu, 2008-2010 Urs Wolfer, 2007 Trolltech ASA
X-KDE-PluginInfo-Authors=Sune Vuorela,Dawit Alemayehu,Urs Wolfer,Michael Howell,Laurent Montel,Dirk Mueller
X-KDE-PluginInfo-Emails=sune@kde.org,adawit@kde.org,uwolfer@kde.org,mhowell123@gmail.com,montel@kde.org,mueller@kde.org
X-KDE-PluginInfo-Website=
......@@ -26,6 +26,7 @@
#include <QWebEnginePage>
#include <kparts_version.h>
#include <KParts/ReadOnlyPart>
#include <QUrl>
......@@ -43,6 +44,7 @@ class FeaturePermissionBar;
class KUrlLabel;
class WebEngineBrowserExtension;
class WebEngineWallet;
class KPluginMetaData;
/**
* A KPart wrapper for the QtWebEngine's browser rendering engine.
......@@ -59,7 +61,10 @@ class KWEBENGINEPARTLIB_EXPORT WebEnginePart : public KParts::ReadOnlyPart
Q_OBJECT
Q_PROPERTY( bool modified READ isModified )
public:
explicit WebEnginePart(QWidget* parentWidget = nullptr, QObject* parent = nullptr,
explicit WebEnginePart(QWidget* parentWidget, QObject* parent,
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
const KPluginMetaData& metaData,
#endif
const QByteArray& cachedHistory = QByteArray(),
const QStringList& = QStringList());
~WebEnginePart() override;
......
......@@ -22,6 +22,11 @@
#include "webenginepart_ext.h"
#include "webenginepart.h"
#include <kparts_version.h>
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
#include <KPluginMetaData>
#endif
#include <QWidget>
WebEngineFactory::~WebEngineFactory()
......@@ -41,7 +46,11 @@ QObject *WebEngineFactory::create(const char* iface, QWidget *parentWidget, QObj
// history management with any KParts based application.
QByteArray histData (m_historyBufContainer.value(parentWidget));
if (!histData.isEmpty()) histData = qUncompress(histData);
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
WebEnginePart* part = new WebEnginePart(parentWidget, parent, metaData(), histData);
#else
WebEnginePart* part = new WebEnginePart(parentWidget, parent, histData);
#endif
WebEngineBrowserExtension* ext = qobject_cast<WebEngineBrowserExtension*>(part->browserExtension());
if (ext) {
connect(ext, QOverload<QObject *, const QByteArray &>::of(&WebEngineBrowserExtension::saveHistory),
......
......@@ -34,8 +34,10 @@
#include <KIO/AccessManager>
#include <KUriFilter>
#include <KLineEdit>
#include <KPluginMetaData>
#include <webenginepart.h>
#include <QJsonDocument>
#include <QInputDialog>
//#include <QUiLoader>
......@@ -74,7 +76,18 @@ class MainWindow : public QMainWindow
Q_OBJECT
public:
MainWindow(const QString& url = QString()): currentZoom(100) {
view = new WebEnginePart(this);
#if KPARTS_VERSION >= QT_VERSION_CHECK(5, 77, 0)
QJsonObject jo = QJsonDocument::fromJson(
"{ \"KPlugin\": {\n"
" \"Id\": \"webenginepart\",\n"
" \"Name\": \"WebEngine\",\n"
" \"Version\": \"0.1\"\n"
"}\n}").object();
KPluginMetaData metaData(jo, QString());
view = new WebEnginePart(this, nullptr, metaData);
#else
view = new WebEnginePart(this, nullptr);
#endif
setCentralWidget(view->widget());
connect(view->view(), &QWebEngineView::loadFinished,
......