From aa78a03de03f3fb7cee4e083d7854b0911a17f7c Mon Sep 17 00:00:00 2001 From: probonopd Date: Thu, 7 Mar 2019 17:44:13 +0000 Subject: [PATCH] Deploy platformthemes/libqgtk2.so, styles/libqgtk2style.so, iconengines and imageformats (#352) --- tools/linuxdeployqt/shared.cpp | 63 +++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/tools/linuxdeployqt/shared.cpp b/tools/linuxdeployqt/shared.cpp index 911b08a..dbddcde 100644 --- a/tools/linuxdeployqt/shared.cpp +++ b/tools/linuxdeployqt/shared.cpp @@ -1217,26 +1217,7 @@ void deployPlugins(const AppDirInfo &appDirInfo, const QString &pluginSourcePath // Plugin white list: QStringList pluginList; - - // Make the bundled application look good on, e.g., Xfce - // Note: http://code.qt.io/qt/qtstyleplugins.git must be compiled (using libgtk2.0-dev) - // https://askubuntu.com/a/910143 - // https://askubuntu.com/a/748186 - // This functionality used to come as part of Qt by default in earlier versions - // At runtime, export QT_QPA_PLATFORMTHEME=gtk2 (Xfce does this itself) - pluginList.append("platformthemes/libqgtk2.so"); - pluginList.append("styles/libqgtk2style.so"); - - // Always bundle iconengines,imageformats - // https://github.com/probonopd/linuxdeployqt/issues/82 - // https://github.com/probonopd/linuxdeployqt/issues/325 - // FIXME - // The following does NOT work; - // findDependencyInfo: "ldd: /usr/local/Qt-5.9.3/plugins/iconengines: not regular file" - // pluginList.append("iconengines"); - // pluginList.append("imageformats"); - // TODO: Need to traverse the directories and add each contained plugin individually - + LogDebug() << "deploymentInfo.deployedLibraries before attempting to bundle required plugins:" << deploymentInfo.deployedLibraries; // Platform plugin: @@ -1257,16 +1238,42 @@ void deployPlugins(const AppDirInfo &appDirInfo, const QString &pluginSourcePath pluginList.append(QStringLiteral("platformthemes/") + plugin); } */ - // All image formats (svg if QtSvg library is used) - QStringList imagePlugins = QDir(pluginSourcePath + QStringLiteral("/imageformats")).entryList(QStringList() << QStringLiteral("*.so")); - foreach (const QString &plugin, imagePlugins) { - if (plugin.contains(QStringLiteral("qsvg"))) { - if (containsHowOften(deploymentInfo.deployedLibraries, "libQt5Svg")) { - pluginList.append(QStringLiteral("imageformats/") + plugin); - } + + // Make the bundled application look good on, e.g., Xfce + // Note: http://code.qt.io/qt/qtstyleplugins.git must be compiled (using libgtk2.0-dev) + // https://askubuntu.com/a/910143 + // https://askubuntu.com/a/748186 + // This functionality used to come as part of Qt by default in earlier versions + // At runtime, export QT_QPA_PLATFORMTHEME=gtk2 (Xfce does this itself) + QStringList extraQtPluginsAdded = { "platformthemes/libqgtk2.so", "styles/libqgtk2style.so" }; + foreach (const QString &plugin, extraQtPluginsAdded) { + if (QFile::exists(pluginSourcePath + "/" + plugin)) { + pluginList.append(plugin); + LogDebug() << plugin << "appended"; } else { - pluginList.append(QStringLiteral("imageformats/") + plugin); + LogWarning() <<"Plugin" << pluginSourcePath + "/" + plugin << "not found, skipping"; + } } + // Always bundle iconengines,imageformats + // https://github.com/probonopd/linuxdeployqt/issues/82 + // https://github.com/probonopd/linuxdeployqt/issues/325 + // FIXME + // The following does NOT work; + // findDependencyInfo: "ldd: /usr/local/Qt-5.9.3/plugins/iconengines: not regular file" + // pluginList.append("iconengines"); + // pluginList.append("imageformats"); + // TODO: Need to traverse the directories and add each contained plugin individually + QStringList extraQtPluginDirs = { "iconengines", "imageformats" }; + foreach (const QString &plugin, extraQtPluginDirs) { + QDir pluginDirectory(pluginSourcePath + "/" + plugin); + if (pluginDirectory.exists()) { + //If it is a plugin directory we will deploy the entire directory + QStringList plugins = pluginDirectory.entryList(QStringList() << QStringLiteral("*.so")); + foreach (const QString &pluginFile, plugins) { + pluginList.append(plugin + "/" + pluginFile); + LogDebug() << plugin + "/" + pluginFile << "appended"; + } + } } }