From f5be10b15b06ae34c1fbce152305db7ba17a840d Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 9 Feb 2021 17:07:02 +0200 Subject: [PATCH] FileFilterHotspot: use QMimeDataBase::mimeTypeForFile() It seems there is no way around checking for the extension then falling back to letting QMimeDataBase examine the file contents; e.g. a file named konsolerc, doesn't have an extension, but it is still a text file. --- src/filterHotSpots/FileFilterHotspot.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/filterHotSpots/FileFilterHotspot.cpp b/src/filterHotSpots/FileFilterHotspot.cpp index 29d83d6a..591db2bd 100644 --- a/src/filterHotSpots/FileFilterHotspot.cpp +++ b/src/filterHotSpots/FileFilterHotspot.cpp @@ -131,12 +131,10 @@ void FileFilterHotSpot::openWithEditorFromProfile(const QString &fullCmd, const // Here we are mostly interested in text-based files, e.g. if it's a // PDF we should let the system default app open it. QMimeDatabase mdb; - const auto mimeList = mdb.mimeTypesForFileName(path); - qCDebug(KonsoleDebug) << "FileFilterHotSpot: mime types for" << path << ":" << mimeList; + const auto mimeType = mdb.mimeTypeForFile(path); + qCDebug(KonsoleDebug) << "FileFilterHotSpot: mime type for" << path << ":" << mimeType; - // If mimeList is empty, then it's not a recognized mime type, e.g. - // a text file without an extension - if (mimeList.isEmpty() || !mimeList.at(0).inherits(QStringLiteral("text/plain"))) { + if (!mimeType.inherits(QStringLiteral("text/plain"))) { openWithSysDefaultApp(path); return; }