+void DolphinViewContainer::slotfileMiddleClickActivated(const KFileItem &item)
+{
+ KService::List services = KApplicationTrader::queryByMimeType(item.mimetype());
+
+ int indexOfAppToOpenFileWith = 1;
+
+ // executable scripts
+ auto mimeType = item.currentMimeType();
+ if (item.isLocalFile() && mimeType.inherits(QStringLiteral("application/x-executable")) && mimeType.inherits(QStringLiteral("text/plain"))
+ && QFileInfo(item.localPath()).isExecutable()) {
+ KConfigGroup cfgGroup(KSharedConfig::openConfig(QStringLiteral("kiorc")), QStringLiteral("Executable scripts"));
+ const QString value = cfgGroup.readEntry("behaviourOnLaunch", "alwaysAsk");
+
+ // in case KIO::WidgetsOpenOrExecuteFileHandler::promptUserOpenOrExecute would not open the file
+ if (value != QLatin1String("open")) {
+ indexOfAppToOpenFileWith = 0;
+ }
+ }
+
+ if (services.length() >= indexOfAppToOpenFileWith + 1) {
+ auto service = services.at(indexOfAppToOpenFileWith);
+
+ KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(service, this);
+ job->setUrls({item.url()});
+
+ job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
+ connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished);
+ job->start();
+ } else {
+ // If no 2nd service available, try to open archives in new tabs, regardless of the "Open archives as folder" setting.
+ const QUrl &url = DolphinView::openItemAsFolderUrl(item);
+ const auto modifiers = QGuiApplication::keyboardModifiers();
+ if (!url.isEmpty()) {
+ // keep in sync with KUrlNavigator::slotNavigatorButtonClicked
+ if (modifiers & Qt::ShiftModifier) {
+ Q_EMIT activeTabRequested(url);
+ } else {
+ Q_EMIT tabRequested(url);
+ }
+ }
+ }
+}
+