Skip to content
Snippets Groups Projects
Commit d4409028 authored by Burak Hançerli's avatar Burak Hançerli :headphones:
Browse files

QDS-10800 Separate Android and WebAssembly repos

parent 590d8c2a
No related branches found
No related tags found
1 merge request!2QDS-10800 Separate Android and WebAssembly repos
Pipeline #62065 passed
Showing
with 79 additions and 1285 deletions
cmake_minimum_required(VERSION 3.14)
project(qtdesignviewer LANGUAGES CXX)
project(qtdesignviewer-wasm LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
......@@ -29,12 +29,9 @@ if(QT_VERSION VERSION_LESS QT_MINIMUM_VERSION)
endif()
qt_add_executable(${PROJECT_NAME}
design-viewer/importdummy_wasm.qml
design-viewer/src/main.cpp
design-viewer/src/dv_android.cpp design-viewer/src/dv_android.h
design-viewer/src/dv_wasm.cpp design-viewer/src/dv_wasm.h
design-viewer/src/dv_base.cpp design-viewer/src/dv_base.h
resources.qrc
resources/importdummy_wasm.qml
src/main.cpp
src/dv_wasm.cpp src/dv_wasm.h
)
target_link_libraries(${PROJECT_NAME} PRIVATE
......@@ -47,21 +44,6 @@ set_property(TARGET ${PROJECT_NAME}
APPEND PROPERTY QT_WASM_INITIAL_MEMORY "50MB"
)
set_property(TARGET ${PROJECT_NAME}
APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/design-viewer/android
)
if (ANDROID)
if(EXISTS ${ANDROID_OPENSSL_PATH})
message(STATUS "Found OpenSSL for Android. Path: ${ANDROID_OPENSSL_PATH}")
set_property(TARGET ${PROJECT_NAME} PROPERTY QT_ANDROID_EXTRA_LIBS
${ANDROID_OPENSSL_PATH}/libcrypto_3.so
${ANDROID_OPENSSL_PATH}/libssl_3.so)
else()
message(WARNING "Cannot find OpenSSL for Android. Path: ${ANDROID_OPENSSL_PATH}")
endif()
endif()
# --install configuration
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.html
......@@ -72,7 +54,7 @@ install(
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/design-viewer/www/
DIRECTORY ${CMAKE_SOURCE_DIR}/resources/www/
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
......
name: Build Android Packages
on:
push:
branches:
- dev
env:
QT_VERSION: 6.2.1
APP_PRO: qtdesignviewer.pro
APP_DIR: qtdesignviewer
APP_NAME: qtdesignviewer
jobs:
build:
name: Ubuntu Latest
runs-on: ubuntu-latest
strategy:
matrix:
abi:
- { arch: "x86_64", suffix: "X86_64", name: "x86_64" }
- { arch: "x86", suffix: "X86", name: "x86" }
- { arch: "armv7", suffix: "ARMv7", name: "armeabi-v7a" }
- { arch: "arm64_v8a", suffix: "ARM64", name: "arm64-v8a" }
steps:
- uses: actions/checkout@v2
with:
ref: dev
path: ${{ env.APP_DIR }}
- name: Download Qt
id: qt
shell: cmake -P {0}
run: |
set(qt_version "$ENV{QT_VERSION}")
string(REPLACE "." "" qt_version_dotless "${qt_version}")
set(qt_package_arch_suffix "gcc_64")
set(qt_package_suffix_desktop "-Linux-RHEL_8_2-GCC-Linux-RHEL_8_2-X86_64")
set(abi ${{ matrix.abi.arch }})
set(qt_package_suffix_android "-Linux-RHEL_8_2-Clang-Android-Android_ANY-${{ matrix.abi.suffix }}")
set(qt_base_url "https://download.qt.io/online/qtsdkrepository/linux_x64")
# Prepare directories
set(working_dir $ENV{GITHUB_WORKSPACE}/Qt)
file(MAKE_DIRECTORY ${working_dir})
function(downloadAndExtract url download_dir archive)
message("Downloading ${url}")
file(DOWNLOAD "${url}" ./${download_dir}/${archive} SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ../${download_dir}/${archive} WORKING_DIRECTORY ${working_dir})
endfunction()
# Download Desktop Qt
set(qt_base_url_desktop "${qt_base_url}/desktop/qt6_${qt_version_dotless}")
message("Downloading ${qt_base_url_desktop}/Updates.xml")
file(DOWNLOAD "${qt_base_url_desktop}/Updates.xml" ./Updates.xml SHOW_PROGRESS)
file(READ ./Updates.xml updates_xml)
string(REGEX MATCH "<Name>qt.qt6.*<Version>([0-9+-.]+)</Version>" updates_xml_output "${updates_xml}")
set(qt_package_version ${CMAKE_MATCH_1})
set(download_dir $ENV{GITHUB_WORKSPACE}/qt6-download-desktop-${qt_package_version})
file(MAKE_DIRECTORY ${download_dir})
file(RENAME ./Updates.xml ${download_dir}/Updates.xml)
# Needs qtdeclarative for qmlimportscanner
foreach(package qtbase qtdeclarative)
downloadAndExtract(
"${qt_base_url_desktop}/qt.qt6.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix_desktop}.7z"
${download_dir}
${package}.7z
)
endforeach()
# uic depends on libicu56.so
if (NOT WIN32 AND NOT APPLE)
downloadAndExtract(
"${qt_base_url_desktop}/qt.qt6.${qt_version_dotless}.${qt_package_arch_suffix}/${qt_package_version}icu-linux-Rhel7.2-x64.7z"
${download_dir}
icu.7z
)
endif()
set(qt_dir_desktop ${working_dir}/${qt_version}/gcc_64)
file(READ "${qt_dir_desktop}/mkspecs/qconfig.pri" qtconfig)
string(REPLACE "Enterprise" "OpenSource" qtconfig "${qtconfig}")
string(REPLACE "licheck.exe" "" qtconfig "${qtconfig}")
string(REPLACE "licheck64" "" qtconfig "${qtconfig}")
string(REPLACE "licheck_mac" "" qtconfig "${qtconfig}")
file(WRITE "${qt_dir_desktop}/mkspecs/qconfig.pri" "${qtconfig}")
# Save the path for other steps
message("::set-output name=qt_dir_desktop::${qt_dir_desktop}")
# Download Android Qt
set(qt_base_url_android "${qt_base_url}/android/qt6_${qt_version_dotless}_${abi}")
message("Downloading ${qt_base_url_android}/Updates.xml")
file(DOWNLOAD "${qt_base_url_android}/Updates.xml" ./Updates.xml SHOW_PROGRESS)
file(READ ./Updates.xml updates_xml)
string(REGEX MATCH "<Name>qt.qt6.*<Version>([0-9+-.]+)</Version>" updates_xml_output "${updates_xml}")
set(qt_package_version ${CMAKE_MATCH_1})
set(download_dir $ENV{GITHUB_WORKSPACE}/qt6-download-android-${qt_package_version})
file(MAKE_DIRECTORY ${download_dir})
file(RENAME ./Updates.xml ${download_dir}/Updates.xml)
foreach(package qttranslations qttools qtsvg qtdeclarative qtbase)
downloadAndExtract(
"${qt_base_url_android}/qt.qt6.${qt_version_dotless}.android_${abi}/${qt_package_version}${package}${qt_package_suffix_android}.7z"
${download_dir}
${package}.7z
)
endforeach()
foreach(package qtwebview qtwebsockets qtwebchannel qtvirtualkeyboard qtsensors qtscxml qtmultimedia qtimageformats qtdatavis3d qtconnectivity qtcharts qt3d)
downloadAndExtract(
"${qt_base_url_android}/qt.qt6.${qt_version_dotless}.addons.${package}.android_${abi}/${qt_package_version}${package}${qt_package_suffix_android}.7z"
${download_dir}
${package}.7z
)
endforeach()
# Special case for qtpositioning as the package is called qtlocation
set(url "${qt_base_url_android}/qt.qt6.${qt_version_dotless}.addons.qtpositioning.android_${abi}/${qt_package_version}qtlocation${qt_package_suffix_android}.7z")
message("Downloading ${url}")
file(DOWNLOAD "${url}" ./${download_dir}/qtpositioning.7z SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ../${download_dir}/qtpositioning.7z WORKING_DIRECTORY ${working_dir})
foreach(package qtshadertools qtquicktimeline qtquick3d qt5compat)
downloadAndExtract(
"${qt_base_url_android}/qt.qt6.${qt_version_dotless}.${package}.android_${abi}/${qt_package_version}${package}${qt_package_suffix_android}.7z"
${download_dir}
${package}.7z
)
endforeach()
set(qt_dir_android ${working_dir}/${qt_version}/android_${abi})
# Save the path for other steps
message("::set-output name=qt_dir_android::${qt_dir_android}")
# Modify target_qt.conf
set(conf_content "\
[Paths]
Prefix=../
HostPrefix=../../${qt_package_arch_suffix}
HostData=../android_${abi}
Sysroot=
SysrootifyPrefix=false
TargetSpec=android-clang
HostSpec=linux-g++
")
file(WRITE ${qt_dir_android}/bin/target_qt.conf ${conf_content})
- name: Checkout qtquickdesigner-components
uses: actions/checkout@v2
with:
repository: qt-labs/qtquickdesigner-components
ref: dev
path: qtquickdesigner-components
- name: Configure, build and install qtquickdesigner-components
run: |
cd qtquickdesigner-components
${{ steps.qt.outputs.qt_dir_desktop }}/bin/qmake -qtconf ${{ steps.qt.outputs.qt_dir_android }}/bin/target_qt.conf && make && make install
- name: Configure
shell: cmake -P {0}
run: |
execute_process(
COMMAND ${{ steps.qt.outputs.qt_dir_desktop }}/bin/qmake
-qtconf ${{ steps.qt.outputs.qt_dir_android }}/bin/target_qt.conf
$ENV{APP_PRO}
-spec android-clang
CONFIG+=debug
CONFIG+=qml_debug
WORKING_DIRECTORY $ENV{APP_DIR}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
# https://github.com/actions/virtual-environments/issues/3757
- name: Fix Android Build Tools
run: |
ln -s ${ANDROID_HOME}/build-tools/31.0.0/d8 ${ANDROID_HOME}/build-tools/31.0.0/dx
ln -s ${ANDROID_HOME}/build-tools/31.0.0/lib/d8.jar ${ANDROID_HOME}/build-tools/31.0.0/lib/dx.jar
- name: Build
id: build
shell: cmake -P {0}
run: |
include(ProcessorCount)
ProcessorCount(N)
execute_process(
COMMAND $ENV{ANDROID_NDK_HOME}/prebuilt/linux-x86_64/bin/make
-f Makefile
qmake_all
WORKING_DIRECTORY $ENV{APP_DIR}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
execute_process(
COMMAND $ENV{ANDROID_NDK_HOME}/prebuilt/linux-x86_64/bin/make
-j ${N}
WORKING_DIRECTORY $ENV{APP_DIR}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
execute_process(
COMMAND $ENV{ANDROID_NDK_HOME}/prebuilt/linux-x86_64/bin/make
INSTALL_ROOT=android-build install
WORKING_DIRECTORY $ENV{APP_DIR}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
execute_process(
COMMAND ${{ steps.qt.outputs.qt_dir_desktop }}/bin/androiddeployqt
--input android-qtdesignviewer-deployment-settings.json
--output android-build
--android-platform android-31
--jdk $ENV{JAVA_HOME_11_X64}
--gradle
WORKING_DIRECTORY $ENV{APP_DIR}
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
# Rename APK
set(apk_dir $ENV{APP_DIR}/android-build/build/outputs/apk/debug)
set(apk_path ${apk_dir}/$ENV{APP_NAME}_${{ matrix.abi.name }}.apk)
file(
RENAME ${apk_dir}/android-build-debug.apk ${apk_path}
RESULT result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
message("::set-output name=apk_path::${apk_path}")
- uses: actions/upload-artifact@v2
with:
name: ${{ env.APP_NAME }}_${{ matrix.abi.name }}
path: ${{ steps.build.outputs.apk_path }}
name: Build WebAssembly Packages
on:
push:
branches:
- dev
env:
QT_VERSION: 6.3.0
APP_DIR: qtdesignviewer
APP_NAME: qtdesignviewer
jobs:
build:
name: Ubuntu Latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: dev
path: ${{ env.APP_DIR }}
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v1.12
with:
cmake-version: '3.21.x'
- name: Download Qt
id: qt
shell: cmake -P {0}
run: |
set(qt_version "$ENV{QT_VERSION}")
string(REPLACE "." "" qt_version_dotless "${qt_version}")
set(qt_package_arch_suffix "wasm_32")
set(qt_host_base_url "https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt6_630")
set(qt_host_package_suffix "-Linux-RHEL_8_4-GCC-Linux-RHEL_8_4-X86_64.7z")
set(qt_host_package_dir_url "${qt_host_base_url}/qt.qt6.${qt_version_dotless}.gcc_64")
# Prepare directories
set(working_dir $ENV{GITHUB_WORKSPACE})
file(MAKE_DIRECTORY ${working_dir})
function(downloadAndExtract url download_dir archive)
message("Downloading ${url} to ${download_dir}/${archive}")
file(DOWNLOAD "${url}" ${download_dir}/${archive} )
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf ${download_dir}/${archive} WORKING_DIRECTORY ${working_dir})
endfunction()
message("Downloading host packages from : ${qt_host_package_dir_url}")
message("Downloading ${qt_host_base_url}/Updates.xml")
file(DOWNLOAD "${qt_host_base_url}/Updates.xml" ./Updates.xml SHOW_PROGRESS)
file(READ ./Updates.xml updates_xml)
string(REGEX MATCH "<Name>qt.qt6.*<Version>([0-9+-.]+)</Version>" updates_xml_output "${updates_xml}")
set(qt_host_package_version ${CMAKE_MATCH_1})
set(download_dir $ENV{GITHUB_WORKSPACE}/qt6-download-${qt_host_package_version})
file(MAKE_DIRECTORY ${download_dir})
file(RENAME ./Updates.xml ${download_dir}/Updates.xml)
foreach(package qtbase qtdeclarative)
downloadAndExtract(
"${qt_host_package_dir_url}/${qt_host_package_version}${package}${qt_host_package_suffix}"
${download_dir}
${package}.7z
)
endforeach()
# and rcc depends on libicu56.so
downloadAndExtract(
"${qt_host_package_dir_url}/${qt_host_package_version}icu-linux-Rhel7.2-x64.7z"
${download_dir}
icu.7z
)
message("Downloading WebAssembly packages from : ${qt_package_dir_url}")
message("Downloading ${qt_base_url}/Updates.xml")
set(qt_base_url "https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt6_630_wasm")
set(qt_package_suffix "-Linux-openSUSE_15_3-GCC-Linux-WebAssembly-X86_64.7z")
set(qt_package_dir_url "${qt_base_url}/qt.qt6.${qt_version_dotless}.${qt_package_arch_suffix}")
file(DOWNLOAD "${qt_base_url}/Updates.xml" ./Updates.xml SHOW_PROGRESS)
file(READ ./Updates.xml updates_xml)
string(REGEX MATCH "<Name>qt.qt6.*<Version>([0-9+-.]+)</Version>" updates_xml_output "${updates_xml}")
set(qt_package_version ${CMAKE_MATCH_1})
set(download_dir $ENV{GITHUB_WORKSPACE}/qt6-download-${qt_package_version})
file(MAKE_DIRECTORY ${download_dir})
file(RENAME ./Updates.xml ${download_dir}/Updates.xml)
# core packages
foreach(package qttranslations qttools qtsvg qtdeclarative qtbase)
downloadAndExtract(
"${qt_package_dir_url}/${qt_package_version}${package}${qt_package_suffix}"
${download_dir}
${package}.7z
)
endforeach()
# additional packages
# to be added: qtshadertools qtquick3d
foreach(package qtquicktimeline qt5compat)
downloadAndExtract(
"${qt_base_url}/qt.qt6.${qt_version_dotless}.${package}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix}"
${download_dir}
${package}.7z
)
endforeach()
# addons packages
foreach(package qtwebsockets qtwebchannel qtvirtualkeyboard qtlottie qtimageformats)
downloadAndExtract(
"${qt_base_url}/qt.qt6.${qt_version_dotless}.addons.${package}.${qt_package_arch_suffix}/${qt_package_version}${package}${qt_package_suffix}"
${download_dir}
${package}.7z
)
endforeach()
set(qt_dir ${working_dir}/${qt_version}/wasm_32)
file(READ "${qt_dir}/mkspecs/qconfig.pri" qtconfig)
string(REPLACE "Enterprise" "OpenSource" qtconfig "${qtconfig}")
string(REPLACE "licheck.exe" "" qtconfig "${qtconfig}")
string(REPLACE "licheck64" "" qtconfig "${qtconfig}")
string(REPLACE "licheck_mac" "" qtconfig "${qtconfig}")
file(WRITE "${qt_dir}/mkspecs/qconfig.pri" "${qtconfig}")
# Save the path for other steps
message("::set-output name=qt_dir::${qt_dir}")
- name: Checkout emsdk
uses: actions/checkout@v2
with:
repository: emscripten-core/emsdk
ref: main
path: emsdk
- name: Install emsdk
run: |
echo "Current path"
pwd
echo "Contents:"
ls -al
cd emsdk
./emsdk install 3.0.0
./emsdk activate 3.0.0
source "emsdk_env.sh"
env
- name: Checkout qtquickdesigner-components
uses: actions/checkout@v2
with:
repository: qt-labs/qtquickdesigner-components
ref: dev
path: qtquickdesigner-components
- name: Configure, build and install qtquickdesigner-components
run: |
source "emsdk/emsdk_env.sh"
cd qtquickdesigner-components
cmake -DCMAKE_BUILD_TYPE:STRING=Release -DQT_QMAKE_EXECUTABLE:STRING=${GITHUB_WORKSPACE}/6.3.0/wasm_32/bin/qmake -DCMAKE_PREFIX_PATH:STRING=${GITHUB_WORKSPACE}/6.3.0/wasm_32 -DCMAKE_C_COMPILER:STRING=${GITHUB_WORKSPACE}/emsdk/upstream/emscripten/emcc -DCMAKE_CXX_COMPILER:STRING=${GITHUB_WORKSPACE}/emsdk/upstream/emscripten/em++ -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${GITHUB_WORKSPACE}/6.3.0/wasm_32/lib/cmake/Qt6/qt.toolchain.cmake -DQT_HOST_PATH:STRING=${GITHUB_WORKSPACE}/6.3.0/gcc_64 .
cmake --build .
cmake --install .
- name: Configure and build qtdesignviewer
run: |
source "emsdk/emsdk_env.sh"
cd qtdesignviewer
cmake -DCMAKE_BUILD_TYPE:STRING=Release -DQT_QMAKE_EXECUTABLE:STRING=${GITHUB_WORKSPACE}/6.3.0/wasm_32/bin/qmake -DCMAKE_PREFIX_PATH:STRING=${GITHUB_WORKSPACE}/6.3.0/wasm_32 -DCMAKE_C_COMPILER:STRING=${GITHUB_WORKSPACE}/emsdk/upstream/emscripten/emcc -DCMAKE_CXX_COMPILER:STRING=${GITHUB_WORKSPACE}/emsdk/upstream/emscripten/em++ -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${GITHUB_WORKSPACE}/6.3.0/wasm_32/lib/cmake/Qt6/qt.toolchain.cmake -DQT_HOST_PATH:STRING=${GITHUB_WORKSPACE}/6.3.0/gcc_64 .
cmake --build .
- name: Create artifact package
run: |
cd qtdesignviewer
# APPLY BUILD NUMBER
sed -i 's/#buildnumber#/${{github.run_number}}/' version.json
# BUILD PACKAGE
mkdir build
mv *.wasm build
mv *.js build
mv *.json build
mv *.otf build
mv *.png build
mv *.svg build
mv index.html build
- uses: actions/upload-artifact@v2
with:
name: qtdesignviewer_wasm
path: qtdesignviewer/build/*
# QDS_CI_BUILD_QT_VERSION_ANDROID and QDS_CI_BUILD_QT_VERSION_WASM are the tags for the docker images.
# https://git.qt.io/design-studio/maintenance/docker-images/container_registry
variables:
QDS_CI_QT_VERSION:
value: "643"
......@@ -8,7 +5,6 @@ variables:
- "643"
- "652"
description: "Qt version for build"
QDS_CI_REGISTRY_IMAGE: "git.qt.io:4567/design-studio/maintenance/docker-images"
QDS_CI_ARTIFACTS_PATH: "${CI_PROJECT_DIR}/artifacts"
DEBIAN_FRONTEND: non-interactive
GIT_SUBMODULE_STRATEGY: recursive
......@@ -22,4 +18,4 @@ stages:
- release
include:
- local: "cicd/gitlab/stages/*"
- local: "cicd/stages/*"
.build-common:
# QDS_CI_BUILD_QT_VERSION_ANDROID and QDS_CI_BUILD_QT_VERSION_WASM are the tags for the docker images.
# https://git.qt.io/design-studio/maintenance/docker-images/container_registry
.build-base:
rules:
- if: $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web"
build-wasm-multiarch:
stage: build
extends: .build-base
tags:
- linux-blade
rules:
- if: $CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web"
- if: $QDS_CI_QT_VERSION == "643" && $QDS_CI_JOB_TARGET_ARCH == "32"
- if: $QDS_CI_QT_VERSION != "643" && $QDS_CI_JOB_TARGET_ARCH == "singlethread"
- if: $QDS_CI_QT_VERSION != "643" && $QDS_CI_JOB_TARGET_ARCH == "multithread"
parallel:
matrix:
- QDS_CI_JOB_TARGET_ARCH:
- "32"
- "singlethread"
- "multithread"
variables:
QDS_BUILD_PATH: "${CI_PROJECT_DIR}/outdir/build"
QDS_CI_JOB_TARGET_PLATFORM: "wasm"
QDS_CI_JOB_ARTIFACTS_PATH: ${QDS_CI_ARTIFACTS_PATH}/${QDS_CI_JOB_TARGET_PLATFORM}/${QDS_CI_JOB_TARGET_ARCH}
artifacts:
name: design-viewer-${CI_JOB_ID}-qt${QDS_CI_QT_VERSION}-${QDS_CI_JOB_TARGET_PLATFORM}-${QDS_CI_JOB_TARGET_ARCH}
expose_as: "build-artifacts"
paths:
- ${QDS_CI_ARTIFACTS_PATH}
before_script:
- mkdir -p ${QDS_CI_JOB_ARTIFACTS_PATH}
build-android-multiarch:
extends: .build-common
image: "${QDS_CI_REGISTRY_IMAGE}/${QDS_CI_JOB_TARGET_PLATFORM}:${QDS_CI_QT_VERSION}-${QDS_CI_JOB_TARGET_PLATFORM}-${QDS_CI_JOB_TARGET_ARCH}"
variables:
QDS_CI_JOB_TARGET_PLATFORM: "android"
QDS_CI_QT_VERSION: "652"
rules:
- if: $QDS_CI_QT_VERSION_ANDROID != "none"
parallel:
matrix:
- QDS_CI_JOB_TARGET_ARCH: "arm64_v8a"
QDS_CI_JOB_OPENSSL_PATH: "/opt/openssl/ssl_3/arm64-v8a"
- QDS_CI_JOB_TARGET_ARCH: "armv7"
QDS_CI_JOB_OPENSSL_PATH: "/opt/openssl/ssl_3/armeabi-v7a"
- QDS_CI_JOB_TARGET_ARCH: "x86"
QDS_CI_JOB_OPENSSL_PATH: "/opt/openssl/ssl_3/x86"
- QDS_CI_JOB_TARGET_ARCH: "x86_64"
QDS_CI_JOB_OPENSSL_PATH: "/opt/openssl/ssl_3/x86_64"
script:
- cd qtquickdesigner-components
- ls -l /opt/openssl/ssl_3/
- ls -l ${QDS_CI_JOB_OPENSSL_PATH}
- |
cmake \
-S . \
-G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE=${QT_PATH}/${QT_VERSION}/${QDS_CI_JOB_TARGET_PLATFORM}_${QDS_CI_JOB_TARGET_ARCH}/lib/cmake/Qt6/qt.toolchain.cmake \
-DANDROID_SDK_ROOT=/opt/android \
-DANDROID_NDK_ROOT=/opt/android/ndk/25.2.9519653 \
-DQT_HOST_PATH=${QT_PATH}/${QT_VERSION}/gcc_64 \
-DCMAKE_INSTALL_PREFIX=${QT_PATH}/${QT_VERSION}/${QDS_CI_JOB_TARGET_PLATFORM}_${QDS_CI_JOB_TARGET_ARCH} \
-DANDROID_OPENSSL_PATH=${QDS_CI_JOB_OPENSSL_PATH}
- cmake --build .
- cmake --install .
- cd ..
- |
cmake \
-S . \
-B ${QDS_BUILD_PATH} \
-G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE=${QT_PATH}/${QT_VERSION}/${QDS_CI_JOB_TARGET_PLATFORM}_${QDS_CI_JOB_TARGET_ARCH}/lib/cmake/Qt6/qt.toolchain.cmake \
-DANDROID_SDK_ROOT=/opt/android \
-DANDROID_NDK_ROOT=/opt/android/ndk/25.2.9519653 \
-DQT_HOST_PATH=${QT_PATH}/${QT_VERSION}/gcc_64 \
-DCMAKE_INSTALL_PREFIX=${QT_PATH}/${QT_VERSION}/${QDS_CI_JOB_TARGET_PLATFORM}_${QDS_CI_JOB_TARGET_ARCH} \
-DANDROID_OPENSSL_PATH=${QDS_CI_JOB_OPENSSL_PATH}
- cmake --build ${QDS_BUILD_PATH} --target all
- cp -r ${QDS_BUILD_PATH}/android-build/build/outputs/apk/debug/* ${QDS_CI_JOB_ARTIFACTS_PATH}
.build-wasm-common:
extends: .build-common
image: "${QDS_CI_REGISTRY_IMAGE}/${QDS_CI_JOB_TARGET_PLATFORM}:${QDS_CI_QT_VERSION}-${QDS_CI_JOB_TARGET_PLATFORM}_${QDS_CI_JOB_TARGET_ARCH}"
variables:
QDS_CI_JOB_TARGET_PLATFORM: "wasm"
image: "git.qt.io:4567/design-studio/maintenance/docker-images/${QDS_CI_JOB_TARGET_PLATFORM}:${QDS_CI_QT_VERSION}-${QDS_CI_JOB_TARGET_PLATFORM}_${QDS_CI_JOB_TARGET_ARCH}"
script:
- mkdir -p ${QDS_CI_JOB_ARTIFACTS_PATH}
- |
if [[ ${QDS_CI_QT_VERSION} == "643" ]]; then
EMSDK_VERSION="3.1.14"
......@@ -110,16 +70,3 @@ build-android-multiarch:
-DCMAKE_INSTALL_PREFIX=${QDS_CI_JOB_ARTIFACTS_PATH}
- cmake --build ${QDS_BUILD_PATH}
- cmake --install ${QDS_BUILD_PATH}
build-wasm_multiarch:
extends: .build-wasm-common
rules:
- if: $QDS_CI_QT_VERSION == "643" && $QDS_CI_JOB_TARGET_ARCH == "32"
- if: $QDS_CI_QT_VERSION != "643" && $QDS_CI_JOB_TARGET_ARCH == "singlethread"
- if: $QDS_CI_QT_VERSION != "643" && $QDS_CI_JOB_TARGET_ARCH == "multithread"
parallel:
matrix:
- QDS_CI_JOB_TARGET_ARCH:
- "32"
- "singlethread"
- "multithread"
......@@ -6,10 +6,7 @@ create-packages:
rules:
- if: $CI_COMMIT_TAG
needs:
- job: build-android-multiarch
optional: false
artifacts: true
- job: build-wasm_multiarch
- job: build-wasm-multiarch
optional: true
artifacts: true
variables:
......
# .clang-format for Qt Creator
#
# This is for clang-format >= 5.0.
#
# The configuration below follows the Qt Creator Coding Rules [1] as closely as
# possible. For documentation of the options, see [2].
#
# Use ../../tests/manual/clang-format-for-qtc/test.cpp for documenting problems
# or testing changes.
#
# In case you update this configuration please also update the qtcStyle() in src\plugins\clangformat\clangformatutils.cpp
#
# [1] https://doc-snapshots.qt.io/qtcreator-extending/coding-style.html
# [2] https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: DontAlign
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: Never
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- forever # avoids { wrapped to next line
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeCategories:
- Regex: '^<Q.*'
Priority: 200
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
# Do not add QT_BEGIN_NAMESPACE/QT_END_NAMESPACE as this will indent lines in between.
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 88
PenaltyBreakBeforeFirstCallParameter: 300
PenaltyBreakComment: 500
PenaltyBreakFirstLessLess: 400
PenaltyBreakString: 600
PenaltyExcessCharacter: 50
PenaltyReturnTypeOnItsOwnLine: 300
PointerAlignment: Right
ReflowComments: false
SortIncludes: CaseSensitive
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++11
TabWidth: 4
UseTab: Never
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.qt.qtdesignviewer"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.2">
<!-- %%INSERT_PERMISSIONS -->
<!-- %%INSERT_FEATURES -->
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" />
<application
android:name="org.qtproject.qt.android.bindings.QtApplication"
android:extractNativeLibs="true"
android:hardwareAccelerated="true"
android:label="Qt Design Viewer"
android:icon="@mipmap/app_icon"
android:requestLegacyExternalStorage="true"
android:allowNativeHeapPointerTagging="false">
<activity
android:name="org.qtproject.qt.android.bindings.QtActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:label="Qt Design Viewer"
android:launchMode="singleTop"
android:screenOrientation="unspecified"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="-- %%INSERT_APP_LIB_NAME%% --" />
<meta-data
android:name="android.app.arguments"
android:value="-- %%INSERT_APP_ARGUMENTS%% --" />
<meta-data
android:name="android.app.extract_android_style"
android:value="minimal" />
</activity>
</application>
</manifest>
design-viewer/android/res/mipmap-hdpi/app_icon.png

3.01 KiB

design-viewer/android/res/mipmap-mdpi/app_icon.png

1.68 KiB

design-viewer/android/res/mipmap-xhdpi/app_icon.png

3.92 KiB

design-viewer/android/res/mipmap-xxhdpi/app_icon.png

6.47 KiB

design-viewer/android/res/mipmap-xxxhdpi/app_icon.png

9.1 KiB

/****************************************************************************
**
** Copyright (C) 2023 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Design Viewer of the Qt Toolkit.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "dv_android.h"
#if !defined(Q_OS_WASM)
#include <QEventLoop>
#include <QFileInfo>
#include <QGuiApplication>
#include <QMessageBox>
#include <QNetworkReply>
#include <QScrollBar>
#include <QSslSocket>
#define QSTRN QString::number
void DvAndroid::printLog(const QString &log)
{
qDebug() << log;
m_logs += log + "\n";
emit logsChanged();
}
void DvAndroid::printWarn(const QString &warn)
{
printLog("WARN: " + warn);
}
void DvAndroid::printError(const QString &error, const QString &fileName, int line)
{
printLog(QString(error)
.prepend("ERROR: ")
.append(" (")
.append(fileName)
.append(":")
.append(QSTRN(line))
.append(")"));
}
void DvAndroid::showWarning(const QString &message)
{
QMessageBox msg(QMessageBox::Warning, "Warning", message, QMessageBox::Ok);
msg.exec();
}
QSharedPointer<QNetworkReply> DvAndroid::fetchResource(const QString &url)
{
printLog("Fetching resource from " + url);
QNetworkRequest request(url);
request.setRawHeader("Authorization", "test");
QSharedPointer<QNetworkReply> reply(m_nam.get(request));
QObject::connect(reply.data(),
&QNetworkReply::sslErrors,
this,
[&](const QList<QSslError> &errors) {
printErr(errors.first().errorString());
});
QEventLoop loop;
QObject::connect(reply.data(), &QNetworkReply::finished, &loop, &QEventLoop::quit);
QObject::connect(reply.data(),
&QNetworkReply::downloadProgress,
this,
[&](qint64 bytesReceived, qint64 bytesTotal) {
float percentage = roundf((float) bytesReceived / (float) bytesTotal * 100);
printLog("Download progress " + QSTRN(percentage) + "% - "
+ QSTRN(bytesReceived) + "/" + QSTRN(bytesTotal));
});
loop.exec();
if (reply->error() != QNetworkReply::NoError) {
printErr(reply->errorString());
} else {
printLog("Resource fetched successfully");
}
return reply;
}
void DvAndroid::printSysInfo()
{
const QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
printLog("Qt Design Viewer");
printLog("System information:");
printLog("-- Qt version: " + QString(QT_VERSION_STR));
printLog("-- OpenSSL support: " + QVariant(QSslSocket::supportsSsl()).toString());
printLog("-- Screen height: " + QSTRN(screenGeometry.height()));
printLog("-- Screen width: " + QSTRN(screenGeometry.width()));
}
bool DvAndroid::initialize()
{
printLog("Initializing Qt Design Viewer...");
printSysInfo();
m_buildInfo = QCoreApplication::applicationVersion() + "\n" + "Qt " + QString(QT_VERSION_STR)
+ "\n" + "OpenSSL support: " + QVariant(QSslSocket::supportsSsl()).toString();
emit buildInfoChanged();
printLog("Initialization complete");
return true;
}
void DvAndroid::downloadAndRun(const QString &url)
{
printLog("=========================");
printLog("Fetching a new project...");
QString projectUrl = url;
if (projectUrl.startsWith("https://designviewer.qt.io/#")) {
projectUrl = projectUrl.split("#").at(1);
projectUrl.prepend("https://designviewer.qt.io/qmlprojects/");
}
auto reply = fetchResource(projectUrl);
if (reply->error() != QNetworkReply::NoError) {
printErr("Could not fetch project");
return;
}
if (!runProject(reply->readAll(), QFileInfo(url).baseName())) {
printErr("Could not run project");
return;
}
}
void DvAndroid::orientateWindow(Qt::ScreenOrientation orientation)
{
QQuickItem *contentItem = m_quickWindow->contentItem();
QQuickItem *childItem{contentItem->childItems().at(0)};
const QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
printLog("Adapting orientation. Initial sizing:");
printLog("-- Screen size: " + QSTRN(screenGeometry.height()) + " x "
+ QSTRN(screenGeometry.width()));
printLog("-- Quick window size: " + QSTRN(m_quickWindow->height()) + " x "
+ QSTRN(m_quickWindow->width()));
printLog("-- Child size: " + QSTRN(childItem->height()) + " x " + QSTRN(childItem->width()));
printLog("-- Child pos: " + QSTRN(childItem->x()) + ", " + QSTRN(childItem->y()));
printLog("-- Child scale: " + QSTRN(childItem->scale()));
printLog("Calculating the new size and scale...");
const QSizeF newContentSize = childItem->size().scaled(screenGeometry.size().toSizeF(),
Qt::AspectRatioMode::KeepAspectRatio);
const qreal newScale = newContentSize.height() / childItem->size().height();
const qreal newX = (childItem->width() - screenGeometry.width()) / -2.0f;
const qreal newY = (childItem->height() - screenGeometry.height()) / -2.0f;
childItem->setScale(newScale);
childItem->setPosition(QPointF(newX, newY));
printLog("-- Calculated item height: " + QSTRN(newContentSize.height()));
printLog("-- Calculated item width: " + QSTRN(newContentSize.width()));
printLog("-- Calculated item scale: " + QSTRN(newScale));
printLog("-- Calculated item pos..: " + QSTRN(newX) + "," + QSTRN(newY));
printLog("Final Sizing:");
printLog("-- Child height: " + QSTRN(childItem->height()));
printLog("-- Child width: " + QSTRN(childItem->width()));
printLog("-- Child scale: " + QSTRN(childItem->scale()));
printLog("-- Child pos-x: " + QSTRN(childItem->x()));
printLog("-- Child pos-y: " + QSTRN(childItem->y()));
}
void DvAndroid::showAppWindow()
{
QScreen *screen = QGuiApplication::primaryScreen();
QObject::connect(screen, &QScreen::orientationChanged, this, &DvAndroid::orientateWindow);
orientateWindow(screen->orientation());
printLog("Initializing and showing the QML app window");
m_quickWindow->show();
}
#endif // !defined(Q_OS_WASM)
/****************************************************************************
**
** Copyright (C) 2023 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Design Viewer of the Qt Toolkit.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#ifndef DV_ANDROID_H
#define DV_ANDROID_H
#include <QLabel>
#include <QLineEdit>
#include <QNetworkAccessManager>
#include <QPushButton>
#include <QScrollArea>
#include <QStringList>
#include <QVBoxLayout>
#include <QWidget>
#include "dv_base.h"
class DvAndroid : public DvBase
{
Q_OBJECT
Q_PROPERTY(QString logs READ logs NOTIFY logsChanged)
Q_PROPERTY(QString buildInfo READ buildInfo NOTIFY buildInfoChanged)
public:
bool initialize() override;
QString logs() const { return m_logs; }
QString buildInfo() const { return m_buildInfo; }
private:
// UI data
QString m_logs;
QString m_buildInfo;
// Other members
QNetworkAccessManager m_nam;
void printLog(const QString &message) override;
void printWarn(const QString &message) override;
void printError(const QString &message, const QString &fileName, int line) override;
void showAppWindow() override;
void showWarning(const QString &message);
void showFatalMessageAndDie(const QStringList &message);
QSharedPointer<QNetworkReply> fetchResource(const QString &url);
void printSysInfo();
signals:
void logsChanged();
void buildInfoChanged();
public slots:
void downloadAndRun(const QString &url);
private slots:
void orientateWindow(Qt::ScreenOrientation orientation);
};
#endif // DV_ANDROID_H
/****************************************************************************
**
** Copyright (C) 2023 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Design Viewer of the Qt Toolkit.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "dv_wasm.h"
#if defined(Q_OS_WASM)
#include <emscripten.h>
#include <functional>
#include <QFile>
std::function<void(char *, size_t, char *)> g_setFileDataCallback;
extern "C" EMSCRIPTEN_KEEPALIVE void qt_callSetFileData(char *content,
size_t contentSize,
char *fileName)
{
if (g_setFileDataCallback == nullptr)
return;
g_setFileDataCallback(content, contentSize, fileName);
g_setFileDataCallback = nullptr;
}
void DvWasm::fetchProject(QByteArray *data, QString *fileName)
{
// Call qt_callSetFileData to make sure the emscripten linker does not
// optimize it away, which may happen if the function is called from JavaScript
// only. Set g_setFileDataCallback to null to make it a no-op.
::g_setFileDataCallback = nullptr;
::qt_callSetFileData(nullptr, 0, nullptr);
auto setFileDataCallback =
[data, fileName](char *content, size_t contentSize, char *projectFilename) {
data->setRawData(content, contentSize);
*fileName = QString::fromUtf8(projectFilename);
};
g_setFileDataCallback = setFileDataCallback;
EM_ASM_({
// Copy the file file content to the C++ heap.
// Note: this could be simplified by passing the content as an
// "array" type to ccall and then let it copy to C++ memory.
// However, this built-in solution does not handle files larger
// than ~15M (Chrome). Instead, allocate memory manually and
// pass a pointer to the C++ side (which will free() it when done).
// TODO: consider slice()ing the file to read it picewise and
// then assembling it in a QByteArray on the C++ side.
const contentSize = contentArray.byteLength;
const heapPointer = _malloc(contentSize);
const heapBytes = new Uint8Array(Module.HEAPU8.buffer, heapPointer, contentSize);
heapBytes.set(contentArray);
// Null out the first data copy to enable GC
reader = null;
contentArray = null;
// Call the C++ file data ready callback
ccall("qt_callSetFileData",
null,
["number", "number", "string"],
[heapPointer, contentSize, projectfileName]);
});
}
void DvWasm::printLog(const QString &message)
{
fprintf(stdout, "%s\n", qPrintable(message));
}
void DvWasm::printWarn(const QString &message)
{
QString escaped = message;
escaped.replace("'", "\'");
escaped.replace("\n", "\\n");
emscripten_run_script("alert('" + escaped.toUtf8() + "');");
}
void DvWasm::printError(const QString &message, const QString &fileName, int line)
{
printWarn(message);
emscripten_run_script("location.hash = ''; location.reload();");
}
void DvWasm::showAppWindow()
{
printLog("Resizing the QML app window");
const QSize size;
const QString command
= QString::fromLatin1("setScreenSize(%1, %2);").arg(size.width()).arg(size.height());
emscripten_run_script(command.toUtf8());
printLog("Showing the QML app window");
m_quickWindow->show();
}
bool DvWasm::initialize()
{
QString projectFileName;
QByteArray projectData;
fetchProject(&projectData, &projectFileName);
if (!runProject(projectData, projectFileName)) {
printError("Failed to run project", projectFileName, 0);
return false;
}
return true;
}
#endif // Q_OS_WASM
/****************************************************************************
**
** Copyright (C) 2023 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Design Viewer of the Qt Toolkit.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#ifndef DV_WASM_H
#define DV_WASM_H
#include "dv_base.h"
class DvWasm : public DvBase
{
public:
bool initialize() override;
private:
QByteArray *m_projectData;
void printLog(const QString &message) override;
void printWarn(const QString &message) override;
void printError(const QString &message, const QString &fileName, int line) override;
void showAppWindow() override;
void fetchProject(QByteArray *data, QString *fileName);
};
#endif
/*
This is a UI file (.ui.qml) that is intended to be edited in Qt Design Studio only.
It is supposed to be strictly declarative and only uses a subset of QML. If you edit
this file manually, you might introduce QML code that is not supported by Qt Design Studio.
Check out https://doc.qt.io/qtcreator/creator-quick-ui-forms.html for details on .ui.qml files.
*/
import QtQuick 6.4
import QtQuick.Controls 6.4
import QtQuick.Controls.Material
import QtQuick.Layouts
Rectangle {
id: root
width: 1024
height: 768
color: "#EAEAEA"
Material.theme: Material.Light
Material.accent: Material.Blue
Material.primary: Material.Blue
ColumnLayout {
id: bar
y: 408
anchors.bottom: column.top
anchors.bottomMargin: 24
anchors.horizontalCenter: parent.horizontalCenter
ProgressBar {
id: progressBar
Layout.minimumWidth: 380
to: 100
value: 50
}
}
ColumnLayout {
id: column
y: 549
height: 113
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: 12
anchors.rightMargin: 22
anchors.leftMargin: 22
TextField {
id: urlTextField
horizontalAlignment: Text.AlignHCenter
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Layout.fillWidth: true
placeholderText: qsTr("Enter URL")
}
Button {
id: downloadButton
text: qsTr("Download and Run")
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
onClicked: backend.downloadAndRun(urlTextField.text)
}
}
Item {
id: header
width: 351
height: 309
anchors.top: parent.top
anchors.topMargin: 12
anchors.horizontalCenter: parent.horizontalCenter
Image {
id: qdsicon
x: 47
y: -23
source: "dvicon.png"
fillMode: Image.PreserveAspectFit
}
ColumnLayout {
anchors.top: qdsicon.bottom
anchors.horizontalCenterOffset: -1
anchors.topMargin: -20
anchors.horizontalCenter: parent.horizontalCenter
Label {
id: label
text: qsTr("Android Design Viewer")
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
}
Label {
id: label1
text: qsTr("Technology Preview")
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
}
Label {
id: label2
text: backend.buildInfo
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
horizontalAlignment: "AlignHCenter"
}
}
}
Rectangle {
id: log
visible: root.height > 620
color: "#ececec"
anchors.left: parent.left
anchors.right: parent.right
anchors.top: header.bottom
anchors.bottom: bar.top
anchors.topMargin: 0
anchors.bottomMargin: 24
anchors.leftMargin: 22
Label {
id: label3
visible: false
text: qsTr("Log")
anchors.top: parent.top
anchors.topMargin: 12
anchors.horizontalCenter: parent.horizontalCenter
font.bold: true
}
ScrollView {
id: scrollArea
anchors.left: parent.left
anchors.right: parent.right
anchors.top: label3.bottom
anchors.bottom: parent.bottom
anchors.rightMargin: 2
TextArea {
id: logTextArea
text: backend.logs
rightInset: 20
readOnly: true
clip: false
anchors.topMargin: 5
placeholderText: qsTr("Application Logs")
width: scrollArea.width
}
}
}
}
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>dvicon.png</file>
</qresource>
</RCC>
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment