Commit 0956eb04 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Port away from deprecated part loading

Instead of using the deprecated KMimeTypeTrader/KServiceTypeTrader load the relevant parts directly
parent 2983a12d
Pipeline #247381 passed with stage
in 54 seconds
......@@ -18,9 +18,3 @@ ecm_qt_install_logging_categories(
FILE kompare.categories
DESTINATION "${KDE_INSTALL_LOGGINGCATEGORIESDIR}"
)
install(FILES
komparenavigationpart.desktop
kompareviewpart.desktop
DESTINATION ${KDE_INSTALL_KSERVICETYPESDIR}
)
......@@ -25,7 +25,6 @@
#include <KMessageBox>
#include <KSqueezedTextLabel>
#include <KStandardAction>
#include <KMimeTypeTrader>
#include <KServiceTypeTrader>
#include <KSharedConfig>
#include <KToggleAction>
......@@ -54,10 +53,11 @@ KompareShell::KompareShell()
setupActions();
setupStatusBar();
m_viewPart = KMimeTypeTrader::createInstanceFromQuery<KParts::ReadWritePart>(QStringLiteral("text/x-patch"), QStringLiteral("Kompare/ViewPart"), this);
const auto viewPartLoadResult = KPluginFactory::instantiatePlugin<KParts::ReadWritePart>(KPluginMetaData(QStringLiteral("kf5/parts/komparepart")), this);
if (m_viewPart)
if (viewPartLoadResult)
{
m_viewPart = viewPartLoadResult.plugin;
setCentralWidget(m_viewPart->widget());
// and integrate the part's GUI with the shell's
createGUI(m_viewPart);
......@@ -66,7 +66,7 @@ KompareShell::KompareShell()
{
// if we couldn't load our Part, we exit since the Shell by
// itself can't do anything useful
KMessageBox::error(this, i18n("Could not load our KompareViewPart."));
KMessageBox::error(this, i18n("Could not load our KompareViewPart: %1", viewPartLoadResult.errorString));
exit(2);
}
......@@ -74,11 +74,12 @@ KompareShell::KompareShell()
m_navTreeDock->setObjectName(QStringLiteral("Navigation"));
// This part is implemented in KompareNavTreePart
m_navTreePart = KServiceTypeTrader::createInstanceFromQuery<KParts::ReadOnlyPart>
(QStringLiteral("KParts/ReadOnlyPart"), QStringLiteral("'Kompare/NavigationPart' in ServiceTypes"), m_navTreeDock);
if (m_navTreePart)
const auto navPartLoadResult = KPluginFactory::instantiatePlugin<KParts::ReadOnlyPart>(KPluginMetaData(QStringLiteral("kf5/parts/komparenavtreepart")), m_navTreeDock);
if (navPartLoadResult)
{
m_navTreePart = navPartLoadResult.plugin;
m_navTreeDock->setWidget(m_navTreePart->widget());
addDockWidget(Qt::TopDockWidgetArea, m_navTreeDock);
// m_navTreeDock->manualDock( m_mainViewDock, KDockWidget::DockTop, 20 );
......@@ -87,7 +88,7 @@ KompareShell::KompareShell()
{
// if we couldn't load our Part, we exit since the Shell by
// itself can't do anything useful
KMessageBox::error(this, i18n("Could not load our KompareNavigationPart."));
KMessageBox::error(this, i18n("Could not load our KompareNavigationPart: %1", navPartLoadResult.errorString));
exit(4);
}
......
[Desktop Entry]
Type=ServiceType
X-KDE-ServiceType=Kompare/NavigationPart
X-KDE-Derived=KParts/ReadOnlyPart
......@@ -62,7 +62,6 @@ Name[x-test]=xxKompareNavTreePartxx
Name[zh_CN]=KompareNavTreePart
Name[zh_TW]=KompareNavTreePart
MimeType=text/x-patch;
ServiceTypes=Kompare/NavigationPart
X-KDE-Library=kf5/parts/komparenavtreepart
Type=Service
Icon=kompare
......
......@@ -66,7 +66,6 @@ Name[x-test]=xxKomparePartxx
Name[zh_CN]=KomparePart
Name[zh_TW]=KomparePart
MimeType=text/x-patch;
ServiceTypes=Kompare/ViewPart,KParts/ReadWritePart,KParts/ReadOnlyPart
X-KDE-Library=kf5/parts/komparepart
Type=Service
Icon=kompare
......
[Desktop Entry]
Type=ServiceType
X-KDE-ServiceType=Kompare/ViewPart
X-KDE-Derived=KParts/ReadOnlyPart
Supports Markdown
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