bool ArkViewer::viewInInternalViewer(const QString& fileName, const QMimeType &mimeType) { setWindowFilePath(fileName); // Set icon and comment for the mimetype. m_iconLabel->setPixmap(QIcon::fromTheme(mimeType.iconName()).pixmap(IconSize(KIconLoader::Small), IconSize(KIconLoader::Small))); m_commentLabel->setText(mimeType.comment()); // Create the ReadOnlyPart instance. m_part = KMimeTypeTrader::self()->createPartInstanceFromQuery<KParts::ReadOnlyPart>(mimeType.name(), this, this); // Drop the KHTMLPart, if necessary. const KService::Ptr service = KMimeTypeTrader::self()->preferredService(mimeType.name(), QStringLiteral("KParts/ReadOnlyPart")); qCDebug(ARK) << "Preferred service for mimetype" << mimeType.name() << "is" << service->library(); if (service.constData()->desktopEntryName() == QLatin1String("khtml")) { KService::List offers = KMimeTypeTrader::self()->query(mimeType.name(), QStringLiteral("KParts/ReadOnlyPart")); offers.removeFirst(); qCDebug(ARK) << "Removed KHTMLPart from the offers for mimetype" << mimeType.name() << ". Using" << offers.first().constData()->desktopEntryName() << "instead."; m_part = offers.first().constData()->createInstance<KParts::ReadOnlyPart>(this, this); } if (!m_part.data()) { return false; } // Insert the KPart into its placeholder. centralWidget()->layout()->replaceWidget(m_partPlaceholder, m_part.data()->widget()); createGUI(m_part.data()); setAutoSaveSettings(QStringLiteral("Viewer"), true); m_part.data()->openUrl(QUrl::fromLocalFile(fileName)); m_part.data()->widget()->setFocus(); m_fileName = fileName; return true; }