diff --git a/src/launch/launch.cpp b/src/launch/launch.cpp index f269f61d..4c617cc8 100644 --- a/src/launch/launch.cpp +++ b/src/launch/launch.cpp @@ -24,6 +24,7 @@ #include "../core/plugin.hpp" #include "../core/rootwrapper.hpp" #include "../ipc/ipc.hpp" +#include "../webengine/webengine.hpp" #include "build.hpp" #include "launch_p.hpp" @@ -74,6 +75,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio bool nativeTextRendering = false; bool desktopSettingsAware = true; bool useSystemStyle = false; + bool useQtWebEngineQuick = false; QString iconTheme = qEnvironmentVariable("QS_ICON_THEME"); QHash envOverrides; QString dataDir; @@ -91,6 +93,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio else if (pragma == "NativeTextRendering") pragmas.nativeTextRendering = true; else if (pragma == "IgnoreSystemSettings") pragmas.desktopSettingsAware = false; else if (pragma == "RespectSystemStyle") pragmas.useSystemStyle = true; + else if (pragma == "EnableQtWebEngineQuick") pragmas.useQtWebEngineQuick = true; else if (pragma.startsWith("IconTheme ")) pragmas.iconTheme = pragma.sliced(10); else if (pragma.startsWith("Env ")) { auto envPragma = pragma.sliced(4); @@ -222,7 +225,11 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio delete coreApplication; QGuiApplication* app = nullptr; - auto qArgC = 0; + auto qArgC = 1; + + if (pragmas.useQtWebEngineQuick) { + web_engine::init(); + } if (pragmas.useQApplication) { app = new QApplication(qArgC, argv); diff --git a/src/webengine/webengine.hpp b/src/webengine/webengine.hpp new file mode 100644 index 00000000..3cd3aaf1 --- /dev/null +++ b/src/webengine/webengine.hpp @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +namespace qs::web_engine { + +inline void init() { + using InitializeFunc = void (*)(); + + QLibrary lib("Qt6WebEngineQuick"); + if (!lib.load()) { + qWarning() << "Failed to load library:" << lib.errorString(); + qWarning() << "You might need to install the necessary package for Qt6WebEngineQuick."; + qWarning() << "QtWebEngineQuick is not Loaded. Using the qml type WebEngineView from " + "QtWebEngine might lead to undefined behaviour!"; + return; + } + + qDebug() << "Loaded library Qt6WebEngineQuick"; + + auto initialize = + reinterpret_cast(lib.resolve("_ZN16QtWebEngineQuick10initializeEv")); + if (!initialize) { + qWarning() << "Failed to resolve symbol 'void QtWebEngineQuick::initialize()' in lib " + "Qt6WebEngineQuick. This should not happen"; + qWarning() << "QtWebEngineQuick is not Loaded. Using the qml type WebEngineView from " + "QtWebEngine might lead to undefined behaviour!"; + return; + } + + qDebug() << "Found symbol QtWebEngineQuick::initialize(). Initializing WebEngine..."; + + initialize(); + + qDebug() << "Successfully initialized QtWebEngineQuick"; +} + +} // namespace qs::web_engine \ No newline at end of file