Skip to content

Commit 2898217

Browse files
committed
Added Qt6 support
1 parent 222c614 commit 2898217

File tree

5 files changed

+121
-7
lines changed

5 files changed

+121
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Just like all linuxdeploy plugins, the Qt plugin's behavior can be configured so
5757
**Qt specific:**
5858
- `$QMAKE=/path/to/my/qmake`: use another `qmake` binary to detect paths of plugins and other resources (usually doesn't need to be set manually, most Qt environments ship scripts changing `$PATH`)
5959
- `$EXTRA_QT_PLUGINS=pluginA;pluginB`: Plugins to deploy even if not found automatically by linuxdeploy-plugin-qt
60+
- `$QT_MAJOR_VERSION=5`: Qt's Version, supported versions are 5 and 6. Default is 5.
6061

6162
QML related:
6263
- `$QML_SOURCES_PATHS`: directory containing the application's QML files — useful/needed if QML files are "baked" into the binaries. `$QT_INSTALL_QML` is prepended to this list internally.

src/deployers/PluginsDeployerFactory.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ PluginsDeployerFactory::PluginsDeployerFactory(AppDir& appDir,
2424
bf::path qtLibexecsPath,
2525
bf::path qtInstallQmlPath,
2626
bf::path qtTranslationsPath,
27-
bf::path qtDataPath) : appDir(appDir),
27+
bf::path qtDataPath,
28+
int qtMajorVersion) : appDir(appDir),
2829
qtPluginsPath(std::move(qtPluginsPath)),
2930
qtLibexecsPath(std::move(qtLibexecsPath)),
3031
qtInstallQmlPath(std::move(qtInstallQmlPath)),
3132
qtTranslationsPath(std::move(qtTranslationsPath)),
32-
qtDataPath(std::move(qtDataPath)) {}
33+
qtDataPath(std::move(qtDataPath)),
34+
qtMajorVersion(qtMajorVersion) {}
3335

