Commit bce36ee9 authored by Elvis Angelaccio's avatar Elvis Angelaccio

part: switch to json loading

Every time we do a 'make install' we also update the mime database (because we
install mimetypes) and this causes the ksycoca file to be regenerated the
next time we run Ark (because we load the Part using KService).

This is annoying and clutters the console output with ksycoca messages. We can use instead the new
json loading mechanism like we already do with our plugins.

Regarding ark_part.desktop, we continue to install it because Konqueror is
probably using it.

Differential Revision: D2140
parent 562f156a
......@@ -127,14 +127,19 @@ void MainWindow::dragMoveEvent(QDragMoveEvent * event)
bool MainWindow::loadPart()
{
KPluginFactory *factory = 0;
KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("ark_part"));
KPluginFactory *factory = Q_NULLPTR;
if (service) {
factory = KPluginLoader(service->library()).factory();
const auto plugins = KPluginLoader::findPlugins(QString(), [](const KPluginMetaData& metaData) {
return metaData.pluginId() == QStringLiteral("arkpart") &&
metaData.serviceTypes().contains(QStringLiteral("KParts/ReadOnlyPart")) &&
metaData.serviceTypes().contains(QStringLiteral("Browser/View"));
});
if (plugins.size() == 1) {
factory = KPluginLoader(plugins.first().fileName()).factory();
}
m_part = factory ? static_cast<KParts::ReadWritePart*>(factory->create<KParts::ReadWritePart>(this)) : 0;
m_part = factory ? static_cast<KParts::ReadWritePart*>(factory->create<KParts::ReadWritePart>(this)) : Q_NULLPTR;
if (!m_part) {
KMessageBox::error(this, i18n("Unable to find Ark's KPart component, please check your installation."));
......
......@@ -30,6 +30,8 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/ark_part.desktop
)
kcoreaddons_desktop_to_json(arkpart ${CMAKE_CURRENT_BINARY_DIR}/ark_part.desktop SERVICES_TYPES kpart.desktop browserview.desktop)
install(TARGETS arkpart DESTINATION ${KDE_INSTALL_PLUGINDIR})
########### install files ###############
......
......@@ -75,7 +75,7 @@
using namespace Kerfuffle;
K_PLUGIN_FACTORY(Factory, registerPlugin<Ark::Part>();)
K_PLUGIN_FACTORY_WITH_JSON(Factory, "ark_part.json", registerPlugin<Ark::Part>();)
namespace Ark
{
......
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