fix(StatusQ): StatusQ is QML module (#10207)

* StatusQ QML module
* qzxing is static lib again
* updated StatusQ resources
* fixed Emoji lookup
* added display to tests-imports ci
This commit is contained in:
Igor Sirotin 2023-04-14 11:18:56 +03:00 committed by GitHub
parent 0463031e31
commit aefa2b9f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 505 additions and 322 deletions

129
Makefile
View File

@ -183,36 +183,26 @@ ifneq ($(detected_OS),Windows)
endif
DOTHERSIDE := vendor/DOtherSide/build/lib/libDOtherSideStatic.a
DOTHERSIDE_CMAKE_PARAMS += -DENABLE_DYNAMIC_LIBS=OFF -DENABLE_STATIC_LIBS=ON
# We don't create qzxing target, it's build as DOtherSide cmake subdirectory
QZXING := vendor/DOtherSide/build/qzxing/libqzxing.$(LIBSTATUS_EXT)
# order matters here, due to "-Wl,-as-needed"
NIM_PARAMS += --passL:"$(DOTHERSIDE)" --passL:"$(shell PKG_CONFIG_PATH="$(QT5_PCFILEDIR)" pkg-config --libs Qt5Core Qt5Qml Qt5Gui Qt5Quick Qt5QuickControls2 Qt5Widgets Qt5Svg Qt5Multimedia)"
else
ifneq ($(QML_DEBUG), false)
DOTHERSIDE := vendor/DOtherSide/build/lib/Debug/DOtherSide.dll
QZXING := vendor/DOtherSide/build/qzxing/Debug/qzxing.dll
else
DOTHERSIDE := vendor/DOtherSide/build/lib/Release/DOtherSide.dll
QZXING := vendor/DOtherSide/build/qzxing/Release/qzxing.dll
endif
DOTHERSIDE_CMAKE_PARAMS += -T"v141" -A x64 -DENABLE_DYNAMIC_LIBS=ON -DENABLE_STATIC_LIBS=OFF \
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON # This is for qzxing, as it doesn't export any symbols
DOTHERSIDE_CMAKE_PARAMS += -T"v141" -A x64 -DENABLE_DYNAMIC_LIBS=ON -DENABLE_STATIC_LIBS=OFF
NIM_PARAMS += -L:$(DOTHERSIDE)
NIM_EXTRA_PARAMS := --passL:"-lsetupapi -lhid"
endif
QZXING_LIBDIR := $(shell pwd)/$(shell dirname "$(QZXING)")
export QZXING_LIBDIR
NIM_PARAMS += --passL:"-L$(QZXING_LIBDIR)" --passL:"-lqzxing"
ifeq ($(detected_OS),Darwin)
ifeq ("$(shell sysctl -nq hw.optional.arm64)","1")
ifneq ($(QT_ARCH),arm64)
STATUSGO_MAKE_PARAMS += GOBIN_SHARED_LIB_CFLAGS="CGO_ENABLED=1 GOOS=darwin GOARCH=amd64"
STATUSKEYCARDGO_MAKE_PARAMS += CGOFLAGS="CGO_ENABLED=1 GOOS=darwin GOARCH=amd64"
DOTHERSIDE_CMAKE_PARAMS += -DCMAKE_OSX_ARCHITECTURES=x86_64
STATUSQ_CMAKE_CONFIG_PARAMS += -DCMAKE_OSX_ARCHITECTURES=x86_64
QRCODEGEN_MAKE_PARAMS += CFLAGS="-target x86_64-apple-macos10.12"
NIM_PARAMS += --cpu:amd64 --os:MacOSX --passL:"-arch x86_64" --passC:"-arch x86_64"
endif
@ -249,6 +239,79 @@ ifeq ($(OUTPUT_CSV), true)
$(shell touch .update.timestamp)
endif
##
## StatusQ
##
ifneq ($(detected_OS),Windows)
STATUSQ := bin/StatusQ/libStatusQ.$(LIBSTATUS_EXT)
else
STATUSQ := bin/StatusQ/StatusQ.$(LIBSTATUS_EXT)
STATUSQ_CMAKE_CONFIG_PARAMS := -T"v141" -A x64
endif
STATUSQ_BUILD_PATH := ui/StatusQ/build
STATUSQ_INSTALL_PATH := $(shell pwd)/bin
STATUSQ_CMAKE_CACHE := $(STATUSQ_BUILD_PATH)/CMakeCache.txt
$(STATUSQ_CMAKE_CACHE): | deps
echo -e "\033[92mConfiguring:\033[39m StatusQ"
cmake -DCMAKE_INSTALL_PREFIX=$(STATUSQ_INSTALL_PATH) \
-DCMAKE_BUILD_TYPE=Release \
-DSTATUSQ_BUILD_SANDBOX=OFF \
-DSTATUSQ_BUILD_SANITY_CHECKER=OFF \
-DSTATUSQ_BUILD_TESTS=OFF \
$(STATUSQ_CMAKE_CONFIG_PARAMS) \
-B $(STATUSQ_BUILD_PATH) \
-S ui/StatusQ
$(HANDLE_OUTPUT)
statusq-configure: | $(STATUSQ_CMAKE_CACHE)
statusq-build: | statusq-configure
echo -e "\033[92mBuilding:\033[39m StatusQ"
cmake --build $(STATUSQ_BUILD_PATH) \
--target StatusQ \
--config Release
-DCMAKE_BUILD_TYPE=Release \
$(HANDLE_OUTPUT)
statusq-install: | statusq-build
echo -e "\033[92mInstalling:\033[39m StatusQ"
cmake --install $(STATUSQ_BUILD_PATH) \
$(HANDLE_OUTPUT)
statusq: | statusq-install
statusq-clean:
echo -e "\033[92mCleaning:\033[39m StatusQ"
rm -rf $(STATUSQ_BUILD_PATH)
rm -rf $(STATUSQ_INSTALL_PATH)/StatusQ
statusq-sanity-checker:
echo -e "\033[92mConfiguring:\033[39m StatusQ SanityChecker"
cmake \
-DSTATUSQ_BUILD_SANDBOX=OFF \
-DSTATUSQ_BUILD_SANITY_CHECKER=ON \
-DSTATUSQ_BUILD_TESTS=OFF \
-B$(STATUSQ_BUILD_PATH) \
-Sui/StatusQ \
$(HANDLE_OUTPUT)
echo -e "\033[92mBuilding:\033[39m StatusQ SanityChecker"
cmake \
--build $(STATUSQ_BUILD_PATH) \
--target SanityChecker \
$(HANDLE_OUTPUT)
run-statusq-sanity-checker: statusq-sanity-checker
echo -e "\033[92mRunning:\033[39m StatusQ SanityChecker"
$(STATUSQ_BUILD_PATH)/bin/SanityChecker
##
## DOtherSide
##
$(DOTHERSIDE): | deps
echo -e $(BUILD_MSG) "DOtherSide"
+ cd vendor/DOtherSide && \
@ -256,7 +319,8 @@ $(DOTHERSIDE): | deps
cd build && \
rm -f CMakeCache.txt && \
cmake $(DOTHERSIDE_CMAKE_PARAMS)\
-DENABLE_DOCS=OFF -DENABLE_TESTS=OFF -DQZXING_USE_QML=ON -DQZXING_MULTIMEDIA=ON -DQZXING_USE_DECODER_QR_CODE=ON \
-DENABLE_DOCS=OFF \
-DENABLE_TESTS=OFF \
.. $(HANDLE_OUTPUT) && \
$(DOTHERSIDE_BUILD_CMD)
@ -331,9 +395,12 @@ QM_BINARIES := $(shell find ui/i18n -iname "*.ts" | sed 's/\.ts/\.qm/' | sed 's/
$(QM_BINARIES): TS_FILE = $(shell echo $@ | sed 's/\.qm/\.ts/' | sed 's/bin/ui/')
$(QM_BINARIES): $(TS_SOURCES) | check-qt-dir
mkdir -p bin/i18n
lrelease -removeidentical $(TS_FILE) -qm $@
lrelease -removeidentical $(TS_FILE) -qm $@ $(HANDLE_OUTPUT)
compile-translations: $(QM_BINARIES)
log-compile-translations:
echo -e "\033[92mCompiling:\033[39m translations"
compile-translations: | log-compile-translations $(QM_BINARIES)
# default token is a free-tier token with limited capabilities and usage
# limits; our docs should include directions for community contributor to setup
@ -392,7 +459,7 @@ else
endif
$(NIM_STATUS_CLIENT): NIM_PARAMS += $(RESOURCES_LAYOUT)
$(NIM_STATUS_CLIENT): $(NIM_SOURCES) $(DOTHERSIDE) | check-qt-dir $(STATUSGO) $(STATUSKEYCARDGO) $(QRCODEGEN) $(FLEETS) rcc $(QM_BINARIES) deps
$(NIM_STATUS_CLIENT): $(NIM_SOURCES) statusq $(DOTHERSIDE) | check-qt-dir $(STATUSGO) $(STATUSKEYCARDGO) $(QRCODEGEN) $(FLEETS) rcc compile-translations deps
echo -e $(BUILD_MSG) "$@" && \
$(ENV_SCRIPT) nim c $(NIM_PARAMS) --passL:"-L$(STATUSGO_LIBDIR)" --passL:"-lstatus" --passL:"-L$(STATUSKEYCARDGO_LIBDIR)" --passL:"-lkeycard" $(NIM_EXTRA_PARAMS) --passL:"$(QRCODEGEN)" --passL:"-lm" src/nim_status_client.nim && \
[[ $$? = 0 ]] && \
@ -401,10 +468,6 @@ $(NIM_STATUS_CLIENT): $(NIM_SOURCES) $(DOTHERSIDE) | check-qt-dir $(STATUSGO) $(
libstatus.dylib \
@rpath/libstatus.dylib \
bin/nim_status_client && \
install_name_tool -change \
$(QZXING) \
@rpath/libqzxing.dylib \
bin/nim_status_client && \
install_name_tool -change \
libkeycard.dylib \
@rpath/libkeycard.dylib \
@ -470,6 +533,8 @@ $(STATUS_CLIENT_APPIMAGE): nim_status_client $(APPIMAGE_TOOL) nim-status.desktop
cp -R $(FLEETS) tmp/linux/dist/usr/.
mkdir -p tmp/linux/dist/usr/i18n
cp bin/i18n/* tmp/linux/dist/usr/i18n
mkdir -p tmp/linux/dist/usr/bin/StatusQ
cp bin/StatusQ/* tmp/linux/dist/usr/bin/StatusQ
# Libraries
cp -r /usr/lib/x86_64-linux-gnu/nss tmp/linux/dist/usr/lib/
@ -479,7 +544,6 @@ $(STATUS_CLIENT_APPIMAGE): nim_status_client $(APPIMAGE_TOOL) nim-status.desktop
cp vendor/status-go/build/bin/libstatus.so tmp/linux/dist/usr/lib/
cp vendor/status-go/build/bin/libstatus.so.0 tmp/linux/dist/usr/lib/
cp $(STATUSKEYCARDGO) tmp/linux/dist/usr/lib/
cp $(QZXING) tmp/linux/dist/usr/lib/
echo -e $(BUILD_MSG) "AppImage"
linuxdeployqt tmp/linux/dist/nim-status.desktop -no-copy-copyright-files -qmldir=ui -qmlimport=$(QT5_QMLDIR) -bundle-non-qt-libs
@ -530,6 +594,8 @@ $(STATUS_CLIENT_DMG): nim_status_client $(DMG_TOOL)
cp -R $(FLEETS) $(MACOS_OUTER_BUNDLE)/Contents/
mkdir -p $(MACOS_OUTER_BUNDLE)/Contents/i18n
cp bin/i18n/* $(MACOS_OUTER_BUNDLE)/Contents/i18n
mkdir -p $(MACOS_OUTER_BUNDLE)/Contents/MacOS/StatusQ
cp bin/StatusQ/* $(MACOS_OUTER_BUNDLE)/Contents/MacOS/StatusQ
echo -e $(BUILD_MSG) "app"
macdeployqt \
@ -593,21 +659,20 @@ $(STATUS_CLIENT_EXE): OUTPUT := tmp/windows/dist/Status
$(STATUS_CLIENT_EXE): INSTALLER_OUTPUT := pkg
$(STATUS_CLIENT_EXE): nim_status_client nim_windows_launcher $(NIM_WINDOWS_PREBUILT_DLLS)
rm -rf pkg/*.exe tmp/windows/dist
mkdir -p $(OUTPUT)/bin $(OUTPUT)/resources $(OUTPUT)/vendor $(OUTPUT)/resources/i18n
mkdir -p $(OUTPUT)/bin $(OUTPUT)/resources $(OUTPUT)/vendor $(OUTPUT)/resources/i18n $(OUTPUT)/bin/StatusQ
cat windows-install.txt | unix2dos > $(OUTPUT)/INSTALL.txt
cp status.ico status.svg resources.rcc $(FLEETS) $(OUTPUT)/resources/
cp bin/i18n/* $(OUTPUT)/resources/i18n
cp cacert.pem $(OUTPUT)/bin/cacert.pem
cp bin/StatusQ/* $(OUTPUT)/bin/StatusQ
cp bin/nim_status_client.exe $(OUTPUT)/bin/Status.exe
cp bin/nim_windows_launcher.exe $(OUTPUT)/Status.exe
rcedit $(OUTPUT)/bin/Status.exe --set-icon $(OUTPUT)/resources/status.ico
rcedit $(OUTPUT)/Status.exe --set-icon $(OUTPUT)/resources/status.ico
cp $(DOTHERSIDE) $(QZXING) $(STATUSGO) $(STATUSKEYCARDGO) tmp/windows/tools/*.dll $(OUTPUT)/bin/
cp $(DOTHERSIDE) $(STATUSGO) $(STATUSKEYCARDGO) tmp/windows/tools/*.dll $(OUTPUT)/bin/
cp "$(shell which libgcc_s_seh-1.dll)" $(OUTPUT)/bin/
cp "$(shell which libwinpthread-1.dll)" $(OUTPUT)/bin/
echo -e $(BUILD_MSG) "deployable folder"
windeployqt --compiler-runtime --qmldir ui --release \
tmp/windows/dist/Status/bin/qzxing.dll
windeployqt --compiler-runtime --qmldir ui --release \
tmp/windows/dist/Status/bin/DOtherSide.dll
mv tmp/windows/dist/Status/bin/vc_redist.x64.exe tmp/windows/dist/Status/vendor/
@ -648,7 +713,7 @@ pkg-windows: check-pkg-target-windows $(STATUS_CLIENT_EXE)
zip-windows: check-pkg-target-windows $(STATUS_CLIENT_7Z)
clean: | clean-common
clean: | clean-common statusq-clean
rm -rf bin/* node_modules bottles/* pkg/* tmp/* $(STATUSGO) $(STATUSKEYCARDGO)
+ $(MAKE) -C vendor/DOtherSide/build --no-print-directory clean
+ $(MAKE) -C vendor/QR-Code-generator/c/ --no-print-directory clean
@ -669,7 +734,7 @@ ICON_TOOL := node_modules/.bin/fileicon
run-linux: nim_status_client
echo -e "\033[92mRunning:\033[39m bin/nim_status_client"
LD_LIBRARY_PATH="$(QT5_LIBDIR)":"$(QZXING_LIBDIR)":"$(STATUSGO_LIBDIR)":"$(STATUSKEYCARDGO_LIBDIR)" \
LD_LIBRARY_PATH="$(QT5_LIBDIR)":"$(STATUSGO_LIBDIR)":"$(STATUSKEYCARDGO_LIBDIR)" \
./bin/nim_status_client
run-macos: nim_status_client
@ -684,17 +749,11 @@ run-macos: nim_status_client
run-windows: nim_status_client $(NIM_WINDOWS_PREBUILT_DLLS)
echo -e "\033[92mRunning:\033[39m bin/nim_status_client.exe"
PATH="$(shell pwd)"/"$(shell dirname "$(DOTHERSIDE)")":"$(QZXING_LIBDIR)":"$(STATUSGO_LIBDIR)":"$(STATUSKEYCARDGO_LIBDIR)":"$(shell pwd)"/"$(shell dirname "$(NIM_WINDOWS_PREBUILT_DLLS)")":"$(PATH)" \
PATH="$(shell pwd)"/"$(shell dirname "$(DOTHERSIDE)")":"$(STATUSGO_LIBDIR)":"$(STATUSKEYCARDGO_LIBDIR)":"$(shell pwd)"/"$(shell dirname "$(NIM_WINDOWS_PREBUILT_DLLS)")":"$(PATH)" \
./bin/nim_status_client.exe
tests-nim-linux: | $(DOTHERSIDE)
LD_LIBRARY_PATH="$(QT5_LIBDIR)":"$(QZXING_LIBDIR)" \
LD_LIBRARY_PATH="$(QT5_LIBDIR)" \
$(ENV_SCRIPT) nim c $(NIM_PARAMS) $(NIM_EXTRA_PARAMS) -r test/nim/message_model_test.nim
statusq-sanity-checker:
cmake -Bui/StatusQ/build -Sui/StatusQ && cmake --build ui/StatusQ/build --target SanityChecker
run-statusq-sanity-checker: statusq-sanity-checker
ui/StatusQ/build/sanity_checker/SanityChecker
endif # "variables.mk" was not included

View File

@ -54,7 +54,7 @@ pipeline {
QTDIR = '/opt/qt/5.15.2/gcc_64'
PATH = "${env.QTDIR}/bin:${env.PATH}"
/* Include library in order to compile the project */
LD_LIBRARY_PATH = "$QTDIR/lib:$WORKSPACE/vendor/DOtherSide/build/qzxing:$WORKSPACE/vendor/status-go/build/bin:$WORKSPACE/vendor/status-keycard-go/build/libkeycard/"
LD_LIBRARY_PATH = "$QTDIR/lib:$WORKSPACE/vendor/status-go/build/bin:$WORKSPACE/vendor/status-keycard-go/build/libkeycard/"
/* Container ports */
RPC_PORT = "${8545 + env.EXECUTOR_NUMBER.toInteger()}"
P2P_PORT = "${6010 + env.EXECUTOR_NUMBER.toInteger()}"

View File

@ -51,7 +51,17 @@ pipeline {
}
stage('Check') {
steps { sh 'make run-statusq-sanity-checker' }
steps { script {
/* Needed for QGuiApplication to import QtQuick.Dialogs */
wrap([
$class: 'Xvfb',
autoDisplayName: true,
parallelBuild: true,
screen: '2560x1440x24',
]) {
sh('make run-statusq-sanity-checker')
}
} }
}
stage('Upload') {

View File

@ -17,7 +17,6 @@ if defined(macosx):
switch("passL", "-rpath" & " " & getEnv("QT5_LIBDIR"))
switch("passL", "-rpath" & " " & getEnv("STATUSGO_LIBDIR"))
switch("passL", "-rpath" & " " & getEnv("STATUSKEYCARDGO_LIBDIR"))
switch("passL", "-rpath" & " " & getEnv("QZXING_LIBDIR"))
# statically link these libs
switch("passL", "bottles/openssl@1.1/lib/libcrypto.a")
switch("passL", "bottles/openssl@1.1/lib/libssl.a")

View File

@ -143,7 +143,7 @@ proc mainProc() =
prepareLogging()
singletonInstance.engine.addImportPath("qrc:/./StatusQ/src")
singletonInstance.engine.addImportPath("qrc:/")
singletonInstance.engine.addImportPath("qrc:/./imports")
singletonInstance.engine.addImportPath("qrc:/./app");
singletonInstance.engine.setNetworkAccessManagerFactory(networkAccessFactory)

View File

@ -10,23 +10,30 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if (APPLE)
set(MACOS_VERSION_MIN_FLAGS -mmacosx-version-min=10.14)
endif()
find_package(
Qt5
COMPONENTS Core Quick QuickControls2 Test QuickTest Qml
COMPONENTS Core Gui Quick QuickControls2 Test QuickTest Qml
REQUIRED)
include (../ui/StatusQ/StatusQSources.cmake)
set(STATUSQ_BUILD_SANDBOX OFF)
set(STATUSQ_BUILD_SANITY_CHECKER OFF)
set(STATUSQ_BUILD_TESTS OFF)
add_subdirectory(../ui/StatusQ StatusQ)
file(GLOB_RECURSE CORE_QML_FILES
"../ui/StatusQ/*.qml" "../ui/app/*.qml" "../ui/imports/*.qml"
"../ui/StatusQ/*/qmldir" "../ui/app/*/qmldir" "../ui/imports/*/qmldir"
"../ui/app/*.qml" "../ui/imports/*.qml"
"../ui/app/*/qmldir" "../ui/imports/*/qmldir"
)
file(GLOB_RECURSE CORE_JS_FILES "../ui/StatusQ/*.js" "../ui/app/*.js")
file(GLOB_RECURSE CORE_JS_FILES "../ui/app/*.js")
file(GLOB_RECURSE STORYBOOK_QML_FILES "stubs/*.qml" "mocks/*.qml" "pages/*.qml"
"src/*.qml" "src/qmldir")
@ -45,11 +52,8 @@ add_library(${PROJECT_LIB}
figmalinkssource.cpp figmalinkssource.h
modelutils.cpp modelutils.h
sectionsdecoratormodel.cpp sectionsdecoratormodel.h
${STATUSQ_HEADERS} ${STATUSQ_SOURCES}
)
target_include_directories(${PROJECT_LIB} PUBLIC ${STATUSQ_DIR}/include)
add_executable(
${PROJECT_NAME}
main.cpp
@ -61,13 +65,17 @@ add_executable(
README.md
)
target_compile_definitions(${PROJECT_NAME}
PRIVATE QML_IMPORT_ROOT="${CMAKE_CURRENT_LIST_DIR}")
target_compile_definitions(${PROJECT_NAME} PRIVATE
QML_IMPORT_ROOT="${CMAKE_CURRENT_LIST_DIR}"
STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}")
target_link_libraries(
${PROJECT_LIB} PUBLIC Qt5::Core Qt5::Quick Qt5::QuickControls2)
${PROJECT_LIB} PUBLIC Qt5::Core Qt5::Gui Qt5::Quick Qt5::QuickControls2)
target_link_libraries(
${PROJECT_NAME} PRIVATE ${PROJECT_LIB} SortFilterProxyModel)
${PROJECT_NAME} PRIVATE ${PROJECT_LIB})
add_dependencies(${PROJECT_NAME} StatusQ)
enable_testing()
@ -83,13 +91,13 @@ add_executable(QmlTests
qmlTests/main.cpp
qmlTests/src/TextUtils.cpp qmlTests/src/TextUtils.h
${TEST_QML_FILES})
target_compile_definitions(QmlTests
PRIVATE QML_IMPORT_ROOT="${CMAKE_CURRENT_LIST_DIR}"
PRIVATE -DQUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/qmlTests")
target_compile_definitions(QmlTests PRIVATE
QML_IMPORT_ROOT="${CMAKE_CURRENT_LIST_DIR}"
STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}"
QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/qmlTests")
target_link_libraries(QmlTests PRIVATE Qt5::QuickTest Qt5::Qml ${PROJECT_LIB})
add_test(NAME QmlTests COMMAND QmlTests)
list(APPEND QML_DIRS "${CMAKE_SOURCE_DIR}/../ui/StatusQ/src")
list(APPEND QML_DIRS "${CMAKE_SOURCE_DIR}/../ui/app")
list(APPEND QML_DIRS "${CMAKE_SOURCE_DIR}/../ui/imports")
list(APPEND QML_DIRS "${CMAKE_SOURCE_DIR}/src")
@ -101,8 +109,5 @@ set(QML_IMPORT_PATH "${QML_DIRS}" CACHE STRING "Qt Creator extra QML import path
if (APPLE)
find_library(AppKit AppKit)
find_library(Foundation Foundation)
target_link_libraries(${PROJECT_LIB} PRIVATE ${AppKit} ${Foundation})
endif()
add_subdirectory(../vendor/SortFilterProxyModel ./SortFilterProxyModel)

View File

@ -8,8 +8,6 @@
#include "figmalinkssource.h"
#include "sectionsdecoratormodel.h"
#include "StatusQ/typesregistration.h"
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
@ -27,7 +25,7 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
const QStringList additionalImportPaths {
QML_IMPORT_ROOT + QStringLiteral("/../ui/StatusQ/src"),
STATUSQ_MODULE_IMPORT_PATH,
QML_IMPORT_ROOT + QStringLiteral("/../ui/app"),
QML_IMPORT_ROOT + QStringLiteral("/../ui/imports"),
QML_IMPORT_ROOT + QStringLiteral("/src"),
@ -44,8 +42,6 @@ int main(int argc, char *argv[])
qmlRegisterType<FigmaLinksSource>("Storybook", 1, 0, "FigmaLinksSource");
qmlRegisterUncreatableType<FigmaLinks>("Storybook", 1, 0, "FigmaLinks", {});
registerStatusQTypes();
auto watcherFactory = [additionalImportPaths](QQmlEngine*, QJSEngine*) {
auto watcher = new DirectoriesWatcher();
watcher->addPaths(additionalImportPaths);

View File

@ -4,6 +4,8 @@ import QtQuick.Layouts 1.14
import Qt.labs.settings 1.0
import StatusQ 0.1 // https://github.com/status-im/status-desktop/issues/10218
import StatusQ.Core.Theme 0.1
import Storybook 1.0

View File

@ -3,6 +3,8 @@ import QtQuick.Controls 2.14
import QtQml 2.14
import QtTest 1.0
import StatusQ 0.1 // https://github.com/status-im/status-desktop/issues/10218
import AppLayouts.Wallet.addaccount.panels 1.0
import AppLayouts.Wallet.addaccount.panels.DerivationPathInput 1.0

View File

@ -3,6 +3,8 @@ import QtQuick.Controls 2.14
import QtQml 2.14
import QtTest 1.0
import StatusQ 0.1 // https://github.com/status-im/status-desktop/issues/10218
import utils 1.0
import shared.status 1.0
import shared.stores 1.0

View File

@ -2,8 +2,6 @@
#include <QQmlEngine>
#include "src/TextUtils.h"
#include "StatusQ/typesregistration.h"
class Setup : public QObject
{
Q_OBJECT
@ -12,7 +10,7 @@ public slots:
void qmlEngineAvailable(QQmlEngine *engine) {
// custom code that needs QQmlEngine, register QML types, add import paths,...
const QStringList additionalImportPaths {
QML_IMPORT_ROOT + QStringLiteral("/../ui/StatusQ/src"),
STATUSQ_MODULE_IMPORT_PATH,
QML_IMPORT_ROOT + QStringLiteral("/../ui/app"),
QML_IMPORT_ROOT + QStringLiteral("/../ui/imports"),
QML_IMPORT_ROOT + QStringLiteral("/stubs"),
@ -23,8 +21,6 @@ public slots:
engine->addImportPath(path);
qmlRegisterSingletonType<TextUtils>("TextUtils", 1, 0, "TextUtils", &TextUtils::qmlInstance);
registerStatusQTypes();
}
};

View File

@ -1,3 +0,0 @@
[submodule "vendor/SortFilterProxyModel"]
path = vendor/SortFilterProxyModel
url = https://github.com/status-im/SortFilterProxyModel.git

View File

@ -2,10 +2,9 @@ cmake_minimum_required(VERSION 3.19)
project(StatusQ)
if (APPLE)
set(MACOS_VERSION_MIN_FLAGS -mmacosx-version-min=10.14)
set(CMAKE_OSX_ARCHITECTURES "x86_64")
endif()
option(STATUSQ_BUILD_SANDBOX "Enable to build StatusQ Sandbox application" ON)
option(STATUSQ_BUILD_SANITY_CHECKER "Enable to build StatusQ Sanity Checker application" ON)
option(STATUSQ_BUILD_TESTS "Enable to build StatusQ UI auto tests" ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
@ -13,18 +12,158 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Although SHARED libraries set this to ON by default,
# all static libraries, that are built into this SHARED,
# (which is qzxing in our case) should also be build with -fPIC.
# This fixes it.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(QZXING_USE_QML ON)
set(QZXING_MULTIMEDIA ON)
set(QZXING_USE_DECODER_QR_CODE ON)
# https://doc.qt.io/qtcreator/creator-qml-modules-with-plugins.html#importing-qml-modules
set(QML_IMPORT_PATH
${CMAKE_SOURCE_DIR}/src;${QML_IMPORT_PATH}
CACHE STRING "")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
find_package(Qt5 COMPONENTS
Core Qml Gui Quick QuickControls2 REQUIRED)
add_subdirectory(../../vendor/SortFilterProxyModel SortFilterProxyModel)
add_subdirectory(../../vendor/qzxing/src qzxing)
add_subdirectory(sandbox)
add_subdirectory(sanity_checker)
add_subdirectory(tests)
### StatusQ library
### TODO: Move to a subdirectory for readability and better structure
if (NOT DEFINED STATUSQ_SHADOW_BUILD)
# About the STATUSQ_SHADOW_BUILD option.
#
# This is an option that defaults to OFF in Debug mode and ON otherwise.
# When ON:
# - resources are compiled into plugin
# - plugin is compiled in the ${CMAKE_BINARY_DIR}/StatusQ
# When OFF:
# - no resources are compiled, it's expected to use QML/JS sources
# - the plugin is compiled in src directory
#
# STATUSQ_SHADOW_BUILD mode is created for sandbox/storybook hot reloading
# without copying all qml files to build directory.
#
# It's expected for the app to add ${STATUSQ_MODULE_IMPORT_PATH} to
# QQmlApplicationEngine::addImportPath.
#
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(STATUSQ_SHADOW_BUILD OFF)
else()
set(STATUSQ_SHADOW_BUILD ON)
endif()
endif()
set(STATUSQ_SOURCE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/StatusQ")
if (${STATUSQ_SHADOW_BUILD})
set(STATUSQ_MODULE_PATH "${CMAKE_BINARY_DIR}/bin/StatusQ")
set(STATUSQ_MODULE_IMPORT_PATH ":/")
else()
set(STATUSQ_MODULE_PATH "${STATUSQ_SOURCE_PATH}")
set(STATUSQ_MODULE_IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src")
endif()
if (NOT PROJECT_IS_TOP_LEVEL)
set(STATUSQ_MODULE_PATH "${STATUSQ_MODULE_PATH}" PARENT_SCOPE)
set(STATUSQ_MODULE_IMPORT_PATH "${STATUSQ_MODULE_IMPORT_PATH}" PARENT_SCOPE)
set(STATUSQ_SHADOW_BUILD "${STATUSQ_SHADOW_BUILD}" PARENT_SCOPE)
endif ()
if (${STATUSQ_SHADOW_BUILD})
qt5_add_big_resources(STATUSQ_QRC_COMPILED
src/statusq.qrc
src/assets.qrc)
endif()
add_library(StatusQ SHARED
${STATUSQ_QRC_COMPILED}
src/plugin.cpp
include/StatusQ/QClipboardProxy.h
include/StatusQ/modelutilsinternal.h
include/StatusQ/rxvalidator.h
include/StatusQ/statussyntaxhighlighter.h
include/StatusQ/statuswindow.h
src/QClipboardProxy.cpp
src/modelutilsinternal.cpp
src/rxvalidator.cpp
src/statussyntaxhighlighter.cpp
src/statuswindow.cpp
)
set_target_properties(StatusQ PROPERTIES
ADDITIONAL_CLEAN_FILES bin/StatusQ/qmldir
DEBUG_POSTFIX "d"
RUNTIME_OUTPUT_DIRECTORY ${STATUSQ_MODULE_PATH}
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${STATUSQ_MODULE_PATH}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${STATUSQ_MODULE_PATH}
LIBRARY_OUTPUT_DIRECTORY ${STATUSQ_MODULE_PATH}
)
if (APPLE)
find_library(AppKit AppKit)
find_library(Foundation Foundation)
target_link_libraries(${PROJECT_NAME} PRIVATE ${AppKit} ${Foundation})
target_sources(StatusQ PRIVATE src/statuswindow_osx.mm)
else ()
target_sources(StatusQ PRIVATE src/statuswindow_other.cpp)
endif ()
if (${STATUSQ_SHADOW_BUILD})
set(COPY_QMLDIR_COMMAND
${CMAKE_COMMAND} -E copy
${STATUSQ_SOURCE_PATH}/qmldir
${STATUSQ_MODULE_PATH}/qmldir)
add_custom_command(
TARGET StatusQ
POST_BUILD
COMMAND ${COPY_QMLDIR_COMMAND}
COMMENT "Copying qmldir to binary directory")
endif ()
target_link_libraries(StatusQ PRIVATE
Qt5::Core
Qt5::Qml
Qt5::Gui
Qt5::Quick
Qt5::QuickControls2
SortFilterProxyModel
qzxing
)
target_include_directories(StatusQ PRIVATE include)
install(TARGETS StatusQ
RUNTIME DESTINATION StatusQ
LIBRARY DESTINATION StatusQ
)
install(FILES src/StatusQ/qmldir
DESTINATION StatusQ
)
# https://doc.qt.io/qtcreator/creator-qml-modules-with-plugins.html#importing-qml-modules
set(QML_IMPORT_PATH
${CMAKE_SOURCE_DIR}/src;${QML_IMPORT_PATH}
CACHE STRING "")
### Add other subdirectories
if (${STATUSQ_BUILD_SANDBOX})
add_subdirectory(sandbox)
endif ()
if (${STATUSQ_BUILD_SANITY_CHECKER})
add_subdirectory(sanity_checker)
endif ()
if (${STATUSQ_BUILD_TESTS})
add_subdirectory(tests)
endif ()

View File

@ -1,29 +0,0 @@
set(STATUSQ_DIR ${CMAKE_CURRENT_LIST_DIR})
set(STATUSQ_HEADERS
${STATUSQ_DIR}/include/StatusQ/QClipboardProxy.h
${STATUSQ_DIR}/include/StatusQ/modelutilsinternal.h
${STATUSQ_DIR}/include/StatusQ/rxvalidator.h
${STATUSQ_DIR}/include/StatusQ/statussyntaxhighlighter.h
${STATUSQ_DIR}/include/StatusQ/statuswindow.h
${STATUSQ_DIR}/include/StatusQ/typesregistration.h
)
set(STATUSQ_SOURCES
${STATUSQ_DIR}/src/QClipboardProxy.cpp
${STATUSQ_DIR}/src/modelutilsinternal.cpp
${STATUSQ_DIR}/src/rxvalidator.cpp
${STATUSQ_DIR}/src/statussyntaxhighlighter.cpp
${STATUSQ_DIR}/src/statuswindow.cpp
${STATUSQ_DIR}/src/typesregistration.cpp
)
if(APPLE)
list(APPEND STATUSQ_SOURCES
${STATUSQ_DIR}/src/statuswindow_osx.mm
)
else()
list(APPEND STATUSQ_SOURCES
${STATUSQ_DIR}/src/statuswindow_other.cpp
)
endif()

View File

@ -1,3 +0,0 @@
#pragma once
void registerStatusQTypes();

View File

@ -1,43 +1,31 @@
project(Sandbox)
find_package(
Qt5
COMPONENTS Core Quick QuickControls2
REQUIRED)
include (../StatusQSources.cmake)
Qt5
COMPONENTS Core Quick QuickControls2
REQUIRED)
file(GLOB_RECURSE QML_FILES "../*.qml" "../qmldir")
file(GLOB_RECURSE JS_FILES "../*.js")
set(HEADERS sandboxapp.h)
set(SOURCES main.cpp sandboxapp.cpp)
qt5_add_big_resources(STATUSQ_SANDBOX_QRC qml.qrc)
set(QRC_FILES qml.qrc ../src/statusq.qrc ../src/assets.qrc)
qt5_add_big_resources(QRC_COMPILED ${QRC_FILES})
add_executable(${PROJECT_NAME}
sandboxapp.h
main.cpp
sandboxapp.cpp
${STATUSQ_SANDBOX_QRC}
${QML_FILES}
${JS_FILES}
)
add_executable(
${PROJECT_NAME}
${HEADERS}
${SOURCES}
${STATUSQ_HEADERS}
${STATUSQ_SOURCES}
${QRC_FILES}
${QRC_COMPILED}
${QML_FILES}
${JS_FILES})
target_compile_definitions(${PROJECT_NAME} PRIVATE
SANDBOX_SRC_DIR="${CMAKE_CURRENT_LIST_DIR}"
STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}"
)
target_include_directories(${PROJECT_NAME} PUBLIC ${STATUSQ_DIR}/include)
target_compile_definitions(${PROJECT_NAME}
PRIVATE SRC_DIR="${CMAKE_CURRENT_LIST_DIR}")
target_link_libraries(
${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick Qt5::QuickControls2
SortFilterProxyModel
qzxing)
if (APPLE)
find_library(AppKit AppKit)
find_library(Foundation Foundation)
target_link_libraries(${PROJECT_NAME} PRIVATE ${AppKit} ${Foundation})
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt5::Core
Qt5::Quick
Qt5::QuickControls2
)

View File

@ -4,8 +4,6 @@
#include "sandboxapp.h"
#include <qqmlsortfilterproxymodeltypes.h>
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
@ -14,8 +12,6 @@ int main(int argc, char *argv[])
SandboxApp app(argc, argv);
qqsfpm::registerTypes();
qputenv("QT_QUICK_CONTROLS_HOVER_ENABLED", QByteArrayLiteral("1"));
app.setOrganizationName("Status");

View File

@ -7,7 +7,7 @@ import Qt.labs.settings 1.0
import QtQml.Models 2.14
import QtMultimedia 5.14
import StatusQ 0.1
import StatusQ 0.1 // https://github.com/status-im/status-desktop/issues/10218
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1

View File

@ -5,14 +5,9 @@
#include <QDebug>
#include <QDirIterator>
#include "StatusQ/typesregistration.h"
#include <QZXing.h>
SandboxApp::SandboxApp(int &argc, char **argv)
: QGuiApplication(argc, argv)
{
QZXing::registerQMLTypes();
#ifdef QT_DEBUG
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, [this](const QString&) {
restartEngine();
@ -22,10 +17,7 @@ SandboxApp::SandboxApp(int &argc, char **argv)
void SandboxApp::startEngine()
{
registerStatusQTypes();
#ifdef QT_DEBUG
const QUrl url = QUrl::fromLocalFile(SRC_DIR + QStringLiteral("/main.qml"));
m_watcher.addPath(applicationDirPath() + "/../");
QDirIterator it(applicationDirPath() + "/../", QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
while (it.hasNext()) {
@ -34,32 +26,26 @@ void SandboxApp::startEngine()
}
it.next();
}
#else
const QUrl url(QStringLiteral("qrc:/main.qml"));
#endif
#ifdef QT_DEBUG
m_engine.addImportPath(SRC_DIR + QStringLiteral("/../src"));
#else
m_engine.addImportPath(QStringLiteral(":/"));
#endif
m_engine.addImportPath(STATUSQ_MODULE_IMPORT_PATH);
qDebug() << m_engine.importPathList();
QObject::connect(&m_engine, &QQmlApplicationEngine::objectCreated,
this, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
this, [this](QObject *obj, const QUrl &objUrl) {
if (!obj && m_url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
m_engine.load(url);
m_engine.load(m_url);
}
void SandboxApp::restartEngine()
{
const QUrl url = QUrl::fromLocalFile(SRC_DIR + QStringLiteral("/main.qml"));
QWindow *rootWindow = qobject_cast<QWindow*>(m_engine.rootObjects().at(0));
if (rootWindow) {
rootWindow->close();
rootWindow->deleteLater();
}
m_engine.clearComponentCache();
m_engine.load(url);
m_engine.load(m_url);
}

View File

@ -24,6 +24,14 @@ private:
#ifdef QT_DEBUG
QFileSystemWatcher m_watcher;
#endif
const QUrl m_url {
#ifdef QT_DEBUG
QUrl::fromLocalFile(SANDBOX_SRC_DIR + QStringLiteral("/main.qml"))
#else
QStringLiteral("qrc:/main.qml")
#endif
};
};
#endif // SANDBOXAPP_H

View File

@ -1,34 +1,27 @@
project(SanityChecker)
find_package(
Qt5
COMPONENTS Core Quick QuickControls2
REQUIRED)
find_package(Qt5
COMPONENTS Core Quick
REQUIRED)
include (../StatusQSources.cmake)
add_executable(${PROJECT_NAME}
main.cpp
)
set(QRC_FILES ../src/statusq.qrc ../src/assets.qrc)
qt5_add_resources(QRC_COMPILED ${QRC_FILES})
add_dependencies(${PROJECT_NAME}
StatusQ)
add_executable(
${PROJECT_NAME}
main.cpp
${QRC_FILES}
${QRC_COMPILED}
${STATUSQ_HEADERS}
${STATUSQ_SOURCES}
)
target_link_libraries(${PROJECT_NAME} PRIVATE
Qt5::Core
Qt5::Quick)
target_include_directories(${PROJECT_NAME} PUBLIC ${STATUSQ_DIR}/include)
target_compile_definitions(${PROJECT_NAME} PRIVATE
STATUSQ_MODULE_PATH="${STATUSQ_MODULE_PATH}"
STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}"
)
target_link_libraries(
${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick Qt5::QuickControls2
SortFilterProxyModel
qzxing)
if (APPLE)
find_library(AppKit AppKit)
find_library(Foundation Foundation)
target_link_libraries(${PROJECT_NAME} PRIVATE ${AppKit} ${Foundation})
endif()
if (STATUSQ_SHADOW_BUILD)
target_compile_definitions(${PROJECT_NAME} PRIVATE
STATUSQ_SHADOW_BUILD
)
endif ()

View File

@ -1,51 +1,63 @@
#include <QCoreApplication>
#include <QGuiApplication>
#include <QDebug>
#include <QDirIterator>
#include <QQmlComponent>
#include <QQmlEngine>
#include "StatusQ/typesregistration.h"
#include <QZXing>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
registerStatusQTypes();
int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv);
QQmlEngine engine;
engine.addImportPath(QStringLiteral(":/"));
#ifdef STATUSQ_SHADOW_BUILD
const QString componentBaseUrlPrefix{"qrc"};
#else
const QString componentBaseUrlPrefix{"file://"};
#endif
QZXing::registerQMLTypes();
const QString iterationPath{QStringLiteral(STATUSQ_MODULE_IMPORT_PATH)};
engine.addImportPath(iterationPath);
// Create a dummy component with StatusQ import.
// NOTE: https://github.com/status-im/status-desktop/issues/10218
QQmlComponent mainComponent(&engine);
mainComponent.setData("import QtQuick 2.15\nimport StatusQ 0.1\nItem { }", {});
if (mainComponent.isError()) {
qWarning() << "Failed to import StatusQ 0.1:" << mainComponent.errors();
return EXIT_FAILURE;
}
// Start iterating over directory
QDirIterator it(":", QDirIterator::Subdirectories);
bool errorsFound = false;
while (it.hasNext()) {
QFileInfo info = it.fileInfo();
for (QDirIterator it(iterationPath, QDirIterator::Subdirectories); it.hasNext(); it.next()) {
if (info.suffix() == QStringLiteral("qml")) {
QFile file(it.filePath());
file.open(QIODevice::ReadOnly);
const QFileInfo info = it.fileInfo();
QTextStream in(&file);
QString line = in.readLine();
if (info.suffix() != QStringLiteral("qml"))
continue;
if (line != QStringLiteral("pragma Singleton")) {
engine.setBaseUrl(QStringLiteral("qrc") + info.dir().path()
+ QDir::separator());
QFile file(it.filePath());
file.open(QIODevice::ReadOnly);
QQmlComponent component(&engine, it.fileName());
QTextStream in(&file);
QString line = in.readLine();
if (component.isError()) {
qWarning() << component.errors();
errorsFound = true;
}
}
if (line == QStringLiteral("pragma Singleton"))
continue;
QUrl baseFileUrl(componentBaseUrlPrefix + info.dir().path() + QDir::separator());
engine.setBaseUrl(baseFileUrl);
QQmlComponent component(&engine, it.fileName());
if (component.isError()) {
qWarning() << component.errors();
errorsFound = true;
}
it.next();
}
if (errorsFound)

View File

@ -2,7 +2,6 @@ pragma Singleton
import QtQuick 2.13
//import shared.status 1.0
import "../../../assets/twemoji/twemoji.js" as Twemoji
import "./emojiList.js" as EmojiJSON
@ -18,8 +17,9 @@ QtObject {
"png": "png",
"svg": "svg"
}
property string base: Qt.resolvedUrl("../../../assets/twemoji/")
readonly property string base: Qt.resolvedUrl("../../../assets/twemoji/")
property var emojiJSON: EmojiJSON
function parse(text, renderSize = size.small, renderFormat = format.svg) {
const renderSizes = renderSize.split("x");
if (!renderSize.includes("x") || renderSizes.length !== 2) {
@ -63,23 +63,25 @@ QtObject {
function fromCodePoint(value) {
return Twemoji.twemoji.convert.fromCodePoint(value)
}
// This regular expression looks for html tag `img` with following attributes in any order:
// - `src` containig with "/assets/twemoji/" substring
// - `alt` (this one is captured)
readonly property var emojiRegexp: /<img(?=[^>]*\balt="([^"]*)")(?=[^>]*\bsrc="[^>]*\/assets\/twemoji\/[^>]*")[^>]*>/g
function deparse(value) {
// /StatusQ/src/assets/twemoji/
return value.replace(/<img src=\".+?\/StatusQ\/src\/assets\/twemoji\/.+?" alt=\"(.+?)\" width=\"[0-9]*\" height=\"[0-9]*\" style=\"(.+?)\" ?\/>/g, "$1");
}
function deparseFromParse(value) {
return value.replace(/<img class=\"emoji\" draggable=\"false\" alt=\"(.+?)\" src=\".+?\/StatusQ\/src\/assets\/twemoji\/.+?" width=\"[0-9]*\" height=\"[0-9]*\" style=\"(.+?)\" ?\/>/g, "$1");
return value.replace(emojiRegexp, "$1");
}
function hasEmoji(value) {
let match = value.match(/<img src=\".+?\/StatusQ\/src\/assets\/twemoji\/.+?" alt=\"(.+?)\" width=\"[0-9]*\" height=\"[0-9]*\" style=\"(.+?)\" ?\/>/g)
let match = value.match(emojiRegexp)
return match && match.length > 0
}
function nbEmojis(value) {
let match = value.match(/<img src=\".+?\/StatusQ\/src\/assets\/twemoji\/.+?" alt=\"(.+?)\" width=\"[0-9]*\" height=\"[0-9]*\" style=\"(.+?)\" ?\/>/g)
let match = value.match(emojiRegexp)
return match ? match.length : 0
}
function getEmojis(value) {
return value.match(/<img class=\"emoji\" draggable=\"false\" alt=\"(.+?)\" src=\".+?\/StatusQ\/src\/assets\/twemoji\/.+?" width=\"[0-9]*\" height=\"[0-9]*\" style=\"(.+?)\" ?\/>/g, "$1");
return value.match(emojiRegexp, "$1");
}
function getEmojiUnicode(shortname) {

View File

@ -1,2 +1,3 @@
module StatusQ
plugin StatusQ
classname StatusQPlugin

View File

@ -51,9 +51,6 @@
<file>assets/fonts/RobotoMono/RobotoMono-SemiBoldItalic.ttf</file>
<file>assets/fonts/RobotoMono/RobotoMono-Thin.ttf</file>
<file>assets/fonts/RobotoMono/RobotoMono-ThinItalic.ttf</file>
<file>assets/img/icons/statuses/automatic.svg</file>
<file>assets/img/icons/statuses/inactive.svg</file>
<file>assets/img/icons/statuses/online.svg</file>
<file>assets/img/icons/bigger/browser.svg</file>
<file>assets/img/icons/bigger/network.svg</file>
<file>assets/img/icons/bigger/pause.svg</file>
@ -62,12 +59,16 @@
<file>assets/img/icons/bigger/send.svg</file>
<file>assets/img/icons/bigger/settings.svg</file>
<file>assets/img/icons/bigger/status-update.svg</file>
<file>assets/img/icons/statuses/automatic.svg</file>
<file>assets/img/icons/statuses/inactive.svg</file>
<file>assets/img/icons/statuses/online.svg</file>
<file>assets/img/icons/tiny/message/delivered.svg</file>
<file>assets/img/icons/tiny/message/pending.svg</file>
<file>assets/img/icons/tiny/message/sent.svg</file>
<file>assets/img/icons/tiny/message/warning.svg</file>
<file>assets/img/icons/tiny/add.svg</file>
<file>assets/img/icons/tiny/arrow-down.svg</file>
<file>assets/img/icons/tiny/bridge.svg</file>
<file>assets/img/icons/tiny/channel-white.svg</file>
<file>assets/img/icons/tiny/channel.svg</file>
<file>assets/img/icons/tiny/chat.svg</file>
@ -83,8 +84,10 @@
<file>assets/img/icons/tiny/contact.svg</file>
<file>assets/img/icons/tiny/double-checkmark.svg</file>
<file>assets/img/icons/tiny/edit.svg</file>
<file>assets/img/icons/tiny/exclamation.svg</file>
<file>assets/img/icons/tiny/external.svg</file>
<file>assets/img/icons/tiny/flash.svg</file>
<file>assets/img/icons/tiny/gas.svg</file>
<file>assets/img/icons/tiny/group-white.svg</file>
<file>assets/img/icons/tiny/group.svg</file>
<file>assets/img/icons/tiny/members.svg</file>
@ -103,6 +106,7 @@
<file>assets/img/icons/tiny/time.svg</file>
<file>assets/img/icons/tiny/tiny-checkmark.svg</file>
<file>assets/img/icons/tiny/tiny-contact.svg</file>
<file>assets/img/icons/tiny/tiny-exclamation.svg</file>
<file>assets/img/icons/tiny/tribute-to-talk.svg</file>
<file>assets/img/icons/tiny/unlocked.svg</file>
<file>assets/img/icons/tiny/warning.svg</file>
@ -135,6 +139,7 @@
<file>assets/img/icons/audio.svg</file>
<file>assets/img/icons/backspace.svg</file>
<file>assets/img/icons/bold.svg</file>
<file>assets/img/icons/bridge.svg</file>
<file>assets/img/icons/browser.svg</file>
<file>assets/img/icons/camera.svg</file>
<file>assets/img/icons/cancel.svg</file>
@ -155,12 +160,14 @@
<file>assets/img/icons/code.svg</file>
<file>assets/img/icons/communities.svg</file>
<file>assets/img/icons/condition-or.svg</file>
<file>assets/img/icons/contact-book.svg</file>
<file>assets/img/icons/contact.svg</file>
<file>assets/img/icons/copy.svg</file>
<file>assets/img/icons/crown.svg</file>
<file>assets/img/icons/dapp.svg</file>
<file>assets/img/icons/delete.svg</file>
<file>assets/img/icons/desktop.svg</file>
<file>assets/img/icons/discord.svg</file>
<file>assets/img/icons/double-checkmark.svg</file>
<file>assets/img/icons/download.svg</file>
<file>assets/img/icons/edit.svg</file>
@ -182,16 +189,21 @@
<file>assets/img/icons/food-and-drinks.svg</file>
<file>assets/img/icons/gallery.svg</file>
<file>assets/img/icons/gif.svg</file>
<file>assets/img/icons/github.svg</file>
<file>assets/img/icons/group-chat.svg</file>
<file>assets/img/icons/group.svg</file>
<file>assets/img/icons/help.svg</file>
<file>assets/img/icons/hide.svg</file>
<file>assets/img/icons/history.svg</file>
<file>assets/img/icons/image.svg</file>
<file>assets/img/icons/images_icon.svg</file>
<file>assets/img/icons/in-contacts.svg</file>
<file>assets/img/icons/info.svg</file>
<file>assets/img/icons/invite-users.svg</file>
<file>assets/img/icons/italic.svg</file>
<file>assets/img/icons/justify.svg</file>
<file>assets/img/icons/key_pair_private_key.svg</file>
<file>assets/img/icons/key_pair_seed_phrase.svg</file>
<file>assets/img/icons/keyboard.svg</file>
<file>assets/img/icons/keycard-logo.svg</file>
<file>assets/img/icons/keycard.svg</file>
@ -211,6 +223,7 @@
<file>assets/img/icons/muted.svg</file>
<file>assets/img/icons/network.svg</file>
<file>assets/img/icons/next.svg</file>
<file>assets/img/icons/nft-profile.svg</file>
<file>assets/img/icons/node-offline.svg</file>
<file>assets/img/icons/node.svg</file>
<file>assets/img/icons/notification-muted.svg</file>
@ -222,6 +235,7 @@
<file>assets/img/icons/paste.svg</file>
<file>assets/img/icons/pause-filled.svg</file>
<file>assets/img/icons/pause.svg</file>
<file>assets/img/icons/pencil-outline.svg</file>
<file>assets/img/icons/pencil.svg</file>
<file>assets/img/icons/pin.svg</file>
<file>assets/img/icons/play-filled.svg</file>
@ -230,8 +244,9 @@
<file>assets/img/icons/private-chat.svg</file>
<file>assets/img/icons/profile.svg</file>
<file>assets/img/icons/public-chat.svg</file>
<file>assets/img/icons/quote.svg</file>
<file>assets/img/icons/qr-scan.svg</file>
<file>assets/img/icons/qr.svg</file>
<file>assets/img/icons/quote.svg</file>
<file>assets/img/icons/reaction-a.svg</file>
<file>assets/img/icons/reaction-b.svg</file>
<file>assets/img/icons/receive.svg</file>
@ -240,6 +255,7 @@
<file>assets/img/icons/remove-contact.svg</file>
<file>assets/img/icons/remove.svg</file>
<file>assets/img/icons/reply.svg</file>
<file>assets/img/icons/retail.svg</file>
<file>assets/img/icons/rotate.svg</file>
<file>assets/img/icons/search.svg</file>
<file>assets/img/icons/secret.svg</file>
@ -259,6 +275,7 @@
<file>assets/img/icons/speech.svg</file>
<file>assets/img/icons/star-icon-outline.svg</file>
<file>assets/img/icons/star-icon.svg</file>
<file>assets/img/icons/status-logo-icon.svg</file>
<file>assets/img/icons/status-update.svg</file>
<file>assets/img/icons/status.svg</file>
<file>assets/img/icons/stickers.svg</file>
@ -267,6 +284,7 @@
<file>assets/img/icons/swap.svg</file>
<file>assets/img/icons/symbols.svg</file>
<file>assets/img/icons/tabs.svg</file>
<file>assets/img/icons/telegram.svg</file>
<file>assets/img/icons/teller.svg</file>
<file>assets/img/icons/text.svg</file>
<file>assets/img/icons/thumbs-down.svg</file>
@ -277,6 +295,8 @@
<file>assets/img/icons/touch-id.svg</file>
<file>assets/img/icons/travel-and-places.svg</file>
<file>assets/img/icons/tributeToTalk.svg</file>
<file>assets/img/icons/twitter.svg</file>
<file>assets/img/icons/unfavourite.svg</file>
<file>assets/img/icons/union.svg</file>
<file>assets/img/icons/unlock.svg</file>
<file>assets/img/icons/unpin.svg</file>
@ -284,6 +304,7 @@
<file>assets/img/icons/view.svg</file>
<file>assets/img/icons/wallet.svg</file>
<file>assets/img/icons/warning.svg</file>
<file>assets/img/icons/youtube.svg</file>
<file>assets/img/status-logo-icon.svg</file>
<file>assets/twemoji/26x26/1f004.png</file>
<file>assets/twemoji/26x26/1f0cf.png</file>
@ -10368,21 +10389,7 @@
<file>assets/twemoji/svg/a9.svg</file>
<file>assets/twemoji/svg/ae.svg</file>
<file>assets/twemoji/svg/e50a.svg</file>
<file>assets/twemoji/twemoji.js</file>
<file>assets/img/icons/tiny/exclamation.svg</file>
<file>assets/img/icons/tiny/tiny-exclamation.svg</file>
<file>assets/img/icons/discord.svg</file>
<file>assets/img/icons/github.svg</file>
<file>assets/img/icons/key_pair_private_key.svg</file>
<file>assets/img/icons/key_pair_seed_phrase.svg</file>
<file>assets/img/icons/pencil-outline.svg</file>
<file>assets/img/icons/qr-scan.svg</file>
<file>assets/img/icons/status-logo-icon.svg</file>
<file>assets/img/icons/telegram.svg</file>
<file>assets/img/icons/twitter.svg</file>
<file>assets/img/icons/unfavourite.svg</file>
<file>assets/img/icons/youtube.svg</file>
<file>assets/twemoji/LICENSE</file>
<file>assets/img/icons/bridge.svg</file>
<file>assets/twemoji/twemoji.js</file>
</qresource>
</RCC>

39
ui/StatusQ/src/plugin.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <QtQml/QQmlExtensionPlugin>
#include <QZXing.h>
#include <qqmlsortfilterproxymodeltypes.h>
#include "StatusQ/QClipboardProxy.h"
#include "StatusQ/modelutilsinternal.h"
#include "StatusQ/rxvalidator.h"
#include "StatusQ/statussyntaxhighlighter.h"
#include "StatusQ/statuswindow.h"
class StatusQPlugin : public QQmlExtensionPlugin {
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char* uri) override
{
Q_ASSERT(uri == QLatin1String("StatusQ"));
qmlRegisterType<StatusWindow>("StatusQ", 0, 1, "StatusWindow");
qmlRegisterType<StatusSyntaxHighlighter>("StatusQ", 0, 1, "StatusSyntaxHighlighter");
qmlRegisterType<RXValidator>("StatusQ", 0, 1, "RXValidator");
qmlRegisterSingletonType<QClipboardProxy>("StatusQ", 0, 1, "QClipboardProxy", &QClipboardProxy::qmlInstance);
qmlRegisterSingletonType<ModelUtilsInternal>(
"StatusQ.Internal", 0, 1, "ModelUtils", &ModelUtilsInternal::qmlInstance);
QZXing::registerQMLTypes();
qqsfpm::registerTypes();
}
void initializeEngine(QQmlEngine* engine, const char* uri) override
{
QQmlExtensionPlugin::initializeEngine(engine, uri);
}
};
#include "plugin.moc"

View File

@ -133,6 +133,7 @@
<file>StatusQ/Core/Utils/emojiList.js</file>
<file>StatusQ/Core/Utils/qmldir</file>
<file>StatusQ/Core/Utils/Utils.qml</file>
<file>StatusQ/Core/Utils/StatesStack.qml</file>
<file>StatusQ/Core/qmldir</file>
<file>StatusQ/Core/LocaleUtils.qml</file>
<file>StatusQ/Core/StatusAnimatedStack.qml</file>
@ -172,7 +173,6 @@
<file>StatusQ/Popups/StatusSearchPopup.qml</file>
<file>StatusQ/Popups/StatusSearchPopupMenuItem.qml</file>
<file>StatusQ/Popups/StatusStackModal.qml</file>
<file>StatusQ/qmldir</file>
<file>StatusQ/Components/StatusListPickerProxies.qml</file>
<file>StatusQ/Layout/StatusSectionLayout.qml</file>
<file>StatusQ/Layout/StatusMainLayout.qml</file>
@ -203,8 +203,18 @@
<file>StatusQ/Core/Utils/ModelUtils.qml</file>
<file>StatusQ/Core/Utils/ModelsComparator.qml</file>
<file>StatusQ/Core/Utils/ModelChangeTracker.qml</file>
<file>StatusQ/Components/StatusPageIndicator.qml</file>
<file>StatusQ/Components/StatusQrCodeScanner.qml</file>
<file>StatusQ/Components/StatusOnlineBadge.qml</file>
<file>StatusQ/Components/StatusGroupBox.qml</file>
<file>StatusQ/Components/StatusDotsLoadingIndicator.qml</file>
<file>StatusQ/Components/StatusDraggableListItem.qml</file>
<file>StatusQ/Components/StatusEmojiAndColorComboBox.qml</file>
<file>StatusQ/Components/StatusStepper.qml</file>
<file>StatusQ/Components/StatusSyncDeviceDelegate.qml</file>
<file>StatusQ/Controls/StatusImageSelector.qml</file>
<file>StatusQ/Controls/StatusLinkText.qml</file>
<file>StatusQ/Core/Utils/ModelChangeGuard.qml</file>
<file>StatusQ/Core/Utils/StackViewStates.qml</file>
</qresource>
</RCC>

View File

@ -1,21 +0,0 @@
#include "StatusQ/typesregistration.h"
#include "StatusQ/QClipboardProxy.h"
#include "StatusQ/modelutilsinternal.h"
#include "StatusQ/rxvalidator.h"
#include "StatusQ/statussyntaxhighlighter.h"
#include "StatusQ/statuswindow.h"
#include <QQmlEngine>
void registerStatusQTypes()
{
qmlRegisterType<StatusWindow>("StatusQ", 0 , 1, "StatusWindow");
qmlRegisterSingletonType<QClipboardProxy>("StatusQ", 0 , 1, "QClipboardProxy",
&QClipboardProxy::qmlInstance);
qmlRegisterType<StatusSyntaxHighlighter>("StatusQ", 0 , 1, "StatusSyntaxHighlighter");
qmlRegisterType<RXValidator>("StatusQ", 0 , 1, "RXValidator");
qmlRegisterSingletonType<ModelUtilsInternal>("StatusQ.Internal", 0 , 1, "ModelUtils",
&ModelUtilsInternal::qmlInstance);
}

View File

@ -10,11 +10,6 @@ enable_testing()
set(CMAKE_AUTOMOC ON)
# TODO: Workaround until we make StatusQ a CMake library
list(APPEND QML_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../src/")
set(QML_IMPORT_PATH "${QML_DIRS}" CACHE STRING "Qt Creator extra qml import paths")
set(QML2_IMPORT_PATH "${QML_DIRS}" CACHE STRING "Qt Creator extra qml import paths")
find_package(QT NAMES Qt6 Qt5 COMPONENTS QuickTest Qml Quick REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS QuickTest Qml Quick REQUIRED)
@ -42,3 +37,8 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::Qml
Qt${QT_VERSION_MAJOR}::Quick
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
STATUSQ_MODULE_PATH="${STATUSQ_MODULE_PATH}"
STATUSQ_MODULE_IMPORT_PATH="${STATUSQ_MODULE_IMPORT_PATH}"
)

View File

@ -1,6 +1,8 @@
import QtQuick 2.0
import QtTest 1.0
import StatusQ 0.1 // https://github.com/status-im/status-desktop/issues/10218
import StatusQ.Components 0.1
import StatusQ.Controls 0.1

View File

@ -13,9 +13,9 @@ public:
public slots:
void qmlEngineAvailable(QQmlEngine *engine)
{
// TODO: Workaround until we make StatusQ a CMake library
engine->addImportPath("../src/");
engine->addImportPath("./qml/");
engine->addImportPath(QStringLiteral(STATUSQ_MODULE_IMPORT_PATH));
engine->addImportPath(QStringLiteral(QUICK_TEST_SOURCE_DIR) + "/qml/");
// TODO: Alternative to not yet supported QML_ELEMENT
qmlRegisterType<MonitorQtOutput>("StatusQ.TestHelpers", 0, 1, "MonitorQtOutput");
}

View File

@ -302,7 +302,7 @@ StatusDialog {
return
}
let error = "";
let emoji = StatusQUtils.Emoji.deparseFromParse(nameInput.input.asset.emoji)
let emoji = StatusQUtils.Emoji.deparse(nameInput.input.asset.emoji)
if (!isEdit) {
//scrollView.communityColor.color.toString().toUpperCase()

View File

@ -52,7 +52,7 @@ func main() {
if err != nil {
return err
}
if info.IsDir() && (info.Name() == "vendor" || info.Name() == "tests") {
if info.IsDir() && (info.Name() == "vendor" || info.Name() == "tests" || info.Name() == "StatusQ") {
return filepath.SkipDir
}
if !info.IsDir() {

View File

@ -763,7 +763,7 @@ Rectangle {
}
}
let textBeforeCursor = StatusQUtils.Emoji.deparseFromParse(plainText.substr(0, i));
let textBeforeCursor = StatusQUtils.Emoji.deparse(plainText.substr(0, i));
return {
cursor: countEmojiLengths(plainText.substr(0, i)) + messageInputField.cursorPosition + text.length - completelyPlainText.length,
@ -817,7 +817,7 @@ Rectangle {
if (match && match.length > 0) {
for (var i = 0; i < match.length; i++) {
length += StatusQUtils.Emoji.deparseFromParse(match[i]).length;
length += StatusQUtils.Emoji.deparse(match[i]).length;
}
length = length - match.length;
}

View File

@ -15,7 +15,7 @@ import shared.popups 1.0
import mainui 1.0
import AppLayouts.Onboarding 1.0
import StatusQ 0.1
import StatusQ 0.1 // Force import StatusQ plugin to load all StatusQ resources
import StatusQ.Core.Theme 0.1
StatusWindow {

View File

@ -28,8 +28,6 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
endif()
endif()
add_subdirectory(../../vendor/qzxing/src qzxing)
add_subdirectory(../../vendor/SortFilterProxyModel SortFilterProxyModel)
add_subdirectory(lib)
if(ENABLE_DOCS)

View File

@ -5,8 +5,6 @@ include(GNUInstallDirs)
option(MONITORING "Tools for real-time inspection of the application." OFF)
set(MONITORING_QML_ENTRY_POINT "" CACHE STRING "QML file intended to start the monitoring tool UI.")
include(../../../ui/StatusQ/StatusQSources.cmake)
if(MONITORING)
include(../../../ui/MonitoringSources.cmake)
endif()
@ -27,7 +25,6 @@ macro(add_target name type)
add_library(${name} ${type}
${SOURCES} ${HEADERS}
${MONITORING_SOURCES} ${MONITORING_HEADERS}
${STATUSQ_HEADERS} ${STATUSQ_SOURCES}
)
if (WIN32)
@ -36,15 +33,23 @@ macro(add_target name type)
set_target_properties(${name} PROPERTIES CXX_STANDARD 11 AUTOMOC ON)
target_include_directories(${name} PUBLIC include include/Qt ${STATUSQ_DIR}/include)
target_include_directories(${name} PUBLIC include include/Qt)
target_link_libraries(${name} PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Qml Qt5::Quick Qt5::Network Qt5::Multimedia SortFilterProxyModel qzxing)
target_link_libraries(${name} PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Qml Qt5::Quick Qt5::Network Qt5::Multimedia)
target_compile_definitions(${name} PRIVATE $<$<CONFIG:Debug>:QT_QML_DEBUG>)
if(DEFINED QML_DEBUG_PORT)
target_compile_definitions(${name} PRIVATE QML_DEBUG_PORT=${QML_DEBUG_PORT})
endif()
if(APPLE)
find_library(AppKit AppKit)
find_library(Foundation Foundation)
find_library(Security Security)
find_library(LocalAuthentication LocalAuthentication)
target_link_libraries(${name} PRIVATE ${AppKit} ${Foundation} ${Security} ${LocalAuthentication})
endif()
if(MONITORING)
target_include_directories(${name} PUBLIC ${MONITORING_INCLUDE_PATH})
@ -53,7 +58,7 @@ macro(add_target name type)
endif()
# for DOtherSide.pc
set(PC_REQUIRES "Qt5Core, Qt5Gui, Qt5Widgets, Qt5Qml, Qt5Quick, Qt5Network, Qt5DBus, Qt5Multimedia, SortFilterProxyModel, qzxing")
set(PC_REQUIRES "Qt5Core, Qt5Gui, Qt5Widgets, Qt5Qml, Qt5Quick, Qt5Network, Qt5DBus, Qt5Multimedia")
if (${Qt5QuickControls2_FOUND})
target_link_libraries(${name} PRIVATE Qt5::QuickControls2)
set(PC_REQUIRES "${PC_REQUIRES}, Qt5QuickControls2")

View File

@ -73,38 +73,20 @@
#include "DOtherSide/Status/KeychainManager.h"
#include "DOtherSide/Status/SoundManager.h"
#include "StatusQ/QClipboardProxy.h"
#include "StatusQ/modelutilsinternal.h"
#include "StatusQ/rxvalidator.h"
#include "StatusQ/statussyntaxhighlighter.h"
#include "StatusQ/statuswindow.h"
#ifdef MONITORING
#include <QProcessEnvironment>
#include "StatusDesktop/Monitoring/Monitor.h"
#endif
#include <qqmlsortfilterproxymodeltypes.h>
#include <QZXing.h>
namespace {
void register_meta_types()
{
qRegisterMetaType<QVector<int>>();
qmlRegisterType<StatusWindow>("StatusQ", 0 , 1, "StatusWindow");
qmlRegisterType<StatusSyntaxHighlighter>("StatusQ", 0 , 1, "StatusSyntaxHighlighter");
qmlRegisterType<RXValidator>("StatusQ", 0, 1, "RXValidator");
qmlRegisterSingletonType<QClipboardProxy>("StatusQ", 0 , 1, "QClipboardProxy", &QClipboardProxy::qmlInstance);
qmlRegisterSingletonType<ModelUtilsInternal>("StatusQ.Internal", 0 , 1, "ModelUtils",
&ModelUtilsInternal::qmlInstance);
#ifdef MONITORING
qmlRegisterSingletonType<Monitor>("Monitoring", 1 , 0, "Monitor", &Monitor::qmlInstance);
#endif
qqsfpm::registerTypes();
QZXing::registerQMLTypes();
}
}

2
vendor/qzxing vendored

@ -1 +1 @@
Subproject commit 3fcdd5b65b9a3dd8bb343cf58743ed1d551e3a92
Subproject commit 80bb1d21903881e4061a41739d413a296ceb3b49