diff --git a/CMakeLists.txt b/CMakeLists.txt
index dceb45a0..f7fd193c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,8 +115,7 @@ if(WITH_WEBENGINE)
WebEngineCore
WebEngineQuick
WebChannel
- WebEngineWidgets
- )
+ WebEngineWidgets)
endif()
set(CMAKE_CXX_FLAGS
@@ -159,14 +158,14 @@ set(PYTHON_EXEC ${Python3_EXECUTABLE})
# changes.
# Only include webengine resources if specified.
if(WITH_WEBENGINE)
- set(GEN_QML_QRC_ARGS "--with-webengine")
+ set(GEN_QRC_ARGS "--with-webengine")
endif()
file(GLOB_RECURSE
QML_FILES CONFIGURE_DEPENDS
${APP_SRC_DIR}/*)
execute_process(
COMMAND
- ${PYTHON_EXEC} ${SCRIPTS_DIR}/gen_qml_qrc.py ${GEN_QML_QRC_ARGS}
+ ${PYTHON_EXEC} ${SCRIPTS_DIR}/gen_qml_qrc.py ${GEN_QRC_ARGS}
WORKING_DIRECTORY ${APP_SRC_DIR})
set(QML_RESOURCES_QML ${APP_SRC_DIR}/qml.qrc)
# Image and misc. resources
@@ -176,7 +175,7 @@ file(GLOB_RECURSE
RES_FILES CONFIGURE_DEPENDS
${PROJECT_SOURCE_DIR}/resources/*)
execute_process(
- COMMAND ${PYTHON_EXEC} ${SCRIPTS_DIR}/gen_resources_qrc.py
+ COMMAND ${PYTHON_EXEC} ${SCRIPTS_DIR}/gen_resources_qrc.py ${GEN_QRC_ARGS}
WORKING_DIRECTORY ${APP_SRC_DIR})
set(QML_RESOURCES ${APP_SRC_DIR}/resources.qrc)
@@ -508,7 +507,6 @@ qt_add_executable(
${COMMON_SOURCES}
${QML_RESOURCES}
${QML_RESOURCES_QML}
- ${LIBCLIENT_SRC_DIR}/webresource.qrc
${SFPM_OBJECTS})
foreach(MODULE ${QT_MODULES})
diff --git a/extras/scripts/gen_resources_qrc.py b/extras/scripts/gen_resources_qrc.py
index e7147848..279040b7 100644
--- a/extras/scripts/gen_resources_qrc.py
+++ b/extras/scripts/gen_resources_qrc.py
@@ -49,21 +49,33 @@ def format_qml_prop(prop):
).lower()
-# Generate the the resources.qrc file and the JamiResources.qml file
-# that will be used to access the resources.
-with open(resfile, 'w', encoding='utf-8') as qrc, \
- open(qmlfile, 'w', encoding='utf-8') as qml:
- qrc.write('\n')
- qml.write('pragma Singleton\nimport QtQuick\nQtObject {\n')
- for root, _, files in os.walk(resdir):
- if len(files):
+def path_contains_dir(filepath, dir_str):
+ """ Return True if the given filepath contains the given directory. """
+ # Split the filepath into its components
+ path_components = os.path.normpath(filepath).split(os.sep)
+ # Return True if the given directory is in the path
+ return dir_str in path_components
+
+
+def gen_resources_qrc(with_webengine):
+ """ Generate the resources.qrc file. """
+ with open(resfile, 'w', encoding='utf-8') as qrc, \
+ open(qmlfile, 'w', encoding='utf-8') as qml:
+ qrc.write('\n')
+ qml.write('pragma Singleton\nimport QtQuick\nQtObject {\n')
+ for root, _, files in os.walk(resdir):
+ # Skip the webengine directory if we can't use webengine
+ if not with_webengine and path_contains_dir(root, 'webengine'):
+ continue
prefix = root.rsplit(os.sep, 1)[-1]
# add a prefix to the resource file
qrc.write(f'\t\n')
for filename in files:
# use posix separators in the resource path
- filepath = os.path.join(root, filename).replace(os.sep, '/')
- qrc.write(f'\t\t{filepath}\n')
+ filepath = os.path.join(
+ root, filename).replace(os.sep, '/')
+ qrc.write(
+ f'\t\t{filepath}\n')
# only record images/icons as properties
if re.match("icons|images", prefix):
resource = f'qrc:/{prefix}/{filename}'
@@ -73,5 +85,15 @@ with open(resfile, 'w', encoding='utf-8') as qrc, \
f' "{resource}"\n'
)
qrc.write('\t\n')
- qml.write('}')
- qrc.write('')
+ qml.write('}')
+ qrc.write('')
+
+
+if __name__ == '__main__':
+ # We can't use webengine if we're building for macOS app store
+ import argparse
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--with-webengine', action='store_true',
+ default=False, help='Include webengine resources')
+ args = parser.parse_args()
+ gen_resources_qrc(args.with_webengine)
diff --git a/src/libclient/web-chatview/linkify-string.js b/resources/webengine/linkify-string.js
similarity index 100%
rename from src/libclient/web-chatview/linkify-string.js
rename to resources/webengine/linkify-string.js
diff --git a/src/libclient/web-chatview/linkify.js b/resources/webengine/linkify.js
similarity index 100%
rename from src/libclient/web-chatview/linkify.js
rename to resources/webengine/linkify.js
diff --git a/src/libclient/web-chatview/previewInfo.js b/resources/webengine/previewInfo.js
similarity index 100%
rename from src/libclient/web-chatview/previewInfo.js
rename to resources/webengine/previewInfo.js
diff --git a/resources/misc/previewInterop.js b/resources/webengine/previewInterop.js
similarity index 100%
rename from resources/misc/previewInterop.js
rename to resources/webengine/previewInterop.js
diff --git a/src/libclient/web-chatview/qwebchannel.js b/resources/webengine/qwebchannel.js
similarity index 100%
rename from src/libclient/web-chatview/qwebchannel.js
rename to resources/webengine/qwebchannel.js
diff --git a/src/app/previewengine.cpp b/src/app/previewengine.cpp
index ab91116d..2b8609be 100644
--- a/src/app/previewengine.cpp
+++ b/src/app/previewengine.cpp
@@ -64,11 +64,15 @@ public:
channel_->registerObject(QStringLiteral("jsbridge"), &parent_);
setWebChannel(channel_);
- runJavaScript(Utils::QByteArrayFromFile(":/linkify.js"), QWebEngineScript::MainWorld);
- runJavaScript(Utils::QByteArrayFromFile(":/linkify-string.js"), QWebEngineScript::MainWorld);
- runJavaScript(Utils::QByteArrayFromFile(":/qwebchannel.js"), QWebEngineScript::MainWorld);
- runJavaScript(Utils::QByteArrayFromFile(":/previewInfo.js"), QWebEngineScript::MainWorld);
- runJavaScript(Utils::QByteArrayFromFile(":/misc/previewInterop.js"),
+ runJavaScript(Utils::QByteArrayFromFile(":webengine/linkify.js"),
+ QWebEngineScript::MainWorld);
+ runJavaScript(Utils::QByteArrayFromFile(":webengine/linkify-string.js"),
+ QWebEngineScript::MainWorld);
+ runJavaScript(Utils::QByteArrayFromFile(":webengine/qwebchannel.js"),
+ QWebEngineScript::MainWorld);
+ runJavaScript(Utils::QByteArrayFromFile(":webengine/previewInfo.js"),
+ QWebEngineScript::MainWorld);
+ runJavaScript(Utils::QByteArrayFromFile(":webengine/previewInterop.js"),
QWebEngineScript::MainWorld);
}
diff --git a/src/libclient/web-chatview/.eslintrc.json b/src/libclient/web-chatview/.eslintrc.json
deleted file mode 100644
index 746c54a4..00000000
--- a/src/libclient/web-chatview/.eslintrc.json
+++ /dev/null
@@ -1,31 +0,0 @@
-{
- "env": {
- "browser": true
- },
- "plugins": ["html"],
- "extends": "eslint:recommended",
- "parserOptions": {
- "ecmaVersion": 6
- },
- "rules": {
- "indent": [
- "error",
- 4
- ],
- "linebreak-style": [
- "error",
- "unix"
- ],
- "quotes": [
- "error",
- "double"
- ],
- "semi": [
- "error",
- "never"
- ],
- "no-inner-declarations": [
- 0
- ]
- }
-}
diff --git a/src/libclient/web-chatview/README b/src/libclient/web-chatview/README
deleted file mode 100644
index 75b6bf9f..00000000
--- a/src/libclient/web-chatview/README
+++ /dev/null
@@ -1,33 +0,0 @@
-# README - chatview
-
-The chatview runs under a WebKit GTK view. It is written using web technologies
-(HTML5/CSS3/JS) and is responsible for displaying everything that deals with the
-navbar, the messages, and the message bar.
-
-## Contributing - syntax
-
-We have a set of ESLint rules that define clear syntax rules (web/.eslintrc.json).
-
-You will need the following tools:
-
-- ESLint (The pluggable linting utility for JavaScript and JSX)
- https://eslint.org/
-- ESLint HTML plugin (eslint-plugin-html)
- https://www.npmjs.com/package/eslint-plugin-html
-
-Before pushing a patch, make sure that it passes ESLint:
-$ eslint chatview.html
-
-Most trivial issues can be fixed using
-$ eslint chatview.js --fix
-
-We will not accept patches introducing non-ESLint-compliant code.
-
-## WebKit GTK
-
-Everything runs under WebKit GTK, that is if you need to write browser specific
-code, you will only need to support WebKit (CSS -webkit- prefix).
-
-Do not use querySelector if getElementById or getElementByClassName can be used
-instead. querySelector doesn't always make the code easier and has very bad
-performances.
diff --git a/src/libclient/webresource.qrc b/src/libclient/webresource.qrc
deleted file mode 100644
index 33f1b7be..00000000
--- a/src/libclient/webresource.qrc
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- web-chatview/linkify.js
- web-chatview/linkify-string.js
- web-chatview/previewInfo.js
- web-chatview/qwebchannel.js
-
-