void KonqPopupMenuPrivate::addPlugins() { QString commonMimeType = m_popupItemProperties.mimeType(); if (commonMimeType.isEmpty()) { commonMimeType = QLatin1String("application/octet-stream"); } const KService::List fileItemPlugins = KMimeTypeTrader::self()->query(commonMimeType, QStringLiteral("KFileItemAction/Plugin"), QStringLiteral("exist Library")); if (!fileItemPlugins.isEmpty()) { const KConfig config(QStringLiteral("kservicemenurc"), KConfig::NoGlobals); const KConfigGroup showGroup = config.group("Show"); foreach (const auto &service, fileItemPlugins) { if (!showGroup.readEntry(service->desktopEntryName(), true)) { // The plugin has been disabled continue; } KAbstractFileItemActionPlugin *abstractPlugin = service->createInstance<KAbstractFileItemActionPlugin>(); if (abstractPlugin) { abstractPlugin->setParent(q); q->addActions(abstractPlugin->actions(m_popupItemProperties, m_parentWidget)); } } } }
void KonqPopupMenuPrivate::addPlugins() { QString commonMimeType = m_popupItemProperties.mimeType(); if (commonMimeType.isEmpty()) { commonMimeType = QLatin1String("application/octet-stream"); } const KService::List konqPlugins = KMimeTypeTrader::self()->query(commonMimeType, "KonqPopupMenu/Plugin", "exist Library"); if (!konqPlugins.isEmpty()) { m_popupMenuInfo.setItemListProperties(m_popupItemProperties); m_popupMenuInfo.setParentWidget(m_parentWidget); KService::List::ConstIterator iterator = konqPlugins.begin(); const KService::List::ConstIterator end = konqPlugins.end(); for(; iterator != end; ++iterator) { //kDebug() << (*iterator)->name() << (*iterator)->library(); KonqPopupMenuPlugin *plugin = (*iterator)->createInstance<KonqPopupMenuPlugin>(q); if (!plugin) continue; plugin->setParent(q); plugin->setup(&m_ownActionCollection, m_popupMenuInfo, q); } } const KService::List fileItemPlugins = KMimeTypeTrader::self()->query(commonMimeType, "KFileItemAction/Plugin", "exist Library"); if (!fileItemPlugins.isEmpty()) { const KConfig config("kservicemenurc", KConfig::NoGlobals); const KConfigGroup showGroup = config.group("Show"); foreach (const KSharedPtr<KService>& service, fileItemPlugins) { if (!showGroup.readEntry(service->desktopEntryName(), true)) { // The plugin has been disabled continue; } // Old API (kdelibs-4.6.0 only) KFileItemActionPlugin* plugin = service->createInstance<KFileItemActionPlugin>(); if (plugin) { plugin->setParent(q); q->addActions(plugin->actions(m_popupItemProperties, m_parentWidget)); } // New API (kdelibs >= 4.6.1) KAbstractFileItemActionPlugin* abstractPlugin = service->createInstance<KAbstractFileItemActionPlugin>(); if (abstractPlugin) { abstractPlugin->setParent(q); q->addActions(abstractPlugin->actions(m_popupItemProperties, m_parentWidget)); } } } }
QList<QAction*> CompressFileItemAction::actions(const KFileItemListProperties& fileItemInfos, QWidget* parentWidget) { // #268163: don't offer compression on already compressed archives. if (m_pluginManager->supportedMimeTypes().contains(fileItemInfos.mimeType())) { return {}; } QList<QAction*> actions; const QIcon icon = QIcon::fromTheme(QStringLiteral("ark")); QMenu *compressMenu = new QMenu(parentWidget); compressMenu->addAction(createAction(icon, i18nc("@action:inmenu Part of Compress submenu in Dolphin context menu", "Here (as TAR.GZ)"), parentWidget, fileItemInfos.urlList(), QStringLiteral("ark --changetofirstpath --add --autofilename tar.gz %F"))); const QMimeType zipMime = QMimeDatabase().mimeTypeForName(QStringLiteral("application/zip")); // Don't offer zip compression if no zip plugin is available. if (!m_pluginManager->preferredWritePluginsFor(zipMime).isEmpty()) { compressMenu->addAction(createAction(icon, i18nc("@action:inmenu Part of Compress submenu in Dolphin context menu", "Here (as ZIP)"), parentWidget, fileItemInfos.urlList(), QStringLiteral("ark --changetofirstpath --add --autofilename zip %F"))); } compressMenu->addAction(createAction(icon, i18nc("@action:inmenu Part of Compress submenu in Dolphin context menu", "Compress to..."), parentWidget, fileItemInfos.urlList(), QStringLiteral("ark --add --changetofirstpath --dialog %F"))); QAction *compressMenuAction = new QAction(i18nc("@action:inmenu Compress submenu in Dolphin context menu", "Compress"), parentWidget); compressMenuAction->setMenu(compressMenu); // #189177: disable compress menu in read-only folders. if (!fileItemInfos.supportsWriting()) { compressMenuAction->setEnabled(false); } actions << compressMenuAction; return actions; }
void KonqPopupMenuPrivate::slotPopupMimeType() { KonqOperations::editMimeType(m_popupItemProperties.mimeType(), m_parentWidget); }