QAbstractFileIconProvider: Fix compilation without feature mimetype

Change-Id: I3aecc1ab97ed549511bc9a5cbc8eb780f5e9a4dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Fabian Kosmale 2021-03-21 14:30:46 +01:00
parent a4ea58bf04
commit 3b281f6693
2 changed files with 15 additions and 0 deletions

View File

@ -43,7 +43,9 @@
#include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
#include <qicon.h>
#if QT_CONFIG(mimetype)
#include <qmimedatabase.h>
#endif
#include <private/qabstractfileiconprovider_p.h>
@ -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())

View File

@ -52,7 +52,9 @@
//
#include <QtGui/private/qtguiglobal_p.h>
#if QT_CONFIG(mimetype)
#include <QtCore/QMimeDatabase>
#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