From 3b281f66937a3a9329c7ff363b16499664c52b4e Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Sun, 21 Mar 2021 14:30:46 +0100 Subject: [PATCH] QAbstractFileIconProvider: Fix compilation without feature mimetype Change-Id: I3aecc1ab97ed549511bc9a5cbc8eb780f5e9a4dd Reviewed-by: Volker Hilsheimer --- src/gui/image/qabstractfileiconprovider.cpp | 11 +++++++++++ src/gui/image/qabstractfileiconprovider_p.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/gui/image/qabstractfileiconprovider.cpp b/src/gui/image/qabstractfileiconprovider.cpp index dbf27d9360..d79e49832b 100644 --- a/src/gui/image/qabstractfileiconprovider.cpp +++ b/src/gui/image/qabstractfileiconprovider.cpp @@ -43,7 +43,9 @@ #include #include #include +#if QT_CONFIG(mimetype) #include +#endif #include @@ -151,7 +153,11 @@ QIcon QAbstractFileIconProviderPrivate::getIconThemeIcon(const QFileInfo &info) return getIconThemeIcon(QAbstractFileIconProvider::Drive); if (info.isDir()) return getIconThemeIcon(QAbstractFileIconProvider::Folder); +#if QT_CONFIG(mimetype) return QIcon::fromTheme(mimeDatabase.mimeTypeForFile(info).iconName()); +#else + return QIcon::fromTheme(QLatin1String("text-x-generic")); +#endif } /*! @@ -267,8 +273,13 @@ QString QAbstractFileIconProvider::type(const QFileInfo &info) const if (QFileSystemEntry::isRootPath(info.absoluteFilePath())) return QGuiApplication::translate("QAbstractFileIconProvider", "Drive"); if (info.isFile()) { +#if QT_CONFIG(mimetype) const QMimeType mimeType = d->mimeDatabase.mimeTypeForFile(info); return mimeType.comment().isEmpty() ? mimeType.name() : mimeType.comment(); +#else + Q_UNUSED(d); + return QGuiApplication::translate("QAbstractFileIconProvider", "File"); +#endif } if (info.isDir()) diff --git a/src/gui/image/qabstractfileiconprovider_p.h b/src/gui/image/qabstractfileiconprovider_p.h index 37646f77e6..c6193fe48a 100644 --- a/src/gui/image/qabstractfileiconprovider_p.h +++ b/src/gui/image/qabstractfileiconprovider_p.h @@ -52,7 +52,9 @@ // #include +#if QT_CONFIG(mimetype) #include +#endif #include "qabstractfileiconprovider.h" QT_BEGIN_NAMESPACE @@ -75,7 +77,9 @@ public: QAbstractFileIconProvider *q_ptr = nullptr; QAbstractFileIconProvider::Options options = {}; +#if QT_CONFIG(mimetype) QMimeDatabase mimeDatabase; +#endif }; QT_END_NAMESPACE