Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ jobs:
uses: actions/cache@v5
with:
path: qt_wasm_lite
key: ${{ matrix.config }}_qt-${{ env.QT_VERSION }}_emcc-${{ env.WEBASSEMBLY_VERSION }}_qtpositioning
key: ${{ matrix.config }}_qt-${{ env.QT_VERSION }}_emcc-${{ env.WEBASSEMBLY_VERSION }}_qtpositioning_${{ hashFiles('misc/qt_lite.txt', 'misc/qt_68_qtbase_remove_dejavu_fonts.patch') }}

- name: Download and patch Qt
if: steps.qt-cache.outputs.cache-hit != 'true'
Expand All @@ -255,6 +255,9 @@ jobs:
$QT_SRC_CONFIGURE -qt-host-path $QT_ROOT_DIR -platform wasm-emscripten -init-submodules -submodules qtdeclarative,qtbase,qtpositioning -skip qtlanguageserver,qtquicktimeline,qtimageformats
cd ${{github.workspace}}/qt_src/qtbase
git apply ${{github.workspace}}/misc/qt_68_qtbase_remove_dejavu_fonts.patch
cd ${{ github.workspace }}
rm -rf qt_wasm_build
mkdir qt_wasm_build


- name: Build Qt for Webassembly (custom version)
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/doc
/build/*
/.qtcreator/CMakeLists.txt.user
**/.qmlls.ini
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ option(ALP_ENABLE_AVLANCHE_WARNING_LAYER "Enables avalanche warning layer (requi
option(ALP_ENABLE_LABELS "Enables label rendering" ON)

set(ALP_EXTERN_DIR "extern" CACHE STRING "name of the directory to store external libraries, fonts etc..")
set(ALP_ANDROID_MIN_SDK_VERSION 28 CACHE STRING "minimum Android API level")
set(ALP_ANDROID_TARGET_SDK_VERSION 36 CACHE STRING "target Android API level")
set(ALP_ANDROID_COMPILE_SDK_VERSION 36 CACHE STRING "compile Android API level")

include(cmake/alp_configure_target.cmake)

if(ALP_ENABLE_TRACK_OBJECT_LIFECYCLE)
add_definitions(-DALP_ENABLE_TRACK_OBJECT_LIFECYCLE)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ After that it should be a normal cmake project. That is, you run cmake to genera
We use Qt Creator (with mingw on Windows), which is the only tested setup atm and makes setup of Android and WebAssembly builds reasonably easy. If you have questions, please go to Discord.

## Dependencies
* Qt 6.8.0, or greater
* Qt 6.11.1, or greater
* g++ 12+, clang or msvc
* OpenGL
* Qt Positioning and Charts modules
Expand Down
27 changes: 12 additions & 15 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ set_target_properties(alpineapp PROPERTIES
QT_ANDROID_VERSION_CODE "${ALP_VERSION_INTEGER}"
)
target_link_libraries(alpineapp PUBLIC gl_engine Qt::Quick Qt::QuickControls2)
alp_configure_target(alpineapp)

if (ALP_ENABLE_QML_HOT_RELOAD)
message(WARNING "building alpine app with qml-hot-reload. It'll slow incremental building due to a fix for hotreload.")
Expand Down Expand Up @@ -178,11 +179,6 @@ else()
endif()

if (ANDROID)
set_target_properties(alpineapp PROPERTIES
QT_ANDROID_COMPILE_SDK_VERSION "36"
QT_ANDROID_TARGET_SDK_VERSION "35"
)

add_android_openssl_libraries(alpineapp)
find_package(Qt6 REQUIRED COMPONENTS Widgets) # for QFileDialogue (adding tracks)
target_link_libraries(alpineapp PUBLIC Qt::Widgets)
Expand All @@ -195,17 +191,18 @@ endif()
if (EMSCRIPTEN)
target_link_options(alpineapp PUBLIC -sASYNCIFY)

set(ALP_INSTALL_FILES
"$<TARGET_FILE_DIR:alpineapp>/alpineapp.js"
"$<TARGET_FILE_DIR:alpineapp>/alpineapp.wasm"
"$<TARGET_FILE_DIR:alpineapp>/alpineapp.html"
"$<TARGET_FILE_DIR:alpineapp>/qtloader.js"
install(
FILES
"$<TARGET_FILE_DIR:alpineapp>/alpineapp.js"
"$<TARGET_FILE_DIR:alpineapp>/alpineapp.wasm"
"$<TARGET_FILE_DIR:alpineapp>/alpineapp.html"
"$<TARGET_FILE_DIR:alpineapp>/qtloader.js"
DESTINATION
${ALP_WWW_INSTALL_DIR})
install(FILES "$<TARGET_FILE_DIR:alpineapp>/alpineapp.worker.js"
DESTINATION ${ALP_WWW_INSTALL_DIR}
OPTIONAL
)

if (ALP_ENABLE_THREADING)
list(APPEND ALP_INSTALL_FILES "$<TARGET_FILE_DIR:alpineapp>/alpineapp.worker.js")
endif()
install(FILES ${ALP_INSTALL_FILES} DESTINATION ${ALP_WWW_INSTALL_DIR})
else()
find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(alpineapp PUBLIC Qt::Widgets)
Expand Down
37 changes: 35 additions & 2 deletions app/GnssInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ QDateTime GnssInformation::timestamp() const
void GnssInformation::position_updated(const QGeoPositionInfo& position)
{
#ifdef ALP_ENABLE_GNSS
if (!position.coordinate().isValid()) {
qDebug() << "GnssInformation: Ignoring invalid position update";
return;
}

m_latitude = position.coordinate().latitude();
m_longitude = position.coordinate().longitude();
m_altitude = position.coordinate().altitude();
Expand All @@ -86,15 +91,42 @@ void GnssInformation::position_updated(const QGeoPositionInfo& position)
#endif
}

void GnssInformation::start_position_updates()
{
#ifdef ALP_ENABLE_GNSS
if (!m_position_source)
return;

m_position_source->startUpdates();

int timeout_ms = m_position_source->minimumUpdateInterval();
if (timeout_ms < 10000)
timeout_ms = 10000;
m_position_source->requestUpdate(timeout_ms);
#endif
}

bool GnssInformation::enabled() const
{
return m_enabled;
}

void GnssInformation::set_enabled(bool new_enabled)
{
qDebug("GnssInformation::set_enabled(%s)", new_enabled ? "true" : "false");
if (m_enabled == new_enabled)
return;

#ifdef ALP_ENABLE_GNSS
if (new_enabled && !m_position_source) {
qDebug("GnssInformation: Cannot enable without QGeoPositionInfoSource");
return;
}
#else
if (new_enabled)
return;
#endif

m_enabled = new_enabled;
#ifdef ALP_ENABLE_GNSS
if (m_enabled) {
Expand All @@ -107,19 +139,20 @@ void GnssInformation::set_enabled(bool new_enabled)
qApp->requestPermission(gnssPermission, this, [this](const QPermission& permission) {
qDebug() << "qApp->requestPermission" << permission;
if (permission.status() == Qt::PermissionStatus::Granted) {
m_position_source->startUpdates();
start_position_updates();
} else {
set_enabled(false);
}
});
emit enabled_changed();
return;
case Qt::PermissionStatus::Denied:
qDebug() << "Qt::PermissionStatus::Denied";
set_enabled(false);
return;
case Qt::PermissionStatus::Granted:
qDebug() << "Qt::PermissionStatus::Granted";
m_position_source->startUpdates();
start_position_updates();
}
} else {
m_position_source->stopUpdates();
Expand Down
1 change: 1 addition & 0 deletions app/GnssInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GnssInformation : public QQuickItem {

private:
void position_updated(const QGeoPositionInfo& position);
void start_position_updates();

private:
double m_latitude = 0;
Expand Down
23 changes: 13 additions & 10 deletions cmake/alp_add_unittest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,24 @@ function(alp_add_unittest name)
FILES
${alpineapp_fonts_SOURCE_DIR}/Roboto/Roboto-Regular.ttf
)
set(ALP_INSTALL_FILES
"$<TARGET_FILE_DIR:${name}>/${name}.js"
"$<TARGET_FILE_DIR:${name}>/${name}.wasm"
"$<TARGET_FILE_DIR:${name}>/${name}.html"
"$<TARGET_FILE_DIR:${name}>/qtloader.js"
install(
FILES
"$<TARGET_FILE_DIR:${name}>/${name}.js"
"$<TARGET_FILE_DIR:${name}>/${name}.wasm"
"$<TARGET_FILE_DIR:${name}>/${name}.html"
"$<TARGET_FILE_DIR:${name}>/qtloader.js"
DESTINATION
${ALP_WWW_INSTALL_DIR})
install(
FILES "$<TARGET_FILE_DIR:${name}>/${name}.worker.js"
DESTINATION ${ALP_WWW_INSTALL_DIR}
OPTIONAL
)

if (ALP_ENABLE_THREADING)
list(APPEND ALP_INSTALL_FILES "$<TARGET_FILE_DIR:${name}>/${name}.worker.js")
endif()
install(FILES ${ALP_INSTALL_FILES} DESTINATION ${ALP_WWW_INSTALL_DIR})
elseif(ANDROID)
add_qml_catch2_console_unittests(${name} ${ARGN})
else()
qt_add_executable(${name} ${ARGN} ${CMAKE_SOURCE_DIR}/unittests/main.cpp)
target_link_libraries(${name} PUBLIC Catch2::Catch2)
endif()
alp_configure_target(${name})
endfunction()
9 changes: 9 additions & 0 deletions cmake/alp_configure_target.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function(alp_configure_target target_name)
if (ANDROID)
set_target_properties(${target_name} PROPERTIES
QT_ANDROID_MIN_SDK_VERSION "${ALP_ANDROID_MIN_SDK_VERSION}"
QT_ANDROID_TARGET_SDK_VERSION "${ALP_ANDROID_TARGET_SDK_VERSION}"
QT_ANDROID_COMPILE_SDK_VERSION "${ALP_ANDROID_COMPILE_SDK_VERSION}"
)
endif()
endfunction()
4 changes: 1 addition & 3 deletions misc/qt_lite.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-static -reduce-exports -gc-binaries
-disable-deprecated-up-to 0x070000
-disable-deprecated-up-to 0x060000
-no-dbus
-no-sql-sqlite
-no-widgets
Expand Down Expand Up @@ -50,14 +50,12 @@
-no-feature-imageformat_xbm
-no-feature-sql-sqlite
-no-feature-jpeg
-no-feature-tiff
-no-feature-ico
-no-feature-gif
-no-feature-qml-jit
-no-feature-quickcontrols2-fluentwinui3
-no-feature-qml-profiler
-no-feature-dom
-no-feature-webp
-no-feature-dbus
-no-feature-quickcontrols2-fluentwinui3
-no-feature-stack_protector
Expand Down
25 changes: 16 additions & 9 deletions plain_renderer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,27 @@ set_target_properties(plain_renderer PROPERTIES
target_link_libraries(plain_renderer PUBLIC gl_engine)
target_include_directories(plain_renderer PRIVATE .)

alp_configure_target(plain_renderer)

if (EMSCRIPTEN)
message(NOTICE "ALP_WWW_INSTALL_DIR = ${ALP_WWW_INSTALL_DIR}")
configure_file(../site/mascot.png mascot.png COPYONLY)
set(ALP_INSTALL_FILES
"$<TARGET_FILE_DIR:plain_renderer>/plain_renderer.js"
"$<TARGET_FILE_DIR:plain_renderer>/plain_renderer.wasm"
"$<TARGET_FILE_DIR:plain_renderer>/plain_renderer.html"
"$<TARGET_FILE_DIR:plain_renderer>/qtloader.js"
"${CMAKE_SOURCE_DIR}/site/mascot.png"
)
if (ALP_ENABLE_THREADING)
list(APPEND ALP_INSTALL_FILES "$<TARGET_FILE_DIR:plain_renderer>/plain_renderer.worker.js")
endif()
install(FILES ${ALP_INSTALL_FILES} DESTINATION ${ALP_WWW_INSTALL_DIR})
install(
FILES
"$<TARGET_FILE_DIR:plain_renderer>/plain_renderer.js"
"$<TARGET_FILE_DIR:plain_renderer>/plain_renderer.wasm"
"$<TARGET_FILE_DIR:plain_renderer>/plain_renderer.html"
"$<TARGET_FILE_DIR:plain_renderer>/qtloader.js"
"${CMAKE_SOURCE_DIR}/site/mascot.png"
DESTINATION
${ALP_WWW_INSTALL_DIR}
)
install(
FILES "$<TARGET_FILE_DIR:plain_renderer>/plain_renderer.worker.js"
DESTINATION ${ALP_WWW_INSTALL_DIR}
OPTIONAL
)

endif()
Loading