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.
wilder
Ahmad Samir 5 years ago committed by Kurt Hindenburg
parent 3b06b6f22a
commit f5be10b15b
  1. 8
      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;
}

Loading…
Cancel
Save