Skip to content

Commit 93a6468

Browse files
Removed compile options for webengine support. Added pragma for loading Qt6WebEngineQuick at runtime
1 parent 572abdc commit 93a6468

File tree

4 files changed

+44
-17
lines changed

4 files changed

+44
-17
lines changed

CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@ if (DBUS)
129129
list(APPEND QT_FPDEPS DBus)
130130
endif()
131131

132-
if (WEBVIEW)
133-
list(APPEND QT_FPDEPS WebView)
134-
endif()
135-
136132
find_package(Qt6 REQUIRED COMPONENTS ${QT_FPDEPS})
137133

138134
# In Qt 6.10, private dependencies are required to be explicit,

src/launch/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ target_link_libraries(quickshell-launch PRIVATE
1111
Qt::Quick Qt::Widgets CLI11::CLI11 quickshell-build
1212
)
1313

14-
if(WEBVIEW)
15-
add_compile_definitions(WEBVIEW_ENABLED)
16-
target_link_libraries(quickshell-launch PRIVATE Qt::WebView)
17-
endif()
18-
1914
qs_add_pchset(launch
2015
DEPENDENCIES Qt::Core CLI11::CLI11
2116
HEADERS

src/launch/launch.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
#include <qtextstream.h>
1818
#include <unistd.h>
1919

20-
#ifdef WEBVIEW_ENABLED
21-
#include <QtWebView>
22-
#endif
23-
2420
#include "../core/common.hpp"
2521
#include "../core/instanceinfo.hpp"
2622
#include "../core/logging.hpp"
2723
#include "../core/paths.hpp"
2824
#include "../core/plugin.hpp"
2925
#include "../core/rootwrapper.hpp"
3026
#include "../ipc/ipc.hpp"
27+
#include "../webengine/webengine.hpp"
3128
#include "build.hpp"
3229
#include "launch_p.hpp"
3330

@@ -78,6 +75,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
7875
bool nativeTextRendering = false;
7976
bool desktopSettingsAware = true;
8077
bool useSystemStyle = false;
78+
bool useQtWebEngineQuick = false;
8179
QString iconTheme = qEnvironmentVariable("QS_ICON_THEME");
8280
QHash<QString, QString> envOverrides;
8381
QString dataDir;
@@ -95,6 +93,7 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
9593
else if (pragma == "NativeTextRendering") pragmas.nativeTextRendering = true;
9694
else if (pragma == "IgnoreSystemSettings") pragmas.desktopSettingsAware = false;
9795
else if (pragma == "RespectSystemStyle") pragmas.useSystemStyle = true;
96+
else if (pragma == "EnableQtWebEngineQuick") pragmas.useQtWebEngineQuick = true;
9897
else if (pragma.startsWith("IconTheme ")) pragmas.iconTheme = pragma.sliced(10);
9998
else if (pragma.startsWith("Env ")) {
10099
auto envPragma = pragma.sliced(4);
@@ -228,11 +227,9 @@ int launch(const LaunchArgs& args, char** argv, QCoreApplication* coreApplicatio
228227
QGuiApplication* app = nullptr;
229228
auto qArgC = 1;
230229

231-
#ifdef WEBVIEW_ENABLED
232-
if (qEnvironmentVariable("QS_WEBVIEW", "0") == "1") {
233-
QtWebView::initialize();
230+
if(pragmas.useQtWebEngineQuick) {
231+
web_engine::init();
234232
}
235-
#endif
236233

237234
if (pragmas.useQApplication) {
238235
app = new QApplication(qArgC, argv);

src/webengine/webengine.hpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <QDebug>
2+
#include <qdebug.h>
3+
#include <qlibrary.h>
4+
#include <qlogging.h>
5+
6+
namespace qs::web_engine {
7+
8+
inline void init()
9+
{
10+
using InitializeFunc = void (*)();
11+
12+
QLibrary lib("Qt6WebEngineQuick");
13+
if (!lib.load()) {
14+
qWarning() << "Failed to load library:" << lib.errorString();
15+
qWarning() << "You might need to install the necessary package for Qt6WebEngineQuick.";
16+
qWarning() << "QtWebEngineQuick is not Loaded. Using the qml type WebEngineView from "
17+
"QtWebEngine might lead to undefined behaviour!";
18+
return;
19+
}
20+
21+
qDebug() << "Loaded library Qt6WebEngineQuick";
22+
23+
auto initialize = reinterpret_cast<InitializeFunc>(lib.resolve("_ZN16QtWebEngineQuick10initializeEv"));
24+
if (!initialize) {
25+
qWarning() << "Failed to resolve symbol 'void QtWebEngineQuick::initialize()' in lib "
26+
"Qt6WebEngineQuick. This should not happen";
27+
qWarning() << "QtWebEngineQuick is not Loaded. Using the qml type WebEngineView from "
28+
"QtWebEngine might lead to undefined behaviour!";
29+
return;
30+
}
31+
32+
qDebug() << "Found symbol QtWebEngineQuick::initialize(). Initializing WebEngine...";
33+
34+
initialize();
35+
36+
qDebug() << "Successfully initialized QtWebEngineQuick";
37+
}
38+
39+
} // namespace qs::web_engine

0 commit comments

Comments
 (0)