QMimeDatabase: pick up XML mimetypes from :/qt-project.org/mime/packages

[ChangeLog][QtCore][QMimeDatabase] QMimeDatabase can now pick up XML
mimetype definitions from :/qt-project.org/mime/packages. GPL-compatible
projects which provide self-contained binaries can use this to provide
a copy of freedesktop.org.xml that will be used instead of the TIKA
mimetypes.

Change-Id: Id363317f920ae2cb1e054f32feb732e0e9168de3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit b12542c964c15d074393a7594c97a96d5c2b047d)
This commit is contained in:
David Faure 2024-07-10 12:02:41 +02:00
parent 2d2975bd9f
commit ed2f80b75d
3 changed files with 7 additions and 4 deletions

View File

@ -71,7 +71,11 @@ bool QMimeDatabasePrivate::shouldCheck()
static QStringList locateMimeDirectories()
{
return QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("mime"), QStandardPaths::LocateDirectory);
QStringList dirs =
QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("mime"),
QStandardPaths::LocateDirectory);
dirs.append(u":/qt-project.org/qmime"_s);
return dirs;
}
#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY)

View File

@ -57,7 +57,7 @@ qt_internal_add_resource(tst_qmimedatabase-xml-fdoxml "testdata"
qt_internal_add_resource(tst_qmimedatabase-xml-fdoxml "testdata-fdoxml"
PREFIX
"/tst_qmimedatabase/qmime"
"/qt-project.org/qmime/packages"
BASE
"../3rdparty"
FILES

View File

@ -139,7 +139,6 @@ void tst_QMimeDatabase::initTestCase()
// Create a temporary "global" XDG data dir. It's used
// 1) to install new global mimetypes later on
// 2) to run update-mime-database right away when testing the cache provider
// 3) to host a copy of freedesktop.org.xml in tst_qmimedatabase-xml-fdoxml
QVERIFY2(m_temporaryDir.isValid(),
("Could not create temporary subdir: " + m_temporaryDir.errorString()).toUtf8());
const QDir here = QDir(m_temporaryDir.path());
@ -150,7 +149,7 @@ void tst_QMimeDatabase::initTestCase()
qputenv("XDG_DATA_DIRS", QFile::encodeName(m_globalXdgDir));
qDebug() << "\nGlobal XDG_DATA_DIRS: " << m_globalXdgDir;
if (m_isUsingCacheProvider || m_hasFreedesktopOrg) {
if (m_isUsingCacheProvider) {
const QString xmlFileName = m_hasFreedesktopOrg
? (s_additionalFilesResourcePrefix + "/freedesktop.org.xml"_L1)
: (s_resourcePrefix + "/tika/packages/tika-mimetypes.xml"_L1);