Commit de78c666 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Port away from deprecated KAboutData::fromPluginMetaData

parent 8ab379e1
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include <QTimer> #include <QTimer>
#include <QWidgetAction> #include <QWidgetAction>
#include <KAboutApplicationDialog> #include <KAboutPluginDialog>
#include <KActionCollection> #include <KActionCollection>
#include <KBookmarkAction> #include <KBookmarkAction>
#include <KDirWatch> #include <KDirWatch>
...@@ -3019,15 +3019,20 @@ void Part::enableExitAfterPrint() ...@@ -3019,15 +3019,20 @@ void Part::enableExitAfterPrint()
m_cliPrintAndExit = true; m_cliPrintAndExit = true;
} }
static const char *kKPlugin = "KPlugin";
void Part::slotAboutBackend() void Part::slotAboutBackend()
{ {
const KPluginMetaData data = m_document->generatorInfo(); const KPluginMetaData data = m_document->generatorInfo();
if (!data.isValid()) if (!data.isValid())
return; return;
KAboutData aboutData = KAboutData::fromPluginMetaData(data); // Here we do a bit of magic because KPluginMetaData doesn't have setters
// so we get the json info from it, modify it and use that for the KAboutPluginDialog
QIcon icon = QIcon::fromTheme(data.iconName()); // in case the internals of KPluginMetaData change it won't be too bad, at most we're
// missing the icon or the generator extra description
QJsonObject rawData = data.rawData();
const QIcon icon = QIcon::fromTheme(data.iconName());
// fall back to mime type icon // fall back to mime type icon
if (icon.isNull()) { if (icon.isNull()) {
...@@ -3037,22 +3042,23 @@ void Part::slotAboutBackend() ...@@ -3037,22 +3042,23 @@ void Part::slotAboutBackend()
QMimeDatabase db; QMimeDatabase db;
QMimeType type = db.mimeTypeForName(mimeTypeName); QMimeType type = db.mimeTypeForName(mimeTypeName);
if (type.isValid()) { if (type.isValid()) {
icon = QIcon::fromTheme(type.iconName()); QJsonObject kplugin = rawData[kKPlugin].toObject();
kplugin[QStringLiteral("Icon")] = type.iconName();
rawData[kKPlugin] = kplugin;
} }
} }
} }
const QString extraDescription = m_document->metaData(QStringLiteral("GeneratorExtraDescription")).toString(); const QString extraDescription = m_document->metaData(QStringLiteral("GeneratorExtraDescription")).toString();
if (!extraDescription.isEmpty()) {
aboutData.setShortDescription(aboutData.shortDescription() + QStringLiteral("\n\n") + extraDescription);
}
if (!icon.isNull()) { if (!extraDescription.isEmpty()) {
// 48x48 is what KAboutApplicationDialog wants, which doesn't match any default so we hardcode it const QString descriptionAndLang = QStringLiteral("Description[%1]").arg(QLocale().name());
aboutData.setProgramLogo(icon.pixmap(48, 48)); QJsonObject kplugin = rawData[kKPlugin].toObject();
kplugin[descriptionAndLang] = QStringLiteral("%1\n\n%2").arg(data.description(), extraDescription);
rawData[kKPlugin] = kplugin;
} }
KAboutApplicationDialog dlg(aboutData, widget()); KAboutPluginDialog dlg(KPluginMetaData(rawData, data.fileName()), widget());
dlg.exec(); dlg.exec();
} }
......
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