3436
std::vector<std::shared_ptr<PluginsDeployer>> PluginsDeployerFactory::getDeployers(const std::string& moduleName) {
3537
if (moduleName == "gui") {
@@ -41,6 +43,10 @@ std::vector<std::shared_ptr<PluginsDeployer>> PluginsDeployerFactory::getDeploye
4143
}
4244

4345
if (moduleName == "network") {
46+
if (qtMajorVersion == 6) {
47+
// Qt6 has no bearer plugin.
48+
return {getInstance<BasicPluginsDeployer>(moduleName)};
49+
}
4450
return {getInstance<BearerPluginsDeployer>(moduleName)};
4551
}
4652

src/deployers/PluginsDeployerFactory.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace linuxdeploy {
2323
const boost::filesystem::path qtInstallQmlPath;
2424
const boost::filesystem::path qtTranslationsPath;
2525
const boost::filesystem::path qtDataPath;
26+
const int qtMajorVersion{5};
2627

2728
template<typename T>
2829
std::shared_ptr<PluginsDeployer> getInstance(const std::string& moduleName) {
@@ -45,7 +46,8 @@ namespace linuxdeploy {
4546
boost::filesystem::path qtLibexecsPath,
4647
boost::filesystem::path qtInstallQmlPath,
4748
boost::filesystem::path qtTranslationsPath,
48-
boost::filesystem::path qtDataPath);
49+
boost::filesystem::path qtDataPath,
50+
int qtMajorVersion = 5);
4951

5052
std::vector<std::shared_ptr<PluginsDeployer>> getDeployers(const std::string& moduleName);
5153
};

src/main.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ int main(const int argc, const char *const *const argv) {
6969
ldLog() << LD_ERROR << "No such directory:" << appDirPath.Get() << std::endl;
7070
return 1;
7171
}
72+
73+
int qtMajorVersion = 5;
74+
auto qtMajorVersionStr = getenv("QT_MAJOR_VERSION");
75+
if (qtMajorVersionStr != nullptr) {
76+
qtMajorVersion = atoi(qtMajorVersionStr);
77+
if (qtMajorVersion < 5) {
78+
ldLog() << std::endl << LD_WARNING << "Minimum Qt version supported is 5" << std::endl;
79+
qtMajorVersion = 5;
80+
}
81+
else if (qtMajorVersion > 6) {
82+
ldLog() << std::endl << LD_WARNING << "Maximum Qt version supported is 6" << std::endl;
83+
qtMajorVersion = 6;
84+
}
85+
}
86+
87+
ldLog() << std::endl << "Using Qt" << qtMajorVersion << std::endl;
7288

7389
appdir::AppDir appDir(appDirPath.Get());
7490

@@ -125,7 +141,9 @@ int main(const int argc, const char *const *const argv) {
125141
return false;
126142
};
127143

128-
std::copy_if(QtModules.begin(), QtModules.end(), std::back_inserter(foundQtModules),
144+
const std::vector<QtModule> *qtmodules = qtMajorVersion == 6 ? &Qt6Modules : &Qt5Modules;
145+
146+
std::copy_if(qtmodules->begin(), qtmodules->end(), std::back_inserter(foundQtModules),
129147
[&matchesQtModule, &libraryNames](const QtModule &module) {
130148
return std::find_if(libraryNames.begin(), libraryNames.end(),
131149
[&matchesQtModule, &module](const std::string &libraryName) {
@@ -139,7 +157,7 @@ int main(const int argc, const char *const *const argv) {
139157
extraPluginsFromEnv = linuxdeploy::util::split(std::string(extraPluginsFromEnvData), ';');
140158

141159
for (const auto& pluginsList : {static_cast<std::vector<std::string>>(extraPlugins.Get()), extraPluginsFromEnv}) {
142-
std::copy_if(QtModules.begin(), QtModules.end(), std::back_inserter(extraQtModules),
160+
std::copy_if(qtmodules->begin(), qtmodules->end(), std::back_inserter(extraQtModules),
143161
[&matchesQtModule, &libraryNames, &pluginsList](const QtModule &module) {
144162
return std::find_if(pluginsList.begin(), pluginsList.end(),
145163
[&matchesQtModule, &module](const std::string &libraryName) {
@@ -223,7 +241,8 @@ int main(const int argc, const char *const *const argv) {
223241
qtLibexecsPath,
224242
qtInstallQmlPath,
225243
qtTranslationsPath,
226-
qtDataPath
244+
qtDataPath,
245+
qtMajorVersion
227246
);
228247

229248
for (const auto& module : qtModulesToDeploy) {

src/qt-modules.h

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class QtModule {
1717
};
1818

1919
// TODO: the list of translation file prefixes is probably incomplete
20-
static const std::vector<QtModule> QtModules = {
20+
static const std::vector<QtModule> Qt5Modules = {
2121
{"3danimation", "libQt53DAnimation", ""},
2222
{"3dcore", "libQt53DCore", ""},
2323
{"3dextras", "libQt53DExtras", ""},
@@ -80,3 +80,89 @@ static const std::vector<QtModule> QtModules = {
8080
{"xmlpatterns", "libQt5XmlPatterns", "qtxmlpatterns"},
8181
{"xml", "libQt5Xml", "qtbase"},
8282
};
83+
84+
static const std::vector<QtModule> Qt6Modules = {
85+
{"concurrent", "libQt6Concurrent", "qtbase"},
86+
{"core5compat", "libQt6Core5Compat", "qtbase"},
87+
{"core", "libQt6Core", "qtbase"},
88+
{"dbus", "libQt6DBus", ""},
89+
{"designercomponents", "libQt6DesignerComponents", ""},
90+
{"designer", "libQt6Designer", ""},
91+
{"eglfsdeviceintegration", "libQt6EglFSDeviceIntegration", ""},
92+
{"eglfskmssupport", "libQt6EglFsKmsSupport", ""},
93+
{"gui", "libQt6Gui", "qtbase"},
94+
{"help", "libQt6Help", "qt_help"},
95+
{"network", "libQt6Network", "qtbase"},
96+
{"opengl", "libQt6OpenGL", ""},
97+
{"openglwidgets", "libQt6OpenGLWidgets", ""},
98+
{"printsupport", "libQt6PrintSupport", ""},
99+
{"qmlmodels", "libQt6QmlModels", ""},
100+
{"qml", "libQt6Qml", "qtdeclarative"},
101+
{"qmlworkerscript", "libQt6QmlWorkerScript", ""},
102+
{"quick3dassetimport", "libQt6Quick3DAssetImport", ""},
103+
{"quick3druntimerender", "libQt6Quick3DRuntimeRender", ""},
104+
{"quick3d", "libQt6Quick3D", ""},
105+
{"quick3dutils", "libQt6Quick3DUtils", ""},
106+
{"quickcontrols2impl", "libQt6QuickControls2Impl", ""},
107+
{"quickcontrols2", "libQt6QuickControls2", ""},
108+
{"quickparticles", "libQt6QuickParticles", ""},
109+
{"quickshapes", "libQt6QuickShapes", ""},
110+
{"quick", "libQt6Quick", "qtdeclarative"},
111+
{"quicktemplates2", "libQt6QuickTemplates2", ""},
112+
{"quicktest", "libQt6QuickTest", ""},
113+
{"quickwidgets", "libQt6QuickWidgets", ""},
114+
{"shadertools", "libQt6ShaderTools", ""},
115+
{"sql", "libQt6Sql", "qtbase"},
116+
{"svg", "libQt6Svg", ""},
117+
{"svgwidgets", "libQt6SvgWidgets", ""},
118+
{"test", "libQt6Test", "qtbase"},
119+
{"uitools", "libQt6UiTools", ""},
120+
{"waylandclient", "libQt6WaylandClient", ""},
121+
{"waylandcompositor", "libQt6WaylandCompositor", ""},
122+
{"widgets", "libQt6Widgets", "qtbase"},
123+
{"xcbqpa", "libQt6XcbQpa", ""},
124+
{"xml", "libQt6Xml", "qtbase"},
125+
126+
/* Not Included in Qt6.0.0, maybe some of them will be added back in 6.1, 6.2
127+
128+
{"3danimation", "libQt63DAnimation", ""},
129+
{"3dcore", "libQt63DCore", ""},
130+
{"3dextras", "libQt63DExtras", ""},
131+
{"3dinput", "libQt63DInput", ""},
132+
{"3dlogic", "libQt63DLogic", ""},
133+
{"3drender", "libQt63DRender", ""},
134+
{"3dquickanimation", "libQt63DQuickAnimation", ""},
135+
{"3dquickextras", "libQt63DQuickExtras", ""},
136+
{"3dquickinput", "libQt63DQuickInput", ""},
137+
{"3dquickrender", "libQt63DQuickRender", ""},
138+
{"3dquickscene2d", "libQt63DQuickScene2D", ""},
139+
{"3dquick", "libQt63DQuick", ""},
140+
{"bluetooth", "libQt6Bluetooth", ""},
141+
{"clucene", "libQt6CLucene", "qt_help"},
142+
{"declarative", "libQt6Declarative", "qtquick1"},
143+
{"gamepad", "libQt6Gamepad", ""},
144+
{"location", "libQt6Location", ""},
145+
{"multimediagsttools", "libQt6MultimediaGstTools", "qtmultimedia"},
146+
{"multimediaquick", "libQt6MultimediaQuick", "qtmultimedia"},
147+
{"multimedia", "libQt6Multimedia", "qtmultimedia"},
148+
{"multimediawidgets", "libQt6MultimediaWidgets", "qtmultimedia"},
149+
{"nfc", "libQt6Nfc", ""},
150+
{"positioning", "libQt6Positioning", ""},
151+
{"remoteobjects", "libQt6RemoteObjects", ""},
152+
{"script", "libQt6Script", "qtscript"},
153+
{"scripttools", "libQt6ScriptTools", "qtscript"},
154+
{"scxml", "libQt6Scxml", ""},
155+
{"sensors", "libQt6Sensors", ""},
156+
{"serialbus", "libQt6SerialBus", ""},
157+
{"serialport", "libQt6SerialPort", "qtserialport"},
158+
{"texttospeech", "libQt6TextToSpeech", ""},
159+
{"webchannel", "libQt6WebChannel", ""},
160+
{"webenginecore", "libQt6WebEngineCore", ""},
161+
{"webengine", "libQt6WebEngine", "qtwebengine"},
162+
{"webenginewidgets", "libQt6WebEngineWidgets", ""},
163+
{"websockets", "libQt6WebSockets", "qtwebsockets"},
164+
{"x11extras", "libQt6X11Extras", ""},
165+
{"xmlpatterns", "libQt6XmlPatterns", "qtxmlpatterns"},
166+
*/
167+
168+
};

0 commit comments

Comments
 (0)